Composite Agent¶
The Composite agent is a built-in agent in the AI Refinery SDK that takes the reposnses from several utility agents and returns a composite answer. Its main function is to combine the information from the draft responses from several utility agents to format a coherent and comprehensive response.
Workflow Overview¶
The workflow of the Composite Agent consists of the following components:
-
Helper Specification: In your project configuration, you can designate a set of helper utility agents for each utility agent. For example, you might pair a
SearchAgent
for web data with aCustomAgent
for proprietary sources. If you designate theCustomAgent
as a helper to theSearchAgent
, the AI Refinery SDK will automatically create a Composite Agent. -
Parallel Draft Generation: Once the Composite Agent is created, it is added to the agent pool accessible by the orchestrator. When the orchestrator assigns a user query to a specific Composite Agent, all utility agents within that Composite Agent, including the primary utility agent, are invoked in parallel. This allows them to independently generate draft responses.
-
Response Compilation: Based on the user query, and the draft responses from the utility agents, the Composite Agent compiles a coherent and comprehensive response, which is then delivered as the final output to the user.
Usage¶
You can easily integrate composite agents into your project by adding the necessary configurations to your project YAML file. Specifically, ensure the following configurations are included:
- Each utility agent that you plan to use in the composite agents are well configured under
utility_agents
. - All utility agents in your project are listed under orchestrator.
- Specify the names of helper agents for a certain utility agent that needs to be composite under
helpers
.
Quickstart¶
To quickly set up a project with a composite agent, use the following YAML configuration. This setup includes:
- A
SearchAgent
namedOnline Shopper
that helps you find the provider and prices of electronics on the internet. - A
CustomAgent
namedInventory Reader
that helps you check the inventory. Inventory Reader
as a helper ofOnline Shopper
Therefore, Online Shopper
will be compiled as a composite agent and it will gather information from both the internet and office inventory before generating the final response.
utility_agents:
- agent_class: SearchAgent
agent_name: Online Shopper # Required. Name of your SearchAgent
agent_description: This agent helps you find on the internet the provider and prices of electronics # Optional. Description of your SearchAgent
helpers: # List of helpers in the composite agent. Required if you want to use composite agents
- "Inventory Reader" # An agent name from the list of utility agents
- agent_class: CustomAgent # A customAgent that you can write to access the office inventory
agent_name: Inventory Reader # Required. Name of your CustomAgent.
agent_description: This agent helps you check the inventory of our offices # Optional. Description of your CustomAgent
orchestrator:
agent_list:
- agent_name: Online Shopper # The name of your composite online shopper agent
- agent_name: Inventory Reader # The name of your inventory reader agent
Template YAML Configuration for composite agents:¶
You can use the following template to create your own composite agents in your project:
utility_agents:
- agent_class: <Class of your utility agent> # Built-in or custom
agent_name: <Name of the agent e.g., Agent 1> # Required
agent_description: <Description of the agent> # Optional.
helpers: # List of helpers in the composite agent. Required if you want to use composite agents
- "Agent 2" # An agent name from the list of utility agents
- "Agent 3" # An agent name from the list of utility agents
config: # See the inidividual agent pages in our agent marketplace for the supported configurations for each agent
<all other configuration for this agent>
- agent_class: <Class of your utility agent> # Built-in or custom
agent_name: <Name of the agent e.g., Agent 2> # Required
agent_description: <Description of the agent> # Optional.
config: # See the inidividual agent pages in our agent marketplace for the supported configurations for each agent
<all other configuration for this agent>
- agent_class: <Class of your utility agent> # Built-in or custom
agent_name: <Name of the agent e.g., Agent 3> # Required
agent_description: <Description of the agent> # Optional.
config: # See the inidividual agent pages in our agent marketplace for the supported configurations for each agent
<all other configuration for this agent>
orchestrator:
agent_list:
- agent_name: Agent 1 # The name of your composite agent
- agent_name: Agent 2 # The name of another agent
- agent_name: Agent 3 # The name of another agent