refactor: 客服agent的切片结构调整重构
This commit is contained in:
@@ -6,6 +6,7 @@ from fastapi import FastAPI
|
||||
|
||||
from api.router import api_router
|
||||
from config import database
|
||||
from rag.milvus_collections import ensure_collections
|
||||
from service.customer_agent.bootstrap import (
|
||||
build_default_knowledge_upload_service,
|
||||
build_default_runtime,
|
||||
@@ -17,11 +18,12 @@ from utils.request_id import RequestIdMiddleware
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
setup_logging() # 幂等:分级日志 + trace_id + 脱敏
|
||||
# 四库会话懒创建:启动不连接任何库,首次访问才建,可手动预热:
|
||||
# asyncio.run(database.init_db())
|
||||
setup_logging()
|
||||
await ensure_collections()
|
||||
app.state.customer_agent_runtime = build_default_runtime()
|
||||
app.state.knowledge_upload_service = build_default_knowledge_upload_service()
|
||||
yield
|
||||
await database.dispose() # 清理已创建的单例(未创建则空操作)
|
||||
await database.dispose()
|
||||
|
||||
|
||||
app = FastAPI(title="智能公募基金系统", version="0.1.0", lifespan=lifespan)
|
||||
|
||||
Reference in New Issue
Block a user