Hierarchical Tasks Agent Workflow Documentation
Overview
This workflow utilizes a hierarchical agent-based approach to answer user queries. It leverages multiple CrewAI agents, each specializing in a specific task, coordinated by a manager agent. The system takes a user's input, generates a prompt, performs searches if needed, and then synthesizes the information to provide a comprehensive and informative response.
Components Overview
The workflow comprises the following components:
- Chat Input: Captures user input from the interface.
- Prompt: Generates a prompt based on user input.
- OpenAI Model: A large language model (LLM) used for text generation and understanding.
- CrewAI Agent (Research): An agent responsible for researching information relevant to the user's query.
- CrewAI Agent (Editor): An agent responsible for evaluating the gathered information for bias and misleading content.
- CrewAI Agent (Manager): An agent that manages and coordinates the Research and Editor agents.
- DuckDuckGo Search: Performs web searches using the DuckDuckGo search engine.
- Hierarchical Crew: Orchestrates the collaboration between multiple CrewAI agents.
- Hierarchical Task: Defines the tasks for the agents.
- Chat Output: Displays the final response to the user.
Detailed Component Descriptions
Chat Input
- Description: Retrieves user input as a message from the chat interface.
- Input Parameters: None.
- Output Parameters: Message (containing user's text input).
- Key Configurations/Conditions: Allows for optional settings to specify sender information and whether to store the message.
Prompt
- Description: Creates a prompt template incorporating the user's query.
- Input Parameters: Message (containing the user's query).
- Output Parameters: Message (containing the formatted prompt).
- Key Configurations/Conditions: Uses a template to structure the prompt, including the user's query.
OpenAI Model
- Description: Generates text using OpenAI's LLMs.
- Input Parameters: Input value (prompt or other text), various parameters controlling generation (e.g.,
max_tokens
,temperature
). - Output Parameters: Text output (generated text), Language Model object.
- Key Configurations/Conditions: Allows selection of different OpenAI models.
CrewAI Agent (Research, Editor, Manager)
- Description: Represents a CrewAI agent capable of performing specific tasks.
- Input Parameters: LLM (Language Model), Tools (optional), Backstory (optional), Goal, Role.
- Output Parameters: Agent output (results of the agent's task).
- Key Configurations/Conditions: Allows configuration of agent behavior through backstory, goal, and role parameters. Can utilize tools for task execution.
DuckDuckGo Search
- Description: Performs web searches using the DuckDuckGo search engine.
- Input Parameters: Search query (text),
max_results
(number of results). - Output Parameters: Data (search results), Tool (DuckDuckGo search tool).
- Key Configurations/Conditions: Allows specifying search region and source (e.g., "text" or "news").
Hierarchical Crew
- Description: Orchestrates the execution of multiple CrewAI agents.
- Input Parameters: Agents (list of agents), optional parameters for configuration (e.g.,
memory
,verbose
). - Output Parameters: Message (containing the synthesized response).
- Key Configurations/Conditions: Enables management of agent interactions and task assignments.
Hierarchical Task
- Description: Defines a task for the hierarchical agent system.
- Input Parameters: Task description (text), expected output (text), tools (optional).
- Output Parameters: HierarchicalTask object (defines the task).
- Key Configurations/Conditions: Defines the specific task to be performed by agents within the hierarchy.
Chat Output
- Description: Displays a message in the chat interface.
- Input Parameters: Message (containing the response text).
- Output Parameters: None.
- Key Configurations/Conditions: Allows customization of sender information and message display.
Workflow Execution
- Chat Input: The workflow begins with user input captured by the Chat Input component.
- Prompt Generation: The user's input is passed to the Prompt component to generate a structured prompt.
- OpenAI Model: The prompt is sent to the OpenAI Model to generate the initial response. This response is also used to inform and guide the subsequent agent behaviors.
- Agent Execution: The OpenAI Model output (a Language Model object) is fed into the CrewAI Agents (Research, Editor and Manager), along with relevant parameters. The Manager agent orchestrates their operations. The Research agent uses the DuckDuckGo Search tool.
- Hierarchical Crew: The manager, research, and editor agents are coordinated by the Hierarchical Crew component. The Hierarchical Task component is used to define tasks for these agents.
- Response Synthesis: The Hierarchical Crew component combines the output of the various agents to generate a final response.
- Chat Output: Finally, the Chat Output component displays the synthesized response to the user.
Additional Notes
The success of this workflow depends on the proper configuration of the agents, their goals, and the availability and functionality of the tools they utilize. The OpenAI Model's performance significantly impacts the overall quality of the response. Error handling and fallback mechanisms may be necessary to manage situations where agents fail to execute their tasks successfully. Consider memory management within the agents to improve performance and consistency.