Skip to content

codePhenomena/langChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸͺ¨ RockyBot: News Research Tool πŸ“ˆ

RockyBot is a simple Streamlit application that lets you perform question-answering over news articles by leveraging LangChain, OpenAI embeddings, and FAISS vector search. Just input up to 3 news URLs, and RockyBot will retrieve relevant answers based on the content of those pages.


πŸš€ Features

  • πŸ“„ Load news articles from provided URLs
  • πŸ” Split content into meaningful text chunks
  • 🧠 Generate embeddings using OpenAI
  • πŸ“¦ Store/retrieve embeddings using FAISS vector index
  • ❓ Ask questions and get source-based answers using a RetrievalQA chain
  • 🧾 Source tracking for transparent results

πŸ› οΈ Tech Stack


πŸ“¦ Installation

  1. Clone the repo
git clone https://github.com/yourusername/rockybot.git
cd rockybot
  1. Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up .env file

Create a .env file in the root directory with your OpenAI API key:

OPENAI_API_KEY=your_openai_api_key_here

πŸ§ͺ Usage

Run the app with:

streamlit run app.py

Then:

  1. Input up to 3 news URLs in the sidebar.
  2. Click Process URLs to fetch and vectorize the content.
  3. Type your question in the input box.
  4. RockyBot will answer your question with sources.

🧠 How It Works

  1. WebBaseLoader scrapes the content from the URL.
  2. RecursiveCharacterTextSplitter splits the content into chunks.
  3. OpenAIEmbeddings generates vector representations of those chunks.
  4. FAISS indexes the vectors for fast retrieval.
  5. RetrievalQAWithSourcesChain uses a language model (via ChatOpenAI) to answer user queries with source tracking.

πŸ“ File Structure

rockybot/
β”œβ”€β”€ app.py                # Main Streamlit app
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ .env                  # Your OpenAI API Key (not included in repo)
β”œβ”€β”€ faiss_store_openai.pkl # Saved FAISS index (generated after first run)

βœ… Example Questions

  • "What is the main topic of the article?"
  • "Who is mentioned in the news?"
  • "What are the key takeaways?"

πŸ“Œ Notes

  • Only the first URL is currently processed (URLs 2 and 3 are ignored).
  • The FAISS index is saved locally as faiss_store_openai.pkl.
  • You may need to delete or refresh the FAISS index if input URLs change.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages