Skip to content
Open
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
14 changes: 5 additions & 9 deletions src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@


class textToJSON():
def __init__(self, transcript_text, target_fields, json={}):
def __init__(self, transcript_text, target_fields, json=None):
self.__transcript_text = transcript_text # str
self.__target_fields = target_fields # List, contains the template field.
self.__json = json # dictionary
self.__json = json if json is not None else {} # dictionary
self.type_check_all()
self.main_loop()

Expand Down Expand Up @@ -63,8 +63,9 @@ def main_loop(self): #FUTURE -> Refactor this to its own class
response = requests.post(ollama_url, json=payload)

# parse response
response.raise_for_status()
json_data = response.json()
parsed_response = json_data['response']
parsed_response = json_data.get('response', None)
# print(parsed_response)
self.add_response_to_json(field, parsed_response)

Expand Down Expand Up @@ -112,12 +113,7 @@ def handle_plural_values(self, plural_value):
values = plural_value.split(";")

# Remove trailing leading whitespace
for i in range(len(values)):
current = i+1
if current < len(values):
clean_value = values[current].lstrip()
values[current] = clean_value

values = [v.strip() for v in values]
print(f"\t[LOG]: Resulting formatted list of values: {values}")

return values
Expand Down