From bdc03997c959bba891345b4b80556fa3739becb0 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:17:34 -0700 Subject: [PATCH] standard-tests[patch]: check for ToolCall["type"] (#24209) --- .../integration_tests/chat_models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/standard-tests/langchain_standard_tests/integration_tests/chat_models.py b/libs/standard-tests/langchain_standard_tests/integration_tests/chat_models.py index 162f7270566..461902da60f 100644 --- a/libs/standard-tests/langchain_standard_tests/integration_tests/chat_models.py +++ b/libs/standard-tests/langchain_standard_tests/integration_tests/chat_models.py @@ -44,6 +44,7 @@ def _validate_tool_call_message(message: BaseMessage) -> None: assert tool_call["name"] == "magic_function" assert tool_call["args"] == {"input": 3} assert tool_call["id"] is not None + assert tool_call["type"] == "tool_call" def _validate_tool_call_message_no_args(message: BaseMessage) -> None: @@ -53,6 +54,7 @@ def _validate_tool_call_message_no_args(message: BaseMessage) -> None: assert tool_call["name"] == "magic_function_no_args" assert tool_call["args"] == {} assert tool_call["id"] is not None + assert tool_call["type"] == "tool_call" class ChatModelIntegrationTests(ChatModelTests): @@ -212,6 +214,7 @@ class ChatModelIntegrationTests(ChatModelTests): assert result.tool_calls tool_call = result.tool_calls[0] assert tool_call["args"].get("answer_style") + assert tool_call["type"] == "tool_call" def test_structured_output(self, model: BaseChatModel) -> None: if not self.has_tool_calling: @@ -266,6 +269,7 @@ class ChatModelIntegrationTests(ChatModelTests): "name": function_name, "args": function_args, "id": "abc123", + "type": "tool_call", }, ], ), @@ -310,6 +314,7 @@ class ChatModelIntegrationTests(ChatModelTests): "name": function_name, "args": function_args, "id": "abc123", + "type": "tool_call", }, ], ), @@ -342,6 +347,7 @@ class ChatModelIntegrationTests(ChatModelTests): "name": function_name, "args": function_args, "id": "abc123", + "type": "tool_call", }, ], ),