Skip to content

Commit 7ca0fd7

Browse files
committed
docs: add single agent doc
1 parent b01c7d2 commit 7ca0fd7

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,37 @@ Use the AgentMesh SDK to build custom agent teams programmatically:
127127
pip install agentmesh-sdk
128128
```
129129

130-
Example usage (replace `YOUR_API_KEY` with your actual API key):
130+
#### 3.1 Single Agent
131+
132+
Run a single super-agent directly without a team, with multi-turn conversation support:
133+
134+
```python
135+
from agentmesh import Agent, LLMModel
136+
from agentmesh.tools import *
137+
138+
# Initialize model
139+
model = LLMModel(model="gpt-4.1", api_key="YOUR_API_KEY")
140+
141+
# Create a single agent with tools
142+
agent = Agent(
143+
name="Assistant",
144+
description="A versatile assistant",
145+
system_prompt="You are a helpful assistant who answers questions using available tools.",
146+
model=model,
147+
tools=[GoogleSearch(), Calculator()]
148+
)
149+
150+
# Single-turn call
151+
response = agent.run_stream("What are the latest trends in multi-agent AI?")
152+
153+
# Multi-turn conversation (history is retained automatically)
154+
agent.run_stream("My project is named AgentMesh")
155+
agent.run_stream("Write a brief intro for my project") # Remembers the project name
156+
```
157+
158+
#### 3.2 Agent Team
159+
160+
Build a multi-agent team where agents collaborate on complex tasks (replace `YOUR_API_KEY` with your actual API key):
131161

132162
```python
133163
from agentmesh import AgentTeam, Agent, LLMModel

docs/README-CN.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,37 @@ python main.py -t general_team # 指定一个team后开始多
124124
pip install agentmesh-sdk
125125
```
126126

127-
以下是一个简单的使用示例,使用前请替换 `YOUR_API_KEY` 为你的实际API密钥:
127+
#### 3.1 单智能体
128+
129+
直接运行单个超级智能体,支持多轮对话:
130+
131+
```python
132+
from agentmesh import Agent, LLMModel
133+
from agentmesh.tools import *
134+
135+
# 初始化模型
136+
model = LLMModel(model="gpt-4.1", api_key="YOUR_API_KEY")
137+
138+
# 创建单个智能体并配置工具
139+
agent = Agent(
140+
name="Assistant",
141+
description="通用助手",
142+
system_prompt="你是一个善于使用工具解决问题的助手。",
143+
model=model,
144+
tools=[GoogleSearch(), Calculator()]
145+
)
146+
147+
# 单次调用
148+
response = agent.run_stream("帮我分析多智能体技术的最新发展趋势")
149+
150+
# 多轮对话(自动保留上下文)
151+
agent.run_stream("我的项目名称是 AgentMesh")
152+
agent.run_stream("帮我为这个项目写一段简介")
153+
```
154+
155+
#### 3.2 多智能体团队
156+
157+
构建多智能体团队,通过协作完成复杂任务,使用前请替换 `YOUR_API_KEY` 为你的实际API密钥:
128158

129159
```python
130160
from agentmesh import AgentTeam, Agent, LLMModel

0 commit comments

Comments
 (0)