Skip to content

Commit

Permalink
feat: Introduce ToolList response format in test_call.py and enhance …
Browse files Browse the repository at this point in the history
…tool validation in tests. This update improves the structure of tool responses and ensures accurate assertions for tool presence in the results.
  • Loading branch information
onuratakan committed Jan 7, 2025
1 parent 36bc31d commit a9dcee5
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions tests/client/test_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class City(BaseModel):
population: int


class ToolList(BaseModel):
tools: list[str]

def test_gpt4o_call():
result = server.call(prompt="Hi, I am Onur Atakan ULUSOY and I am a male", response_format=Human)
print(result)
Expand Down Expand Up @@ -46,12 +49,36 @@ def test_call_with_tools():


def test_call_with_mcp_server():
result = server.call(prompt="What are your tools?", tools=["add_numbers", "fetch"], mcp_servers=[{"command": "uvx", "args": ["mcp-server-fetch"]}])
result = server.call(prompt="What are your tools?", response_format=ToolList, tools=["add_numbers", "fetch"], mcp_servers=[{"command": "uvx", "args": ["mcp-server-fetch"]}])
print(result)
assert "add_numbers" in result and "fetch" in result

any_found_add_numbers = False
any_found_fetch = False
for tool in result.tools:
if "add_numbers" in tool.lower():
any_found_add_numbers = True

if "fetch" in tool.lower():
any_found_fetch = True


print(any_found_add_numbers, any_found_fetch)
assert any_found_add_numbers and any_found_fetch


def test_call_with_env_variable():
result = server.call(prompt="What are your tools?", tools=["add_numbers", "fetch"], mcp_servers=[{"command": "uvx", "args": ["mcp-server-fetch"], "env": {"test": "test"}}],)
result = server.call(prompt="What are your tools?", response_format=ToolList, tools=["add_numbers", "fetch"], mcp_servers=[{"command": "uvx", "args": ["mcp-server-fetch"], "env": {"test": "test"}}],)
print(result)
assert "add_numbers" in result and "fetch" in result

any_found_add_numbers = False
any_found_fetch = False
for tool in result.tools:
if "add_numbers" in tool.lower():
any_found_add_numbers = True

if "fetch" in tool.lower():
any_found_fetch = True


print(any_found_add_numbers, any_found_fetch)
assert any_found_add_numbers and any_found_fetch

0 comments on commit a9dcee5

Please sign in to comment.