DEV Community

Yuyi Kimura (YK46)
Yuyi Kimura (YK46)

Posted on

Chat with News: Interact with your articles

This is a submission for the Open Source AI Challenge with pgai and Ollama

What I Built

This application enables you to fetch, embed, and interact with news articles from RSS sources. The CLI tool allows you to set up RSS links, fetch and embed available articles, and expose an API for seamless interaction.

A simple web application was also developed to provide a more user-friendly experience. You can ask questions about articles published on specific dates, and Ollama LLM will respond while retrieving the related article for fact-checking or obtaining more details from the original source.

Setting up RSS feeds, fetching articles, and creating embeddings takes only minutes. With just a few CLI commands, you can have your article database ready in no time.

A set of CLI commands to build your articles-base

Demo

Website

https://chat-with-news.onrender.com
The project is set up to answer questions based on the news published on the selected date. This help improves the RAG by limiting the numbers of articles while also giving context more relevant to the question.

Source code

https://github.com/ypk46/chat-with-news

Tools Used

  1. pgvector: I'm using pgvector to store the article embeddings that are generated through llama3.2 model. Database diagram
  2. pgai: I use pgai to call llama3.2 model through SQL queries to get related articles and generate an answer. SQL queries using pgai
  3. pgai Vectorizer: I set up a CLI command to run track changes on the articles table and vectorize all pending articles using llama3.2 model. You can set up a cron job to run every X minutes, to have your articles embeddings always ready. See code here.
  4. Ollama: I use Ollama to host the llama3.2 which serves a couple purposes:
    • Generate an article's summary to display on the web.
    • Generate the embeddings from the article full content.
    • Generate answers to user's question related to any article on a given date.

Demo image of the web application

Final Thoughts

This demo helped me establish some solid groundwork for a personal project involving news aggregation and AI. I believe the tools developed by the Timescale team truly empower developers, making them more efficient and simplifying tedious tasks in a consistent and user-friendly way.

The pgai Vectorizer has been a game-changer for me. Keeping an embeddings store up to date can be repetitive and time-consuming. However, building a vectorizer worker is straightforward and highly effective for ensuring that your real data and embeddings store remain synchronized.

Prize Categories

This submission qualifies for:

  • Open-source Models from Ollama
  • Vectorizer Vibe
  • All the Extensions

Top comments (0)