Playback speed
×
Share post
Share post at current time
0:00
/
0:00
Transcript

[Hands-on] Building A Multi-agent News Generator

...using Cohere’s Command R7B and CrewAI.

We talked about Cohere’s latest Command R7B model last week.

It’s a multilingual 7B-parameter open-weight model specialized in enterprise-focused LLM use cases…

…and outperforms other similarly sized open-weight models in core business use cases such as RAG, tool use, and AI agents.

Today, let’s build a multi-agent news generator using this model:

The app will take a user query, search the web for it, and turn it into a well-crafted news article with citations!

Here’s our tech stack for this demo:

  • Cohere ultra-fast Command R7B as the LLM.

  • CrewAI for multi-agent orchestration.

We’ll have two agents in this multi-agent app:

  • Research analyst agent:

    • Accepts a user query.

    • Uses the Serper web search tool to fetch results from the internet.

    • Consolidates the results.

  • Content writer agent:

    • Uses the curated results to prepare a polished, publication-ready article.

If you prefer to watch, we have added a video demo above.

You can find the entire code in this GitHub repository: AI Engineering Hub.

Let’s build this application!


Setup

Create a .env file for their corresponding API keys:

Next, setup the LLM and web search tool as follows:

In the above code, we define the LLM and the search tool.

Notice the use of temperature in this code. We discussed what it is in yesterday’s issue.


Research Analyst Agent

This agent will take a user query and then use the Serper web search tool to fetch results from the internet and consolidate them:

This is implemented below:

Here, we define our first agent and its goal. Along with that, we also give it access to the tools and the LLM.

Next, we must also create a task for it.

Below, we assign the research analyst agent a research task with a description and expected output:


Content writer agent

The role of the content writer is to use the curated results and turn them into a polished, publication-ready news article.

The agent, like Agent 1, is defined below:

Let’s also give it its job, where we describe its writing task with all the details and expected output:

Almost done!


Launch crew

Below, we build our crew of agents and run the multi-agent app:

This produces the following output:

Perfect, it works as expected!

You can find all the code and instructions to run in this GitHub repo: AI Engineering Hub.

We launched this repo recently, wherein we’ll publish the code for such hands-on AI engineering newsletter issues.

This repository will be dedicated to:

  • In-depth tutorials on LLMs and RAGs.

  • Real-world AI agent applications.

  • Examples to implement, adapt, and scale in your projects.

Find it here: AI Engineering Hub (and do star it).

👉 Over to you: What other topics would you like to learn about?

Thanks for reading Daily Dose of Data Science! Subscribe below and receive a free data science PDF (530+ pages) with 150+ core data science and machine learning lessons.


P.S. For those wanting to develop “Industry ML” expertise:

At the end of the day, all businesses care about impact. That’s it!

  • Can you reduce costs?

  • Drive revenue?

  • Can you scale ML models?

  • Predict trends before they happen?

We have discussed several other topics (with implementations) in the past that align with such topics.

Develop "Industry ML" Skills

Here are some of them:

All these resources will help you cultivate key skills that businesses and companies care about the most.