From 8f47cbe2cd7d9fbf012b73657434ead9907f98bd Mon Sep 17 00:00:00 2001 From: vidhip222 Date: Fri, 20 Mar 2026 23:11:44 -0400 Subject: [PATCH] fix: register exception handlers and fix handle_plural_values() whitespace stripping --- api/main.py | 5 ++++- src/llm.py | 14 ++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/api/main.py b/api/main.py index d0b8c79..b2bb7e8 100644 --- a/api/main.py +++ b/api/main.py @@ -1,7 +1,10 @@ from fastapi import FastAPI from api.routes import templates, forms +from api.errors.handlers import register_exception_handlers app = FastAPI() app.include_router(templates.router) -app.include_router(forms.router) \ No newline at end of file +app.include_router(forms.router) + +register_exception_handlers(app) \ No newline at end of file diff --git a/src/llm.py b/src/llm.py index 70937f9..d5570c8 100644 --- a/src/llm.py +++ b/src/llm.py @@ -104,7 +104,7 @@ def add_response_to_json(self, field, value): return - def handle_plural_values(self, plural_value): + def handle_plural_values(self, plural_value: str) -> list[str]: """ This method handles plural values. Takes in strings of the form 'value1; value2; value3; ...; valueN' @@ -116,16 +116,10 @@ def handle_plural_values(self, plural_value): ) print( - f"\t[LOG]: Formating plural values for JSON, [For input {plural_value}]..." + f"\t[LOG]: Formatting plural values for JSON, [For input {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 plural_value.split(";") if v.strip()] print(f"\t[LOG]: Resulting formatted list of values: {values}")