Skip to content

Commit

Permalink
specify tool_choice in tool calling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Aug 19, 2024
1 parent 06b62ee commit 1b78a7b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_stop_sequence(self, model: BaseChatModel) -> None:
def test_tool_calling(self, model: BaseChatModel) -> None:
if not self.has_tool_calling:
pytest.skip("Test requires tool calling.")
model_with_tools = model.bind_tools([magic_function])
model_with_tools = model.bind_tools([magic_function], tool_choice="any")

# Test invoke
query = "What is the value of magic_function(3)? Use the tool."
Expand All @@ -188,7 +188,7 @@ def test_tool_calling_with_no_arguments(self, model: BaseChatModel) -> None:
if not self.has_tool_calling:
pytest.skip("Test requires tool calling.")

model_with_tools = model.bind_tools([magic_function_no_args])
model_with_tools = model.bind_tools([magic_function_no_args], tool_choice="any")
query = "What is the value of magic_function()? Use the tool."
result = model_with_tools.invoke(query)
_validate_tool_call_message_no_args(result)
Expand All @@ -212,7 +212,7 @@ def test_bind_runnables_as_tools(self, model: BaseChatModel) -> None:
name="greeting_generator",
description="Generate a greeting in a particular style of speaking.",
)
model_with_tools = model.bind_tools([tool_])
model_with_tools = model.bind_tools([tool_], tool_choice="any")
query = "Using the tool, generate a Pirate greeting."
result = model_with_tools.invoke(query)
assert isinstance(result, AIMessage)
Expand Down

0 comments on commit 1b78a7b

Please sign in to comment.