File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff 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" )
Original file line number Diff line number Diff 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+
5559class RetrievalResponse (BaseModel ):
5660 message : Message
5761 context : RAGContext
Original file line number Diff line number Diff line change 99
1010from 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 )
9394async 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
You can’t perform that action at this time.
0 commit comments