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! π
- 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
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]
- Source: BBC News Archive - Kaggle
- Size:
2,225 articles - Categories:
Business, Sport, Politics, Tech, Entertainment - Columns:
category, filename, title, content
| 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 |
- Clone the repository
git clone https://github.com/yourusername/newswise.git
cd newswise- Install dependencies
pip install langchain langchain-anthropic langchain-community langchain-huggingface faiss-cpu langgraph sentence-transformers pandas- 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- Download dataset
kaggle datasets download -d hgultekin/bbcnewsarchive
unzip bbcnewsarchive.zip- Run the notebook
Open
newswise.ipynbin Google Colab or Jupyter and run all cells.
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
/exitto end the session
- 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
MIT License: free to use, modify and share.
- BBC News Archive Dataset by Habib GΓΌltekin on Kaggle
- LangChain and LangGraph teams
- Anthropic for Claude