Skip to content

Commit

Permalink
Fix tool calling when using openai with groq (#1245)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Oct 10, 2024
1 parent 3fc39a4 commit 2151f42
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions griptape/drivers/prompt/openai_chat_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/drivers/prompt/test_openai_chat_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"})),
]
)
Expand Down Expand Up @@ -288,7 +287,7 @@ def messages(self):
},
{"role": "assistant", "content": "assistant-input"},
{
"content": [{"text": "thought", "type": "text"}],
"content": "",
"role": "assistant",
"tool_calls": [
{
Expand Down

0 comments on commit 2151f42

Please sign in to comment.