Skip to content

Computational-Imaging-LAB/RAG-Streamlit

Repository files navigation

RAG-Agent

A powerful Retrieval Augmented Generation (RAG) system that enables you to chat with your documents using local LLMs through Ollama.

Features

  • 📄 PDF Processing: Upload and process PDF documents
  • 💬 Interactive Chat: Streaming responses for natural conversation
  • 🧠 Contextual Retrieval: RAG system pulls relevant information from your documents
  • 📊 Database Management: Create, manage and search document collections
  • 👤 User Authentication: Secure login system for multi-user support
  • 📱 Responsive Design: Works well on desktop and mobile

Prerequisites

  • Python 3.8+
  • Ollama installed and running locally (https://ollama.ai)
  • Models pulled into Ollama (e.g., ollama pull llama3.2:latest)

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/RAG-Agent.git
cd RAG-Agent
  1. Install dependencies:
pip install -r requirements_streamlit.txt

Usage

  1. Start the Streamlit app:
streamlit run app_streamlit.py
  1. Open your browser and navigate to: http://localhost:8501

  2. Working with the Application:

    • Login/Register: Create an account or login to access your document collections
    • Upload Documents: Use the file uploader to add PDF documents to your collection
    • Create Collections: Organize your documents into collections with descriptions
    • Chat with Documents: Ask questions and get answers based on your documents
    • Toggle Features: Enable/disable RAG to switch between document-based and general responses
    • Change Models: Select from available Ollama models through the dropdown

How It Works

The RAG-Agent system:

  1. Processes uploaded PDF documents, breaking them into chunks
  2. Creates vector embeddings of these chunks using sentence-transformers
  3. Stores these embeddings in a ChromaDB vector database
  4. On receiving a question, finds the most relevant document chunks
  5. Sends the relevant context along with your question to the LLM
  6. Returns a response grounded in your documents

Project Structure

  • app_streamlit.py: Main Streamlit application
  • rag-agent/src/: Core RAG system components
    • fileloader.py: Document processing and embedding
    • ollama_pure_chat.py: Interface with Ollama API
    • document_parser.py: Document parsing utilities

Configuration

Database and storage paths are configured to use the localdatabase/ directory by default. This can be changed by setting the PERSISTENT_STORAGE_BASE environment variable.

Troubleshooting

  • Ollama Connection Issues: Ensure Ollama is running with ollama serve
  • Model Not Found: Verify you've pulled the model with ollama pull modelname
  • PDF Processing Errors: Try different PDF files or check if your PDF is searchable/OCR'd
  • Database Issues: Check permissions on the localdatabase directory

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published