Skip to content

Commit 25a26c2

Browse files
committed
error model
1 parent f64ddd8 commit 25a26c2

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/backend/fastapi_app/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def create_app(testing: bool = False):
5252
else:
5353
if not testing:
5454
load_dotenv(override=True)
55-
logging.basicConfig(level=logging.DEBUG)
55+
logging.basicConfig(level=logging.INFO)
5656
# Turn off particularly noisy INFO level logs from Azure Core SDK:
57-
# logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING)
58-
# logging.getLogger("azure.identity").setLevel(logging.WARNING)
57+
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING)
58+
logging.getLogger("azure.identity").setLevel(logging.WARNING)
5959

6060
if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"):
6161
logger.info("Configuring Azure Monitor")

src/backend/fastapi_app/api_models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class RAGContext(BaseModel):
5252
followup_questions: list[str] | None = None
5353

5454

55+
class ErrorResponse(BaseModel):
56+
error: str
57+
58+
5559
class RetrievalResponse(BaseModel):
5660
message: Message
5761
context: RAGContext

src/backend/fastapi_app/routes/api_routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from fastapi_app.api_models import (
1111
ChatRequest,
12+
ErrorResponse,
1213
ItemPublic,
1314
ItemWithDistance,
1415
RetrievalResponse,
@@ -89,7 +90,7 @@ async def search_handler(
8990
return [ItemPublic.model_validate(item.to_dict()) for item in results]
9091

9192

92-
@router.post("/chat", response_model=RetrievalResponse | dict)
93+
@router.post("/chat", response_model=RetrievalResponse | ErrorResponse)
9394
async def chat_handler(
9495
context: CommonDeps,
9596
database_session: DBSession,
@@ -130,7 +131,6 @@ async def chat_handler(
130131
)
131132
return response
132133
except Exception as e:
133-
# return exception inside JSON
134134
return {"error": str(e)}
135135

136136

0 commit comments

Comments
 (0)