Skip to content

Commit a7b5a46

Browse files
Add restriction when setting Utilities function in model tool (#346)
1 parent 125527b commit a7b5a46

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

aixplain/modules/agent/tool/model_tool.py

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def __init__(
6060
if function is not None:
6161
if isinstance(function, str):
6262
function = Function(function)
63+
assert (
64+
function is None or function is not Function.UTILITIES or model is not None
65+
), "Agent Creation Error: Utility function must be used with an associated model."
6366

6467
try:
6568
if isinstance(supplier, dict):

tests/unit/agent_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from aixplain.modules.agent import PipelineTool, ModelTool
99
from aixplain.modules.agent.utils import process_variables
1010
from urllib.parse import urljoin
11+
from aixplain.enums.function import Function
1112

1213

1314
def test_fail_no_data_query():
@@ -265,3 +266,9 @@ def test_process_variables():
265266
"input": "Hello, how are you?",
266267
"target_language": "English",
267268
}
269+
270+
271+
def test_fail_utilities_without_model():
272+
with pytest.raises(Exception) as exc_info:
273+
AgentFactory.create(name="Test", tools=[ModelTool(function=Function.UTILITIES)], llm_id="6646261c6eb563165658bbb1")
274+
assert str(exc_info.value) == "Agent Creation Error: Utility function must be used with an associated model."

0 commit comments

Comments
 (0)