Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/agent_tools/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Set TRPC_AGENT_API_KEY、TRPC_AGENT_BASE_URL、TRPC_AGENT_MODEL_NAME
TRPC_AGENT_API_KEY=your-api-key
TRPC_AGENT_BASE_URL=your-base-url
TRPC_AGENT_MODEL_NAME=your-model-name
2 changes: 1 addition & 1 deletion examples/agent_tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ pip3 install -e .
然后运行下面的命令:

```bash
cd examples/tool_with_agent_tool/
cd examples/agent_tools/
python3 run_agent.py
```
3 changes: 3 additions & 0 deletions examples/claude_agent/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Set TRPC_AGENT_API_KEY, TRPC_AGENT_BASE_URL, TRPC_AGENT_MODEL_NAME
TRPC_AGENT_API_KEY=your-api-key
TRPC_AGENT_BASE_URL=your-base-url
TRPC_AGENT_MODEL_NAME=your-model-name
2 changes: 1 addition & 1 deletion examples/claude_agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ git clone https://github.com/trpc-group/trpc-agent-python.git
cd trpc-agent-python
python3 -m venv .venv
source .venv/bin/activate
pip3 install -e .[agent-claude]
pip3 install -e '.[agent-claude]'
```

2. 在 `.env` 文件中设置环境变量(也可以通过export设置):
Expand Down
3 changes: 3 additions & 0 deletions examples/claude_agent_with_cancel/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Set TRPC_AGENT_API_KEY、TRPC_AGENT_BASE_URL、TRPC_AGENT_MODEL_NAME
TRPC_AGENT_API_KEY=your-api-key
TRPC_AGENT_BASE_URL=your-base-url
TRPC_AGENT_MODEL_NAME=your-model-name
2 changes: 1 addition & 1 deletion examples/claude_agent_with_cancel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ git clone https://github.com/trpc-group/trpc-agent-python.git
cd trpc-agent-python
python3 -m venv .venv
source .venv/bin/activate
pip3 install -e .[agent-claude]
pip3 install -e '.[agent-claude]'
```

2. 在 `.env` 文件中设置环境变量(也可以通过export设置):
Expand Down
3 changes: 3 additions & 0 deletions examples/claude_agent_with_code_writer/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Set TRPC_AGENT_API_KEY、TRPC_AGENT_BASE_URL、TRPC_AGENT_MODEL_NAME
TRPC_AGENT_API_KEY=yhNrIaLLjibwZ4PHdenwiFEw@4462
TRPC_AGENT_BASE_URL=http://v2.open.venus.woa.com/llmproxy
TRPC_AGENT_MODEL_NAME=deepseek-v3-local-II
2 changes: 1 addition & 1 deletion examples/claude_agent_with_skills/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git clone https://github.com/trpc-group/trpc-agent-python.git
cd trpc-agent-python
python3 -m venv .venv
source .venv/bin/activate
pip3 install -e .
pip3 install -e '.[agent-claude]'
```

2. Claude Agent SKILL 前置配置
Expand Down
8 changes: 3 additions & 5 deletions examples/claude_agent_with_streaming_tool/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Environment variables for A2A Agent with Cancel example
# Copy this file and configure with your own values

# Model API Configuration
TRPC_AGENT_API_KEY=your_api_key_here
TRPC_AGENT_BASE_URL=your_base_url_here
TRPC_AGENT_MODEL_NAME=your_model_name_here
TRPC_AGENT_API_KEY=your-api-key
TRPC_AGENT_BASE_URL=your-base-url
TRPC_AGENT_MODEL_NAME=your-model-name
10 changes: 7 additions & 3 deletions examples/claude_agent_with_streaming_tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ async for event in runner.run_async(...):

## 环境要求

- Python 3.10+(推荐 3.12)
- trpc-agent 框架
- claude-agent-sdk
```bash
git clone https://github.com/trpc-group/trpc-agent-python.git
cd trpc-agent-python
python3 -m venv .venv
source .venv/bin/activate
pip3 install -e '.[agent-claude]'
```

## 运行示例

Expand Down
42 changes: 21 additions & 21 deletions examples/claude_agent_with_streaming_tool/agent/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
"""Prompts for the ClaudeAgent streaming tool demo."""

INSTRUCTION = """
你是一个专业的文件操作助手。
You are a professional file operation assistant.

**你的任务:**
- 理解用户的文件操作需求
- 使用合适的工具来完成任务
- 生成高质量的文件内容
**Your Tasks:**
- Understand the user's file operation requirements
- Use the appropriate tools to complete tasks
- Generate high-quality file content

**可用工具:**
1. `write_file(path, content)`: 将内容写入指定路径的文件 (流式工具 - 参数实时显示)
2. `get_file_info(path)`: 获取文件信息 (普通工具 - 参数完成后才显示)
**Available Tools:**
1. `write_file(path, content)`: Write content to a file at the specified path (streaming tool - parameters are displayed in real time)
2. `get_file_info(path)`: Get file information (regular tool - parameters are displayed only after completion)

**使用指南:**
- 当用户要求创建文件时,使用 write_file 工具
- 当用户要求查看文件信息时,使用 get_file_info 工具
- 可以组合使用多个工具完成复杂任务
**Usage Guide:**
- Use the write_file tool when the user asks to create a file
- Use the get_file_info tool when the user asks to view file information
- Combine multiple tools to complete complex tasks

**示例场景:**
- 创建 HTML 网页
- 创建 Python 脚本
- 查询文件信息
- 创建配置文件
**Example Scenarios:**
- Create an HTML webpage
- Create a Python script
- Query file information
- Create configuration files

**注意事项:**
- 生成的内容应该完整、格式正确
- 文件路径应该合理
- 代码文件应该包含适当的注释
**Notes:**
- Generated content should be complete and properly formatted
- File paths should be reasonable
- Code files should include appropriate comments
"""
2 changes: 1 addition & 1 deletion examples/claude_agent_with_streaming_tool/run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import uuid

from dotenv import load_dotenv
from trpc_agent_sdk.models import constants as const
from trpc_agent_sdk.models import _constants as const
from trpc_agent_sdk.runners import Runner
from trpc_agent_sdk.server.agents.claude import destroy_claude_env
from trpc_agent_sdk.server.agents.claude import setup_claude_env
Expand Down
3 changes: 3 additions & 0 deletions examples/claude_agent_with_travel_planner/.env
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Set TRPC_AGENT_API_KEY、TRPC_AGENT_BASE_URL、TRPC_AGENT_MODEL_NAME
TRPC_AGENT_API_KEY=yhNrIaLLjibwZ4PHdenwiFEw@4462
TRPC_AGENT_BASE_URL=http://v2.open.venus.woa.com/llmproxy
TRPC_AGENT_MODEL_NAME=deepseek-v3-local-II
49 changes: 49 additions & 0 deletions examples/claude_agent_with_travel_planner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,52 @@ uv pip install duckduckgo-mcp-server
cd examples/claude_agent_with_travel_planner/
python3 run_agent.py
```

