A professional, local-first Retrieval-Augmented Generation (RAG) agent. This application allows users to log in with a unique ID, index web documents via URL, and chat with an AI assistant that has "memory" of both the document and the conversation history.
Before running the application, ensure you have the following installed:
- Python 3.11 or 3.12 (Recommended for stability).
- Ollama: Download Ollama here.
- Local Models: Once Ollama is installed, run these commands in your terminal to download the necessary models:
ollama pull llama3.1 ollama pull nomic-embed-text
Follow these steps to set up the project on your local machine:
Create a project folder and navigate into it:
mkdir rag-agent-app
cd rag-agent-appCreate and activate a virtual environment to keep your dependencies isolated:
# Create the environment
python -m venv venv
# Activate it (macOS/Linux)
source venv/bin/activate
# Activate it (Windows)
# venv\Scripts\activatepip install streamlit beautifulsoup4 langchain langchain-ollama langchain-community langchain-core langchain-text-splittersstreamlit run app.pyThe project is designed with Separation of Concerns:
-
LLM Selection: To change the reasoning model, edit get_llm() in engine.py (e.g., change llama3.1 to gemma2).
-
Embedding Selection: By default, it uses HuggingFace models, update get_embeddings() in engine.py to change it if required.
-
Chunking: You can adjust the chunk_size and chunk_overlap in engine.py to optimize how the agent "reads" longer or shorter articles.
-
Login: Enter any Unique ID. This ID acts as your "account" key.
-
Paste URL: In the sidebar, paste a link to a blog post, news article, or documentation.
-
Chat: Ask questions like "What are the main points of this article?" or "Explain the specific methodology used."
-
Persistent History: Even if you close the app, logging back in with the same ID will retrieve your previous chat history from the SQLite database.
-
Multi-Document: If you paste a new URL, the agent will re-index and begin answering based on the new context.
rag-agent-app/
├── app.py # Main Entry point (Streamlit UI)
├── engine.py # Core RAG & Agent Logic (LangChain/Ollama)
├── database.py # SQLite Database handlers
├── requirements.txt # Project dependencies
└── readme.md # Project documentation