forked from phoenix/litellm-mirror
fix(proxy_server.py): handle scenario where no json body is passed in - e.g. GET request
https://github.com/BerriAI/litellm/issues/1062
This commit is contained in:
parent
6cdcc1370f
commit
db8d793618
1 changed files with 4 additions and 1 deletions
|
@ -289,7 +289,10 @@ async def user_api_key_auth(request: Request, api_key: str = fastapi.Security(ap
|
||||||
valid_token_dict.pop("token", None)
|
valid_token_dict.pop("token", None)
|
||||||
return UserAPIKeyAuth(api_key=api_key, **valid_token_dict)
|
return UserAPIKeyAuth(api_key=api_key, **valid_token_dict)
|
||||||
else:
|
else:
|
||||||
data = await request.json()
|
try:
|
||||||
|
data = await request.json()
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
data = {} # Provide a default value, such as an empty dictionary
|
||||||
model = data.get("model", None)
|
model = data.get("model", None)
|
||||||
if model in litellm.model_alias_map:
|
if model in litellm.model_alias_map:
|
||||||
model = litellm.model_alias_map[model]
|
model = litellm.model_alias_map[model]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue