Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integration test with multiple parts #681

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions libs/genai/tests/integration_tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def search(
request = HumanMessage(
content=(
"Please tell the primary color of following birds: "
"sparrow, hawk, crow by using searchm"
"sparrow, hawk, crow by using search tool."
)
)
response = llm_with_search_force.invoke([request])
Expand All @@ -342,19 +342,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
Loading