From 12950cc602800feb001e573461d659c3c394820b Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:33:56 -0700 Subject: [PATCH] standard-tests[patch]: improve runnable tool description (#24210) --- .../integration_tests/chat_models.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 2aaba72c03..162f727056 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 @@ -191,12 +191,22 @@ class ChatModelIntegrationTests(ChatModelTests): pytest.skip("Test requires tool calling.") prompt = ChatPromptTemplate.from_messages( - [("human", "Hello. Please respond in the style of {answer_style}.")] + [ + ("system", "Repeat what the user says in the style of {answer_style}."), + ("human", "{user_input}"), + ] ) llm = GenericFakeChatModel(messages=iter(["hello matey"])) chain = prompt | llm | StrOutputParser() - model_with_tools = model.bind_tools([chain.as_tool()]) - query = "Using the tool, ask a Pirate how it would say hello." + tool_ = chain.as_tool( + name="repeat_in_answer_style", + description="Repeat the user_input in a particular style of speaking.", + ) + model_with_tools = model.bind_tools([tool_]) + query = ( + "Using the repeat_in_answer_style tool, ask a Pirate how they would say " + "hello." + ) result = model_with_tools.invoke(query) assert isinstance(result, AIMessage) assert result.tool_calls