Skip to content

Commit

Permalink
refactor(test): use ToolRunner to run tool in test_wrap_tool_input
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejmajek committed Jan 24, 2025
1 parent 1545c52 commit 86019fc
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/tools/test_tool_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
from typing import Any, Dict, List, Type

from langchain_core.messages import AIMessage, ToolCall
from langchain_core.tools import BaseTool
from pydantic import BaseModel, Field

from rai.agents.tool_runner import ToolRunner
from rai.tools.utils import wrap_tool_input


Expand All @@ -43,13 +46,14 @@ def _run(self, tool_input: TestToolInput) -> str:
return "done"

tool = TestTool()
result = tool.invoke(
{
"a": 1,
"b": "test",
"c": {"a": 1, "b": 2},
"d": [1, 2, 3],
"e": b"test",
}
logger = logging.getLogger(__name__)
runner = ToolRunner(tools=[tool], logger=logger)
tool_call = ToolCall(
name="test_tool",
args={"a": 1, "b": "test", "c": {"a": 1, "b": 2}, "d": [1, 2, 3], "e": b"test"},
id="123",
)

_ = runner.invoke(
{"messages": [AIMessage(content="Hello, how are you?", tool_calls=[tool_call])]}
)
assert result == "done"

0 comments on commit 86019fc

Please sign in to comment.