Skip to content

The agent engineering platform.

standard-tests[patch]: improve runnable tool description (#24210)

Bagatur12950cc60280
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