Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,34 @@ __Contributors:__
- Vincent Harkins (@vharkins1)
- Marc Vergés (@marcvergees)
- Jan Sans


## Local Development Setup (Beginner Friendly)

1. Clone your fork and enter project folder:

- git clone <your-fork-url>
cd FireForm (Terminal)

2. Create virtual environment:

- python3 -m venv venv
source venv/bin/activate

3. Install dependencies:

4. Initialize database tables:

5. Run backend server:

6. Open Swagger UI in browser: (http://127.0.0.1:8000/docs)

### Common Errors

- `sqlite3.OperationalError: no such table`
→ Run database initialization step.

- `Could not connect to Ollama`
→ Ensure Ollama server is running locally.


3 changes: 3 additions & 0 deletions api/routes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def fill_form(form: FormFill, db: Session = Depends(get_db)):
controller = Controller()
path = controller.fill_form(user_input=form.input_text, fields=fetched_template.fields, pdf_form_path=fetched_template.pdf_path)

if not path:
raise AppError("PDF generation failed", status_code=400)

submission = FormSubmission(**form.model_dump(), output_pdf_path=path)
return create_form(db, submission)

Expand Down
7 changes: 5 additions & 2 deletions src/file_manipulator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
import logging
from src.filler import Filler
from src.llm import LLM
from commonforms import prepare_form

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class FileManipulator:
def __init__(self):
Expand All @@ -22,14 +25,14 @@ def fill_form(self, user_input: str, fields: list, pdf_form_path: str):
It receives the raw data, runs the PDF filling logic,
and returns the path to the newly created file.
"""
print("[1] Received request from frontend.")
logger.info("[1] Received request from frontend.")
print(f"[2] PDF template path: {pdf_form_path}")

if not os.path.exists(pdf_form_path):
print(f"Error: PDF template not found at {pdf_form_path}")
return None # Or raise an exception

print("[3] Starting extraction and PDF filling process...")
logger.info("[3] Starting extraction...")
try:
self.llm._target_fields = fields
self.llm._transcript_text = user_input
Expand Down
9 changes: 4 additions & 5 deletions src/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ def main_loop(self):
}

try:
response = requests.post(ollama_url, json=payload)
response = requests.post(ollama_url, json=payload, timeout=30)
response.raise_for_status()
except requests.exceptions.ConnectionError:
raise ConnectionError(
f"Could not connect to Ollama at {ollama_url}. "
"Please ensure Ollama is running and accessible."
except requests.exceptions.Timeout:
raise TimeoutError(
f"Ollama request timed out after 30 seconds at {ollama_url}"
)
except requests.exceptions.HTTPError as e:
raise RuntimeError(f"Ollama returned an error: {e}")
Expand Down