The Newsletter AI Agent uses a sophisticated process powered by CrewAI to generate high-quality newsletters about specific topics. This page explains the newsletter generation process in detail.
The newsletter generation process is implemented using CrewAI, which orchestrates the agents and their tasks. The workflow is defined in the NewsletterCrew class:
Copy
def generate_newsletter(self, topic: str) -> str: # Create tasks for each agent research_task = Task( description=f"Research the topic '{topic}' and gather comprehensive information.", expected_output="Detailed research data in JSON format.", agent=self.researcher ) writing_task = Task( description="Transform the research data into engaging newsletter content.", expected_output="Draft newsletter in markdown format.", agent=self.writer, context=[research_task] ) editing_task = Task( description="Review and finalize the newsletter content.", expected_output="Final newsletter in markdown format.", agent=self.editor, context=[writing_task] ) # Execute the tasks result = self.crew.kickoff(tasks=[research_task, writing_task, editing_task]) return result
This workflow ensures that each agent builds upon the work of the previous one, creating a cohesive and high-quality newsletter.
The agents interact with each other through the tasks’ context. Each task has access to the output of its context tasks, allowing agents to build upon each other’s work:
The Researcher Agent performs its task independently, gathering information about the topic
The Writer Agent receives the Researcher Agent’s output as context for its task
The Editor Agent receives the Writer Agent’s output as context for its task
This sequential process ensures that each agent has the information it needs to perform its task effectively.
You can customize the language model used by the agents by modifying the LLM initialization in src/newsletter_crew.py:
Copy
self.llm = LLM( model="gemini/gemini-2.0-flash-lite", # Change to another supported model temperature=0.7, # Adjust for more or less creativity api_key=os.getenv("GOOGLE_API_KEY"), verbose=False # Set to True for more detailed output)
The newsletter is generated in markdown format, which can be easily converted to HTML, PDF, or other formats. The markdown format includes:
Headers: For section titles and article titles
Links: For references to sources
Formatting: For emphasis, lists, and other styling
Images: For thumbnails and other visual elements
Here’s an example of the output format:
Copy
# AI Technology Newsletter*Issue Date: March 7, 2025***Focus Topic:** Artificial Intelligence## Executive SummaryA brief summary of the latest developments in AI technology...## Latest News### [Google Announces New AI Model](https://example.com/news/1)*Published: March 5, 2025*Google has announced a new AI model that achieves state-of-the-art results on several benchmarks...## Industry Updates### [AI Adoption in Healthcare](https://example.com/news/2)*Published: March 3, 2025*Healthcare organizations are increasingly adopting AI technologies to improve patient care...## Tools & Frameworks### [New Version of TensorFlow Released](https://example.com/news/3)*Published: March 1, 2025*Google has released a new version of TensorFlow with improved performance and new features...---*This newsletter is automatically generated using AI technology.**For more information, please contact us.*