-
Notifications
You must be signed in to change notification settings - Fork 130
Description
name: 🐛 Bug Report
about: Create a report to help us improve FireForm.
title: "[BUG]: Synchronous LLM requests block FastAPI server during form filling"
labels: bug
assignees: ''
⚡ Describe the Bug
The form filling API endpoint blocks the entire FastAPI server when processing LLM requests.
Since the LLM calls in llm.py use synchronous requests.post() and the route handler in forms.py is synchronous, any delay or failure in Ollama causes the server to hang indefinitely.
👣 Steps to Reproduce
-
Start the FastAPI server
uvicorn api.main:app --reload -
Send a POST request to /forms/fill
-
If Ollama is slow or unresponsive, the request hangs.
-
Try making another request to any endpoint.
Result:
The server becomes unresponsive until the first request finishes.
📉 Expected Behavior
The API should process LLM requests asynchronously so that multiple requests can be handled concurrently without blocking the server.
🖥️ Environment
OS: Windows
Python: 3.13.1
FastAPI: 0.104+
Ollama: latest
Model: mistral
🕵️ Possible Fix
The issue appears to be caused by synchronous HTTP requests in llm.py:
response = requests.post(OLLAMA_URL, json=payload)
Potential solution:
Replace requests with httpx.AsyncClient
Convert LLM processing functions to async
Use await for LLM requests
Update FastAPI route handlers accordingly
Example:
import httpx
async with httpx.AsyncClient() as client:
response = await client.post(OLLAMA_URL, json=payload)
This would prevent the FastAPI event loop from being blocked during LLM processing.