Skip to content

Commit d3ebae5

Browse files
authored
fix: refine case of beginner
Feat/optimize beginner cases
2 parents 18359b6 + 12e0f22 commit d3ebae5

29 files changed

+644
-264
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5+
.history
6+
.DS_Store
57

68
# C extensions
79
*.so
Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,71 @@
11
# Hello World Demo
22

33
## 简介
4+
45
构建一个最简单的聊天 Agent
56

67
## 项目说明
8+
79
本示例演示了 VeADK 的核心功能:
10+
811
- **Agent 创建**:使用简单的配置创建 AI Agent
912
- **短期记忆**:使用本地后端(local backend)存储对话历史,实现会话级别的上下文记忆
1013
- **多轮对话**:通过 session_id 关联对话,Agent 能记住之前的对话内容
1114

1215
## 前置依赖
16+
1317
1. **开通火山方舟模型服务**:前往 [Ark console](https://exp.volcengine.com/ark?mode=chat)
14-
2. **准备 model_api_key**:在控制台获取 **API Key**
1518

1619
## 运行方法
17-
### 1. 安装veadk和agentkit python sdk 配置环境变量
1820

19-
```bash
20-
uv pip install veadk-python
21-
uv pip install agentkit-sdk-python
21+
### 1. 环境配置
22+
23+
若未安装 uv,请先安装(任选其一)
24+
2225
```
26+
# macOS / Linux(官方安装脚本)
27+
curl -LsSf https://astral.sh/uv/install.sh | sh
28+
# 或使用 Homebrew(macOS)
29+
brew install uv
30+
```
31+
32+
初始化项目依赖
2333

24-
`config.yaml` 中设置你的模型信息:
25-
```yaml
26-
model:
27-
agent:
28-
name: doubao-seed-1-6-251015
29-
api_key: XXXX
3034
```
35+
uv sync
36+
source .venv/bin/activate
37+
```
38+
39+
## 2. 环境变量配置
40+
41+
```
42+
export MODEL_AGENT_NAME=doubao-seed-1-6-251015
43+
# 这一步需要把YOUR_AK换成自己的ak
44+
export VOLCENGINE_ACCESS_KEY=YOUR_AK
45+
# 这一步需要把YOUR_AK换成自己的sk
46+
export VOLCENGINE_SECRET_KEY=YOUR_SK
47+
```
48+
49+
### 3. 运行本地客户端
3150

32-
### 2. 运行本地客户端
3351
```bash
34-
python agent.py
52+
# 启动服务端
53+
uv run agent.py
54+
55+
# 启动客户端进行测试
56+
uv run client.py
3557
```
3658

37-
### 3. 运行veadk web客户端并使用浏览器登录 http://127.0.0.1:8000
59+
### 4. 运行veadk web客户端并使用浏览器登录 http://127.0.0.1:8000
60+
3861
```bash
3962
cd ..
4063
veadk web
4164

4265
```
4366

44-
### 4. 部署到vefaas
67+
### 5. 部署到vefaas
68+
4569
> **安全提示:请勿在生产环境中禁用密钥认证。确保 `VEFAAS_ENABLE_KEY_AUTH` 保持为 `true`(或不设置,默认为开启),并正确配置访问密钥和角色。只有在本地受控环境调试时,才可临时关闭认证,并务必加以警告。**
4670
4771
```bash
@@ -53,38 +77,47 @@ export VOLCENGINE_ACCESS_KEY=YOUR_AK
5377
# 这一步需要把YOUR_AK换成自己的sk
5478
export VOLCENGINE_SECRET_KEY=YOUR_SK
5579
# 这一步部署应用到云上
80+
veadk deploy --vefaas-app-name=hello-world --use-adk-web
81+
# 可以使用更多的复杂配置进行部署
5682
veadk deploy --vefaas-app-name=hello-world --use-adk-web --veapig-instance-name=<your veapig instance name> --iam-role "trn:iam::<your account id>:role/<your iam role name>"
5783

5884
```
5985

60-
### 5. 部署到AgentKit 并且使用client.py测试
86+
### 6. 部署到AgentKit 并且使用client.py测试
6187

6288
```bash
6389
cd hello_world
6490
# Uncomment the following line in agent.py to run the agentkit app server
6591
# agent_server_app.run(host="0.0.0.0", port=8000)
6692
agentkit config
6793
agentkit launch
94+
95+
# 使用命令进行调试
96+
agentkit invoke 'who r u'
6897
```
6998

70-
## 示例 Prompt
99+
## 7. 示例 Prompt
100+
71101
示例代码展示了一个简单的两轮对话:
72102

73103
**第一轮对话**
104+
74105
```
75106
输入:我叫VeADK
76107
输出:你好VeADK!很高兴认识你。
77108
```
78109

79110
**第二轮对话**(测试记忆功能):
111+
80112
```
81113
输入:你还记得我叫什么吗?
82114
输出:当然记得,你叫VeADK。
83115
```
84116

85117
你也可以尝试以下对话:
118+
86119
- "我今年25岁" → "我多大了?"
87120
- "我喜欢编程" → "你知道我的爱好吗?"
88121
- "我住在北京" → "你记得我住在哪里吗?"
89122

90-
这些示例展示了 Agent 如何在同一会话中保持上下文记忆。
123+
这些示例展示了 Agent 如何在同一会话中保持上下文记忆。

02-use-cases/beginner/hello_world/README_en.md

Lines changed: 0 additions & 88 deletions
This file was deleted.

02-use-cases/beginner/hello_world/agent.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,4 @@ async def main():
3535
)
3636

3737
if __name__ == "__main__":
38-
import asyncio
39-
40-
asyncio.run(main())
41-
# Uncomment the following line to run the agentkit app server
42-
# agent_server_app.run(host="0.0.0.0", port=8000)
38+
agent_server_app.run(host="0.0.0.0", port=8000)

02-use-cases/beginner/hello_world/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# Step 0: setup running configs
1111
app_name = "hello_world"
1212
user_id = "agentkit_user"
13-
session_id = "agentkit_sample_session"
13+
session_id = "agentkit_session"
1414
base_url = "http://127.0.0.1:8000"
15-
api_key = "test key"
15+
api_key = "agentkit test key"
1616

1717
task_num = 1
1818

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "agentkit-hello-world-example"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"agentkit-sdk-python>=0.1.13",
9+
"google-adk>=1.18.0,<1.20.0",
10+
"urllib3<2.0.0",
11+
"veadk-python==0.2.29",
12+
"volcengine-python-sdk>=4.0.31",
13+
]
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
veadk-python==0.2.26
2-
agentkit-sdk-python==0.1.13
1+
veadk-python==0.2.29
2+
agentkit-sdk-python==0.1.14
3+
urllib3<2.0.0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# AgentKit configuration
2+
agentkit.yaml
3+
agentkit*.yaml
4+
5+
# Python cache
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# Virtual environments
11+
.venv/
12+
venv/
13+
ENV/
14+
env/
15+
16+
# IDE
17+
.vscode/
18+
.idea/
19+
.windsurf/
20+
21+
# Git
22+
.git/
23+
.gitignore
24+
25+
# Docker
26+
Dockerfile*
27+
.dockerignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

0 commit comments

Comments
 (0)