I really like writing. Should you comply with me or my weblog, it’s possible you’ll discover. That is why I am continuously producing new content material and speaking about information science and synthetic intelligence.
I found this ardour a number of years in the past, simply earlier than I started my path to information science, studying and evolution. On the time, I used to be saying that higher studying methods on this space are training new abilities, writing someplace and instructing what you have realized.
Plus, I had simply moved to the US and nobody knew me right here. So I needed to begin someplace and created my skilled picture on this aggressive market. I keep in mind speaking to my cousin. Write a weblog publish about your expertise. Inform folks what you are doing. And I did.
And I by no means stopped.
Quick ahead to 2025, and now I’ve virtually 200 revealed articles. Lots of them are heading in direction of information science, revealed books, and wonderful audiences.
The writing has helped me a lot within the subject of knowledge science.
Lately, one in every of my pursuits has been the topic of fantastic pure language processing and large-scale language fashions. It’s fascinating to study how these fashionable fashions work.
This curiosity additionally led to the event of agent AI experiments. So I realized Kuruwaia straightforward and open supply package deal that helps you construct AI brokers in a enjoyable and straightforward approach with little code. I made a decision to create and check an agent crew to jot down a weblog publish and see what it might end up.
On this publish you’ll discover ways to create these brokers and work collectively to create a easy weblog publish.
Let’s try this.
What’s a crew?
a crew An AI agent is a mixture of two or extra brokers, every performing duties in direction of the top purpose.
On this case examine, we create a crew to collaborate on small weblog posts on the precise subjects we offer.
The circulation works like this:
- Choose a selected subject for the agent to jot down.
- As soon as the crew is began, I am going to the information base and browse a number of the beforehand written articles and attempt to mimic my writing fashion. Subsequent, we generate a set of pointers and move it to the subsequent agent:
- The planner agent then takes over and searches the web for good content material on the subject. Create a plan in your content material and ship it to the subsequent agent:
- The author agent receives the writing plan and executes it in line with the context and data it receives.
- Lastly, the content material is handed to the final agent, the editor. The editor critiques the content material and returns the ultimate doc as output.
Within the subsequent part, we’ll see how one can create this.
code
Crewai is a good Python package deal to simplify our code. So let’s begin by putting in the 2 packages you want.
pip set up crewai crewai-tools
Then, if obligatory, you may comply with their directions Fast Begin An entire mission construction has been created utilizing pages and a number of other instructions on the terminal. Primarily, it installs some dependencies, generates the proposed folder construction for the Crewai mission, and generates .yaml and .py information.
I personally choose to create them myself, however that is as much as you. The web page is listed within the References part.
Folder Construction
So I am going right here.
Create these folders.
And these information:
- in config Folder: Create a file
brokers.yamlandduties.yaml - in information Folder, right here I add information in my writing fashion.
- Within the mission root: Create
crew.pyandfundamental.py.
Crewai is in search of inside brokers and duties, so create a folder along with your identify. config For the Folder and Data Base in a information folder.
Now let’s arrange the agent.
agent
The brokers are:
- Agent’s identify:
writer_style - position: LLMS is a good position participant so you may inform what position you play right here.
- purpose: Inform the mannequin what the agent’s purpose is.
- Backstory: Clarify the story behind this agent and who it’s.
writer_style:
position: >
Writing Model Analyst
purpose: >
Totally learn the information base and study the traits of the crew,
corresponding to tone, fashion, vocabulary, temper, and grammar.
backstory: >
You're an skilled ghost author who can mimic any writing fashion.
You know the way to determine the tone and magnificence of the unique author and mimic
their writing fashion.
Your work is the idea for the Content material Author to jot down an article on this subject.
I will not bore you with all of the brokers created for this crew. I feel you bought the thought. It is a collection of prompts clarify to every agent what they’re attempting to do. All agent directions are saved within the brokers.yaml file.
Consider it as in case you are the supervisor who hires folks to create a group. Take into consideration what sort of specialists you want and what abilities you want.
We want 4 specialists to work in direction of our final purpose of making written content material: (1) Author stylist(2)a planner(3)a author, (4) an editor.
If you wish to view these setups, take a look at the complete code within the GitHub repository.
activity
Now, again to the analogy of managers hiring folks, it is time to separate duties after “hiring” the whole crew. I do know I wish to create a weblog publish, however I’ve 4 brokers, and every is aware of what to do.
Nicely, it consists of information duties.yaml.
As an example, let me present you the code for the author agent. Once more, these are the elements you want to make on the immediate.
- Job identify:
write - clarification: Explanations are like telling an skilled the way you wish to carry out the duty, similar to telling you the way you wish to rent a brand new job. Give correct directions to get the absolute best outcomes.
- Anticipated output: That is the way you wish to see the output. Please observe that we offer directions corresponding to the dimensions of the weblog publish, the quantity of paragraphs, and different data that may assist the agent present the anticipated output.
- Brokers that run it:This exhibits the agent that performs this activity.
brokers.yamlfile. - Output file: It is at all times relevant now, but when so, that is the argument to make use of. You requested a markdown file as output.
write:
description: >
1. Use the content material plan to craft a compelling weblog publish on {subject}.
2. Incorporate search engine optimisation key phrases naturally.
3. Sections/Subtitles are correctly named in an enticing method. Ensure that
so as to add Introduction, Downside Assertion, Code, Earlier than You Go, References.
4. Add a summarizing conclusion - That is the "Earlier than You Go" part.
5. Proofread for grammatical errors and alignment with the author's fashion.
6. Use analogies to make the article extra participating and sophisticated ideas simpler
to know.
expected_output: >
A well-written weblog publish in markdown format, prepared for publication.
The article should be inside a 7 to 12 minutes learn.
Every part should have not less than 3 paragraphs.
When writing code, you'll write a snippet of code and clarify what it does.
Watch out to not add an enormous snippet at a time. Break it in cheap chunks.
Within the examples, create a pattern dataset for the code.
Within the Earlier than You Go part, you'll write a conclusion that's participating
and factually correct.
agent: content_writer
output_file: blog_post.md
As soon as the brokers and duties have been outlined, it is time to create a crew circulation.
Crew coding
Subsequent, create the file crew.pyinterprets beforehand introduced flows into Python code.
Begin by importing the required modules.
#Imports
import os
from crewai import Agent, Job, Course of, Crew, LLM
from crewai.mission import CrewBase, agent, crew, activity
from crewai.information.supply.pdf_knowledge_source import PDFKnowledgeSource
from crewai_tools import SerperDevTool
I will use the fundamentals Agent, Job, Crew, Course of and LLM Create our circulation. PDFKnowledgeSource It helps my first agent study my writing fashion. SerperDevtool is a instrument for looking out the Web. To do that, get the API key https://serper.dev/signup.
A greatest observe in software program growth is to maintain API keys and configuration settings separate out of your code. I will use it .env It should file this and supply a protected place to retailer these values. The instructions to load these into your setting are:
from dotenv import load_dotenv
load_dotenv()
Subsequent, use PDFKnowledgeSource To point out the crew the place to seek for the author’s fashion. By default, the instrument appears to be like on the mission’s information folder, so the identify is similar.
# Data sources
pdfs = PDFKnowledgeSource(
file_paths=['article1.pdf',
'article2.pdf',
'article3.pdf'
]
)
Now you may arrange the LLM you wish to use in your crew. It might be one in every of them. I examined these bundles and what I preferred essentially the most was qwen-qwq-32b and gpt-4o. If you choose Openai, you additionally want an API key. For Qwen-Qwq, please take away the code and touch upon the Openai line. You want a GROQ API key.
# LLMs
llm = LLM(
# mannequin="groq/qwen-qwq-32b",
# api_key= os.environ.get("GROQ_API_KEY"),
mannequin= "gpt-4o",
api_key= os.environ.get("OPENAI_API_KEY"),
temperature=0.4
)
Now we have to create a Crew basesignifies the place Crewai can discover the agent and activity configuration information.
# Creating the crew: base exhibits the place the brokers and duties are outlined
@CrewBase
class BlogWriter():
"""Crew to jot down a weblog publish"""
agents_config = "config/brokers.yaml"
tasks_config = "config/duties.yaml"
Agent Perform
And also you’re prepared to jot down code for every agent. They’re made up of ornaments @agent To point that the next operate is an agent: The next is used to point out the agent identify and stage of redundancy within the configuration file utilizing class brokers: It’s also possible to use boolean values corresponding to True or false.
Lastly, specify whether or not the agent is utilizing the instrument and which mannequin to make use of.
# Configuring the brokers
@agent
def writer_style(self) -> Agent:
return Agent(
config=self.agents_config['writer_style'],
verbose=1,
knowledge_sources=[pdfs]
)
@agent
def planner(self) -> Agent:
return Agent(
config=self.agents_config['planner'],
verbose=True,
instruments=[SerperDevTool()],
llm=llm
)
@agent
def content_writer(self) -> Agent:
return Agent(
config=self.agents_config['content_writer'],
verbose=1
)
@agent
def editor(self) -> Agent:
return Agent(
config=self.agents_config['editor'],
verbose=1
)
Job Perform
The subsequent step is to create a activity. Like brokers, we create features and enhance them @activity. Use a category activity to inherit Crewai performance after which level to the duty you wish to use duties.yaml The file to make use of for every activity created. Should you anticipate an output file, please use output_file An argument.
# Configuring the duties
@activity
def fashion(self) -> Job:
return Job(
config=self.tasks_config['mystyle'],
)
@activity
def plan(self) -> Job:
return Job(
config=self.tasks_config['plan'],
)
@activity
def write(self) -> Job:
return Job(
config=self.tasks_config['write'],
output_file='output/blog_post.md' # That is the file that will probably be comprise the ultimate weblog publish.
)
@activity
def edit(self) -> Job:
return Job(
config=self.tasks_config['edit']
)
crew
Create options to attach all the things collectively, @crew Decorator. This operate arranges the brokers and duties within the order through which they’re executed, because the processes chosen listed here are the only. In different phrases, all the things runs so as from begin to end.
@crew
def crew(self) -> Crew:
"""Creates the Weblog Submit crew"""
return Crew(
brokers= [self.writer_style(), self.planner(), self.content_writer(), self.editor(), self.illustrator()],
duties= [self.style(), self.plan(), self.write(), self.edit(), self.illustrate()],
course of=Course of.sequential,
verbose=True
)
Run the crew
It is very straightforward to run the crew. Create fundamental.py File and import the crew base BlogWriter It has been created. Subsequent, use the operate crew().kickoff(inputs) To try this, move the dictionary within the enter used to generate the weblog publish.
# Script to run the weblog author mission
# Warning management
import warnings
warnings.filterwarnings('ignore')
from crew import BlogWriter
def write_blog_post(subject: str):
# Instantiate the crew
my_writer = BlogWriter()
# Run
outcome = (my_writer
.crew()
.kickoff(inputs = {
'subject': subject
})
)
return outcome
if __name__ == "__main__":
write_blog_post("Worth Optimization with Python")
It is there. The outcome is a good weblog publish created by LLM. See under.
That is superb!
Earlier than you go
Earlier than you go, please know that this weblog publish was 100% created by me. This crew I created was an experiment I wished to do to study extra about create AI brokers and make them work collectively. And like I stated, I really like writing, so that is one thing I can learn and charge high quality.
In my view, this crew hadn’t accomplished an excellent job but. They managed to finish the duty efficiently, however gave me a really shallow publish and code. I will not publish this, however not less than it could be the beginning.
From right here we suggest studying extra about Crewai. Package deal creator João de Moura took their free course, displaying create various kinds of crew. It is actually fascinating.
GitHub Repository
https://github.com/gurezende/crew_writer
About me
If you wish to know extra about my work or wish to comply with my weblog (it is actually me!), right here is my contacts and portfolio.
reference
[Quickstart CrewAI](https://docs.crewai.com/quickstart))
[CrewAI Documentation](https://docs.crewai.com/introduction))
[GROQ](https://groq.com/))
[OpenAI](https://openai.com))
[CrewAI Free Course](https://learn.crewai.com/))

