The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
standard tests: add test for few-shot examples (#21019)
ccurme01a3228d8eb9
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.pyindex f3496e4fb0..5f11c6f1f9 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@@ -217,3 +217,43 @@ class ChatModelIntegrationTests(ABC):]result_list_content = model_with_tools.invoke(messages_list_content)assert isinstance(result_list_content, AIMessage)++ def test_structured_few_shot_examples(+ self,+ chat_model_class: Type[BaseChatModel],+ chat_model_params: dict,+ chat_model_has_tool_calling: bool,+ ) -> None:+ """+ Test that model can process few-shot examples with tool calls.+ """+ if not chat_model_has_tool_calling:+ pytest.skip("Test requires tool calling.")+ model = chat_model_class(**chat_model_params)+ model_with_tools = model.bind_tools([my_adder_tool])+ function_name = "my_adder_tool"+ function_args = {"a": 1, "b": 2}+ function_result = json.dumps({"result": 3})++ messages_string_content = [+ HumanMessage(content="What is 1 + 2"),+ AIMessage(+ content="",+ tool_calls=[+ {+ "name": function_name,+ "args": function_args,+ "id": "abc123",+ },+ ],+ ),+ ToolMessage(+ name=function_name,+ content=function_result,+ tool_call_id="abc123",+ ),+ AIMessage(content=function_result),+ HumanMessage(content="What is 3 + 4"),+ ]+ result_string_content = model_with_tools.invoke(messages_string_content)+ assert isinstance(result_string_content, AIMessage)