导入方式修改
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m44s

This commit is contained in:
2026-05-05 23:17:00 +08:00
parent b5c15ef445
commit 3ae9daa01a
51 changed files with 445 additions and 532 deletions

View File

@@ -7,6 +7,9 @@ import json
import asyncio
from typing import AsyncGenerator, Dict, Any, Optional, Tuple
# LangGraph 序列化器(修复 checkpoint 反序列化警告)
from langgraph.checkpoint.serde.jsonplus import JsonPlusSerializer
# 本地模块
from ..model_services import get_cached_chat_services
from ..main_graph.main_graph_builder import build_react_main_graph
@@ -18,6 +21,23 @@ from ..logger import debug, info, warning, error
from ..main_graph.state import MainGraphState, CurrentAction
# ========== 自定义类型序列化器 ==========
def create_serde() -> JsonPlusSerializer:
"""创建带自定义类型注册的序列化器"""
from backend.app.core.intent import ReasoningAction, RetrievalConfig, ReasoningResult
return JsonPlusSerializer(
allowed_msgpack_modules=[
("app.core.intent", "ReasoningAction"),
("app.core.intent", "RetrievalConfig"),
("app.core.intent", "ReasoningResult"),
("app.main_graph.state", "CurrentAction"),
("app.main_graph.state", "ErrorSeverity"),
("app.main_graph.state", "ErrorRecord"),
]
)
class AIAgentService:
def __init__(self, checkpointer):
self.checkpointer = checkpointer
@@ -55,6 +75,7 @@ class AIAgentService:
tools=self.tools,
mem0_client=self.mem0_client
)
# 注意serde 已在创建 checkpointer 时传入,这里只需传入 checkpointer
self.graph = graph_builder.compile(checkpointer=self.checkpointer)
info(f"✅ 单图初始化完成")