Skip to main content

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.

ParameterTypeDefaultDescription
nameText[required]The name of the agent, serving as its unique identifier.
descriptionText[required]A brief summary of the agent's role and functionality.
llm_idTextOpenAI's GPT-4o MiniThe ID of the large language model (LLM) that powers the agent.
toolsList[Tool][]List of tools defining additional functionalities for the agent.
api_keyTextconfig.TEAM_API_KEYAPI key for authenticating requests to manage the agent.
vendorUnion[Dict, Text, Supplier, int]"aiXplain"Specifies the owner or provider of the agent.
versionOptional[Text]NoneVersion number of the agent, useful for tracking updates.
use_mentalist_and_inspectorboolFalseEnables advanced planning and supervision features if a supervisor is enabled.

Agent Methods

Lists the core functions for creating, managing, and retrieving agents programmatically.

FunctionDescription
createCreates a new agent with specified parameters, tools, and configurations.
validateValidates the agent by checking its tools, name, and associated LLM.
runExecutes the agent on specified input data or query, providing results.
run_asyncExecutes the agent asynchronously, returning a polling URL for the response.
to_dictConverts the agent's configuration and metadata to a dictionary format.
deleteDeletes the agent configuration from the platform.
updateUpdates the agent with new configurations and metadata.
deployDeploys the agent, changing its status from DRAFT to ONBOARDED.
create_model_toolCreates a model tool using a specified model and function.
create_pipeline_toolCreates a pipeline tool by linking a pipeline to the agent.
listLists all agents available on the platform for the given API key.
getFetches the details of an agent using its unique ID.

Follow this quickstart to create your first agent.