Преглед на файлове

fix: add max_token only when field not present

Timothy J. Baek преди 1 година
родител
ревизия
83181b7968
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      backend/apps/openai/main.py

+ 2 - 1
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