Skip to content

A Retrieval-Augmented Generation (RAG) system built with Ollama and ChromaDB, featuring a Streamlit web interface for document upload and testing.

Notifications You must be signed in to change notification settings

CodeStrate/OllamaAgent

Repository files navigation

RAG App with NVIDIA Nemotron!

A Retrieval-Augmented Generation (RAG) system built with Ollama and ChromaDB, featuring a Streamlit web interface for document upload and testing.

Features

  • Document Ingestion: Upload and process PDF documents
  • Vector Storage: Persistent document embeddings using ChromaDB
  • RAG Query System: Ask questions about uploaded documents
  • Streamlit UI: User-friendly web interface for testing
  • Error Handling: Comprehensive exception handling throughout

Project Structure

├── config.yaml          # Configuration settings
├── common_utils.py       # Utility functions
├── ingestion.py         # DocumentIngestion class
├── LLM.py              # RAGLLMSystem class
├── streamlit_app.py    # Streamlit web interface
├── requirements.txt    # Python dependencies
└── README.md          # This file

Classes Overview

DocumentIngestion Class

  • load_documents(doc_paths): Load PDF documents
  • chunk_documents(docs): Split documents into chunks
  • init_vector_store(): Initialize ChromaDB vector store
  • add_documents_to_store(chunks): Add chunks to vector store
  • process_documents(doc_paths): Complete pipeline from paths to vector store

RAGLLMSystem Class

  • query(question): Query the RAG system
  • add_documents(doc_paths): Add new documents to knowledge base
  • get_vector_store_info(): Get vector store status information

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Make sure Ollama is running with the required models:
# Install Ollama if not already installed
# Then pull the required models
ollama pull nemotron-mini
ollama pull nomic-embed-text

Usage

Option 1: Streamlit Web Interface (Recommended)

  1. Run the Streamlit app:
streamlit run streamlit_app.py
  1. Open your browser to the provided URL (usually http://localhost:8501)

  2. Use the interface to:

    • Initialize the RAG system
    • Upload PDF documents
    • Ask questions about your documents

Option 2: Python Script

from LLM import RAGLLMSystem

# Initialize the system
rag_system = RAGLLMSystem()

# Add documents
doc_paths = ["path/to/your/document.pdf"]
rag_system.add_documents(doc_paths)

# Query the system
response = rag_system.query("What is this document about?")
print(response)

Configuration

Edit config.yaml to customize:

  • Ollama Models: Change LLM and embedding models
  • Chunk Settings: Adjust chunk size and overlap
  • Vector Store: Modify collection name and directory
  • Retrieval: Set number of documents to retrieve

Streamlit UI Features

Sidebar

  • System Status: Shows if RAG system is active
  • Document Upload: Upload multiple PDF files
  • Vector Store Info: Display current configuration
  • Clear Chat: Reset conversation history

Main Interface

  • Chat Interface: Interactive Q&A with your documents
  • SideBar: To Upload Files

Next Steps

  • Add support for more document types (DOCX, TXT, etc.)
  • Implement parsing of images and tables from documents
  • Add chat history persistence
  • Include tools like Firecrawl, MCP Server
  • Add APIs using FastAPI and Agent-ify it using LangGraph

About

A Retrieval-Augmented Generation (RAG) system built with Ollama and ChromaDB, featuring a Streamlit web interface for document upload and testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages