Skip to content

Commit bc03bf0

Browse files
committed
optimize code comments.
1 parent 5f3fb6f commit bc03bf0

73 files changed

Lines changed: 954 additions & 304 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/a2a/agentscope_interop/demo_agentscope_a2a_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""AgentScope A2A server demo.
32
43
Run:

examples/a2a/google_sdk_interop/demo_google_sdk_a2a_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""Minimal Google A2A SDK server demo (local).
32
43
Run:

function_hubs/shortest_path.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
#!/usr/bin/env python3
21
"""
32
使用 Google OR-Tools 解决最短路径问题的示例
43
54
这个示例展示了如何使用 OR-Tools 的图算法来解决城市间的最短路径问题。
65
"""
76

8-
from ortools.graph.python import min_cost_flow
97
import time
8+
109
import matplotlib.pyplot as plt
1110
import networkx as nx
1211
import pandas as pd
12+
from ortools.graph.python import min_cost_flow
13+
1314
from oxygent import oxy
1415

15-
shortest_path_tools = oxy.FunctionHub(
16-
name="shortest_path_tools")
16+
shortest_path_tools = oxy.FunctionHub(name="shortest_path_tools")
1717
column_data = {}
1818

1919

20-
@shortest_path_tools.tool(description="Update city and distance information based on Excel.")
20+
@shortest_path_tools.tool(
21+
description="Update city and distance information based on Excel."
22+
)
2123
async def info_update(file_path, sheet_name=0):
2224
# 读取 Excel 文件
2325
df = pd.read_excel(file_path, sheet_name=sheet_name)
@@ -35,16 +37,18 @@ async def info_update(file_path, sheet_name=0):
3537
return "File is Empty"
3638

3739

38-
@shortest_path_tools.tool(description="A tool that can calculate the shortest path between different points")
40+
@shortest_path_tools.tool(
41+
description="A tool that can calculate the shortest path between different points"
42+
)
3943
async def shortest_path(start_city: str, end_city):
4044
# 城市列表
41-
city_to_index = {city: i for i, city in enumerate(column_data['cities'])}
45+
city_to_index = {city: i for i, city in enumerate(column_data["cities"])}
4246
print(start_city, end_city)
4347

44-
cities = column_data['cities']
45-
start_cities = column_data['start_cities']
46-
end_cities = column_data['end_cities']
47-
distances = column_data['distances']
48+
cities = column_data["cities"]
49+
start_cities = column_data["start_cities"]
50+
end_cities = column_data["end_cities"]
51+
distances = column_data["distances"]
4852
# 转换城市名称为索引
4953
start_nodes = [city_to_index[city] for city in start_cities]
5054
end_nodes = [city_to_index[city] for city in end_cities]
@@ -54,9 +58,11 @@ async def shortest_path(start_city: str, end_city):
5458
# 添加每条边到图中 (注意:我们需要添加双向边,因为城市之间的道路是双向的)
5559
for i in range(len(start_nodes)):
5660
sp_func.add_arc_with_capacity_and_unit_cost(
57-
start_nodes[i], end_nodes[i], 1, distances[i])
61+
start_nodes[i], end_nodes[i], 1, distances[i]
62+
)
5863
sp_func.add_arc_with_capacity_and_unit_cost(
59-
end_nodes[i], start_nodes[i], 1, distances[i])
64+
end_nodes[i], start_nodes[i], 1, distances[i]
65+
)
6066

6167
# 设置起点和终点的供应/需求
6268
sp_func.set_node_supply(city_to_index[start_city], 1) # 起点
@@ -133,20 +139,24 @@ def visualize_city_path(cities, start_cities, end_cities, distances, path):
133139
for u, v in path:
134140
path_edges.append((cities[u], cities[v]))
135141

136-
nx.draw_networkx_edges(G, city_positions, edgelist=path_edges, width=3, edge_color='r')
142+
nx.draw_networkx_edges(
143+
G, city_positions, edgelist=path_edges, width=3, edge_color="r"
144+
)
137145

