"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "fbdfb7e4fa4b679074836ee96f888d65637065b7"
Commit 60afd6ec authored by Aditya Pratap Singh's avatar Aditya Pratap Singh
Browse files

Add workaround for gpt-4-vision-preview model that support 4k tokens

parent 8662437a
...@@ -99,10 +99,10 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)): ...@@ -99,10 +99,10 @@ async def proxy(path: str, request: Request, user=Depends(get_current_user)):
print("Error loading request body into a dictionary:", e) print("Error loading request body into a dictionary:", e)
raise HTTPException(status_code=400, detail="Invalid JSON in request body") raise HTTPException(status_code=400, detail="Invalid JSON in request body")
# Check if the model is "gpt-4-vision-preview" and set "max_tokens" to 10000 # 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 # This is a workaround until OpenAI fixes the issue with this model
if body_dict.get("model") == "gpt-4-vision-preview": if body_dict.get("model") == "gpt-4-vision-preview":
body_dict["max_tokens"] = 10000 body_dict["max_tokens"] = 4000
print("Modified body_dict:", body_dict) print("Modified body_dict:", body_dict)
# Try to convert the modified body back to JSON # Try to convert the modified body back to JSON
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment