Skip to content

Fix bedrock description handling #1507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pydantic_ai_slim/pydantic_ai/models/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
PromptVariableValuesTypeDef,
SystemContentBlockTypeDef,
ToolChoiceTypeDef,
ToolSpecificationTypeDef,
ToolTypeDef,
VideoBlockTypeDef,
)
Expand Down Expand Up @@ -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)
Expand Down