Skip to content

Commit

Permalink
Merged GPT4-V into GPT4-Turbo to accommodate OpenAI's new API change.
Browse files Browse the repository at this point in the history
  • Loading branch information
GaiZhenbiao committed Apr 17, 2024
1 parent 5881220 commit 7231bea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion modules/models/OpenAIVision.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def _get_gpt4v_style_history(self):
content.append(
{
"type": "image_url",
"image_url": f"data:image/{self.get_image_type(image)};base64,{self.get_base64_image(image)}"
"image_url": {
"url": f"data:image/{self.get_image_type(image)};base64,{self.get_base64_image(image)}",
}
},
)
if content:
Expand Down
14 changes: 9 additions & 5 deletions modules/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ def get_type(cls, model_name: str):
model_type = None
model_name_lower = model_name.lower()
if "gpt" in model_name_lower:
if "instruct" in model_name_lower:
model_type = ModelType.OpenAIInstruct
elif "vision" in model_name_lower:
try:
assert MODEL_METADATA[model_name]["multimodal"] == True
model_type = ModelType.OpenAIVision
else:
model_type = ModelType.OpenAI
except:
if "instruct" in model_name_lower:
model_type = ModelType.OpenAIInstruct
elif "vision" in model_name_lower:
model_type = ModelType.OpenAIVision
else:
model_type = ModelType.OpenAI
elif "chatglm" in model_name_lower:
model_type = ModelType.ChatGLM
elif "ollama" in model_name_lower:
Expand Down
6 changes: 3 additions & 3 deletions modules/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"GPT4",
"GPT4 32K",
"GPT4 Turbo",
"GPT4 Vision",
"Claude 3 Haiku",
"Claude 3 Sonnet",
"Claude 3 Opus",
Expand Down Expand Up @@ -155,11 +154,12 @@
"token_limit": 32768,
},
"GPT4 Turbo": {
"model_name": "gpt-4-turbo-preview",
"model_name": "gpt-4-turbo",
"token_limit": 128000,
"multimodal": True
},
"GPT4 Vision": {
"model_name": "gpt-4-vision-preview",
"model_name": "gpt-4-turbo",
"token_limit": 128000,
"multimodal": True
},
Expand Down

0 comments on commit 7231bea

Please sign in to comment.