Files
company-ai-platform/app/modules/work_assistant/application.py
T
2026-11-14 22:48:33 +08:00

38 lines
1.4 KiB
Python

"""Local assistant entry point without schedulers, business DB or shared AI memory."""
from fastapi import FastAPI
from contextlib import asynccontextmanager
from importlib.util import find_spec
from app.core.config import get_settings
from app.core.http.middleware import request_id_middleware
from app.modules.work_assistant.routes import router
def create_assistant_app() -> FastAPI:
@asynccontextmanager
async def lifespan(app):
from app.modules.work_assistant.bid_queue import bid_queue
bid_queue.start()
yield
bid_queue.close()
from app.modules.work_assistant.model_gateway import close_model_client
close_model_client()
app = FastAPI(title="管理系统工作助手", debug=False, lifespan=lifespan)
app.middleware("http")(request_id_middleware)
prefix = get_settings().api_prefix
app.include_router(router, prefix=f"{prefix}/work-assistant")
@app.get(f"{prefix}/health")
def health() -> dict:
ready = find_spec("langgraph") is not None
return {"status": "ok", "service": "work-assistant", "protocol_versions": [1,2] if ready else [1],
"orchestration": "langgraph" if ready else "legacy", "features": {
"module_skills": ready, "explicit_turn_intent": ready, "adaptive_evidence_review": ready,
"structured_computation":ready}}
return app
app = create_assistant_app()