Live AI provider/model switching without restart
CI / Lint & Format (push) Failing after 8s
CI / Tests (push) Has been skipped
CI / Security Scan (push) Failing after 8s
CI / Docker Build (push) Has been skipped

Backend:
- RuntimeAIConfig singleton: mutable in-memory overrides for provider/model
- PATCH /admin/api/ai/config: change active provider/model on the fly
- GET /admin/api/ai/config: read current runtime state
- ai_vision.py: uses runtime_ai_config before falling back to settings
- health/status endpoints reflect runtime overrides

Frontend:
- 'Définir comme actif' button in AI config section
- Live feedback message on save
This commit is contained in:
2026-06-25 11:07:17 -04:00
parent 7dd26ea636
commit 92cf23dbb3
6 changed files with 216 additions and 14 deletions
+9 -4
View File
@@ -188,15 +188,20 @@ async def root():
@app.get("/health", tags=["Santé"])
async def health():
from app.services.runtime_config import runtime_ai_config
active_provider = runtime_ai_config.provider or settings.AI_PROVIDER
active_model = runtime_ai_config.model or (
settings.OPENROUTER_MODEL if active_provider == "openrouter"
else settings.GEMINI_MODEL
)
ai_configured = (
(settings.AI_PROVIDER == "gemini" and bool(settings.GEMINI_API_KEY)) or
(settings.AI_PROVIDER == "openrouter" and bool(settings.OPENROUTER_API_KEY))
(active_provider == "gemini" and bool(settings.GEMINI_API_KEY)) or
(active_provider == "openrouter" and bool(settings.OPENROUTER_API_KEY))
)
active_model = settings.OPENROUTER_MODEL if settings.AI_PROVIDER == "openrouter" else settings.GEMINI_MODEL
return {
"status": "healthy",
"ai_enabled": settings.AI_ENABLED,
"ai_provider": settings.AI_PROVIDER,
"ai_provider": active_provider,
"ai_configured": ai_configured,
"ocr_enabled": settings.OCR_ENABLED,
"model": active_model,