Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions pydantic_ai_slim/pydantic_ai/models/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@ def _map_tool_definition(f: ToolDefinition) -> ChatCompletionInputTool:
},
}
)
if f.strict is not None:
tool_param['function']['strict'] = f.strict
return tool_param

async def _map_user_message(
Expand Down
45 changes: 0 additions & 45 deletions tests/models/test_huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,51 +893,6 @@ async def test_thinking_part_in_history(allow_model_requests: None):
)


@pytest.mark.parametrize('strict', [True, False, None])
async def test_tool_strict_mode(allow_model_requests: None, strict: bool | None):
tool_call = ChatCompletionOutputToolCall.parse_obj_as_instance( # type:ignore
{
'function': ChatCompletionOutputFunctionDefinition.parse_obj_as_instance( # type:ignore
{
'name': 'my_tool',
'arguments': '{"x": 42}',
}
),
'id': '1',
'type': 'function',
}
)
responses = [
completion_message(
ChatCompletionOutputMessage.parse_obj_as_instance( # type:ignore
{
'content': None,
'role': 'assistant',
'tool_calls': [tool_call],
}
)
),
completion_message(ChatCompletionOutputMessage(content='final response', role='assistant')), # type: ignore
]
mock_client = MockHuggingFace.create_mock(responses)
model = HuggingFaceModel('hf-model', provider=HuggingFaceProvider(hf_client=mock_client, api_key='x'))
agent = Agent(model)

@agent.tool_plain(strict=strict)
def my_tool(x: int) -> int:
return x

result = await agent.run('hello')
assert result.output == 'final response'

kwargs = get_mock_chat_completion_kwargs(mock_client)[0]
tools = kwargs['tools']
if strict is not None:
assert tools[0]['function']['strict'] is strict
else:
assert 'strict' not in tools[0]['function']


@pytest.mark.parametrize(
'content_item, error_message',
[
Expand Down