Skip to content

Commit 5c11ade

Browse files
committed
add commonforms integration and fix ollama serve issue
1 parent 6353b01 commit 5c11ade

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def main_loop(self): #FUTURE -> Refactor this to its own class
5151
prompt = self.build_prompt(field)
5252
# print(prompt)
5353
# ollama_url = "http://localhost:11434/api/generate"
54-
ollama_url = os.getenv("OLLAMA_HOST", "htto://localhost:1134") + "/api/generate"
54+
ollama_host = os.getenv("OLLAMA_HOST", "http://localhost:11434").rstrip("/")
55+
ollama_url = f"{ollama_host}/api/generate"
5556

5657
payload = {
5758
"model": "mistral",
@@ -171,4 +172,3 @@ def fill_form(user_input: str, definitions: list, pdf_form: str):
171172

172173
# Your main.py expects this function to return the path
173174
return output_pdf
174-

src/main.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import os
22
from backend import Fill
3+
from commonforms import prepare_form
4+
from pypdf import PdfReader
5+
6+
def input_fields(num_fields: int):
7+
fields = []
8+
for i in range(num_fields):
9+
field = input(f"Enter description for field {i + 1}: ")
10+
fields.append(field)
11+
return fields
312

413
def run_pdf_fill_process(user_input: str, definitions: list, pdf_form_path: str):
514
"""
@@ -36,7 +45,21 @@ def run_pdf_fill_process(user_input: str, definitions: list, pdf_form_path: str)
3645

3746

3847
if __name__ == "__main__":
39-
file = "/home/juan/Documents/california/UCSC/rte2025/src/inputs/file.pdf"
40-
input = "Hi. The employee's name is John Doe. His job title is managing director. His department supervisor is Jane Doe. His phone number is 123456. His email is jdoe@ucsc.edu. The signature is <Mamañema>, and the date is 01/02/2005"
48+
file = "[ENTER_DIR_HERE]/FireForm/src/inputs/file.pdf"
49+
user_input = "Hi. The employee's name is John Doe. His job title is managing director. His department supervisor is Jane Doe. His phone number is 123456. His email is jdoe@ucsc.edu. The signature is <Mamañema>, and the date is 01/02/2005"
4150
descriptions = ["Employee's name", "Employee's job title", "Employee's department supervisor", "Employee's phone number", "Employee's email", "Signature", "Date"]
42-
run_pdf_fill_process(input, descriptions, file)
51+
prepared_pdf = "temp_outfile.pdf"
52+
prepare_form(file,prepared_pdf)
53+
54+
reader = PdfReader(prepared_pdf)
55+
fields = reader.get_fields()
56+
if(fields):
57+
num_fields = len(fields)
58+
else:
59+
num_fields = 0
60+
61+
62+
63+
#descriptions = input_fields(num_fields) # Uncomment to edit fields
64+
65+
run_pdf_fill_process(user_input, descriptions, file)

0 commit comments

Comments
 (0)