Skip to content

Commit 9c066c3

Browse files
vachillocollindutter
authored andcommitted
fix: remove content from Message if content is an empty array (#1895)
fix: remove from Message if is an empty array
1 parent 6816309 commit 9c066c3

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

griptape/drivers/prompt/openai_chat_prompt_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def __to_openai_messages(self, messages: list[Message]) -> list[dict]:
273273

274274
# Some OpenAi-compatible services don't accept an empty array for content
275275
if not openai_message["content"]:
276-
openai_message["content"] = ""
276+
del openai_message["content"]
277277

278278
openai_messages.append(openai_message)
279279

tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def messages(self):
385385
},
386386
{"role": "assistant", "content": "assistant-input"},
387387
{
388-
"content": "",
389388
"role": "assistant",
390389
"tool_calls": [
391390
{
@@ -403,7 +402,7 @@ def messages(self):
403402
],
404403
"role": "user",
405404
},
406-
{"audio": {"id": "audio-id"}, "content": "", "role": "assistant"},
405+
{"audio": {"id": "audio-id"}, "role": "assistant"},
407406
{"content": [{"type": "text", "text": "assistant-audio-transcription"}], "role": "assistant"},
408407
{"content": [{"type": "text", "text": "generic-value"}], "role": "user"},
409408
]

0 commit comments

Comments
 (0)