Skip to content

Commit 20935eb

Browse files
committed
don't include modalities in OpenAI chat requests
1 parent 3f1635c commit 20935eb

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

llms/extensions/providers/openai.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def __init__(self, **kwargs):
1818
super().__init__(**kwargs)
1919
self.modalities["image"] = OpenAiGenerator(**kwargs)
2020

21+
async def process_chat(self, chat, provider_id=None):
22+
ret = await super().process_chat(chat, provider_id)
23+
chat.pop("modalities", None) # openai chat completion doesn't support modalities
24+
return ret
25+
2126
# https://platform.openai.com/docs/api-reference/images
2227
class OpenAiGenerator(GeneratorBase):
2328
sdk = "openai/image"

llms/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ def __init__(self, **kwargs):
13051305
super().__init__(**kwargs)
13061306

13071307
async def process_chat(self, chat, provider_id=None):
1308-
ret = await process_chat(chat, provider_id)
1308+
ret = await super().process_chat(chat, provider_id)
13091309
chat.pop("modalities", None) # groq doesn't support modalities
13101310
messages = chat.get("messages", []).copy()
13111311
for message in messages:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)