Skip to content

Commit 89c463d

Browse files
committed
fix: details
1 parent 0fb2251 commit 89c463d

File tree

6 files changed

+95
-101
lines changed

6 files changed

+95
-101
lines changed

docs/docs/agent/agent-to-agent.md

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -62,64 +62,64 @@ flowchart LR
6262
3. 配置服务器参数(端口、主机等)
6363
=== "代码"
6464

65-
```python title="server.py" linenums="1" hl_lines="5"
66-
from google.adk.a2a.utils.agent_to_a2a import to_a2a
67-
from veadk import Agent
68-
from veadk.tools.demo_tools import get_city_weather
69-
70-
agent = Agent(
71-
name="weather_agent",
72-
description="An agent that can get the weather of a city",
73-
tools=[get_city_weather],
74-
)
75-
76-
app = to_a2a(agent=agent)
77-
```
65+
```python title="server.py" linenums="1" hl_lines="1 11"
66+
from google.adk.a2a.utils.agent_to_a2a import to_a2a
67+
from veadk import Agent
68+
from veadk.tools.demo_tools import get_city_weather
69+
70+
agent = Agent(
71+
name="weather_agent",
72+
description="An agent that can get the weather of a city",
73+
tools=[get_city_weather],
74+
)
75+
76+
app = to_a2a(agent=agent)
77+
```
7878
### 客户端集成
7979
1. 导入 RemoteVeAgent 类
8080
2. 配置远程 Agent 连接参数
8181
3. 在 Root Agent 中添加 Remote Agent 作为 Sub Agent
8282
=== "代码"
8383

84-
```python title="client.py" linenums="1"
85-
from veadk import Agent, Runner
86-
from veadk.a2a.remote_ve_agent import RemoteVeAgent
87-
88-
async def main(prompt: str) -> str:
89-
"""Main function for run an agent.
84+
```python title="client.py" linenums="1"
85+
from veadk import Agent, Runner
86+
from veadk.a2a.remote_ve_agent import RemoteVeAgent
9087

