"""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: settings = get_settings() if settings.app_env.lower() in {"prod", "production"} and settings.app_mode != "work-assistant": raise RuntimeError("The standalone assistant requires APP_MODE=work-assistant in production") @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 = 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, "conversation_reply_memory": True, "semantic_routing": ready, "bounded_reply_references": True}} return app app = create_assistant_app()