{"id":2886,"date":"2025-04-05T07:03:48","date_gmt":"2025-04-05T07:03:48","guid":{"rendered":"https:\/\/mailitics.com\/index.php\/2025\/04\/05\/creating-an-ai-agent-to-write-blog-posts-with-crewai\/"},"modified":"2025-04-05T07:03:48","modified_gmt":"2025-04-05T07:03:48","slug":"creating-an-ai-agent-to-write-blog-posts-with-crewai","status":"publish","type":"post","link":"https:\/\/mailitics.com\/index.php\/2025\/04\/05\/creating-an-ai-agent-to-write-blog-posts-with-crewai\/","title":{"rendered":"Creating an AI Agent to Write Blog Posts with CrewAI"},"content":{"rendered":"<p>    Creating an AI Agent to Write Blog Posts with CrewAI<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<h2 class=\"wp-block-heading\"><strong><mdspan datatext=\"el1743790161212\" class=\"mdspan-comment\">Introduction<\/mdspan><\/strong><\/h2>\n<p class=\"wp-block-paragraph\">I love writing. You may notice that if you follow me or my blog. For that reason, I am constantly producing new content and talking about Data Science and Artificial Intelligence.<\/p>\n<p class=\"wp-block-paragraph\">I discovered this passion a couple of years ago when I was just starting my path in Data Science, learning and evolving my skills. At that time, I heard some more experienced professionals in the area saying that a good study technique was practicing new skills and writing about it somewhere, teaching whatever you learned.<\/p>\n<p class=\"wp-block-paragraph\">In addition, I had just moved to the US, and nobody knew me here. So I had to start somewhere, creating my professional image in this competitive market. I remember I talked to my cousin, who\u2019s also in the Tech industry, and he told me: <em>write blog posts about your experiences. Tell people what you are doing.<\/em> And so I did.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">And I never stopped.<\/p>\n<p class=\"wp-block-paragraph\">Fast forward to 2025, now I have almost two hundred published articles, many of them with Towards Data Science, a published Book, and a good audience.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">Writing helped me so much in the Data Science area.<\/p>\n<p class=\"wp-block-paragraph\">Most recently, one of my interests has been the amazing Natural Language Processing and Large Language Models subjects. Learning about how these modern models work is fascinating.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">That interest led me to experiment with <a href=\"https:\/\/towardsdatascience.com\/tag\/agentic-ai\/\" title=\"Agentic Ai\">Agentic Ai<\/a> as well. So, I learned about <strong>CrewAI<\/strong>, an easy and open-source package that helps us build AI agents in a fun and easy way, with little code. I decided to test it by creating a crew of agents to write a blog post, and then see how that goes.<\/p>\n<p class=\"wp-block-paragraph\">In this post, we will learn how to create those agents and make them work together to produce a simple blog post.<\/p>\n<p class=\"wp-block-paragraph\">Let\u2019s do that.<\/p>\n<h2 class=\"wp-block-heading\"><strong>What is a Crew?<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">A <strong>crew<\/strong> of AI agents is a combination of two or more agents, each of them performing a task towards a final goal.<\/p>\n<p class=\"wp-block-paragraph\">In this case study, we will create a crew that will work together to produce a small blog post about a given topic that we will provide.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdebjQAXRAKHKupR59LMJtJ6rEzohsUC9HdNw95G5018eppX2fXNpN_YuSBmcYef18UNMkC2Vqt155n47vctT6FzxFntC3oFVIsflWgEBCj47xEQy4n5cqCYYeo4shbbJHAOYicMw?key=Uc4-qRSb9f6hqMTf-kScY3IJ\" alt=\"\"><figcaption class=\"wp-element-caption\"><em>Crew of Agents workflow. Image by the author<\/em><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">The flow works like this:<\/p>\n<ol class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">We choose a given topic for the agents to write about.<\/li>\n<li class=\"wp-block-list-item\">Once the crew is started, it will go to the knowledge base, read some of my previously written articles, and try to mimic my writing style. Then, it generates a set of guidelines and passes it to the next agent.<\/li>\n<li class=\"wp-block-list-item\">Next, the Planner agent takes over and searches the Internet looking for good content about the topic. It creates a plan of content and sends it to the next agent.<\/li>\n<li class=\"wp-block-list-item\">The Writer agent receives the writing plan and executes it according to the context and information received.<\/li>\n<li class=\"wp-block-list-item\">Finally, the content is passed to the last agent, the Editor, who reviews the content and returns the final document as the output.<\/li>\n<\/ol>\n<p class=\"wp-block-paragraph\">In the following section, we will see how this can be created.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Code<\/strong><\/h2>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/towardsdatascience.com\/tag\/crewai\/\" title=\"CrewAI\">CrewAI<\/a> is a great Python package because it simplifies the code for us. So, let\u2019s begin by installing the two needed packages.<\/p>\n<p class=\"wp-block-paragraph\"><code>pip install crewai crewai-tools<\/code><\/p>\n<p class=\"wp-block-paragraph\">Next, if you want, you can follow the instructions on their <em>Quickstart<\/em> page and have a full project structure created for you with just a couple of commands on a terminal. Basically, it will install some dependencies, generate the folder structure suggested for CrewAI projects, as well as generate some .yaml and .py files.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">I personally prefer to create those myself, but it is up to you. The page is listed in the References section.<\/p>\n<h3 class=\"wp-block-heading\">Folder Structure<\/h3>\n<p class=\"wp-block-paragraph\">So, here we go.<\/p>\n<p class=\"wp-block-paragraph\">We will create these folders:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">knowledge<\/li>\n<li class=\"wp-block-list-item\">config<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">And these files:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">In the <strong>config <\/strong>folder: create the files <code>agents.yaml<\/code> and <code>tasks.yaml<\/code>\n<\/li>\n<li class=\"wp-block-list-item\">In the <strong>knowledge <\/strong>folder, that\u2019s where I will add the files with my writing style.<\/li>\n<li class=\"wp-block-list-item\">In the project <strong>root<\/strong>: create <code>crew.py<\/code> and <code>main.py<\/code>.<\/li>\n<\/ul>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeBUGlSE114uFmIFMECYfy-QVxch76w0gGZesZxzsR1XQgNEnplyED82rzacsqf8wS7WFN4W0e0VZVp7RSHQuhGR73ZC17aE96UdaqJALpxsQb7GPWLcy0qfG2Hpw2QvqVpDwkUHw?key=Uc4-qRSb9f6hqMTf-kScY3IJ\" alt=\"\"><figcaption class=\"wp-element-caption\">Folders structure. Image by the author.<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Make sure to create the folders with the names mentioned, as CrewAI looks for agents and tasks inside the <strong>config <\/strong>folder and for the knowledge base within a <strong>knowledge <\/strong>folder.<\/p>\n<p class=\"wp-block-paragraph\">Next, let us set our agents.\u00a0<\/p>\n<h3 class=\"wp-block-heading\">Agents<\/h3>\n<p class=\"wp-block-paragraph\">The agents are composed of:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">\n<strong>Name of the agent<\/strong>: <code>writer_style<\/code>\n<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Role<\/strong>: LLMs are good role players, so here you can tell them which role to play.<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Goal<\/strong>: tell the model what the goal of that agent is.<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Backstory<\/strong>: Describe the story behind this agent, who it is, what it does.\u00a0<\/li>\n<\/ul>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-yaml\">writer_style:\n\u00a0\u00a0role: &gt;\n\u00a0\u00a0\u00a0\u00a0Writing Style Analyst\n\u00a0\u00a0goal: &gt;\n\u00a0\u00a0\u00a0\u00a0Thoroughly read the knowledge base and learn the characteristics of the crew, \n    such as tone, style, vocabulary, mood, and grammar.\n\u00a0\u00a0backstory: &gt;\n\u00a0\u00a0\u00a0\u00a0You are an experienced ghost writer who can mimic any writing style.\n\u00a0\u00a0\u00a0\u00a0You know how to identify the tone and style of the original writer and mimic \n    their writing style.\n\u00a0\u00a0\u00a0\u00a0Your work is the basis for the Content Writer to write an article on this topic.<\/code><\/pre>\n<p class=\"wp-block-paragraph\">I won\u2019t bore you with all the agents created for this crew. I believe you got the idea. It is a set of prompts explaining to each agent what they are going to do. All the agents instructions are stored in the agents.yaml file.<\/p>\n<p class=\"wp-block-paragraph\">Think of it as if you were a manager hiring people to create a team. Think about what kinds of professionals you would need, and what skills are needed.<\/p>\n<p class=\"wp-block-paragraph\">We need 4 professionals who will work towards the final goal of producing written content: (1) a <em>Writer Stylist<\/em>, (2) a <em>Planner<\/em>, (3) a <em>Writer, <\/em>and (4) an <em>Editor<\/em>.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">If you want to see the setup for them, just check the full code in the GitHub repository.<\/p>\n<h3 class=\"wp-block-heading\">Tasks<\/h3>\n<p class=\"wp-block-paragraph\">Now, back to the analogy of the manager hiring people, once we \u201chired\u201d our entire crew, it is time to separate the tasks. We know that we want to produce a blog post, we have 4 agents, but what each of them will do.<\/p>\n<p class=\"wp-block-paragraph\">Well, that will be configured in the file <code>tasks.yaml<\/code>.<\/p>\n<p class=\"wp-block-paragraph\">To illustrate, let me show you the code for the Writer agent. Once again, these are the parts needed for the prompt:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">\n<strong>Name of the task<\/strong>: <code>write<\/code>\n<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Description<\/strong>: The description is like telling the professional how you want that task to be performed, just like we would tell a new hire how to perform their new job. Give precise instructions to get the best result possible.<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Expected output:<\/strong> This is how we want to see the output. Notice that I give instructions like the size of the blog post, the quantity of paragraphs, and other information that helps my agent to give me the expected output.\u00a0<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Agent to perform it<\/strong>: Here, we are indicating the agent who will perform this task, using the same name set in the <code>agents.yaml<\/code> file.<\/li>\n<li class=\"wp-block-list-item\">\n<strong>Output file<\/strong>: Now always applicable, but if so, this is the argument to use. We asked for a markdown file as output.<\/li>\n<\/ul>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">write:\n\u00a0\u00a0description: &gt;\n\u00a0\u00a0\u00a0\u00a01. Use the content plan to craft a compelling blog post on {topic}.\n\u00a0\u00a0\u00a0\u00a02. Incorporate SEO keywords naturally.\n\u00a0\u00a0\u00a0\u00a03. Sections\/Subtitles are properly named in an engaging manner. Make sure \n    to add Introduction, Problem Statement, Code, Before You Go, References.\n\u00a0\u00a0\u00a0\u00a04. Add a summarizing conclusion - This is the \"Before You Go\" section.\n\u00a0\u00a0\u00a0\u00a05. Proofread for grammatical errors and alignment with the writer's style.\n\u00a0\u00a0\u00a0\u00a06. Use analogies to make the article more engaging and complex concepts easier\n    to understand.\n\u00a0\u00a0expected_output: &gt;\n\u00a0\u00a0\u00a0\u00a0A well-written blog post in markdown format, ready for publication.\n\u00a0\u00a0\u00a0\u00a0The article must be within a 7 to 12 minutes read.\n\u00a0\u00a0\u00a0\u00a0Each section must have at least 3 paragraphs.\n\u00a0\u00a0\u00a0\u00a0When writing code, you will write a snippet of code and explain what it does. \n    Be careful to not add a huge snippet at a time. Break it in reasonable chunks.\n\u00a0\u00a0\u00a0\u00a0In the examples, create a sample dataset for the code.\n\u00a0\u00a0\u00a0\u00a0In the Before You Go section, you will write a conclusion that is engaging\n    and factually accurate.\n\u00a0\u00a0agent: content_writer\n\u00a0\u00a0output_file: blog_post.md<\/code><\/pre>\n<p class=\"wp-block-paragraph\">After the agents and tasks are defined, it is time to create our crew flow.<\/p>\n<h3 class=\"wp-block-heading\">Coding the Crew<\/h3>\n<p class=\"wp-block-paragraph\">Now we will create the file <code>crew.py<\/code>, where we will translate the previously presented flow to <a href=\"https:\/\/towardsdatascience.com\/tag\/python\/\" title=\"Python\">Python<\/a> code.<\/p>\n<p class=\"wp-block-paragraph\">We begin by importing the needed modules.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">#Imports\nimport os\nfrom crewai import Agent, Task, Process, Crew, LLM\nfrom crewai.project import CrewBase, agent, crew, task\nfrom crewai.knowledge.source.pdf_knowledge_source import PDFKnowledgeSource\nfrom crewai_tools import SerperDevTool<\/code><\/pre>\n<p class=\"wp-block-paragraph\">We will use the basic <code>Agent<\/code>, <code>Task<\/code>, <code>Crew<\/code>, <code>Process <\/code>and <code>LLM <\/code>to create our flow. <code>PDFKnowledgeSource<\/code> will help the first agent learning my writing style, and SerperDevTool is the tool to search the internet. For that one, make sure to get your API key at <a href=\"https:\/\/serper.dev\/signup\">https:\/\/serper.dev\/signup<\/a>.<\/p>\n<p class=\"wp-block-paragraph\">A best practice in software development is to keep your API keys and configuration settings separate from your code. We\u2019ll use a <code>.env<\/code> file for this, providing a secure place to store these values. Here\u2019s the command to load them into our environment.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">from dotenv import load_dotenv\nload_dotenv()<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Then, we will use the <code>PDFKnowledgeSource<\/code> to show the Crew where to search for the writer\u2019s style. By default, that tool looks at the knowledge folder of your project, thus the importance of the name being the same.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Knowledge sources\n\npdfs = PDFKnowledgeSource(\n\u00a0\u00a0\u00a0\u00a0file_paths=['article1.pdf',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'article2.pdf',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'article3.pdf'\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n)<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Now we can set up the LLM we want to use for the Crew. It can be any of them. I tested a bunch of them, and those I liked the most were <code>qwen-qwq-32b<\/code> and <code>gpt-4o<\/code>. If you choose OpenAI\u2019s, you will need an API Key as well. For Qwen-QWQ, just uncomment the code and comment out the OpenAI\u2019s lines.. You need an API key from Groq.\u00a0<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># LLMs\n\nllm = LLM(\n\u00a0\u00a0\u00a0\u00a0# model=\"groq\/qwen-qwq-32b\",\n\u00a0\u00a0\u00a0\u00a0# api_key= os.environ.get(\"GROQ_API_KEY\"),\n\u00a0\u00a0\u00a0\u00a0model= \"gpt-4o\",\n\u00a0\u00a0\u00a0\u00a0api_key= os.environ.get(\"OPENAI_API_KEY\"),\n\u00a0\u00a0\u00a0\u00a0temperature=0.4\n)<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Now we have to create a <strong>Crew Base<\/strong>, showing where CrewAI can find the agents and tasks configuration files.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Creating the crew: base shows where the agents and tasks are defined\n\n@CrewBase\nclass BlogWriter():\n\u00a0\u00a0\u00a0\u00a0\"\"\"Crew to write a blog post\"\"\"\n\u00a0\u00a0\u00a0\u00a0agents_config = \"config\/agents.yaml\"\n\u00a0\u00a0\u00a0\u00a0tasks_config = \"config\/tasks.yaml\"<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Agents Functions<\/h3>\n<p class=\"wp-block-paragraph\">And we are ready to create the code for each agent. They are composed of a decorator <code>@agent<\/code> to show that the following function is an agent. We then use the class Agent and indicate the name of the agent in the config file, the level of verbosity, being 1 low, 2 high. You can also use a Boolean value, such as true or false.<\/p>\n<p class=\"wp-block-paragraph\">Lastly, we specify if the agent uses any tool, and what model it will use.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Configuring the agents\n\u00a0\u00a0\u00a0\u00a0@agent\n\u00a0\u00a0\u00a0\u00a0def writer_style(self) -&gt; Agent:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Agent(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.agents_config['writer_style'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0verbose=1,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0knowledge_sources=[pdfs]\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@agent\n\u00a0\u00a0\u00a0\u00a0def planner(self) -&gt; Agent:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Agent(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.agents_config['planner'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0verbose=True,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tools=[SerperDevTool()],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0llm=llm\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@agent\n\u00a0\u00a0\u00a0\u00a0def content_writer(self) -&gt; Agent:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Agent(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.agents_config['content_writer'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0verbose=1\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@agent\n\u00a0\u00a0\u00a0\u00a0def editor(self) -&gt; Agent:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Agent(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.agents_config['editor'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0verbose=1\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Tasks Functions<\/h3>\n<p class=\"wp-block-paragraph\">The next step is creating the tasks. Similarly to the agents, we will create a function and decorate it with <code>@task<\/code>. We use the class Task to inherit CrewAI\u2019s functionalities and then point to the task to be used from our <code>tasks.yaml<\/code> file to be used for each task created. If any output file is expected, use the <code>output_file<\/code> argument.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Configuring the tasks\u00a0\u00a0\u00a0\u00a0\n\n\u00a0\u00a0\u00a0\u00a0@task\n\u00a0\u00a0\u00a0\u00a0def style(self) -&gt; Task:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Task(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.tasks_config['mystyle'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@task\n\u00a0\u00a0\u00a0\u00a0def plan(self) -&gt; Task:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Task(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.tasks_config['plan'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@task\n\u00a0\u00a0\u00a0\u00a0def write(self) -&gt; Task:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Task(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.tasks_config['write'],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0output_file='output\/blog_post.md' # This is the file that will be contain the final blog post.\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0@task\n\u00a0\u00a0\u00a0\u00a0def edit(self) -&gt; Task:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Task(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0config=self.tasks_config['edit']\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Crew<\/h3>\n<p class=\"wp-block-paragraph\">To glue everything together, we now create a function and decorate it with the <code>@crew<\/code> decorator. That function will line up the agents and the tasks in the order to be performed, since the process chosen here is the simplest: sequential. In other words, everything runs in sequence, from start to finish.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\">@crew\n\n\u00a0\u00a0\u00a0\u00a0def crew(self) -&gt; Crew:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"\"\"Creates the Blog Post crew\"\"\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Crew(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0agents= [self.writer_style(), self.planner(), self.content_writer(), self.editor(), self.illustrator()],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tasks= [self.style(), self.plan(), self.write(), self.edit(), self.illustrate()],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0process=Process.sequential,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0verbose=True\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Running the Crew<\/h3>\n<p class=\"wp-block-paragraph\">Running the crew is very simple. We create the <code>main.py<\/code> file and import the Crew Base <code>BlogWriter<\/code> created. Then we just use the functions <code>crew().kickoff(inputs)<\/code> to run it, passing a dictionary with the inputs to be used to generate the blog post.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Script to run the blog writer project\n\n# Warning control\nimport warnings\nwarnings.filterwarnings('ignore')\nfrom crew import BlogWriter\n\n\ndef write_blog_post(topic: str):\n\u00a0\u00a0\u00a0\u00a0# Instantiate the crew\n\u00a0\u00a0\u00a0\u00a0my_writer = BlogWriter()\n\u00a0\u00a0\u00a0\u00a0# Run\n\u00a0\u00a0\u00a0\u00a0result = (my_writer\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.crew()\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.kickoff(inputs = {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'topic': topic\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0})\n\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0return result\n\nif __name__ == \"__main__\":\n\n\u00a0\u00a0\u00a0\u00a0write_blog_post(\"Price Optimization with Python\")<\/code><\/pre>\n<p class=\"wp-block-paragraph\">There it is. The result is a nice blog post created by the LLM. See below.<\/p>\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXerz6wFeDYgPh195oA5NV-hiSxROP1wfBLHg7ZSS97jHLjCSbG8P_drDX7ozss_gu2LeIBHasLOXfgeelXuXBsuPErbylECfI-ulj3KSx6cWTqaHRvVld5v1FtcaNaES4mD6aD_eg?key=Uc4-qRSb9f6hqMTf-kScY3IJ\" alt=\"\"><figcaption class=\"wp-element-caption\">Resulting blog post. GIF by the author.<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">That is so nice!<\/p>\n<h2 class=\"wp-block-heading\"><strong>Before You Go<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Before you go, know that this blog post was 100% created by me. This crew I created was an experiment I wanted to do to learn more about how to create AI agents and make them work together. And, like I said, I love writing, so this is something I would be able to read and assess the quality.<\/p>\n<p class=\"wp-block-paragraph\">My opinion is that this crew still didn\u2019t do a very good job. They were able to complete the tasks successfully, but they gave me a very shallow post and code. I would not publish this, but at least it could be a start, maybe.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">From here, I encourage you to learn more about CrewAI. I took their free course where Jo\u00e3o de Moura, the creator of the package, shows us how to create different kinds of crews. It is really interesting.<\/p>\n<h3 class=\"wp-block-heading\">GitHub Repository<\/h3>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/gurezende\/Crew_Writer\">https:\/\/github.com\/gurezende\/Crew_Writer<\/a><\/p>\n<h3 class=\"wp-block-heading\">About Me<\/h3>\n<p class=\"wp-block-paragraph\">If you want to learn more about my work, or follow my blog (it is really me!), here are my contacts and portfolio.<\/p>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gustavorsantos.me\/\">https:\/\/gustavorsantos.me<\/a><\/p>\n<h2 class=\"wp-block-heading\"><strong>References<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">[Quickstart CrewAI](<a href=\"https:\/\/docs.crewai.com\/quickstart\">https:\/\/docs.crewai.com\/quickstart<\/a>)<\/p>\n<p class=\"wp-block-paragraph\">[CrewAI Documentation](<a href=\"https:\/\/docs.crewai.com\/introduction\">https:\/\/docs.crewai.com\/introduction<\/a>)<\/p>\n<p class=\"wp-block-paragraph\">[GROQ](<a href=\"https:\/\/groq.com\/\">https:\/\/groq.com\/<\/a>)<\/p>\n<p class=\"wp-block-paragraph\">[OpenAI](<a href=\"https:\/\/openai.com\/\">https:\/\/openai.com<\/a>)<\/p>\n<p class=\"wp-block-paragraph\">[CrewAI Free Course](<a href=\"https:\/\/learn.crewai.com\/\">https:\/\/learn.crewai.com\/<\/a>)<\/p>\n<p class=\"wp-block-paragraph\">\n<p>The post <a href=\"https:\/\/towardsdatascience.com\/creating-an-ai-agent-to-write-blog-posts-with-crewai\/\">Creating an AI Agent to Write Blog Posts with CrewAI<\/a> appeared first on <a href=\"https:\/\/towardsdatascience.com\/\">Towards Data Science<\/a>.<\/p>\n<\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><br \/>\n    Gustavo Santos<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/towardsdatascience.com\/creating-an-ai-agent-to-write-blog-posts-with-crewai\/\">Go to original source<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating an AI Agent to Write Blog Posts with CrewAI Introduction I love writing. You may notice that if you follow me or my blog. For that reason, I am constantly producing new content and talking about Data Science and Artificial Intelligence. I discovered this passion a couple of years ago when I was just [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[678,799,62,69,2283,83,157],"tags":[98,29,108],"class_list":["post-2886","post","type-post","status-publish","format-standard","hentry","category-agentic-ai","category-ai-agent","category-aimldsaimlds","category-artificial-intelligence","category-crewai","category-data-science","category-python","tag-ai","tag-blog","tag-my"],"_links":{"self":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/2886"}],"collection":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/comments?post=2886"}],"version-history":[{"count":0,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/2886\/revisions"}],"wp:attachment":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/media?parent=2886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/categories?post=2886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/tags?post=2886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}