diff --git a/aixplain/factories/agent_factory/__init__.py b/aixplain/factories/agent_factory/__init__.py index 80ea9e2e..c7f51ae0 100644 --- a/aixplain/factories/agent_factory/__init__.py +++ b/aixplain/factories/agent_factory/__init__.py @@ -64,6 +64,7 @@ def create( description: Text, instructions: Optional[Text] = None, llm: Optional[Union[LLM, Text]] = None, + llm_id: Optional[Text] = None, tools: Optional[List[Union[Tool, Model]]] = None, api_key: Text = config.TEAM_API_KEY, supplier: Union[Dict, Text, Supplier, int] = "aiXplain", @@ -72,7 +73,6 @@ def create( workflow_tasks: Optional[List[WorkflowTask]] = None, output_format: Optional[OutputFormat] = None, expected_output: Optional[Union[BaseModel, Text, dict]] = None, - **kwargs, ) -> Agent: """Create a new agent in the platform. @@ -86,6 +86,7 @@ def create( description (Text): description of the agent instructions. instructions (Text): instructions of the agent. llm (Optional[Union[LLM, Text]], optional): LLM instance to use as an object or as an ID. + llm_id (Optional[Text], optional): ID of LLM to use if no LLM instance provided. Defaults to None. tools (List[Union[Tool, Model]], optional): list of tool for the agent. Defaults to []. api_key (Text, optional): team/user API key. Defaults to config.TEAM_API_KEY. supplier (Union[Dict, Text, Supplier, int], optional): owner of the agent. Defaults to "aiXplain". @@ -94,7 +95,7 @@ def create( workflow_tasks (List[WorkflowTask], optional): list of tasks for the agent. Defaults to []. output_format (OutputFormat, optional): default output format for agent responses. Defaults to OutputFormat.TEXT. expected_output (Union[BaseModel, Text, dict], optional): expected output. Defaults to None. - **kwargs: Additional keyword arguments. + Returns: Agent: created Agent """ @@ -102,16 +103,6 @@ def create( workflow_tasks = [] if workflow_tasks is None else list(workflow_tasks) from aixplain.utils.llm_utils import get_llm_instance - # Extract llm_id from kwargs if present (deprecated parameter) - llm_id = kwargs.get("llm_id", None) - if llm_id is not None: - warnings.warn( - "The 'llm_id' parameter is deprecated and will be removed in a future version. " - "Use the 'llm' parameter instead by passing the LLM ID or LLM instance directly.", - DeprecationWarning, - stacklevel=2, - ) - if llm is None and llm_id is not None: llm = get_llm_instance(llm_id, api_key=api_key, use_cache=True) elif llm is None: diff --git a/aixplain/factories/team_agent_factory/__init__.py b/aixplain/factories/team_agent_factory/__init__.py index e9d2ba7a..5463902e 100644 --- a/aixplain/factories/team_agent_factory/__init__.py +++ b/aixplain/factories/team_agent_factory/__init__.py @@ -23,7 +23,6 @@ import json import logging -import warnings from typing import Dict, List, Optional, Text, Union from urllib.parse import urljoin @@ -55,12 +54,15 @@ def create( cls, name: Text, agents: List[Union[Text, Agent]], + llm_id: Text = "669a63646eb56306647e1091", llm: Optional[Union[LLM, Text]] = None, supervisor_llm: Optional[Union[LLM, Text]] = None, + mentalist_llm: Optional[Union[LLM, Text]] = None, description: Text = "", api_key: Text = config.TEAM_API_KEY, supplier: Union[Dict, Text, Supplier, int] = "aiXplain", version: Optional[Text] = None, + use_mentalist: bool = True, inspectors: List[Inspector] = [], inspector_targets: List[Union[InspectorTarget, Text]] = [InspectorTarget.STEPS], instructions: Optional[Text] = None, @@ -73,57 +75,24 @@ def create( Args: name: The name of the team agent. agents: A list of agents to be added to the team. + llm_id: The ID of the LLM to be used for the team agent. llm (Optional[Union[LLM, Text]], optional): The LLM to be used for the team agent. supervisor_llm (Optional[Union[LLM, Text]], optional): Main supervisor LLM. Defaults to None. + mentalist_llm (Optional[Union[LLM, Text]], optional): LLM for planning. Defaults to None. description: The description of the team agent to be displayed in the aiXplain platform. api_key: The API key to be used for the team agent. supplier: The supplier of the team agent. version: The version of the team agent. + use_mentalist: Whether to use the mentalist agent. inspectors: A list of inspectors to be added to the team. inspector_targets: Which stages to be inspected during an execution of the team agent. (steps, output) + use_mentalist_and_inspector: Whether to use the mentalist and inspector agents. (legacy) instructions: The instructions to guide the team agent (i.e. appended in the prompt of the team agent). output_format: The output format to be used for the team agent. expected_output: The expected output to be used for the team agent. Returns: A new team agent instance. - - Deprecated Args: - llm_id: DEPRECATED. Use 'llm' parameter instead. The ID of the LLM to be used for the team agent. - mentalist_llm: DEPRECATED. LLM for planning. - use_mentalist: DEPRECATED. Whether to use the mentalist agent. """ - # Handle deprecated parameters from kwargs - if "llm_id" in kwargs: - llm_id = kwargs.pop("llm_id") - warnings.warn( - "Parameter 'llm_id' is deprecated and will be removed in a future version. " - "Please use 'llm' parameter instead.", - DeprecationWarning, - stacklevel=2, - ) - else: - llm_id = "669a63646eb56306647e1091" - - if "mentalist_llm" in kwargs: - mentalist_llm = kwargs.pop("mentalist_llm") - warnings.warn( - "Parameter 'mentalist_llm' is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - else: - mentalist_llm = None - - if "use_mentalist" in kwargs: - use_mentalist = kwargs.pop("use_mentalist") - warnings.warn( - "Parameter 'use_mentalist' is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - else: - use_mentalist = True - # legacy params if "use_mentalist_and_inspector" in kwargs: logging.warning( diff --git a/aixplain/factories/team_agent_factory/utils.py b/aixplain/factories/team_agent_factory/utils.py index 2441d9db..1a6ba90f 100644 --- a/aixplain/factories/team_agent_factory/utils.py +++ b/aixplain/factories/team_agent_factory/utils.py @@ -396,6 +396,6 @@ def build_team_agent_from_yaml(yaml_code: str, llm_id: str, api_key: str, team_i agents=agent_objs, llm=llm, api_key=api_key, + use_mentalist=True, inspectors=[], - use_mentalist=True, # Deprecated parameter ) diff --git a/aixplain/modules/agent/__init__.py b/aixplain/modules/agent/__init__.py index 18483076..c647a2f7 100644 --- a/aixplain/modules/agent/__init__.py +++ b/aixplain/modules/agent/__init__.py @@ -578,9 +578,10 @@ def run( content: Optional[Union[Dict[Text, Text], List[Text]]] = None, max_tokens: int = 4096, max_iterations: int = 5, + output_format: Optional[OutputFormat] = None, + expected_output: Optional[Union[BaseModel, Text, dict]] = None, trace_request: bool = False, progress_verbosity: Optional[str] = "compact", - **kwargs, ) -> AgentResponse: """Runs an agent call. @@ -596,35 +597,15 @@ def run( content (Union[Dict[Text, Text], List[Text]], optional): Content inputs to be processed according to the query. Defaults to None. max_tokens (int, optional): maximum number of tokens which can be generated by the agent. Defaults to 2048. max_iterations (int, optional): maximum number of iterations between the agent and the tools. Defaults to 10. + output_format (OutputFormat, optional): response format. If not provided, uses the format set during initialization. + expected_output (Union[BaseModel, Text, dict], optional): expected output. Defaults to None. trace_request (bool, optional): return the request id for tracing the request. Defaults to False. progress_verbosity (Optional[str], optional): Progress display mode - "full" (detailed), "compact" (brief), or None (no progress). Defaults to "compact". - **kwargs: Additional keyword arguments. Returns: Dict: parsed output from model """ start = time.time() - - # Extract deprecated parameters from kwargs - output_format = kwargs.get("output_format", None) - expected_output = kwargs.get("expected_output", None) - - if output_format is not None: - warnings.warn( - "The 'output_format' parameter is deprecated and will be removed in a future version. " - "Set the output format during agent initialization instead.", - DeprecationWarning, - stacklevel=2, - ) - - if expected_output is not None: - warnings.warn( - "The 'expected_output' parameter is deprecated and will be removed in a future version. " - "Set the expected output during agent initialization instead.", - DeprecationWarning, - stacklevel=2, - ) - if session_id is not None and history is not None: raise ValueError("Provide either `session_id` or `history`, not both.") diff --git a/aixplain/modules/team_agent/__init__.py b/aixplain/modules/team_agent/__init__.py index e374472e..1e91777f 100644 --- a/aixplain/modules/team_agent/__init__.py +++ b/aixplain/modules/team_agent/__init__.py @@ -30,7 +30,6 @@ import time import traceback import re -import warnings from enum import Enum from typing import Dict, List, Text, Optional, Union, Any from urllib.parse import urljoin @@ -91,23 +90,14 @@ class TeamAgent(Model, DeployableMixin[Agent]): name (Text): Name of the Team Agent agents (List[Agent]): List of agents that the Team Agent uses. description (Text, optional): description of the Team Agent. Defaults to "". - llm (Optional[LLM]): Main LLM instance for the team agent. - supervisor_llm (Optional[LLM]): Supervisor LLM instance for the team agent. + llm_id (Text, optional): large language model. Defaults to GPT-4o (6646261c6eb563165658bbb1). api_key (str): The TEAM API key used for authentication. supplier (Text): Supplier of the Team Agent. version (Text): Version of the Team Agent. cost (Dict, optional): model price. Defaults to None. + use_mentalist (bool): Use Mentalist agent for pre-planning. Defaults to True. inspectors (List[Inspector]): List of inspectors that the team agent uses. inspector_targets (List[InspectorTarget]): List of targets where the inspectors are applied. Defaults to [InspectorTarget.STEPS]. - status (AssetStatus): Status of the Team Agent. Defaults to DRAFT. - instructions (Optional[Text]): Instructions to guide the team agent. - output_format (OutputFormat): Response format. Defaults to TEXT. - expected_output (Optional[Union[BaseModel, Text, dict]]): Expected output format. - - Deprecated Attributes: - llm_id (Text): DEPRECATED. Use 'llm' parameter instead. Large language model ID. - mentalist_llm (Optional[LLM]): DEPRECATED. LLM for planning. - use_mentalist (bool): DEPRECATED. Whether to use Mentalist agent for pre-planning. """ is_valid: bool @@ -118,12 +108,15 @@ def __init__( name: Text, agents: List[Agent] = [], description: Text = "", + llm_id: Text = "6646261c6eb563165658bbb1", llm: Optional[LLM] = None, supervisor_llm: Optional[LLM] = None, + mentalist_llm: Optional[LLM] = None, api_key: Optional[Text] = config.TEAM_API_KEY, supplier: Union[Dict, Text, Supplier, int] = "aiXplain", version: Optional[Text] = None, cost: Optional[Dict] = None, + use_mentalist: bool = True, inspectors: List[Inspector] = [], inspector_targets: List[InspectorTarget] = [InspectorTarget.STEPS], status: AssetStatus = AssetStatus.DRAFT, @@ -134,38 +127,6 @@ def __init__( ) -> None: """Initialize a TeamAgent instance. - # Handle deprecated parameters from kwargs - if "llm_id" in additional_info: - llm_id = additional_info.pop("llm_id") - warnings.warn( - "Parameter 'llm_id' is deprecated and will be removed in a future version. " - "Please use 'llm' parameter instead.", - DeprecationWarning, - stacklevel=2, - ) - else: - llm_id = "6646261c6eb563165658bbb1" - - if "mentalist_llm" in additional_info: - mentalist_llm = additional_info.pop("mentalist_llm") - warnings.warn( - "Parameter 'mentalist_llm' is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - else: - mentalist_llm = None - - if "use_mentalist" in additional_info: - use_mentalist = additional_info.pop("use_mentalist") - warnings.warn( - "Parameter 'use_mentalist' is deprecated and will be removed in a future version.", - DeprecationWarning, - stacklevel=2, - ) - else: - use_mentalist = True - Args: id (Text): Unique identifier for the team agent. name (Text): Name of the team agent. @@ -554,9 +515,10 @@ def run( content: Optional[Union[Dict[Text, Text], List[Text]]] = None, max_tokens: int = 2048, max_iterations: int = 30, + output_format: Optional[OutputFormat] = None, + expected_output: Optional[Union[BaseModel, Text, dict]] = None, trace_request: bool = False, progress_verbosity: Optional[str] = "compact", - **kwargs, ) -> AgentResponse: """Runs a team agent call. @@ -572,31 +534,14 @@ def run( content (Union[Dict[Text, Text], List[Text]], optional): Content inputs to be processed according to the query. Defaults to None. max_tokens (int, optional): maximum number of tokens which can be generated by the agents. Defaults to 2048. max_iterations (int, optional): maximum number of iterations between the agents. Defaults to 30. + output_format (OutputFormat, optional): response format. If not provided, uses the format set during initialization. + expected_output (Union[BaseModel, Text, dict], optional): expected output. Defaults to None. trace_request (bool, optional): return the request id for tracing the request. Defaults to False. progress_verbosity (Optional[str], optional): Progress display mode - "full" (detailed), "compact" (brief), or None (no progress). Defaults to "compact". Returns: AgentResponse: parsed output from model """ - # Handle deprecated parameters from kwargs - output_format = kwargs.pop("output_format", None) - if output_format is not None: - warnings.warn( - "Parameter 'output_format' in run() is deprecated and will be removed in a future version. " - "Please set 'output_format' during TeamAgent initialization instead.", - DeprecationWarning, - stacklevel=2, - ) - - expected_output = kwargs.pop("expected_output", None) - if expected_output is not None: - warnings.warn( - "Parameter 'expected_output' in run() is deprecated and will be removed in a future version. " - "Please set 'expected_output' during TeamAgent initialization instead.", - DeprecationWarning, - stacklevel=2, - ) - start = time.time() result_data = {} if session_id is not None and history is not None: diff --git a/aixplain/modules/team_agent/inspector.py b/aixplain/modules/team_agent/inspector.py index b518e76e..2e870c00 100644 --- a/aixplain/modules/team_agent/inspector.py +++ b/aixplain/modules/team_agent/inspector.py @@ -16,6 +16,8 @@ name="team" agents=agents, description="team description", + llm_id="xyz", + use_mentalist=True, inspectors=[inspector], ) """