feat(multimodal): 实现本地模型管线与请求用量配置
This commit is contained in:
+19
-4
@@ -9,6 +9,10 @@ from app.config import get_settings
|
||||
from app.container import container
|
||||
from app.errors import ApiError, api_error_handler, http_error_handler, validation_error_handler
|
||||
from app.routes import router as api_router
|
||||
from app.media_routes import router as media_router
|
||||
from app.local_model_routes import router as local_model_router
|
||||
from app.usage_routes import router as usage_router
|
||||
from app.provider_preview_routes import router as provider_preview_router
|
||||
from app.schemas import HealthResponse, ServiceStatusResponse
|
||||
|
||||
settings = get_settings()
|
||||
@@ -16,10 +20,17 @@ settings = get_settings()
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(_: FastAPI):
|
||||
yield
|
||||
# 第三方 MCP Server 必须跟随 AI Core 退出,不能遗留孤儿进程。
|
||||
container.plugins.shutdown()
|
||||
container.mcp_servers.shutdown()
|
||||
from app.services import transcription_service
|
||||
transcription_service.recover_interrupted()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
await transcription_service.shutdown()
|
||||
from app.local_models import manager
|
||||
for _, key in list(manager._downloads):
|
||||
await manager.cancel_download(key)
|
||||
container.plugins.shutdown()
|
||||
container.mcp_servers.shutdown()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
@@ -41,6 +52,10 @@ app.add_exception_handler(ApiError, api_error_handler)
|
||||
app.add_exception_handler(RequestValidationError, validation_error_handler)
|
||||
app.add_exception_handler(StarletteHttpException, http_error_handler)
|
||||
app.include_router(api_router)
|
||||
app.include_router(media_router)
|
||||
app.include_router(local_model_router)
|
||||
app.include_router(usage_router)
|
||||
app.include_router(provider_preview_router)
|
||||
|
||||
|
||||
@app.get("/health", response_model=HealthResponse, tags=["System"])
|
||||
|
||||
Reference in New Issue
Block a user