mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
standard-tests[patch]: improve runnable tool description (#24210)
This commit is contained in:
parent
e8ee781a42
commit
12950cc602
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user