feat:优化流式输出,增加临时多轮对话记录

This commit is contained in:
2026-09-29 09:55:17 -07:00
parent 6a38a5f15e
commit a89a458c22
10 changed files with 153 additions and 23 deletions
+8 -1
View File
@@ -7,6 +7,7 @@ from fastapi import FastAPI
from loguru import logger
from app.api.agent import router
from app.api.conversations import router as conversation_router
from app.core.exceptions import register_exception_handlers
from app.core.logging import setup_logging
@@ -19,7 +20,12 @@ async def lifespan(application: FastAPI):
from app.processor.graph import build_graph
from app.services.agent import AgentService
application.state.agent_service = AgentService(build_graph())
from app.services.conversation import InMemoryConversationStore
# TODO 接入 MongoDB 后替换为持久化实现,并同步替换图的 checkpointer
store = InMemoryConversationStore()
application.state.conversation_store = store
application.state.agent_service = AgentService(build_graph(), store)
try:
yield
finally:
@@ -38,6 +44,7 @@ def create_app() -> FastAPI:
# 统一处理请求校验、HTTP 错误和未捕获异常
register_exception_handlers(application)
application.include_router(router)
application.include_router(conversation_router)
return application