-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee849d1
commit b62ba45
Showing
2 changed files
with
50 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/agentchat/contrib/capabilities/test_tools_capability.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
|
||
from autogen import AssistantAgent | ||
from autogen.agentchat.contrib.capabilities.tools_capability import ToolSpecs, ToolsCapability | ||
|
||
|
||
@pytest.fixture | ||
def add_tool_spec(): | ||
def add(x: int, y: int) -> int: | ||
return x + y | ||
|
||
return ToolSpecs( | ||
tool_func=add, | ||
tool_description="Provide add function to two argument and return sum.", | ||
tool_name="add_function", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def test_agent(): | ||
return AssistantAgent( | ||
name="test_agent", | ||
llm_config={ | ||
"config_list": [{"model": "gpt-4O", "api_key": "sk-proj-ABC"}], | ||
}, | ||
) | ||
|
||
|
||
class TestToolsCapability: | ||
def test_add_capability(self, add_tool_spec, test_agent) -> None: | ||
# Arrange | ||
tools_capability = ToolsCapability(tool_list=[add_tool_spec]) | ||
assert "tools" not in test_agent.llm_config | ||
# Act | ||
tools_capability.add_to_agent(agent=test_agent) | ||
# Assert | ||
assert len(test_agent.llm_config["tools"]) == 1 |