fix(proxy_server.py): handle misformatted json body in chat completion request

This commit is contained in:
Krrish Dholakia 2023-12-22 12:30:36 +05:30
parent 1e526c7e06
commit 979575a2a6
2 changed files with 10 additions and 3 deletions

View file

@ -962,7 +962,12 @@ async def chat_completion(request: Request, model: Optional[str] = None, user_ap
global general_settings, user_debug, proxy_logging_obj
try:
data = {}
data = await request.json() # type: ignore
body = await request.body()
body_str = body.decode()
try:
data = ast.literal_eval(body_str)
except:
data = json.loads(body_str)
# Include original request and headers in the data
data["proxy_server_request"] = {