Skip to content

Commit 28735b7

Browse files
committed
Merge branch 'main' into feat/skills
2 parents 43ad192 + 5fce720 commit 28735b7

14 files changed

Lines changed: 405 additions & 32 deletions

File tree

config.yaml.full

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ database:
151151
region: cn-beijing # default Volcengine TOS Vector region
152152
bucket:
153153
account_id:
154-
154+
155+
# Dynamic config
156+
nacos:
157+
endpoint:
158+
password:
155159

156160

157161
# [optional] for prompt optimization in cli/app

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ title: A2A Agent
3232

3333
| 场景名称 | 说明 |
3434
| - | - |
35-
| **内部代码组织** | 您在单个 Agent 内将复杂任务拆分为更小、可管理的函数或模块,这类场景出于性能与简洁考虑,更适合作为本地子 |
36-
| **性能关键的内部操作** | 某个 Sub Agent 负责与主 Agent 执行紧密耦合的高频、低延迟操作,这类场景由于需要低延迟响应,更适合作为本地Local Sub-Agents |
35+
| **内部代码组织** | 您在单个 Agent 内将复杂任务拆分为更小、可管理的函数或模块,这类场景出于性能与简洁考虑,更适合作为本地 Local Sub-Agents |
36+
| **性能关键的内部操作** | 某个 Sub Agent 负责与主 Agent 执行紧密耦合的高频、低延迟操作,这类场景由于需要低延迟响应,更适合作为本地 Local Sub-Agents |
3737
| **共享内存或上下文** | 当 Sub Agent 需要直接访问主 Agent 的内部状态或共享内存以提高效率时,A2A 的网络开销与序列化/反序列化会适得其反 |
3838
| **简单的辅助函数** | 对于无需独立部署或复杂状态管理的小型复用逻辑,直接在同一 Agent 中编写函数或类,通常比拆分为独立的 A2A Agent 更合适 |
3939

docs/docs/configuration.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ veidentity:
142142
| 名称 | 值 | 释义 |
143143
|------|----|------|
144144
| DEFAULT_AGENT_NAME | `veAgent` | Agent 的缺省名称 |
145-
| DEFAULT_MODEL_AGENT_NAME | `doubao-seed-1-6-250615` | Agent 的推理模型名称 |
146-
| DEFAULT_MODEL_AGENT_PROVIDER | `openai` | Agent 的推理模型提供商 |
145+
| DEFAULT_MODEL_AGENT_NAME | `doubao-seed-1-6-251015` | Agent 的推理模型名称 |
146+
| DEFAULT_MODEL_AGENT_PROVIDER | `openai` | Agent 的推理模型提供商,方舟平台兼容 openai 规范,因此使用方舟默认是 openai 即可 |
147147
| DEFAULT_MODEL_AGENT_API_BASE | `https://ark.cn-beijing.volces.com/api/v1/` | 模型 API 基础地址 |
148+
| DEFAULT_IMAGE_GENERATE_MODEL_NAME | `doubao-seedream-4-5-251128` | image_generate 工具默认使用的方舟生图模型 |
149+
| DEFAULT_IMAGE_GENERATE_MODEL_API_BASE | `https://ark.cn-beijing.volces.com/api/v3/` | image_generate 工具默认使用的方舟生图模型 API 基础地址 |
150+
| DEFAULT_VIDEO_MODEL_NAME | `doubao-seedance-1-5-pro-251215` | video_generate 工具默认使用的方舟视频生成模型 |
151+
| DEFAULT_VIDEO_MODEL_API_BASE | `https://ark.cn-beijing.volces.com/api/v3/` | video_generate 工具默认使用的方舟视频生成模型 API 基础地址 |
148152
| DEFAULT_APMPLUS_OTEL_EXPORTER_ENDPOINT | `http://apmplus-cn-beijing.volces.com:4317` | APMPlus OpenTelemetry Trace 导出地址 |
149153
| DEFAULT_APMPLUS_OTEL_EXPORTER_SERVICE_NAME | `veadk_tracing` | APMPlus 服务名 |
150154
| DEFAULT_COZELOOP_OTEL_EXPORTER_ENDPOINT | `https://api.coze.cn/v1/loop/opentelemetry/v1/traces` | CozeLoop OTEL Trace 上报地址 |
@@ -155,5 +159,5 @@ veidentity:
155159
| DEFAULT_CR_REPO_NAME | `veadk-user-repo` | 容器镜像仓库名称 |
156160
| DEFAULT_TLS_LOG_PROJECT_NAME | `veadk-logs` | TLS 日志项目名称 |
157161
| DEFAULT_TLS_TRACING_INSTANCE_NAME | `veadk-tracing` | TLS Tracing 实例名称 |
158-
| DEFAULT_TOS_BUCKET_NAME | `veadk-default-bucket` | 默认 TOS 存储桶名称 |
162+
| DEFAULT_TOS_BUCKET_NAME | `veadk-default-bucket` | 默认 TOS 存储桶名称,由于 TOS 存储桶全球唯一,因此强烈建议用户自定义存储桶名称,避免与其他用户冲突导致运行失败 |
159163
| DEFAULT_COZELOOP_SPACE_NAME | `VeADK Space` | CozeLoop 空间名称 |

