From c1ee9f63892b4c0b1fd5a3bcf7a1e8c6cdcc40e9 Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Tue, 27 Aug 2024 13:10:23 -0700 Subject: [PATCH] Don't send empty properties (#1112) --- CHANGELOG.md | 1 + griptape/drivers/prompt/google_prompt_driver.py | 16 +++++++++++----- .../drivers/prompt/test_google_prompt_driver.py | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9acb8c2..c351588c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/griptape/drivers/prompt/google_prompt_driver.py b/griptape/drivers/prompt/google_prompt_driver.py index bbba4e0f9..6b18f6041 100644 --- a/griptape/drivers/prompt/google_prompt_driver.py +++ b/griptape/drivers/prompt/google_prompt_driver.py @@ -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) diff --git a/tests/unit/drivers/prompt/test_google_prompt_driver.py b/tests/unit/drivers/prompt/test_google_prompt_driver.py index ce3db921f..5d01217d9 100644 --- a/tests/unit/drivers/prompt/test_google_prompt_driver.py +++ b/tests/unit/drivers/prompt/test_google_prompt_driver.py @@ -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",