重构 Agent:引入 LangGraph StateGraph 替代手写 FC 循环
架构变更:
- 新增 app/services/agent/ 模块(state/prompts/graph/tools)
- 7 个工具从 _tool_xxx 方法提取为 @tool 装饰器函数
- 构建 assistant + ToolNode 的 ReAct 图
- agent_dispatcher.py 改为薄壳入口,支持 USE_LANGGRAPH 开关
- MemorySaver checkpoint 持久化对话(thread_id=wechat-{user_id})
- 新增依赖:langchain-core, langchain-openai, langgraph
向后兼容:
- USE_LANGGRAPH=false 可切回旧版 FC 循环
- LangGraph 初始化失败自动降级到 Legacy 模式
- 企微图片处理/VLM分析逻辑不变
This commit is contained in:
5
app/services/agent/__init__.py
Normal file
5
app/services/agent/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""
|
||||
LangGraph Agent 模块
|
||||
|
||||
基于 LangGraph StateGraph 的企微交互 Agent,替代手写 FC 循环。
|
||||
"""
|
||||
Reference in New Issue
Block a user