Skip to content

Commit f0f6fab

Browse files
committed
add documents
1 parent 10c3d40 commit f0f6fab

File tree

15 files changed

+145
-61
lines changed

15 files changed

+145
-61
lines changed

docs/content/3.agent/3.agent-builder.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ navigation:
99

1010
您可以通过一个 Agent 配置文件来构建 Agent 运行时实例,准备如下项目:
1111

12-
::code-tree{default-value="config.yaml"}
12+
::code-tree{default-value="agent.yaml"}
1313

1414
```yaml [agent.yaml]
1515
root_agent:
@@ -48,7 +48,23 @@ print(response)
4848

4949
其中,每个 `agent``type` 负责指定 Agent 的类型。
5050

51-
可以通过如下代码来实例化这个 Agent:
51+
可以通过如下代码来实例化这个 Agent:
52+
53+
```python
54+
import asyncio
55+
56+
from veadk.agent_builder import AgentBuilder
57+
from veadk.runner import Runner
58+
59+
agent_builder = AgentBuilder()
60+
61+
agent = agent_builder.build(path="agent.yaml")
62+
63+
runner = Runner(agent=agent)
64+
response = asyncio.run(runner.run("北京天气"))
65+
66+
print(response)
67+
```
5268

5369
## 参数定义
5470

docs/content/5.tools/1.builtin-tools.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ VeADK 中集成了多个火山引擎提供的工具:
1414
| [`web_search`](https://www.volcengine.com/docs/85508/1650263) | 公域搜索 | `from veadk.tools.builtin_tools.web_search import web_search` |
1515
| [`web_scraper`](https://www.volcengine.com/docs/84296/1545470) | 聚合搜索(邀测阶段),代码见[这里](https://github.com/volcengine/mcp-server/tree/main/server) | `from veadk.tools.builtin_tools.web_scraper import web_scraper` |
1616
| [`vesearch`](https://www.volcengine.com/docs/85508/1512748) | 联网搜索,头条搜索等 | `from veadk.tools.builtin_tools.vesearch import vesearch` |
17-
| | | |
18-
| | | |
19-
20-
## 使用
17+
| [`image_generate`](https://www.volcengine.com/docs/82379/1541523) | 图片生成 | `from veadk.tools.builtin_tools.image_generate import image_generate` |
18+
| [`image_edit`](https://www.volcengine.com/docs/82379/1541523) | 图片编辑(图生图) | `from veadk.tools.builtin_tools.image_edit import image_edit` |
19+
| [`video_generate`](https://www.volcengine.com/docs/82379/1520757) | 视频生成 | `from veadk.tools.builtin_tools.video_generate import video_generate` |
2120

2221
::note
2322
使用 `vesearch` 前,请先在火山引擎控制台创建一个搜索智能体,并获取其 Endpoint。
2423
::
2524

25+
## 使用
26+
2627
以下示例展示了如何在 VeADK 中集成并调用内置工具 `web_search`,用于获取今天的三条热点新闻:
2728

2829
```python [agent.py]
@@ -47,5 +48,5 @@ print(response)
4748

4849
## 系统工具
4950

50-
- `load_knowledgebase`:检索知识库工具,在你给 Agent 传入`knowledgebase`参数后,将会自动挂载该工具,Agent 将在运行时自主决定何时查询知识库;
51-
- `load_memory`:检索长期记忆工具,在你给 Agent 传入`long_term_memory`参数后,将会自动挂载该工具,Agent 将在运行时自主决定何时查询长期记忆。
51+
- `load_knowledgebase`:检索知识库工具,在你给 Agent 传入 `knowledgebase` 参数后,将会自动挂载该工具,Agent 将在运行时自主决定何时查询知识库;
52+
- `load_memory`:检索长期记忆工具,在你给 Agent 传入 `long_term_memory` 参数后,将会自动挂载该工具,Agent 将在运行时自主决定何时查询长期记忆。

docs/content/6.memory/1.overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: 记忆功能概述
2+
title: 概述
33
description: 智能体上下文的重要组成部分
44
navigation:
5-
icon: i-lucide-zap
5+
icon: i-lucide-file
66
---
77

88
在 VeADK 中,记忆(memory)能够为 Agent 提供上下文支撑,主要分为短期记忆和长期记忆:

docs/content/6.memory/2.short-term-memory.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,58 @@ navigation:
1010
VeADK 通过以下方式定义一个短期记忆(在不进行特殊指定的情况下,记忆默认将会在内存中存储):
1111

