feat(standard-tests): parametrize tool calling test (#33496)

This commit is contained in:
ccurme
2025-10-15 10:43:09 -04:00
committed by GitHub
parent 4da5a8081f
commit 89b7933ef1

View File

@@ -113,6 +113,15 @@ def _validate_tool_call_message(message: BaseMessage) -> None:
assert tool_call["id"] is not None assert tool_call["id"] is not None
assert tool_call.get("type") == "tool_call" assert tool_call.get("type") == "tool_call"
content_tool_calls = [
block for block in message.content_blocks if block["type"] == "tool_call"
]
assert len(content_tool_calls) == 1
content_tool_call = content_tool_calls[0]
assert content_tool_call["name"] == "magic_function"
assert content_tool_call["args"] == {"input": 3}
assert content_tool_call["id"] is not None
def _validate_tool_call_message_no_args(message: BaseMessage) -> None: def _validate_tool_call_message_no_args(message: BaseMessage) -> None:
assert isinstance(message, AIMessage) assert isinstance(message, AIMessage)
@@ -1325,6 +1334,7 @@ class ChatModelIntegrationTests(ChatModelTests):
result = custom_model.invoke("hi") result = custom_model.invoke("hi")
assert isinstance(result, AIMessage) assert isinstance(result, AIMessage)
@pytest.mark.parametrize("model", [{}, {"output_version": "v1"}], indirect=True)
def test_tool_calling(self, model: BaseChatModel) -> None: def test_tool_calling(self, model: BaseChatModel) -> None:
"""Test that the model generates tool calls. """Test that the model generates tool calls.