From 4269d9044ecf6b5cb19dc11ced7af433d840d48a Mon Sep 17 00:00:00 2001 From: David Montague <35119617+dmontagu@users.noreply.github.com> Date: Wed, 16 Apr 2025 08:50:48 -0600 Subject: [PATCH] Fix bedrock description handling --- pydantic_ai_slim/pydantic_ai/models/bedrock.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pydantic_ai_slim/pydantic_ai/models/bedrock.py b/pydantic_ai_slim/pydantic_ai/models/bedrock.py index b54df588b..af5e4acff 100644 --- a/pydantic_ai_slim/pydantic_ai/models/bedrock.py +++ b/pydantic_ai_slim/pydantic_ai/models/bedrock.py @@ -55,6 +55,7 @@ PromptVariableValuesTypeDef, SystemContentBlockTypeDef, ToolChoiceTypeDef, + ToolSpecificationTypeDef, ToolTypeDef, VideoBlockTypeDef, ) @@ -214,14 +215,16 @@ def _get_tools(self, model_request_parameters: ModelRequestParameters) -> list[T @staticmethod def _map_tool_definition(f: ToolDefinition) -> ToolTypeDef: - return { - 'toolSpec': { - 'name': f.name, - 'description': f.description, - 'inputSchema': {'json': f.parameters_json_schema}, - } + tool_spec: ToolSpecificationTypeDef = { + 'name': f.name, + 'inputSchema': {'json': f.parameters_json_schema}, } + if f.description: + tool_spec['description'] = f.description + + return {'toolSpec': tool_spec} + @property def base_url(self) -> str: return str(self.client.meta.endpoint_url)