“AI Agentic workflow will drive massive progress this year,” commented Andrew Ng, highlighting the significant advancements anticipated in AI. With the growing popularity of large language models, Autonomous Agents are becoming a topic of discussion. In this article, we will explore Autonomous Agents, cover the components of building an Agentic workflow, and discuss the practical implementation of a Content creation agent using Groq and crewAI. In this article you will get understanding about the ai agentic workflows and how you can create content with ai agent using groq and crewai, with that we are also providing agentic workflow example so that you can get full understanding on agentic workflow topic.
Agentic workflow is a new way of using AI, specifically large language models (LLMs) like me, to tackle complex tasks. It’s different from the traditional approach where you just give an LLM a prompt and get a response.
Here’s the gist of agentic workflows:
Imagine a group of engineers gathering to plan the development of a new software app. Each engineer brings expertise and insights, discussing various features, functionalities, and potential challenges. They brainstorm, analyze, and strategize together, aiming to create a comprehensive plan that meets the project’s goals.
To replicate this using large language models, eventually gave rise to the Autonomous Agents.
Autonomous agents possess reasoning and planning capabilities similar to human intelligence, making them advanced AI systems. They are essentially LLMs with brain that has the ability to self-reason and plan the decomposition of the tasks. A prime example of such an agent is “Devin AI,” which has sparked numerous discussions about its potential to replace human or software engineers.
Although this replacement might be premature due to the complexity and iterative nature of software development, the ongoing research in this field aims to address key areas like self-reasoning and memory utilization.
Before exploring the components required for building an agentic workflow, let’s first understand how humans execute a simple task.
Let’s say as a human how do we approach a problem statement?
When we approach a problem statement as humans, we follow a structured process to ensure efficient and successful execution. Take, for example, building a customer service chatbot. We don’t dive straight into coding. Instead, we plan by breaking down the task into smaller, manageable sub-tasks such as fetching data, cleaning data, building the model, and so on.
For each sub-task, we use our relevant experience and the right tools/framework knowledge to get the task done. Each sub-task requires careful planning and execution, previous learnings, ensuring we don’t make mistakes in executing the task.
This method involves multiple iterations until the task is completed successfully. Agents workflow operates in a similar fashion. Let’s break it down step by step to see how it mirrors our approach.
At the heart of the workflow are the Agents. Users provide a detailed description of the task. Once the task is outlined, the Agent utilizes planning and reasoning components to break down the task further. This involves using a large language model with prompt techniques like REACT. In this prompt engineering approach, we divide the process into three parts: Thoughts, Actions, and Observation. Thoughts reason about what needs to be done, actions refer to the supported tools and the additional context required by the LLM,
It’s time to dirty our hands with some code writing.
Let us now look into the steps to build Agentic Workflow using CrewAI and Groq Open Source Model.
pip install crewai
pip install 'crewai[tools]'
pip install langchain_groq
To integrate the Tool and Large language model environment, securely store your API keys using the getpass module. The SERPER_API_KEY can be obtained from serper.dev, and the GROQ_API_KEY from console.groq.com.
import os
from getpass import getpass
from crewai import Agent,Task,Crew,Process
from crewai_tools import SerperDevTool
from langchain_groq import ChatGroq
SERPER_API_KEY = getpass("Your serper api key")
os.environ['SERPER_API_KEY'] = SERPER_API_KEY
GROQ_API_KEY = getpass("Your Groq api key")
os.environ['GROQ_API_KEY'] = GROQ_API_KEY
Groq is a hardware and software platform building the LPU AI Inference Engine, known for being the fastest LLM inference engine in the world. With Groq, users can efficiently perform inference on open-source LLMs such as Gemma, Mistral, and Llama with low latency and high throughput. To integrate Groq into crewAI, you can seamlessly import it via Langchain.
llm = ChatGroq(model="gemma-7b-it",groq_api_key=GROQ_API_KEY)
print(llm.invoke("hi"))
SerperDevTool is a search API that browses the internet to return metadata, relevant query result URLs, and brief snippets as descriptions. This information aids agents in executing tasks more effectively by providing them with contextual data from web searches.
search_tool = SerperDevTool()
Agents are the core component of the entire code implementation in crewAI. An agent is responsible for performing tasks, making decisions, and communicating with other agents to complete decomposed tasks.
To achieve better results, it is essential to appropriately prompt the agent’s attributes. Each agent definition in crewAI includes role, goal, backstory, tools, and LLM. These attributes give agents their identity:
One of the major advantages of crewAI is its multi-agent functionality. Multi-agent functionality allows one agent’s response to be delegated to another agent. To enable task delegation, the allow_delegations parameter should be set to True.
Agents run multiple times until they convey the correct result. You can control the maximum number of interactions by setting the max_iter parameter to 10 or a value close to it.
Note:
researcher = Agent(
role = "Researcher",
goal='Pioneer revolutionary advancements in {subject_area}',
backstory=(
"As a visionary researcher, your insatiable curiosity drives you"
"to delve deep into emerging fields. With a passion for innovation"
"and a dedication to scientific discovery, you seek to"
"develop technologies and solutions that could transform the future."),
llm = llm,
max_iter = 5,
tools = [search_tool],
allow_delegation=True,
verbose=True
)
writer = Agent(
role = "Writer",
goal='Craft engaging and insightful narratives about {subject_area}',
verbose=True,
backstory=(
"You are a skilled storyteller with a talent for demystifying"
"complex innovations. Your writing illuminates the significance"
"of new technological discoveries, connecting them with everyday"
"lives and broader societal impacts."
),
tools = [search_tool],
llm = llm,
max_iter = 5,
allow_delegation=False
)
Agents can only execute tasks when provided by the user. Tasks are specific requirements completed by agents, which provide all necessary details for execution. For the Agent to decompose and plan the subtask, the user needs to define a clear description and expected outcome. Each task requires linking with the responsible agents and necessary tools.
Further crewAI provides the flexibility to provide the async execution to execute the task, since in our case the execution is in sequential order, we can let it as False.
research_task = Task(
description = (
"Explore and identify the major development within {subject_area}"
"Detailed SEO report of the development in a comprehensive narrative."
),
expected_output='A report, structured into three detailed paragraphs',
tools = [search_tool],
agent = researcher
)
write_task = Task(
description=(
"Craft an engaging article on recent advancements within {subject_area}"
"The article should be clear, captivating, and optimistic, tailored for a broad audience."
),
expected_output='A blog article on recent advancements in {subject_area} in markdown.',
tools = [search_tool],
agent = writer,
async_execution = False,
output_file = "blog.md"
)
To execute a multi-agent setup in crewAI, you need to define the Crew. A Crew is a collection of Agents working together to accomplish a set of tasks. Each Crew establishes the strategy for task execution, agent cooperation, and the overall workflow. In our case, the workflow is sequential, with one agent delegating tasks to the next.
Finally, the Crew executes by running the kickoff function, followed by user input.
crew = Crew(
agents = [researcher,writer],
tasks = [research_task,write_task],
process = Process.sequential,
max_rpm = 3,
cache=True
)
result = crew.kickoff(inputs={'subject_area':"Indian Elections 2024"})
print(result)
Output: New file created: blog.md
As mentioned in the blog, the field of Agents remains research-focused, with development gaining momentum through the release of multiple open-source agent frameworks. This article mainly is a beginner’s guide for those interested in building agents without relying on closed-source large language models. Furthermore, this article summarizes the importance and necessity of prompt engineering to maximize the potential of both large language models and agents.
Hope you like the article and get understanding about the agentic workflows with agentic workflow example and their components of ai agentic workflows and also you clear how you can can create content using crewai and grow.
A. crewAI integrates seamlessly with the Langchain backend, a robust data framework that links large language models (LLMs) to custom data sources. With over 50 LLM integrations, Langchain stands as one of the largest tools for integrating LLMs. Therefore, any Langchain-supported LLM can utilize a custom LLM to connect with crewAI agents.
A. crewAI is an open-source agents framework that supports multi-agent functionalities. Similar to crewAI, there are various powerful open-source agent frameworks available, such as AutoGen, OpenAGI, SuperAGI, AgentLite, and more.
A. Yes, crewAI is open source and free to use. One can easily build an agentic workflow in just around 15 lines of code.
A. Yes, Groq is currently free to use with some API restrictions like requests per minute and tokens per minute. It offers low-latency inference for open-source models such as Gemma, Mistral, Llama, and others.