File tree 3 files changed +9
-5
lines changed
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):
52
52
else :
53
53
if not testing :
54
54
load_dotenv (override = True )
55
- logging .basicConfig (level = logging .DEBUG )
55
+ logging .basicConfig (level = logging .INFO )
56
56
# 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 )
59
59
60
60
if os .getenv ("APPLICATIONINSIGHTS_CONNECTION_STRING" ):
61
61
logger .info ("Configuring Azure Monitor" )
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ class RAGContext(BaseModel):
52
52
followup_questions : list [str ] | None = None
53
53
54
54
55
+ class ErrorResponse (BaseModel ):
56
+ error : str
57
+
58
+
55
59
class RetrievalResponse (BaseModel ):
56
60
message : Message
57
61
context : RAGContext
Original file line number Diff line number Diff line change 9
9
10
10
from fastapi_app .api_models import (
11
11
ChatRequest ,
12
+ ErrorResponse ,
12
13
ItemPublic ,
13
14
ItemWithDistance ,
14
15
RetrievalResponse ,
@@ -89,7 +90,7 @@ async def search_handler(
89
90
return [ItemPublic .model_validate (item .to_dict ()) for item in results ]
90
91
91
92
92
- @router .post ("/chat" , response_model = RetrievalResponse | dict )
93
+ @router .post ("/chat" , response_model = RetrievalResponse | ErrorResponse )
93
94
async def chat_handler (
94
95
context : CommonDeps ,
95
96
database_session : DBSession ,
@@ -130,7 +131,6 @@ async def chat_handler(
130
131
)
131
132
return response
132
133
except Exception as e :
133
- # return exception inside JSON
134
134
return {"error" : str (e )}
135
135
136
136
You can’t perform that action at this time.
0 commit comments