Skip to content

Commit c16fd87

Browse files
committed
wip
1 parent be00823 commit c16fd87

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

  • ai21/clients/studio/resources/agents

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ai21.models.ai21_base_model import AI21BaseModel
66
from ai21.models.agents import Agent
77
from ai21.models.maestro.run import MaestroMessage
8-
from ai21.types import NOT_GIVEN, NotGiven
8+
from typing import Optional
99

1010

1111
class AgentToMaestroRunConverter(AI21BaseModel):
@@ -15,27 +15,27 @@ class AgentToMaestroRunConverter(AI21BaseModel):
1515
agent_id: str
1616
input: List[Dict[str, str]]
1717
verbose: bool = False
18-
output_type: Dict[str, Any] | NotGiven = NOT_GIVEN
19-
include: List[str] | NotGiven = NOT_GIVEN
18+
output_type: Optional[Dict[str, Any]] = None
19+
include: Optional[List[str]] = None
2020
structured_rag_enabled: bool = False
2121
dynamic_planning_enabled: bool = False
2222
response_language: str = "english"
2323

2424
# Agent configuration (will be populated from agent fetch)
25-
agent_models: List[str] | NotGiven = NOT_GIVEN
26-
agent_tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN
27-
agent_tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN
28-
agent_requirements: List[Dict[str, Any]] | NotGiven = NOT_GIVEN
29-
agent_budget: str | NotGiven = NOT_GIVEN
25+
agent_models: Optional[List[str]] = None
26+
agent_tools: Optional[List[Dict[str, Any]]] = None
27+
agent_tool_resources: Optional[Dict[str, Any]] = None
28+
agent_requirements: Optional[List[Dict[str, Any]]] = None
29+
agent_budget: Optional[str] = None
3030

3131
# Computed maestro parameters
3232
maestro_input: List[MaestroMessage] = Field(default_factory=list)
33-
maestro_models: List[str] | NotGiven = NOT_GIVEN
34-
maestro_tools: List[Dict[str, Any]] | NotGiven = NOT_GIVEN
35-
maestro_tool_resources: Dict[str, Any] | NotGiven = NOT_GIVEN
36-
maestro_requirements: List[Dict[str, Any]] | NotGiven = NOT_GIVEN
37-
maestro_budget: str | NotGiven = NOT_GIVEN
38-
maestro_include: List[str] | NotGiven = NOT_GIVEN
33+
maestro_models: Optional[List[str]] = None
34+
maestro_tools: Optional[List[Dict[str, Any]]] = None
35+
maestro_tool_resources: Optional[Dict[str, Any]] = None
36+
maestro_requirements: Optional[List[Dict[str, Any]]] = None
37+
maestro_budget: Optional[str] = None
38+
maestro_include: Optional[List[str]] = None
3939

4040
def model_post_init(self, __context) -> None:
4141
"""Convert agent parameters to maestro parameters after initialization"""
@@ -48,7 +48,7 @@ def model_post_init(self, __context) -> None:
4848
self.maestro_tool_resources = self.agent_tool_resources
4949
self.maestro_requirements = self.agent_requirements
5050
self.maestro_budget = self.agent_budget
51-
self.maestro_include = self.include if self.include is not NOT_GIVEN else NOT_GIVEN
51+
self.maestro_include = self.include
5252

5353
@classmethod
5454
def from_agent_and_params(
@@ -57,15 +57,15 @@ def from_agent_and_params(
5757
agent_id: str,
5858
input: List[Dict[str, str]],
5959
verbose: bool = False,
60-
output_type: Dict[str, Any] | NotGiven = NOT_GIVEN,
61-
include: List[str] | NotGiven = NOT_GIVEN,
60+
output_type: Optional[Dict[str, Any]] = None,
61+
include: Optional[List[str]] = None,
6262
structured_rag_enabled: bool = False,
6363
dynamic_planning_enabled: bool = False,
6464
response_language: str = "english",
6565
**kwargs,
6666
) -> "AgentToMaestroRunConverter":
6767
"""Create converter from agent configuration and run parameters"""
68-
agent_requirements = NOT_GIVEN
68+
agent_requirements = None
6969
if agent.requirements:
7070
agent_requirements = [req.model_dump() for req in agent.requirements]
7171

@@ -78,11 +78,11 @@ def from_agent_and_params(
7878
structured_rag_enabled=structured_rag_enabled,
7979
dynamic_planning_enabled=dynamic_planning_enabled,
8080
response_language=response_language,
81-
agent_models=agent.models or NOT_GIVEN,
82-
agent_tools=agent.tools or NOT_GIVEN,
83-
agent_tool_resources=agent.tool_resources or NOT_GIVEN,
81+
agent_models=agent.models,
82+
agent_tools=agent.tools,
83+
agent_tool_resources=agent.tool_resources,
8484
agent_requirements=agent_requirements,
85-
agent_budget=agent.budget.value if agent.budget else NOT_GIVEN,
85+
agent_budget=agent.budget.value if agent.budget else None,
8686
**kwargs,
8787
)
8888

@@ -98,5 +98,5 @@ def to_maestro_create_params(self) -> dict:
9898
"include": self.maestro_include,
9999
"response_language": self.response_language,
100100
}
101-
# Remove NOT_GIVEN values
102-
return {k: v for k, v in params.items() if v is not NOT_GIVEN}
101+
# Remove None values
102+
return {k: v for k, v in params.items() if v is not None}

0 commit comments

Comments
 (0)