91-
Args:
92-
prompt (str): The prompt to run.
88+
async def main(prompt: str) -> str:
89+
"""Main function for run an agent.
9390
94-
Returns:
95-
str: The response from the agent.
96-
"""
97-
weather_agent = RemoteVeAgent(
98-
name="weather_agent",
99-
url="http://localhost:8000/", # <--- url of A2A server
100-
)
101-
print(f"Remote agent name is {weather_agent.name}.")
102-
print(f"Remote agent description is {weather_agent.description}.")
91+
Args:
92+
prompt (str): The prompt to run.
10393
104-
agent = Agent(
105-
name="root_agent",
106-
description="An assistant for fetching weather.",
107-
instruction="You are a helpful assistant. You can invoke weather agent to get weather information.",
108-
sub_agents=[weather_agent],
109-
)
94+
Returns:
95+
str: The response from the agent.
96+
"""
97+
weather_agent = RemoteVeAgent(
98+
name="weather_agent",
99+
url="http://localhost:8000/", # <--- url of A2A server
100+
)
101+
print(f"Remote agent name is {weather_agent.name}.")
102+
print(f"Remote agent description is {weather_agent.description}.")
103+
104+
agent = Agent(
105+
name="root_agent",
106+
description="An assistant for fetching weather.",
107+
instruction="You are a helpful assistant. You can invoke weather agent to get weather information.",
108+
sub_agents=[weather_agent],
109+
)
110110

111-
runner = Runner(agent=agent)
112-
response = await runner.run(messages=prompt)
111+
runner = Runner(agent=agent)
112+
response = await runner.run(messages=prompt)
113113

114-
return response
114+
return response
115115

116116

117-
if __name__ == "__main__":
118-
import asyncio
117+
if __name__ == "__main__":
118+
import asyncio
119119

120-
response = asyncio.run(main("What is the weather like of Beijing?"))
121-
print(response)
122-
```
120+
response = asyncio.run(main("What is the weather like of Beijing?"))
121+
print(response)
122+
```
123123
### 交互流程
124124
下图为示例对应的交互流程图
125125
```mermaid
@@ -195,52 +195,52 @@ veADK 的 A2A 鉴权机制提供了灵活的认证选项,支持标准的 Beare
195195

196196
=== "代码"
197197
```python title="client.py" linenums="1"
198-
# <...code truncated...>
198+
# <...code truncated...>
199+
200+
# 创建自定义的 httpx.AsyncClient 实例
201+
custom_client = httpx.AsyncClient(
202+
# 基础 URL 设置
203+
base_url="https://vefaas.example.com/agents/",
204+
205+
# 超时设置(秒)
206+
timeout=30.0,
207+
208+
# 连接池设置
209+
limits=httpx.Limits(
210+
max_connections=100, # 最大并发连接数
211+
max_keepalive_connections=20, # 最大保活连接数
212+
keepalive_expiry=60.0, # 保活连接过期时间
213+
),
214+
215+
# 重试配置(需要 httpx >= 0.24.0)
216+
follow_redirects=True, # 跟随重定向
199217

200-
# 创建自定义的 httpx.AsyncClient 实例
201-
custom_client = httpx.AsyncClient(
202-
# 基础 URL 设置
203-
base_url="https://vefaas.example.com/agents/",
204-
205-
# 超时设置(秒)
206-
timeout=30.0,
207-
208-
# 连接池设置
209-
limits=httpx.Limits(
210-
max_connections=100, # 最大并发连接数
211-
max_keepalive_connections=20, # 最大保活连接数
212-
keepalive_expiry=60.0, # 保活连接过期时间
213-
),
214-
215-
# 重试配置(需要 httpx >= 0.24.0)
216-
follow_redirects=True, # 跟随重定向
217-
218-
# 自定义默认请求头
219-
headers={
220-
"User-Agent": "Custom-VeADK-Client/1.0",
221-
"X-Custom-Header": "custom-value"
222-
},
223-
224-
# SSL 验证选项(生产环境中建议保持默认的 True)
225-
verify=True,
226-
227-
# 代理配置(如需使用代理)
228-
proxies="http://proxy.example.com:8080",
229-
230-
# 并发请求设置
231-
http2=True, # 启用 HTTP/2 支持
232-
)
218+
# 自定义默认请求头
219+
headers={
220+
"User-Agent": "Custom-VeADK-Client/1.0",
221+
"X-Custom-Header": "custom-value"
222+
},
233223

234-
# 创建 RemoteVeAgent 实例时,将自定义客户端传递给 httpx_client 参数
235-
remote_agent = RemoteVeAgent(
236-
name="a2a_agent",
237-
url="https://example.com/a2a",
238-
auth_token="your_token_here",
239-
auth_method="header",
240-
httpx_client=custom_client,
241-
)
242-
243-
# <...code truncated...>
224+
# SSL 验证选项(生产环境中建议保持默认的 True)
225+
verify=True,
226+
227+
# 代理配置(如需使用代理)
228+
proxies="http://proxy.example.com:8080",
229+
230+
# 并发请求设置
231+
http2=True, # 启用 HTTP/2 支持
232+
)
233+
234+
# 创建 RemoteVeAgent 实例时,将自定义客户端传递给 httpx_client 参数
235+
remote_agent = RemoteVeAgent(
236+
name="a2a_agent",
237+
url="https://example.com/a2a",
238+
auth_token="your_token_here",
239+
auth_method="header",
240+
httpx_client=custom_client,
241+
)
242+
243+
# <...code truncated...>
244244
```
245245

246246

docs/docs/agent/agent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ root_agent = Agent(
6666

6767
如果您想使用本地模型或其他提供商的模型,可以在初始化时指定模型相关配置:
6868

69-
```python title="agent.py" linenums="1" hl_lines="4-6"
69+
```python title="agent.py" linenums="1" hl_lines="4-7"
7070
from veadk import Agent
7171

7272
agent = Agent(
@@ -98,7 +98,7 @@ agent = Agent(model=llm)
9898

9999
此外,您还可以根据[火山引擎方舟大模型平台](https://www.volcengine.com/product/ark)的能力,指定一些[额外选项](https://www.volcengine.com/docs/82379/1494384?lang=zh),例如您可以禁用豆包 1.6 系列模型的思考能力,以实现更加快速的响应:
100100

101-
```python title="agent.py" linenums="1" hl_lines="7-11"
101+
```python title="agent.py" linenums="1" hl_lines="7"
102102
import asyncio
103103

104104
from veadk import Agent, Runner

docs/docs/knowledgebase/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ KnowledgeBase 在 veadk 框架中扮演 Agent 的外部知识库 角色。它像
1616

1717
4) 与 Agent 无缝集成 :通过在创建 Agent 时传入 knowledgebase=kb 参数,Agent 就能自动利用这个知识库来增强其回答能力。
1818

19-
## 使用方法
19+
## 使用方法
2020

2121
以下是使用 KnowledgeBase 的典型步骤,并对比了 viking 和 opensearch 的配置差异。
2222

docs/docs/memory/long-term-memory.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ runner = Runner(
5858
)
5959
```
6060

61-
### ...
62-
6361
## 记忆管理
6462

6563
### 添加会话到长期记忆
@@ -108,10 +106,6 @@ print(res)
108106
- 设计长期记忆数据结构以支持多会话信息保存;
109107
- 配合短期记忆使用,实现会话内上下文快速访问。
110108

111-
```
112-
# 占位: 单租户多会话长期记忆结构示例
113-
```
114-
115109
### 示例
116110

117111
以下示例演示了一个完整的流程:Runner1 告诉 Agent 一个信息("My favorite project is Project Alpha"),将会话存入记忆,然后创建一个全新的 Runner2,验证其能否回答相关问题。

docs/docs/quickstart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ veadk --version
2828
```
2929
2. 配置`uv`环境
3030
本项目使用`uv`进行构建,(了解如何[安装`uv`](https://docs.astral.sh/uv/getting-started/installation/)
31-
```bash
31+
```plantext
3232
# 选择 3.10及以上版本
3333
uv venv --python 3.10
3434
```
@@ -42,11 +42,11 @@ veadk --version
4242
source .venv/bin/activate
4343
```
4444
=== "Windows CMD"
45-
```bash
45+
```cmd
4646
.venv\Scripts\activate.bat
4747
```
4848
=== "Windows PowerShell"
49-
```bash
49+
```powershell
5050
.venv\Scripts\activate.ps1
5151
```
5252
安装 VeADK

docs/docs/references/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ title: 贡献代码
1818

1919
`pre-commit` 将在您提交代码前进行一系列检查,例如代码格式规范检查、密钥泄漏检查等。未使用 `pre-commit` 检查过的提交将不会通过 Github 中的 CI/CD 工作流检查,这意味着代码将不会被合并。
2020

21-
```bash [Terminal]
21+
```bash
2222
pip install pre-commit
2323

2424
pre-commit install .

0 commit comments

Comments
 (0)