fix(anthropic.py): fix translation from /v1/messages format to openai format

This commit is contained in:
Krrish Dholakia 2024-08-08 15:55:01 -07:00
parent 2776d9cb0d
commit 4ac0afef2c
4 changed files with 105 additions and 7 deletions

View file

@ -5373,7 +5373,13 @@ async def anthropic_response(
litellm.adapters = [{"id": "anthropic", "adapter": anthropic_adapter}]
global user_temperature, user_request_timeout, user_max_tokens, user_api_base
data: dict = {**anthropic_data, "adapter_id": "anthropic"}
body = await request.body()
body_str = body.decode()
try:
request_data: dict = ast.literal_eval(body_str)
except Exception:
request_data = json.loads(body_str)
data: dict = {**request_data, "adapter_id": "anthropic"}
try:
data["model"] = (
general_settings.get("completion_model", None) # server default