Improve Ollama error handling and add LLM healthcheck#269
Improve Ollama error handling and add LLM healthcheck#269sanvishukla wants to merge 1 commit intofireform-core:mainfrom
Conversation
|
Hi @sanvishukla , I appreciate the focus on backend reliability! I submitted PR #239 on March 13 to address these specific Ollama connection timeouts and hardening. It might be worth consolidating our work to ensure we don't have redundant error-handling logic in the main loop. |
|
Hey @utkarshqz, thanks for pointing this out, I went through your PR. From what I understand, your changes focus on improving visibility during extraction, progress logging + handling slow requests, while this PR is more focused on cases where the LLM backend isn’t reachable at all, like when Ollama isn’t running, misconfigured, or the model isn’t pulled. The idea here was to make those failures clearer (returning a 503 instead of a traceback) and also add a lightweight /health/llm endpoint to quickly verify setup without running the full pipeline. I think they address slightly different failure modes and could work well together, especially combining runtime logging with clearer error handling and health checks. Happy to refactor or align things if needed to avoid any duplication! |
|
Thanks @sanvishukla! Good to be on the same page. I'm finishing up some work on the batching routes, and having a reliable /health check from your end would be great for the frontend UI. Let's make sure our endpoint naming is consistent so the integration is smooth. |
Summary:
This PR adds clearer errors when the Ollama backend is unreachable and introduces a /health/llm endpoint to quickly verify LLM availability, improving setup and debugging for new users.
closes #268
Changes:
src/llm.py: more detailed ConnectionError message (includes URL, OLLAMA_HOST, and troubleshooting steps).api/errors/base.py: new LLMUnavailableError (HTTP 503).src/file_manipulator.py: wrap ConnectionError from LLM in LLMUnavailableError.api/main.py: register AppError handler and add GET /health/llm using Ollama’s /api/tags.api/errors/handlers.py: reuse existing handler for the new error.Testing:
With Ollama stopped: /health/llm and /forms/fill return 503 with a JSON error instead of a traceback.


With ollama serve running and mistral pulled: /health/llm returns {"status": "ok"} and /forms/fill still succeeds and generates a filled PDF.

