@@ -28,8 +28,8 @@ async def add_conversation(request: Request):
2828 return response
2929
3030 except Exception as e :
31- logger .exception ("Exception in /generate" )
32- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
31+ logger .exception ("Exception in /generate: %s" , str ( e ) )
32+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
3333
3434
3535@router .post ("/update" )
@@ -64,8 +64,8 @@ async def update_conversation(request: Request):
6464 status_code = 200 ,
6565 )
6666 except Exception as e :
67- logger .exception ("Exception in /history/update" )
68- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
67+ logger .exception ("Exception in /history/update: %s" , str ( e ) )
68+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
6969
7070
7171@router .post ("/message_feedback" )
@@ -104,8 +104,8 @@ async def update_message_feedback(request: Request):
104104 )
105105
106106 except Exception as e :
107- logger .exception ("Exception in /history/message_feedback" )
108- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
107+ logger .exception ("Exception in /history/message_feedback: %s" , str ( e ) )
108+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
109109
110110
111111@router .delete ("/delete" )
@@ -135,8 +135,8 @@ async def delete_conversation(request: Request):
135135 status_code = 404 ,
136136 detail = f"Conversation { conversation_id } not found or user does not have permission." )
137137 except Exception as e :
138- logger .exception ("Exception in /history/delete" )
139- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
138+ logger .exception ("Exception in /history/delete: %s" , str ( e ) )
139+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
140140
141141
142142@router .get ("/list" )
@@ -164,8 +164,8 @@ async def list_conversations(
164164 return JSONResponse (content = conversations , status_code = 200 )
165165
166166 except Exception as e :
167- logger .exception ("Exception in /history/list" )
168- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
167+ logger .exception ("Exception in /history/list: %s" , str ( e ) )
168+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
169169
170170
171171@router .post ("/read" )
@@ -197,8 +197,8 @@ async def get_conversation_messages(request: Request):
197197 status_code = 200 )
198198
199199 except Exception as e :
200- logger .exception ("Exception in /history/read" )
201- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
200+ logger .exception ("Exception in /history/read: %s" , str ( e ) )
201+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
202202
203203
204204@router .post ("/rename" )
@@ -223,8 +223,8 @@ async def rename_conversation(request: Request):
223223 return JSONResponse (content = rename_conversation , status_code = 200 )
224224
225225 except Exception as e :
226- logger .exception ("Exception in /history/rename" )
227- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
226+ logger .exception ("Exception in /history/rename: %s" , str ( e ) )
227+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
228228
229229
230230@router .delete ("/delete_all" )
@@ -252,8 +252,8 @@ async def delete_all_conversations(request: Request):
252252 )
253253
254254 except Exception as e :
255- logging .exception ("Exception in /history/delete_all" )
256- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
255+ logging .exception ("Exception in /history/delete_all: %s" , str ( e ) )
256+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
257257
258258
259259@router .post ("/clear" )
@@ -285,8 +285,8 @@ async def clear_messages(request: Request):
285285 status_code = 200 )
286286
287287 except Exception as e :
288- logger .exception ("Exception in /history/clear" )
289- return JSONResponse (content = {"error" : str ( e ) }, status_code = 500 )
288+ logger .exception ("Exception in /history/clear: %s" , str ( e ) )
289+ return JSONResponse (content = {"error" : "An internal error has occurred!" }, status_code = 500 )
290290
291291
292292@router .get ("/history/ensure" )
@@ -303,15 +303,15 @@ async def ensure_cosmos():
303303 "message" : "CosmosDB is configured and working" },
304304 status_code = 200 )
305305 except Exception as e :
306- logger .exception ("Exception in /history/ensure" )
306+ logger .exception ("Exception in /history/ensure: %s" , str ( e ) )
307307 cosmos_exception = str (e )
308308
309309 if "Invalid credentials" in cosmos_exception :
310- return JSONResponse (content = {"error" : cosmos_exception }, status_code = 401 )
310+ return JSONResponse (content = {"error" : "Invalid credentials" }, status_code = 401 )
311311 elif "Invalid CosmosDB database name" in cosmos_exception or "Invalid CosmosDB container name" in cosmos_exception :
312- return JSONResponse (content = {"error" : cosmos_exception }, status_code = 422 )
312+ return JSONResponse (content = {"error" : "Invalid CosmosDB configuration" }, status_code = 422 )
313313 else :
314314 return JSONResponse (
315315 content = {
316- "error" : f "CosmosDB is not configured or not working: { cosmos_exception } " },
316+ "error" : "CosmosDB is not configured or not working" },
317317 status_code = 500 )
0 commit comments