Skip to content

Commit

Permalink
Don't send empty properties (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Aug 27, 2024
1 parent 4ae9711 commit c1ee9f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Parsing streaming response with some OpenAi compatible services.
- Issue in `PromptSummaryEngine` if there are no artifacts during recursive summarization.
- Issue in `GooglePromptDriver` using Tools with no schema.

**Note**: This release includes breaking changes. Please refer to the [Migration Guide](./MIGRATION.md#030x-to-031x) for details.

Expand Down
16 changes: 11 additions & 5 deletions griptape/drivers/prompt/google_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ def __to_google_tools(self, tools: list[BaseTool]) -> list[dict]:
tool_declaration = types.FunctionDeclaration(
name=tool.to_native_tool_name(activity),
description=tool.activity_description(activity),
parameters={
"type": schema["type"],
"properties": schema["properties"],
"required": schema.get("required", []),
},
**(
{
"parameters": {
"type": schema["type"],
"properties": schema["properties"],
"required": schema.get("required", []),
}
}
if schema.get("properties")
else {}
),
)

tool_declarations.append(tool_declaration)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/drivers/prompt/test_google_prompt_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class TestGooglePromptDriver:
"description": "test description: foo",
"parameters": {"type": "OBJECT", "properties": {"test": {"type": "STRING"}}, "required": ["test"]},
},
{"name": "MockTool_test_list_output", "description": "test description", "parameters": {"type": "OBJECT"}},
{"name": "MockTool_test_no_schema", "description": "test description", "parameters": {"type": "OBJECT"}},
{"name": "MockTool_test_list_output", "description": "test description"},
{"name": "MockTool_test_no_schema", "description": "test description"},
{
"name": "MockTool_test_str_output",
"description": "test description: foo",
Expand Down

0 comments on commit c1ee9f6

Please sign in to comment.