Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
60afd6ec
Commit
60afd6ec
authored
Jan 20, 2024
by
Aditya Pratap Singh
Browse files
Add workaround for gpt-4-vision-preview model that support 4k tokens
parent
8662437a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
backend/apps/openai/main.py
backend/apps/openai/main.py
+2
-2
No files found.
backend/apps/openai/main.py
View file @
60afd6ec
...
@@ -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
10
000
# Check if the model is "gpt-4-vision-preview" and set "max_tokens" to
4
000
# 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"
]
=
10
000
body_dict
[
"max_tokens"
]
=
4
000
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment