From bad715aa0015dee39be4118cb549f903b9095ef3 Mon Sep 17 00:00:00 2001 From: nelson <1475262689@qq.com> Date: Wed, 8 Apr 2026 19:16:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=B4=E7=95=8C=E8=A7=89?= =?UTF-8?q?=E5=AF=9Fagent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- critical_awareness_agent/__init__.py | 1 + critical_awareness_agent/agent.py | 48 ++++++++++++++++++++++++++++ note_agent/agent.py | 4 ++- root_agent/agent.py | 7 ++-- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 critical_awareness_agent/__init__.py create mode 100644 critical_awareness_agent/agent.py diff --git a/critical_awareness_agent/__init__.py b/critical_awareness_agent/__init__.py new file mode 100644 index 0000000..a66dcf3 --- /dev/null +++ b/critical_awareness_agent/__init__.py @@ -0,0 +1 @@ +# ADK agent_loader 会自动扫描并加载 agent.py diff --git a/critical_awareness_agent/agent.py b/critical_awareness_agent/agent.py new file mode 100644 index 0000000..a62312a --- /dev/null +++ b/critical_awareness_agent/agent.py @@ -0,0 +1,48 @@ +import os + + +from google.adk.models.lite_llm import LiteLlm +from agent_base.agent_base import HuiYuBaseAgent + +# ============================================================ +# 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) +# ============================================================ +critical_awareness_agent = HuiYuBaseAgent( + name="critical_awareness_agent", + model=model, + description="用于处理用户心智散乱、情绪化或认知混淆的专家。它通过‘三界(外中内)’判别法强制用户回归觉知。当用户表达焦虑、愤怒、分心或无法区分事实与观点时,必须调用此工具。", + instruction=( + """ + 你是一位精通“临界觉察法”的资深导师。你的目标是协助学生通过识别外界、中界、内界的边界,回归当下觉知。 + + 判定逻辑: + - 外界 (External): 纯粹感官原始数据,无形容词/评价。 + - 中界 (Middle): 想法、念头、逻辑、评判、语言、对未来的担忧。 + - 内界 (Internal): 身体生理感受、情绪在身体上的投影(如心跳、紧缩感)。 + + 回复规范: + 1. 必须快速拆解输入内容,给出 [外界/中界/内界] 的结构化分析。 + 2. 语气简洁、敏锐,像手术刀一样切开混沌。 + 3. 引导学生作为“观察者”,清晰的觉知三界都在发生什么。 + 4. 提醒学生回归当下的觉知 + """ + ) +) + +root_agent = critical_awareness_agent # 将 critical_awareness_agent 作为 root_agent 导出,供 adk web 注册 \ No newline at end of file diff --git a/note_agent/agent.py b/note_agent/agent.py index ad6c83d..901d241 100644 --- a/note_agent/agent.py +++ b/note_agent/agent.py @@ -55,7 +55,7 @@ def generate_image_note(title: str, description: str) -> str: # ============================================================ # 定义 Agent(继承 HuiYuBaseAgent) # ============================================================ -root_agent = HuiYuBaseAgent( +note_agent = HuiYuBaseAgent( name="note_agent", model=model, description="一个多模态笔记助手,能够将图片、文字等内容转换为结构化的 Markdown 笔记。", @@ -75,3 +75,5 @@ root_agent = HuiYuBaseAgent( ), tools=[generate_text_note, generate_image_note], ) + +root_agent = note_agent diff --git a/root_agent/agent.py b/root_agent/agent.py index 78caea3..c94d64d 100644 --- a/root_agent/agent.py +++ b/root_agent/agent.py @@ -2,7 +2,8 @@ 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 +from critical_awareness_agent.agent import critical_awareness_agent +from note_agent.agent import note_agent # ============================================================ # MiniMax 模型配置(从 .env 文件读取) @@ -31,6 +32,8 @@ root_agent = HuiYuBaseAgent( "你是一个乐于助人的中文 AI 助手,你的名字叫小慧,请用中文回答用户的问题,回答要准确、简洁、友好。\n\n" "你有一个子助手「笔记助手」(note_agent),当用户需要生成笔记、整理内容、做总结时," "请将任务委派给 note_agent 处理。" + "你还有一个子助手「临界觉察助手」(critical_awareness_agent),当用户出现心智散乱、情绪化或认知混淆时," + "请将任务委派给 critical_awareness_agent 处理。" ), - sub_agents=[note_agent], + sub_agents=[note_agent, critical_awareness_agent], # 将 note_agent 和 critical_awareness_agent 作为子 Agent ) -- 2.49.1