diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eceb30e1..1f2ccca49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `PromptTask` will merge in its Structure's Rulesets and Rules. - `PromptTask` not checking whether Structure was set before building Prompt Stack. - `BaseTask.full_context` context being empty when not connected to a Structure. +- Tool calling when using `OpenAiChatPromptDriver` with Groq. ## \[0.32.0\] - 2024-09-17 diff --git a/griptape/drivers/prompt/openai_chat_prompt_driver.py b/griptape/drivers/prompt/openai_chat_prompt_driver.py index 75a604805..8e87be7d5 100644 --- a/griptape/drivers/prompt/openai_chat_prompt_driver.py +++ b/griptape/drivers/prompt/openai_chat_prompt_driver.py @@ -200,6 +200,9 @@ def __to_openai_messages(self, messages: list[Message]) -> list[dict]: ] ], } + # Some OpenAi-compatible services don't accept an empty array for content + if not openai_message["content"]: + openai_message["content"] = "" # Action calls must be attached to the message, not sent as content. action_call_content = [ diff --git a/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py b/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py index 26358e132..35f31a2a2 100644 --- a/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py @@ -251,7 +251,6 @@ def prompt_stack(self): prompt_stack.add_assistant_message( ListArtifact( [ - TextArtifact("thought"), ActionArtifact(ToolAction(tag="MockTool_test", name="MockTool", path="test", input={"foo": "bar"})), ] ) @@ -288,7 +287,7 @@ def messages(self): }, {"role": "assistant", "content": "assistant-input"}, { - "content": [{"text": "thought", "type": "text"}], + "content": "", "role": "assistant", "tool_calls": [ {