Skip to main content

module aixplain.modules.agent

Global Variables

  • output_format
  • tool
  • utils

class Agent

Advanced AI system capable of performing tasks by leveraging specialized software tools and resources from aiXplain marketplace.

Attributes:

  • id (Text): ID of the Agent
  • name (Text): Name of the Agent
  • tools (List[Tool]): List of tools that the Agent uses.
  • description (Text, optional): description of the Agent. Defaults to "".
  • llm_id (Text): large language model. Defaults to GPT-4o (6646261c6eb563165658bbb1).
  • supplier (Text): Supplier of the Agent.
  • version (Text): Version of the Agent.
  • backend_url (str): URL of the backend.
  • api_key (str): The TEAM API key used for authentication.
  • cost (Dict, optional): model price. Defaults to None.

method __init__

__init__(
id: str,
name: str,
description: str,
tools: List[Tool] = [],
llm_id: str = '6646261c6eb563165658bbb1',
api_key: Optional[str] = 'd0d1ea8a13cfe80dbb34378c3941e5df13d724e1059fa065d1a802dacd4ade15',
supplier: Union[Dict, str, Supplier, int] = 'aiXplain',
version: Optional[str] = None,
cost: Optional[Dict] = None,
status: AssetStatus = <AssetStatus.DRAFT: 'draft'>,
**additional_info
)None

Create an Agent with the necessary information.

Args:

  • id (Text): ID of the Agent
  • name (Text): Name of the Agent
  • description (Text): description of the Agent.
  • tools (List[Tool]): List of tools that the Agent uses.
  • llm_id (Text, optional): large language model. Defaults to GPT-4o (6646261c6eb563165658bbb1).
  • supplier (Text): Supplier of the Agent.
  • version (Text): Version of the Agent.
  • backend_url (str): URL of the backend.
  • api_key (str): The TEAM API key used for authentication.
  • cost (Dict, optional): model price. Defaults to None.

method delete

delete()None

Delete Agent service


method deploy

deploy()None

method run

run(
data: Optional[str, Dict] = None,
query: Optional[str] = None,
session_id: Optional[str] = None,
history: Optional[List[Dict]] = None,
name: str = 'model_process',
timeout: float = 300,
parameters: Dict = {},
wait_time: float = 0.5,
content: Optional[Dict[str, str], List[str]] = None,
max_tokens: int = 2048,
max_iterations: int = 10,
output_format: OutputFormat = <OutputFormat.TEXT: 'text'>
) → Dict

Runs an agent call.

Args:

  • data (Optional[Union[Dict, Text]], optional): data to be processed by the agent. Defaults to None.
  • query (Optional[Text], optional): query to be processed by the agent. Defaults to None.
  • session_id (Optional[Text], optional): conversation Session ID. Defaults to None.
  • history (Optional[List[Dict]], optional): chat history (in case session ID is None). Defaults to None.
  • name (Text, optional): ID given to a call. Defaults to "model_process".
  • timeout (float, optional): total polling time. Defaults to 300.
  • parameters (Dict, optional): optional parameters to the model. Defaults to "".
  • wait_time (float, optional): wait time in seconds between polling calls. Defaults to 0.5.
  • 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 (ResponseFormat, optional): response format. Defaults to TEXT.

Returns:

  • Dict: parsed output from model

method run_async

run_async(
data: Optional[str, Dict] = None,
query: Optional[str] = None,
session_id: Optional[str] = None,
history: Optional[List[Dict]] = None,
name: str = 'model_process',
parameters: Dict = {},
content: Optional[Dict[str, str], List[str]] = None,
max_tokens: int = 2048,
max_iterations: int = 10,
output_format: OutputFormat = <OutputFormat.TEXT: 'text'>
) → Dict

Runs asynchronously an agent call.

Args:

  • data (Optional[Union[Dict, Text]], optional): data to be processed by the agent. Defaults to None.
  • query (Optional[Text], optional): query to be processed by the agent. Defaults to None.
  • session_id (Optional[Text], optional): conversation Session ID. Defaults to None.
  • history (Optional[List[Dict]], optional): chat history (in case session ID is None). Defaults to None.
  • name (Text, optional): ID given to a call. Defaults to "model_process".
  • parameters (Dict, optional): optional parameters to the model. Defaults to "".
  • 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 (ResponseFormat, optional): response format. Defaults to TEXT.

Returns:

  • dict: polling URL in response

method to_dict

to_dict() → Dict

method update

update()None

Update agent.


method validate

validate()None

Validate the Agent.