138146
# 绘制节点
139-
nx.draw_networkx_nodes(G, city_positions, node_size=700, node_color='lightblue')
147+
nx.draw_networkx_nodes(G, city_positions, node_size=700, node_color="lightblue")
140148

141149
# 绘制节点标签
142-
nx.draw_networkx_labels(G, city_positions, font_size=12, font_family='SimHei')
150+
nx.draw_networkx_labels(G, city_positions, font_size=12, font_family="SimHei")
143151

144152
# 绘制边权重
145-
edge_labels = nx.get_edge_attributes(G, 'weight')
146-
nx.draw_networkx_edge_labels(G, city_positions, edge_labels=edge_labels, font_size=8)
153+
edge_labels = nx.get_edge_attributes(G, "weight")
154+
nx.draw_networkx_edge_labels(
155+
G, city_positions, edge_labels=edge_labels, font_size=8
156+
)
147157

148-
plt.title("中国城市间最短路径", fontsize=16, fontfamily='SimHei')
149-
plt.axis('off')
158+
plt.title("中国城市间最短路径", fontsize=16, fontfamily="SimHei")
159+
plt.axis("off")
150160
plt.tight_layout()
151161
plt.savefig("city_shortest_path.png")
152162
print("\n城市路径图已保存为 'city_shortest_path.png'")

oxygent/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""OxyGent -- Multi-Agent System framework.
2+
3+
Public API surface re-exported for convenience.
4+
"""
5+
16
from dotenv import load_dotenv
27

38
from .config import Config

oxygent/banner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""ASCII art banners for the OxyGent startup display."""
2+
13
oxygent_larry3d = """
24
_____ ____ __
35
/\ __`\ /\ _`\ /\ \__

oxygent/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
"""Configuration settings for the MAS."""
1+
"""Centralized configuration singleton for the OxyGent framework.
2+
3+
Loads settings from ``config.json`` with environment-based layering (``default``
4+
then ``APP_ENV``), supports ``${VAR}`` environment-variable substitution, and
5+
exposes typed getter/setter methods grouped by domain (app, log, LLM, agent,
6+
tool, server, Elasticsearch, Redis, message, token tracking, etc.).
7+
"""
28

39
import json
410
import logging

oxygent/core_tools/retrieve_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""Tool Retrieval Module.
1+
"""Semantic tool retrieval via vector similarity search.
22
3-
This file demonstrates the structure of the 'retrieve_tools', which can select
4-
appropriate functions for an agent based on specific circumstances and requirements.
3+
Provides a FunctionHub tool that queries a Vearch vector database to find
4+
the most relevant tools for a given query, filtered by application and agent.
55
"""
66

77
from typing import Any

oxygent/databases/base_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""base_db.py Base Database Class Module.
1+
"""Base database service class with retry and error handling.
22
3-
This file defines the base class for database services, providing common functionality
4-
such as retry mechanisms and error handling for database operations.
3+
Defines the abstract base class for all database services, providing common
4+
functionality such as configurable retry mechanisms and error handling.
55
"""
66

77
import asyncio

oxygent/databases/db_es/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Elasticsearch database backends (JES, local filesystem, in-memory)."""
2+
13
from .jes_es import JesEs
24
from .local_es import LocalEs
35
from .memory_es import MemoryEs

oxygent/databases/db_es/base_es.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""base_es.py Base Elasticsearch Database Class Module.
1+
"""Abstract base class for Elasticsearch database services.
22
3-
This file defines the abstract base class for Elasticsearch database services,
4-
inheriting from BaseDB and providing the interface contract for ES operations.
3+
Inherits from BaseDB and defines the interface contract for Elasticsearch
4+
operations including index management, document CRUD, and search queries.
55
"""
66

77
import logging

0 commit comments

Comments
 (0)