Build a multi-agent AI news assistant using Open AI swarm and Llama...

@Sumanth_077
Sumanth@Sumanth_077
10 views Dec 12, 2024 ~1 min read
1
Build a multi-agent AI news assistant using Open AI swarm and Llama 3.2 running locally on your computer (100% free and open source):
2
1. Install and import necessary Libraries

@getreflex for building the web app in Python
@OpenAI Swarm for multi-agent orchestration
@ollama for running llama 3.2 locally

Also:

• Load environment variables
• Initialize Swarm client
• Install and run Llama 3.2 using Ollama
Media image
3
2. Create News Search Function

The News Search Agent queries DuckDuckGo for the latest news on a given topic, returning up to three articles with their titles, URLs, and summaries.
Media image
4
3. Create 3 different agents:

• The News Search Agent will search for news.
• The News Synthesis Agent will review various sources, extract key themes, and construct a unified narrative.
• The News Summary Agent will provide concise summaries.
Media image
5
4. Let's define the State [Backend]

The State class handles the application's workflow, from topic initialization to news processing. It resets states, processes news with search, synthesis, and summary agents asynchronously, and manages errors efficiently.
Media image
6
5. Let’s Build the Frontend (UI)

The news_page function creates a user-friendly interface with:

• A topic input field for entering news topics.
• A "Process News" button with a loading indicator.
• A results section to display the summary and copy it to the clipboard.
Media image
7
6. Finally setup the app

Initializes the Reflex app and adds the main page to it, making the app functional and ready to run.
Media image
8
7. Here is working Application demo using Reflex
9
The code for the app is Open Source, Find the GitHub repo below:

Check out the code and give it a star if you like it!

github.com/Sumanth077/new…
10
If you find this useful, RT to share it with your friends.

Don't forget to follow me @Sumanth_077 for more such content and tutorials on Python, AI & ML!


x.com/Sumanth_077/st…
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • LinkedIn & Instagram Carousel Maker
Create Free Account

Includes 7-day Premium trial