Pull intent model on startup alongside main model

If OLLAMA_INTENT_MODEL is configured and differs from OLLAMA_MODEL,
both are pulled concurrently as fire-and-forget tasks at startup.
Deduplicates via a set so pulling the same model twice is never attempted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 19:37:36 -05:00
parent 931a059e9f
commit 504091bfcf
+10 -5
View File
@@ -93,18 +93,23 @@ def create_app() -> Quart:
start_log_retention_loop()
start_notification_loop()
async def _pull_model():
async def _pull_model(model: str) -> None:
try:
await ensure_model(Config.OLLAMA_MODEL)
await ensure_model(model)
except Exception:
logger.warning(
"Failed to ensure model '%s' — chat may not work until model is available",
Config.OLLAMA_MODEL,
model,
exc_info=True,
)
# Fire-and-forget so model pull doesn't block startup
asyncio.create_task(_pull_model())
# Pull main model and (if configured) a separate intent model concurrently.
# Fire-and-forget so pulls don't block startup.
models_to_pull = {Config.OLLAMA_MODEL}
if Config.OLLAMA_INTENT_MODEL and Config.OLLAMA_INTENT_MODEL != Config.OLLAMA_MODEL:
models_to_pull.add(Config.OLLAMA_INTENT_MODEL)
for _model in models_to_pull:
asyncio.create_task(_pull_model(_model))
@app.route("/")
async def serve_index():