整合旧图和新图:添加完整的记忆检索、总结和完成流程
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m42s
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m42s
This commit is contained in:
@@ -13,7 +13,7 @@ from app.main_graph.config import set_stream_writer
|
||||
from ..model_services.chat_services import get_all_chat_services, LocalVLLMChatProvider
|
||||
from app.main_graph.utils.rag_initializer import init_rag_tool
|
||||
from app.core.intent_classifier import get_intent_classifier
|
||||
from app.logger import info, warning
|
||||
from app.logger import info, warning, error
|
||||
from app.main_graph.state import MainGraphState, CurrentAction
|
||||
|
||||
|
||||
@@ -27,8 +27,19 @@ class AIAgentService:
|
||||
self.intent_classifier = get_intent_classifier()
|
||||
# RAG 管道(可选,需要时设置)
|
||||
self.rag_pipeline = None
|
||||
# Mem0 客户端
|
||||
self.mem0_client = None
|
||||
|
||||
async def initialize(self):
|
||||
# 0. 初始化 Mem0 客户端
|
||||
from app.memory.mem0_client import Mem0Client
|
||||
# 创建一个临时的 LLM 用于 Mem0(用第一个可用的)
|
||||
chat_services = get_all_chat_services()
|
||||
temp_llm = None
|
||||
if chat_services:
|
||||
temp_llm = list(chat_services.values())[0]
|
||||
self.mem0_client = Mem0Client(temp_llm)
|
||||
|
||||
# 1. 初始化 RAG 工具(如果需要)
|
||||
def create_local_llm():
|
||||
provider = LocalVLLMChatProvider()
|
||||
@@ -42,11 +53,14 @@ class AIAgentService:
|
||||
set_global_rag_tool(rag_tool)
|
||||
|
||||
# 2. 构建各模型的 Graph(使用新版 React 模式)
|
||||
chat_services = get_all_chat_services()
|
||||
for name, llm in chat_services.items():
|
||||
try:
|
||||
info(f"🔄 初始化模型 '{name}'...")
|
||||
graph = build_react_main_graph(llm=llm, tools=self.tools).compile(checkpointer=self.checkpointer)
|
||||
graph = build_react_main_graph(
|
||||
llm=llm,
|
||||
tools=self.tools,
|
||||
mem0_client=self.mem0_client
|
||||
).compile(checkpointer=self.checkpointer)
|
||||
self.graphs[name] = graph
|
||||
info(f"✅ 模型 '{name}' 初始化成功")
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user