standard-tests[patch]: update test_bind_runnables_as_tools (#24241)

Reduce number of tool arguments from two to one.
This commit is contained in:
ccurme 2024-07-15 08:35:07 -04:00 committed by GitHub
parent 0da5078cad
commit 6fc7610b1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -193,22 +193,16 @@ class ChatModelIntegrationTests(ChatModelTests):
pytest.skip("Test requires tool calling.")
prompt = ChatPromptTemplate.from_messages(
[
("system", "Repeat what the user says in the style of {answer_style}."),
("human", "{user_input}"),
]
[("human", "Hello. Please respond in the style of {answer_style}.")]
)
llm = GenericFakeChatModel(messages=iter(["hello matey"]))
chain = prompt | llm | StrOutputParser()
tool_ = chain.as_tool(
name="repeat_in_answer_style",
description="Repeat the user_input in a particular style of speaking.",
name="greeting_generator",
description="Generate a greeting 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."
)
query = "Using the tool, generate a Pirate greeting."
result = model_with_tools.invoke(query)
assert isinstance(result, AIMessage)
assert result.tool_calls