refactor: 重构目录结构,扁平化agent布局

- 将 agents/root_agent、agents/note_agent 移至项目根目录
- 将 base/ 重命名为 agent_base/,避免被ADK误识别为agent
- 移除所有 __init__.py 中的 sys.path.insert hack
- root_agent 添加 note_agent 作为子智能体(sub_agents)
- 更新所有 import 路径
- 更新 README.md 和 API_DOC.md
This commit is contained in:
2026-04-08 02:46:15 +08:00
parent f5e8de559e
commit 7f3176efc7
11 changed files with 102 additions and 111 deletions

1
root_agent/__init__.py Normal file
View File

@@ -0,0 +1 @@
# ADK agent_loader 会自动扫描并加载 agent.py

36
root_agent/agent.py Normal file
View File

@@ -0,0 +1,36 @@
import os
from agent_base.agent_base import HuiYuBaseAgent
from google.adk.models.lite_llm import LiteLlm
from note_agent.agent import root_agent as note_agent
# ============================================================
# MiniMax 模型配置(从 .env 文件读取)
# ============================================================
MINIMAX_API_KEY = os.getenv("MINIMAX_API_KEY")
MINIMAX_API_BASE = os.getenv("MINIMAX_API_BASE")
MINIMAX_MODEL = os.getenv("MINIMAX_MODEL")
# ============================================================
# 创建 LiteLlm 模型适配器
# ============================================================
model = LiteLlm(
model=MINIMAX_MODEL,
api_base=MINIMAX_API_BASE,
api_key=MINIMAX_API_KEY,
)
# ============================================================
# 定义 Agent继承 HuiYuBaseAgent自动获得防注入 + 日志能力)
# ============================================================
root_agent = HuiYuBaseAgent(
name="huiyu_agent",
model=model,
description="一个智能助手,能够回答用户的各种问题。",
instruction=(
"你是一个乐于助人的中文 AI 助手,你的名字叫小慧,请用中文回答用户的问题,回答要准确、简洁、友好。\n\n"
"你有一个子助手「笔记助手」note_agent当用户需要生成笔记、整理内容、做总结时"
"请将任务委派给 note_agent 处理。"
),
sub_agents=[note_agent],
)