Agents
Agents are powerful tools on the aiXplain platform that combine the capabilities of Large Language Models (LLMs) with external tools to perform a variety of tasks. This section introduces the core concepts of agents, their features, and practical examples to help you get started.
Example
This example demonstrates how to build an agent using the aiXplain SDK. The agent is powered by the Groq LLaMA 3.1 70B model and includes a speech synthesis tool. The agent takes text input and provides an audio-enabled response.
from aixplain.factories import AgentFactory
from aixplain.modules.agent import ModelTool
agent = AgentFactory.create(
name="Agent",
description="An AI agent powered by the Groq LLaMA 3.1 70B model and speech synthesis capabilities, designed to provide informative and audio-enabled responses.",
tools=[
ModelTool(model="6171eec2c714b775a4b48caf") # speech syntehsis model
],
llm_id="66b2708c6eb5635d1c71f611" # groq llama 3.1 70B
)
agent_response = agent.run("What's an agent?")
print(agent_response)
Guide to Building the Example Agent
Initialize the Agent
Create a new agent instance by specifying its name, description, tools, and LLM ID.
from aixplain.factories import AgentFactory
from aixplain.modules.agent import ModelTool
agent = AgentFactory.create(
name="Agent",
description="An AI agent powered by the Groq LLaMA 3.1 70B model and speech synthesis capabilities, designed to provide informative and audio-enabled responses.",
tools=[
ModelTool(model="6171eec2c714b775a4b48caf") # speech syntehsis model
],
llm_id="66b2708c6eb5635d1c71f611" # groq llama 3.1 70B
)
Run the Agent
Use the run
method to execute the agent with a query. The agent processes the input and returns a response.
agent_response = agent.run("What's an agent?")
print(agent_response)
Update the Agent
Update the agent configuration, such as adding new tools or modifying the description
agent.description = "Updated description with enhanced functionalities."
agent.update()
Debug the Agent
Iterate and test the agent until the responses meet your expectations. Adjust tools, configurations, or input queries as needed for optimal results.
Deploy the Agent
Deploy the agent to make it available for use in production.
agent.deploy()
Agent Parameters
Covers the parameters used in the create method to define an agent's identity, functionality, and configuration.
Parameter | Type | Default | Description |
---|---|---|---|
name | Text | [required] | The name of the agent, serving as its unique identifier. |
description | Text | [required] | A brief summary of the agent's role and functionality. |
llm_id | Text | OpenAI's GPT-4o Mini | The ID of the large language model (LLM) that powers the agent. |
tools | List[Tool] | [] | List of tools defining additional functionalities for the agent. |
api_key | Text | config.TEAM_API_KEY | API key for authenticating requests to manage the agent. |
vendor | Union[Dict, Text, Supplier, int] | "aiXplain" | Specifies the owner or provider of the agent. |
version | Optional[Text] | None | Version number of the agent, useful for tracking updates. |
use_mentalist_and_inspector | bool | False | Enables advanced planning and supervision features if a supervisor is enabled. |
Agent Methods
Lists the core functions for creating, managing, and retrieving agents programmatically.
Function | Description |
---|---|
create | Creates a new agent with specified parameters, tools, and configurations. |
validate | Validates the agent by checking its tools, name, and associated LLM. |
run | Executes the agent on specified input data or query, providing results. |
run_async | Executes the agent asynchronously, returning a polling URL for the response. |
to_dict | Converts the agent's configuration and metadata to a dictionary format. |
delete | Deletes the agent configuration from the platform. |
update | Updates the agent with new configurations and metadata. |
deploy | Deploys the agent, changing its status from DRAFT to ONBOARDED . |
create_model_tool | Creates a model tool using a specified model and function. |
create_pipeline_tool | Creates a pipeline tool by linking a pipeline to the agent. |
list | Lists all agents available on the platform for the given API key. |
get | Fetches the details of an agent using its unique ID. |
Follow this quickstart to create your first agent.