From 83181b7968b462ad5e218802273213b6fa6ca3ab Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 22 Jan 2024 01:41:00 -0800 Subject: [PATCH] fix: add max_token only when field not present --- backend/apps/openai/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/apps/openai/main.py b/backend/apps/openai/main.py index fd6acee7..1529ab93 100644 --- a/backend/apps/openai/main.py +++ b/backend/apps/openai/main.py @@ -87,7 +87,8 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)): # Check if the model is "gpt-4-vision-preview" and set "max_tokens" to 4000 # This is a workaround until OpenAI fixes the issue with this model if body.get("model") == "gpt-4-vision-preview": - body["max_tokens"] = 4000 + if "max_tokens" not in body: + body["max_tokens"] = 4000 print("Modified body_dict:", body) # Convert the modified body back to JSON