1212
```python [memory.py]
13-
from veadk.memory.short_term_memory import ShortTermMemory
13+
import asyncio
1414

15-
# 创建短期记忆
16-
short_term_memory = ShortTermMemory()
15+
from veadk import Agent
16+
from veadk.memory import ShortTermMemory
17+
from veadk.runner import Runner
1718

18-
# 在短期记忆中创建一个会话
19-
await short_term_memory.create_session(
20-
app_name=app_name, user_id=user_id, session_id=session_id
21-
)
19+
short_term_memory = ShortTermMemory(backend="local")
20+
agent = Agent(short_term_memory=short_term_memory)
2221

23-
# 获取会话服务
24-
session_service = short_term_memory.session_service
25-
```
22+
runner = Runner(agent=agent)
23+
24+
response = asyncio.run(runner.run("北京天气"))
2625

27-
## 参数
26+
print(response)
27+
```
2828

2929
## 后端适配
30+
31+
通过设置初始化 `ShortTermMemory` 时的 `backend` 参数来指定不同的短期记忆存储后端:
32+
33+
| 类别 | 说明 |
34+
| :- | :- |
35+
| `local` | 内存短期记忆,程序结束后即清空 |
36+
| `mysql` | 使用 MySQL 数据库存储短期记忆,可实现持久化 |
37+
| `sqlite` | 使用本地 SQLite 数据库存储短期记忆,可实现持久化 |
38+
| `postgresql` | 使用 PostgreSQL 数据库存储短期记忆,可实现持久化 |
39+
| `database` | 已废弃,设置后将会自动转为 `sqlite` |
40+
41+
::warning
42+
后端选项 `database` 已废弃。
43+
::
44+
45+
## 详细参数
46+
47+
::field-group
48+
::field{name="backend" type="Literal['local','mysql','sqlite','postgresql','database']"}
49+
默认 `local` - 短期记忆后端,`local` 表示内存存储,`mysql` 表示 MySQL/PostgreSQL 存储,`sqlite` 表示 SQLite 存储。
50+
::
51+
52+
::field{name="backend_configs" type="dict"}
53+
后端特定配置。默认空字典。
54+
::
55+
56+
::field{name="db_url" type="string"}
57+
数据库连接 URL,例如 `sqlite:///./test.db`。最高优先级,设置后会覆盖 `backend` 参数。
58+
::
59+
60+
::field{name="local_database_path" type="string"}
61+
本地数据库路径,仅在 `backend``sqlite` 时使用。默认 `/tmp/veadk_local_database.db`
62+
::
63+
64+
::field{name="after_load_memory_callback" type="Callable | None"}
65+
加载后端记忆后调用的回调函数。回调函数接收 `Session` 作为输入。默认 `None`
66+
::
67+
::

docs/content/6.memory/3.long-term-memory.md

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,10 @@ VeADK 的长期记忆通常存储在数据库中,通过如下方式定义一
1212
```python
1313
from veadk.memory.long_term_memory import LongTermMemory
1414

15-
long_term_memory = LongTermMemory(backend=...) # 默认的数据库为`opensearch`
16-
17-
# 装配到Agent中,同时会自动挂载`load_memory_tool`工具
18-
agent = Agent(long_term_memory=long_term_memory)
19-
20-
# 运行时可选将某个session存储到长期记忆中
21-
session = await session_service.get_session(
22-
app_name=app_name,
23-
user_id=user_id,
24-
session_id=session_id,
25-
) # 获取当前session
26-
await self.long_term_memory.add_session_to_memory(session) # 添加
15+
long_term_memory = LongTermMemory()
2716
```
2817

