Skip to content

Commit

Permalink
Fix integration test with multiple parts
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrito87 committed Jan 8, 2025
1 parent bd24d50 commit 625118d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions libs/genai/tests/integration_tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ def test_safety_settings_gemini() -> None:
assert len(out2.content) > 0


@pytest.mark.xfail(reason="on the model's side")
def test_chat_function_calling_with_multiple_parts() -> None:
@tool
def search(
Expand Down Expand Up @@ -342,19 +341,22 @@ def search(
assert len(response.tool_calls) > 0
tool_call = response.tool_calls[0]
assert tool_call["name"] == "search"
tool_messages = []
for tool_call in response.tool_calls:
tool_response = search.run(tool_call["args"])
tool_message = ToolMessage(
name="search",
content=json.dumps(tool_response),
tool_call_id=tool_call["id"],
)
tool_messages.append(tool_message)
assert len(tool_messages) > 0
assert len(response.tool_calls) == len(tool_messages)

tool_response = search("sparrow")
tool_message = ToolMessage(
name="search",
content=json.dumps(tool_response),
tool_call_id="0",
)

result = llm_with_search.invoke([request, response, tool_message])
result = llm_with_search.invoke([request, response, *tool_messages])

assert isinstance(result, AIMessage)
assert "brown" in result.content
assert len(result.tool_calls) > 0


def _check_tool_calls(response: BaseMessage, expected_name: str) -> None:
Expand Down

0 comments on commit 625118d

Please sign in to comment.