docs/docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ hide:
116116

117117
---
118118

119-
提供短期记忆与长期记忆的完整解决方案:短期记忆可基于 MySQL 实现持久化存储;长期记忆则依托 Viking DB、云搜索服务构建。VeADK 以 LlamaINdex 作为知识库核心处理入口,同时支持 Viking 知识库后端无缝接入。
119+
提供短期记忆与长期记忆的完整解决方案:短期记忆可基于 MySQL 实现持久化存储;长期记忆则依托 Viking DB、云搜索服务构建。VeADK 以 LlamaIndex 作为知识库核心处理入口,同时支持 Viking 知识库后端无缝接入。
120120

121121
- :material-toolbox:{ .lg .middle } __内置丰富工具和生态集成__
122122

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ title: 长期记忆
1717

1818
## 支持后端类型
1919

20-
| 类别 | 说明 |
20+
调试可以用 `local` 后端。生产更建议使用 `viking``mem0` 后端。
21+
22+
| 类别 | 说明 |
2123
| :----------- | :--------------------------------------------------------- |
22-
| `local` | 内存跨 Session 记忆,程序结束后即清空 |
23-
| `opensearch` | 使用 OpenSearch 作为长期记忆存储,可实现持久化和检索 |
24-
| `redis` | 使用 Redis 作为长期记忆存储,Redis 需要支持 Rediseach 功能 |
25-
| `viking` | 使用 VikingDB 记忆库产品作为长期记忆存储 |
26-
| `viking_mem` | 已废弃,设置后将会自动转为 `viking` |
24+
| `local` | 内存跨 Session 记忆,程序结束后即清空 (仅适用于本地调试) |
25+
| `viking` | 使用 VikingDB 记忆库产品作为长期记忆存储 (生产推荐) |
26+
| `mem0` | 使用 Mem0 记忆库产品作为长期记忆存储 (生产推荐) |
27+
| `viking_mem` | 已废弃,设置后将会自动转为 `viking` |
28+
| `opensearch` | 使用 OpenSearch 作为长期记忆存储,可实现持久化和检索 |
29+
| `redis` | 使用 Redis 作为长期记忆存储,Redis 需要支持 Rediseach 功能 |
2730

2831
## 初始化方法
2932

docs/docs/memory/short-term-memory.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,23 @@ VeADK 中,您可以使用如下短期记忆后端服务来初始化您的短
211211
```python
212212
from google.adk.apps.app import App
213213
from google.adk.apps.app import EventsCompactionConfig
214+
from veadk.agent import Agent
215+
216+
root_agent = Agent(
217+
description="hello world agent",
218+
instruction="""你是一个智能助手,擅长用中文礼貌回复用户的问题。""",
219+
)
214220

215221
app = App(
216-
name='my-agent',
222+
name='my_agent',
217223
root_agent=root_agent,
218224
events_compaction_config=EventsCompactionConfig(
219225
compaction_interval=3, # 每 3 次新调用触发一次压缩。
220226
overlap_size=1 # 包含前一个窗口的最后一次事件重叠。
221227
),
222228
)
229+
230+
root_agent = agent
223231
```
224232

225233
### 定义压缩器

docs/docs/veadk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ graph LR
4141

4242
## VeADK 体系结构
4343

44-
VeADK 基于模块化设计,主要组件包括:智能体运行时、工具、记忆系统、知识库、观测系统、评测系统等。各组件通过明确的接口进行解耦,以便在不同业务场景下替换或扩展。
44+
VeADK 基于模块化设计,主要组件包括:执行引擎、工具、记忆系统、知识库、观测系统、评测系统等。各组件通过明确的接口进行解耦,以便在不同业务场景下替换或扩展。
4545

4646
### 核心组件
4747

veadk/agent.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
if not os.getenv("LITELLM_LOCAL_MODEL_COST_MAP"):
2525
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
2626

27+
import uuid
28+
2729
from google.adk.agents import LlmAgent, RunConfig
2830
from google.adk.agents.base_agent import BaseAgent
2931
from google.adk.agents.context_cache_config import ContextCacheConfig
@@ -89,6 +91,7 @@ class Agent(LlmAgent):
8991

9092
model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
9193

94+
id: str = Field(default_factory=lambda: str(uuid.uuid4()).split("-")[0])
9295
name: str = DEFAULT_AGENT_NAME
9396
description: str = DEFAULT_DESCRIPTION
9497
instruction: Union[str, InstructionProvider] = DEFAULT_INSTRUCTION
@@ -278,7 +281,13 @@ def model_post_init(self, __context: Any) -> None:
278281

