Skip to content

Commit cebfdae

Browse files
author
benshuk
committed
chore: ⚰️ deprecate tool_resources from Maestro and Agents
1 parent 6d99892 commit cebfdae

File tree

10 files changed

+23
-41
lines changed

10 files changed

+23
-41
lines changed

ai21/clients/common/agents/agents.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
)
1414
from ai21.models.agents.agent import ResponseLanguage
1515
from ai21.types import NOT_GIVEN, NotGiven
16-
from ai21.utils.typing import remove_not_given
16+
from ai21.utils.typing import remove_not_given, warn_if_tool_resources_in_kwargs
1717

1818

1919
class BaseAgents(ABC):
@@ -26,19 +26,19 @@ def _create_body(
2626
description: str | NotGiven,
2727
models: List[str] | NotGiven,
2828
tools: List[Dict[str, Any]] | NotGiven,
29-
tool_resources: Dict[str, Any] | NotGiven,
3029
requirements: List[AgentRequirement] | NotGiven,
3130
budget: BudgetLevel | NotGiven,
3231
response_language: ResponseLanguage | NotGiven,
3332
**kwargs,
3433
) -> dict:
34+
warn_if_tool_resources_in_kwargs(kwargs)
35+
3536
return remove_not_given(
3637
{
3738
"name": name,
3839
"description": description,
3940
"models": models,
4041
"tools": tools,
41-
"tool_resources": tool_resources,
4242
"requirements": requirements,
4343
"budget": budget,
4444
"response_language": response_language,
@@ -53,20 +53,20 @@ def _modify_body(
5353
description: str | NotGiven,
5454
models: List[str] | NotGiven,
5555
tools: List[Dict[str, Any]] | NotGiven,
56-
tool_resources: Dict[str, Any] | NotGiven,
5756
requirements: List[AgentRequirement] | NotGiven,
5857
budget: BudgetLevel | NotGiven,
5958
visibility: Visibility | NotGiven,
6059
response_language: ResponseLanguage | NotGiven,
6160
**kwargs,
6261
) -> dict:
62+
warn_if_tool_resources_in_kwargs(kwargs)
63+
6364
return remove_not_given(
6465
{
6566
"name": name,
6667
"description": description,
6768
"models": models,
6869
"tools": tools,
69-
"tool_resources": tool_resources,
7070
"requirements": requirements,
7171
"budget": budget,
7272
"visibility": visibility,
@@ -85,7 +85,6 @@ def create(
8585
avatar: str | NotGiven = NOT_GIVEN,
8686
models: List[str] | NotGiven = NOT_GIVEN,
8787
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
88-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
8988
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
9089
budget: BudgetLevel | NotGiven = NOT_GIVEN,
9190
response_language: ResponseLanguage | NotGiven = NOT_GIVEN,
@@ -110,7 +109,6 @@ def modify(
110109
description: str | NotGiven = NOT_GIVEN,
111110
models: List[str] | NotGiven = NOT_GIVEN,
112111
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
113-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
114112
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
115113
budget: BudgetLevel | NotGiven = NOT_GIVEN,
116114
visibility: Visibility | NotGiven = NOT_GIVEN,

ai21/clients/common/agents/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ai21.models.agents import Agent
55
from ai21.models.agents.agent import AgentRequirement
66
from ai21.models.maestro.run import Requirement
7-
from ai21.utils.typing import remove_not_given
7+
from ai21.utils.typing import remove_not_given, warn_if_tool_resources_in_kwargs
88

99

1010
class BaseAgentRun(ABC):
@@ -31,11 +31,12 @@ def convert_agent_to_maestro_run_payload(
3131
agent: Agent,
3232
**kwargs,
3333
):
34+
warn_if_tool_resources_in_kwargs(kwargs)
35+
3436
return remove_not_given(
3537
{
3638
"models": agent.models,
3739
"tools": agent.tools,
38-
"tool_resources": agent.tool_resources,
3940
"requirements": self._convert_requirements(agent.requirements),
4041
"budget": agent.budget,
4142
"response_language": agent.response_language,

ai21/clients/common/maestro/run.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
OutputOptions,
1212
Requirement,
1313
RunResponse,
14-
ToolResources,
1514
ToolDefinition,
1615
)
1716
from ai21.types import NOT_GIVEN, NotGiven
18-
from ai21.utils.typing import remove_not_given
17+
from ai21.utils.typing import remove_not_given, warn_if_tool_resources_in_kwargs
1918

2019

2120
class BaseMaestroRun(ABC):
@@ -27,19 +26,19 @@ def _create_body(
2726
input: str | List[MaestroMessage],
2827
models: List[str] | NotGiven,
2928
tools: List[ToolDefinition] | NotGiven,
30-
tool_resources: ToolResources | NotGiven,
3129
requirements: List[Requirement] | NotGiven,
3230
budget: Budget | NotGiven,
3331
include: List[OutputOptions] | NotGiven,
3432
response_language: str | NotGiven,
3533
**kwargs,
3634
) -> dict:
35+
warn_if_tool_resources_in_kwargs(kwargs)
36+
3737
return remove_not_given(
3838
{
3939
"input": input,
4040
"models": models,
4141
"tools": tools,
42-
"tool_resources": tool_resources,
4342
"requirements": requirements,
4443
"budget": budget,
4544
"include": include,
@@ -55,7 +54,6 @@ def create(
5554
input: str | List[MaestroMessage],
5655
models: List[str] | NotGiven = NOT_GIVEN,
5756
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
58-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
5957
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
6058
budget: Budget | NotGiven = NOT_GIVEN,
6159
include: List[OutputOptions] | NotGiven = NOT_GIVEN,
@@ -79,7 +77,6 @@ def create_and_poll(
7977
input: str | List[MaestroMessage],
8078
models: List[str] | NotGiven = NOT_GIVEN,
8179
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
82-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
8380
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
8481
budget: Budget | NotGiven = NOT_GIVEN,
8582
include: List[OutputOptions] | NotGiven = NOT_GIVEN,

ai21/clients/studio/resources/agents/agents.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def create(
8383
description: str | NotGiven = NOT_GIVEN,
8484
models: List[str] | NotGiven = NOT_GIVEN,
8585
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
86-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
8786
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
8887
budget: BudgetLevel | NotGiven = NOT_GIVEN,
8988
response_language: ResponseLanguage | NotGiven = NOT_GIVEN,
@@ -95,7 +94,6 @@ def create(
9594
description=description,
9695
models=models,
9796
tools=tools,
98-
tool_resources=tool_resources,
9997
requirements=requirements,
10098
budget=budget,
10199
response_language=response_language,
@@ -120,7 +118,6 @@ def modify(
120118
description: str | NotGiven = NOT_GIVEN,
121119
models: List[str] | NotGiven = NOT_GIVEN,
122120
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
123-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
124121
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
125122
budget: BudgetLevel | NotGiven = NOT_GIVEN,
126123
visibility: Visibility | NotGiven = NOT_GIVEN,
@@ -134,7 +131,6 @@ def modify(
134131
response_language=response_language,
135132
models=models,
136133
tools=tools,
137-
tool_resources=tool_resources,
138134
requirements=requirements,
139135
budget=budget,
140136
visibility=visibility,

ai21/clients/studio/resources/agents/async_agents.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ async def create(
8989
avatar: str | NotGiven = NOT_GIVEN,
9090
models: List[str] | NotGiven = NOT_GIVEN,
9191
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
92-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
9392
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
9493
budget: BudgetLevel | NotGiven = NOT_GIVEN,
9594
response_language: ResponseLanguage | NotGiven = NOT_GIVEN,
@@ -103,7 +102,6 @@ async def create(
103102
avatar=avatar,
104103
models=models,
105104
tools=tools,
106-
tool_resources=tool_resources,
107105
requirements=requirements,
108106
budget=budget,
109107
response_language=response_language,
@@ -128,7 +126,6 @@ async def modify(
128126
description: str | NotGiven = NOT_GIVEN,
129127
models: List[str] | NotGiven = NOT_GIVEN,
130128
tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN,
131-
tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN,
132129
requirements: List[AgentRequirement] | NotGiven = NOT_GIVEN,
133130
budget: BudgetLevel | NotGiven = NOT_GIVEN,
134131
visibility: Visibility | NotGiven = NOT_GIVEN,
@@ -141,7 +138,6 @@ async def modify(
141138
description=description,
142139
models=models,
143140
tools=tools,
144-
tool_resources=tool_resources,
145141
requirements=requirements,
146142
budget=budget,
147143
visibility=visibility,

ai21/clients/studio/resources/maestro/run.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
Requirement,
1616
RunResponse,
1717
TERMINATED_RUN_STATUSES,
18-
ToolResources,
1918
ToolDefinition,
2019
)
2120
from ai21.types import NotGiven, NOT_GIVEN
@@ -28,7 +27,6 @@ def create(
2827
input: str | List[MaestroMessage],
2928
models: List[str] | NotGiven = NOT_GIVEN,
3029
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
31-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
3230
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
3331
budget: Budget | NotGiven = NOT_GIVEN,
3432
include: List[OutputOptions] | NotGiven = NOT_GIVEN,
@@ -39,7 +37,6 @@ def create(
3937
input=input,
4038
models=models,
4139
tools=tools,
42-
tool_resources=tool_resources,
4340
requirements=requirements,
4441
budget=budget,
4542
include=include,
@@ -75,7 +72,6 @@ def create_and_poll(
7572
input: str | List[MaestroMessage],
7673
models: List[str] | NotGiven = NOT_GIVEN,
7774
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
78-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
7975
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
8076
budget: Budget | NotGiven = NOT_GIVEN,
8177
include: List[OutputOptions] | NotGiven = NOT_GIVEN,
@@ -88,7 +84,6 @@ def create_and_poll(
8884
input=input,
8985
models=models,
9086
tools=tools,
91-
tool_resources=tool_resources,
9287
requirements=requirements,
9388
budget=budget,
9489
include=include,
@@ -108,7 +103,6 @@ async def create(
108103
input: str | List[MaestroMessage],
109104
models: List[str] | NotGiven = NOT_GIVEN,
110105
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
111-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
112106
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
113107
budget: Budget | NotGiven = NOT_GIVEN,
114108
include: List[OutputOptions] | NotGiven = NOT_GIVEN,
@@ -119,7 +113,6 @@ async def create(
119113
input=input,
120114
models=models,
121115
tools=tools,
122-
tool_resources=tool_resources,
123116
requirements=requirements,
124117
budget=budget,
125118
include=include,
@@ -155,7 +148,6 @@ async def create_and_poll(
155148
input: str | List[MaestroMessage],
156149
models: List[str] | NotGiven = NOT_GIVEN,
157150
tools: List[ToolDefinition] | NotGiven = NOT_GIVEN,
158-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
159151
requirements: List[Requirement] | NotGiven = NOT_GIVEN,
160152
budget: Budget | NotGiven = NOT_GIVEN,
161153
include: List[OutputOptions] | NotGiven = NOT_GIVEN,
@@ -168,7 +160,6 @@ async def create_and_poll(
168160
input=input,
169161
models=models,
170162
tools=tools,
171-
tool_resources=tool_resources,
172163
requirements=requirements,
173164
budget=budget,
174165
include=include,

ai21/models/agents/agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import List, Optional
66

77
from ai21.models.ai21_base_model import AI21BaseModel
8-
from ai21.models.maestro.run import Budget, ToolDefinition, ToolResources
8+
from ai21.models.maestro.run import Budget, ToolDefinition
99

1010

1111
class BudgetLevel(str, Enum):
@@ -54,7 +54,6 @@ class Agent(AI21BaseModel):
5454
user_id: str
5555
models: Optional[List[str]] = None
5656
tools: Optional[List[ToolDefinition]] = None
57-
tool_resources: Optional[ToolResources] = None
5857
requirements: Optional[List[AgentRequirement]] = None
5958
budget: Optional[Budget] = None
6059
visibility: Optional[Visibility] = None

ai21/models/maestro/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
OutputOptions,
77
Requirement,
88
ToolDefinition,
9-
ToolResources,
109
WebSearchResult,
1110
HttpTool,
1211
McpTool,
@@ -23,7 +22,6 @@
2322
"OutputOptions",
2423
"Requirement",
2524
"ToolDefinition",
26-
"ToolResources",
2725
"WebSearchResult",
2826
"HttpTool",
2927
"McpTool",

ai21/models/maestro/run.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ class WebSearch(TypedDict, total=False):
7878
use_cached_pages: Optional[bool]
7979

8080

81-
class ToolResources(TypedDict, total=False):
82-
file_search: Optional[FileSearch]
83-
web_search: Optional[WebSearch]
84-
85-
8681
ToolDefinition = Annotated[
8782
Union[
8883
HttpTool,

ai21/utils/typing.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from typing import Any, Dict, get_args, cast
23

34
from ai21.types import NotGiven
@@ -30,3 +31,13 @@ def extract_type(type_to_extract: Any) -> type:
3031
raise RuntimeError(
3132
f"Expected type {type_to_extract} to have a type argument at index 0 but it did not"
3233
) from err
34+
35+
36+
def warn_if_tool_resources_in_kwargs(kwargs: Dict[str, Any], stacklevel: int = 3) -> None:
37+
if "tool_resources" in kwargs:
38+
warnings.warn(
39+
"The 'tool_resources' parameter is deprecated and will be removed in a future version. "
40+
"Use the 'tools' parameter instead.",
41+
DeprecationWarning,
42+
stacklevel=stacklevel,
43+
)

0 commit comments

Comments
 (0)