29-
长期记忆中的 backend 字段定义如下:
30-
31-
| backend | 说明 |
32-
| --- | --- |
33-
| local | GIGO 模式的内存存储,不具备向量检索功能,仅用于测试 |
34-
| viking | 火山引擎 [Viking 记忆库](https://www.volcengine.com/docs/84313/1783345)服务 |
35-
| opensearch | OpenSearch 数据库 |
36-
| redis | Redis 数据库,但不具备向量搜索功能 |
37-
| mysql | MySQL 数据库,但不具备向量搜索功能 |
18+
通过如下例子说明长期记忆:
3819

3920
以下示例展示了如何在 VeADK 中使用长期记忆实现跨会话的信息保留与调用。开发者可以通过 `save_session_to_long_term_memory` 方法,将某一会话中的知识性信息存入长期记忆存储后端。在新的会话中,即使上下文为空,Agent 依然能够基于长期记忆准确回忆并回答相关问题。
4021

@@ -66,3 +47,43 @@ student_prompt = "..."
6647
response = await runner.run(messages=student_prompt, session_id=new_session_id)
6748
print(response)
6849
```
50+
51+
## 后端适配
52+
53+
通过设置初始化 `LongTermMemory` 时的 `backend` 参数来指定不同的长期记忆存储后端:
54+
55+
| 类别 | 说明 |
56+
| :- | :- |
57+
| `local` | 内存跨 Session 记忆,程序结束后即清空 |
58+
| `opensearch` | 使用 OpenSearch 作为长期记忆存储,可实现持久化和检索 |
59+
| `redis` | 使用 Redis 作为长期记忆存储,Redis 需要支持 Redisearch 功能 |
60+
| `viking` | 使用 VikingDB 记忆库产品作为长期记忆存储 |
61+
| `viking_mem` | 已废弃,设置后将会自动转为 `viking` |
62+
63+
::warning
64+
后端选项 `database` 已废弃。
65+
::
66+
67+
## 详细参数
68+
69+
::field-group
70+
::field{name="backend" type="Literal['local','opensearch','redis','viking','viking_mem'] | BaseLongTermMemoryBackend"}
71+
默认为`opensearch` - 长期记忆后端类型
72+
::
73+
74+
::field{name="backend_config" type="dict"}
75+
长期记忆后端配置,默认空字典。
76+
::
77+
78+
::field{name="top_k" type="int"}
79+
默认 5 - 检索时返回最相似的文档数量。
80+
::
81+
82+
::field{name="app_name" type="string"}
83+
Agent 应用名称,用于多应用区分。默认空字符串。
84+
::
85+
86+
::field{name="user_id" type="string"}
87+
Agent 用户 ID,用于区分不同用户的长期记忆。默认空字符串。
88+
::
89+
::

docs/content/8.observation/1.tracing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
title: 数据追踪
33
description: 火山引擎云平台提供了多种 Tracing 平台
44
navigation:
5-
icon: i-lucide-code-xml
5+
icon: i-lucide-eye
66
---
77

8-
98
VeADK 提供可观测(Tracing)的能力,用于记录 Agent 执行过程中的关键路径与中间状态。支持将 Trace 数据输出至本地文件,或通过不同的 Exporter 上报至火山引擎平台,包括 CozeLoop、APMPlus、TLS,有助于开发者进行调试、性能分析、行为追踪等任务。
109

1110
## 本地观测

docs/content/8.observation/2.evaluation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 评测
33
description: 运行、评测、调优闭环支撑,助力 Agent 更加智能
44
navigation:
5-
icon: i-lucide-code-xml
5+
icon: i-lucide-chart-candlestick
66
---
77

88
VeADK 构建一套完整的自动化评测(Evaluation)流程,其主要功能包括:

docs/content/9.deploy/1.from-scratch.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: 从脚手架开始
3-
description: Text, title, and styling in standard markdown.
3+
description: 从零开始创建一个企业级 Agent 模板
44
navigation:
5-
icon: i-lucide-heading-1
5+
icon: i-lucide-cloud-upload
66
---
77

88

99
#### 初始化
1010

1111
你可以运行`veadk init`命令来初始化一个新的Agent项目:
1212

13-
```bash
13+
```bash [Terminal]
1414
$ veadk init
1515
Welcome use VeADK to create your project. We will generate a `weather-reporter` application for you.
1616
Local directory name [veadk-cloud-proj]:

docs/content/9.deploy/2.from-proj.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: 部署已有项目
3-
description: Text, title, and styling in standard markdown.
3+
description: 将已有 Agent 项目部署到 VeFaaS 平台
44
navigation:
5-
icon: i-lucide-heading-1
5+
icon: i-lucide-cloud-upload
66
---
77

88

docs/content/9.deploy/3.from-code.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: 代码部署
3-
description: Text, title, and styling in standard markdown.
3+
description: 编写代码部署项目
44
navigation:
5-
icon: i-lucide-heading-1
5+
icon: i-lucide-cloud-upload
66
---
77

88

0 commit comments

Comments
 (0)