279282
logger.info(f"{self.__class__.__name__} `{self.name}` init done.")
280283
logger.debug(
281-
f"Agent: {self.model_dump(include={'name', 'model_name', 'model_api_base', 'tools'})}"
284+
f"Agent: {self.model_dump(include={'id', 'name', 'model_name', 'model_api_base', 'tools'})}"
285+
)
286+
287+
def update_model(self, model_name: str):
288+
logger.info(f"Updating model to {model_name}")
289+
self.model = self.model.model_copy(
290+
update={"model": f"{self.model_provider}/{model_name}"}
282291
)
283292

284293
async def _run(

veadk/auth/veauth/mse_veauth.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from veadk.auth.veauth.utils import get_credential_from_vefaas_iam
18+
from veadk.configs.database_configs import MSENacosConfig
19+
from veadk.utils.logger import get_logger
20+
from veadk.utils.volcengine_sign import ve_request
21+
22+
logger = get_logger(__name__)
23+
24+
25+
def get_instance_id_by_name(instance_name: str, region: str, project_name: str) -> str:
26+
logger.info(f"Fetching MSE Nacos instance id by instance name {instance_name} ...")
27+
28+
access_key = os.getenv("VOLCENGINE_ACCESS_KEY")
29+
secret_key = os.getenv("VOLCENGINE_SECRET_KEY")
30+
session_token = ""
31+
32+
if not (access_key and secret_key):
33+
# try to get from vefaas iam
34+
cred = get_credential_from_vefaas_iam()
35+
access_key = cred.access_key_id
36+
secret_key = cred.secret_access_key
37+
session_token = cred.session_token
38+
39+
res = ve_request(
40+
request_body={
41+
"Filter": {"Status": [], "ProjectName": project_name},
42+
"PageNumber": 1,
43+
"PageSize": 10,
44+
"ProjectName": project_name,
45+
},
46+
header={"X-Security-Token": session_token},
47+
action="ListNacosRegistries",
48+
ak=access_key,
49+
sk=secret_key,
50+
service="mse",
51+
version="2022-01-01",
52+
region=region,
53+
host="open.volcengineapi.com",
54+
)
55+
56+
try:
57+
for item in res["Result"]["Items"]:
58+
if item["Name"] == instance_name:
59+
logger.info(
60+
f"Found MSE Nacos instance id {item['Id']} by instance name {instance_name}"
61+
)
62+
return item["Id"]
63+
raise ValueError(f"Id by instance name {instance_name} not found: {res}")
64+
except Exception as e:
65+
logger.error(
66+
f"Failed to get MSE Nacos instance id by name {instance_name}: {e}, response: {res}"
67+
)
68+
raise e
69+
70+
71+
def get_mse_cridential(
72+
instance_name: str,
73+
region: str = "cn-beijing",
74+
project_name: str = "default",
75+
) -> MSENacosConfig:
76+
logger.info("Fetching MSE Nacos token...")
77+
78+
access_key = os.getenv("VOLCENGINE_ACCESS_KEY")
79+
secret_key = os.getenv("VOLCENGINE_SECRET_KEY")
80+
session_token = ""
81+
82+
if not (access_key and secret_key):
83+
# try to get from vefaas iam
84+
cred = get_credential_from_vefaas_iam()
85+
access_key = cred.access_key_id
86+
secret_key = cred.secret_access_key
87+
session_token = cred.session_token
88+
89+
instance_id = get_instance_id_by_name(
90+
instance_name=instance_name, region=region, project_name=project_name
91+
)
92+
93+
res = ve_request(
94+
request_body={
95+
"Id": instance_id,
96+
"ProjectName": project_name,
97+
},
98+
header={"X-Security-Token": session_token},
99+
action="GetNacosRegistry",
100+
ak=access_key,
101+
sk=secret_key,
102+
service="mse",
103+
version="2022-01-01",
104+
region=region,
105+
host="open.volcengineapi.com",
106+
)
107+
108+
try:
109+
logger.info(
110+
f"Successfully fetched MSE Nacos endpoint {res['Result']['NacosRegistry']['PublicAddress']} and corresponding password."
111+
)
112+
return MSENacosConfig(
113+
endpoint=res["Result"]["NacosRegistry"]["PublicAddress"],
114+
password=res["Result"]["NacosRegistry"]["InitialPassword"],
115+
)
116+
except Exception as e:
117+
logger.error(f"Failed to get MSE Nacos token: {e}, response: {res}")
118+
raise e

veadk/configs/database_configs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,13 @@ class TOSVectorConfig(BaseSettings):
178178
user_agent_soft_version: str | None = None
179179

180180
user_agent_customized_key_values: dict[str, str] | None = None
181+
182+
183+
class MSENacosConfig(BaseSettings):
184+
model_config = SettingsConfigDict(env_prefix="NACOS_")
185+
186+
endpoint: str
187+
port: str = "8848" # hard coding by Volcengine MSE Nacos service
188+
189+
username: str = "nacos" # hard coding by Volcengine MSE Nacos service
190+
password: str

0 commit comments

Comments
 (0)