From 9662b601771a5531a8f4b1aed7711839cc81b253 Mon Sep 17 00:00:00 2001 From: Luciano Scarpulla Date: Wed, 13 Nov 2024 17:54:58 +0800 Subject: [PATCH] add decorator test --- tests/test_tools.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_tools.py b/tests/test_tools.py index 1926831..ce2ca5f 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -5,6 +5,7 @@ from pydantic import Field import simplemind as sm from simplemind.providers import Anthropic +from simplemind.providers._base_tools import BaseTool MODELS = [ Anthropic, @@ -102,3 +103,17 @@ def test_multiple_tools(provider_cls): data = conv.send(tools=[get_location, get_weather]) assert "San Francisco" in data.text assert "42" in data.text + + +@pytest.mark.parametrize( + "provider_cls", + MODELS, +) +def test_tool_decorator(provider_cls): + @sm.tool(llm_provider=provider_cls.NAME) + def exchange_rate(currency_pair: str) -> float: + return 7.9 + + assert isinstance(exchange_rate, BaseTool) + assert exchange_rate.name == "exchange_rate" + assert list(exchange_rate.properties.keys()) == ["currency_pair"]