## 结果输出暂存

[2026-04-01 19:40:31][INFO][trpc_agent_sdk][trpc_agent_sdk/server/agents/claude/_setup.py:227][48891] Proxy server proxy process started (PID: 48948)
[2026-04-01 19:40:32][INFO][trpc_agent_sdk][trpc_agent_sdk/server/agents/claude/_setup.py:244][48891] Proxy server is ready at http://0.0.0.0:8082
[2026-04-01 19:40:32][INFO][trpc_agent_sdk][trpc_agent_sdk/server/agents/claude/_runtime.py:27][48891] ClaudeAgent event loop thread started
🆔 Session ID: 3d329114...
👤 User ID: Alice

💬 请输入您的旅游需求(输入 'quit' 或 'exit' 退出):
> beijing
📝 用户: beijing

🤖 Agent: ⠋ Resolving dependencies...
Installed 39 packages in 65ms
DuckDuckGo MCP Server initialized:
SafeSearch: MODERATE (kp=-1)
Default Region: none
[04/01/26 19:40:44] INFO Processing request of type ListToolsRequest server.py:720
INFO Processing request of type ListToolsRequest server.py:720

🔧 [Tool Call: mcp__travel_planner_tools__get_current_date({})]

🔧 [Tool Call: mcp__travel_planner_tools__search({"query": "Beijing travel guide 2026", "max_results": 5, "region": "cn-zh"})]
📊 [Tool Result: mcp__travel_planner_tools__get_current_date({"result": "2026-04-01"})]
[04/01/26 19:40:51] INFO Processing request of type CallToolRequest server.py:720
[04/01/26 19:40:52] INFO HTTP Request: POST https://html.duckduckgo.com/html "HTTP/1.1 200 OK" _client.py:1740
📊 [Tool Result: mcp__travel_planner_tools__search({"result": "Found 5 search results:\n\n1. Beijing Travel Guide 2026: Top Attractions, Best Time & Insider Tips\n URL: https://bespokechinatravel.com/travel-guide/beijing/\n Summary: Plan yourBeiji)]
今天是2026年4月1日,以下是关于北京旅游的一些建议和资源:

### 1. [北京旅游指南2026:顶级景点、最佳时间和内部贴士](https://bespokechinatravel.com/travel-guide/beijing/)
- 提供全面的旅游指南,包括景点推荐、最佳旅行时间、行程安排、美食、交通和实用贴士。

### 2. [2026年北京旅行计划:7个步骤](https://www.chinahighlights.com/beijing/beijing-trip-planner.htm)
- 帮助规划行程,包括停留时间、最佳季节、交通方式和预算。

### 3. [2026年北京旅游指南:历史、胡同与城市生活](https://www.thechinajourney.com/zh_cn/%E5%8C%97%E4%BA%AC%E6%97%85%E6%B8%B8%E6%8C%87%E5%8D%97/)
- 推荐春季(3月至5月)和秋季(9月至11月)为最佳旅行季节,气候舒适,风景优美。

### 4. [中国旅游指南:北京](https://global.chinadaily.com.cn/a/202603/27/WS69c5dda4a310d6866eb402e5.html)
- 介绍北京的传统与现代结合的魅力,从胡同到商业街。

### 5. [北京2026:何时去、住哪里、做什么](https://www.nationalgeographic.com/travel/best-of-the-world-2026/article/beijing-china)
- 推荐2026年北京的新景点和必看之地,从故宫到隐藏的庭院。

如果您有具体的需求(如住宿、交通、景点推荐等),请告诉我,我可以为您进一步规划!
----------------------------------------
> quit
👋 再见!
2 changes: 1 addition & 1 deletion trpc_agent_sdk/tools/_agent_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def _run_async_impl(
parts=[Part.from_text(text=str(input_value))],
)
# Import Runner here to avoid circular import
from trpc_agent_sdk._runners import Runner
from trpc_agent_sdk.runners import Runner

runner = Runner(
app_name=f"{self.agent.name}{AGENT_TOOL_APP_NAME_SUFFIX}",
Expand Down
Loading