Skip to content

Commit

Permalink
Fix a possible bug that occurs when attempting to encode a dictionary…
Browse files Browse the repository at this point in the history
… (dict) object as a string in a FastAPI application.
  • Loading branch information
yym68686 committed Jul 24, 2024
1 parent e6f7928 commit 1e617f9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ async def try_all_providers(self, request: RequestModel, providers: List[Dict],

@app.post("/v1/chat/completions")
async def request_model(request: RequestModel, token: str = Depends(verify_api_key)):
try:
return await model_handler.request_model(request, token)
except Exception as e:
print('\033[31m')
print(f"request_model Error: {str(e)}")
traceback.print_exc()
print('\033[0m')
# try:
return await model_handler.request_model(request, token)
# except Exception as e:
# print('\033[31m')
# print(f"request_model Error: {str(e)}")
# traceback.print_exc()
# print('\033[0m')

@app.options("/v1/chat/completions")
async def options_handler():
Expand Down

0 comments on commit 1e617f9

Please sign in to comment.