RPG-coder/kaggle-agentic-ai

An intelligent news Q&A agent built with LangChain and LangGraph. With RAG answer questions from BBC News articles with conversation memory.

β˜… 0Forks 0Jupyter NotebookGitHub β†—Compare
anthropicfaisshuggingfacelangchainlanggraphllmnewsnlppythonrag

README

NewsWise - Intelligent News Q & A Agent

An intelligent news Q&A agent built with LangChain and LangGraph. Using RAG (Retrieval Augmented Generation) to answer questions from BBC New articles (Source: Kaggle) with conversation memory.

Heads up! This repo is purely for learning purposes, just me exploring and experimenting. Nothing fancy here! πŸ˜„

Features

  • RAG Pipeline: Retrieves relevant BBC news articles using FAISS vector search
  • LLM-powered answer: Using Claude (Anthropic) model to answer question from retrieved context (from RAG's retrieval)
  • Conversation Memory: Remember previous question and answer across turns
  • LangGraph Flow: Built with StateGraph production ready workflow
  • MemorySaver: Persist graph state between interactions
  • HuggingFaceEmbeddings: for semantic search

Architecture

  User Question
       ↓
  [LangGraph StateGraph]
       ↓
  [ask] β†’ get user input
       ↓
  [route] β†’ /exit or continue
       ↓
  [answer] β†’ RAG Chain
       β”œβ”€β”€ FAISS Retriever (top 3 articles)
       β”œβ”€β”€ ChatPromptTemplate + History
       └── Claude LLM β†’ StrOutputParser
       ↓
  Loop back to [ask]

Dataset

  • Source: BBC News Archive - Kaggle
  • Size: 2,225 articles
  • Categories: Business, Sport, Politics, Tech, Entertainment
  • Columns: category, filename, title, content

Tech Stack

Tool Purpose
LangChain LLM chaining, prompt templates, RAG
LangGraph Agent flow, state management
Anthropic Claude LLM for answer generation
FAISS Vector store for semantic search
HuggingFace Sentence embeddings
Pandas Dataset loading and processing

Setup

  1. Clone the repository
git clone https://github.com/yourusername/newswise.git
cd newswise
  1. Install dependencies
pip install langchain langchain-anthropic langchain-community langchain-huggingface faiss-cpu langgraph sentence-transformers pandas
  1. Set up API keys Add to your environment or Google Colab secrets:
ANTHROPIC_API_KEY=your_anthropic_api_key
KAGGLE_USERNAME=your_kaggle_username
KAGGLE_KEY=your_kaggle_api_key
  1. Download dataset
kaggle datasets download -d hgultekin/bbcnewsarchive
unzip bbcnewsarchive.zip
  1. Run the notebook Open newswise.ipynb in Google Colab or Jupyter and run all cells.

Usage

Enter a Question: What happened in football?
Agent: Based on the provided context...

Enter a Question: Who was mentioned in the last answer?
Agent: Based on the previous answer...

Enter a Question: /exit
  • Type any news-related question
  • Type /exit to end the session

Future Improvements

  • Add category filter tool
  • Swap MemorySaver to PostgreSQL for production
  • Add Gradio UI for web interface
  • Add source citation in answers
  • Deploy to Hugging Face Spaces

License

MIT License: free to use, modify and share.

Acknowledgements

  • BBC News Archive Dataset by Habib GΓΌltekin on Kaggle
  • LangChain and LangGraph teams
  • Anthropic for Claude

Contributors

RPG-coder

Issues