Skip to content

federicoandreis/ragsistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

RAGsistant

A production-ready hybrid RAG (Retrieval-Augmented Generation) system that combines Neo4j graph database and ChromaDB vector store for intelligent document querying. Features a clean Streamlit interface and modular architecture for easy extension.

Latest Updates

  • πŸ›‘οΈ Enhanced security with required environment variables for database credentials
  • πŸ—ƒοΈ Implemented robust ChromaDB and Neo4j connectors with comprehensive error handling
  • πŸ“Š Added detailed configuration options in .env.example with clear documentation
  • πŸ§ͺ Improved test coverage and code quality

πŸš€ Features

  • Hybrid Storage: Combines graph (Neo4j) and vector (ChromaDB) databases for optimal retrieval
  • Document Processing: Supports PDF, DOCX, TXT, Markdown, and CSV files
  • Intelligent Routing: Pattern-based and LLM-based query routing
  • Entity Extraction: Multiple extraction methods (spaCy, LLM-based)
  • Graph Enhancement: Entity coalescing, relation repair, and community detection
  • Modular Architecture: Clean separation of concerns for easy maintenance
  • Production Ready: Comprehensive configuration, logging, and error handling

πŸ“‹ Prerequisites

  • Python 3.9 or higher
  • Neo4j (local installation or Docker) with the Graph Data Science (GDS) plugin
  • Ollama (for local LLM inference)

πŸ› οΈ Installation

1. Clone the Repository

git clone https://github.com/your-username/ragsistant.git
cd ragsistant

2. Create Virtual Environment

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Install spaCy Model

python -m spacy download en_core_web_sm

5. Setup Configuration

# Copy and edit the environment variables
cp .env.example .env

# Important: Set your Neo4j password in the .env file
# NEO4J_PASSWORD is required and has no default for security

6. Install Dependencies

# Install Python dependencies
pip install -r requirements.txt

# Install development dependencies (optional)
pip install -e ".[dev]"

7. Start Required Services

Neo4j

IMPORTANT: RAGsistant requires the Neo4j Graph Data Science (GDS) module. Make sure your Neo4j instance has GDS installed and enabled.

# Using Docker (with GDS)
docker run --name neo4j-gds \
    --publish 7474:7474 \
    --publish 7687:7687 \
    --env NEO4J_AUTH=neo4j/test1234 \
    --env NEO4J_PLUGINS='["graph-data-science"]' \
    neo4j:latest

Local install (with GDS)

Or start local Neo4j installation


#### Ollama
```bash
# Install Ollama from https://ollama.ai
ollama pull gemma3:1b
ollama pull mxbai-embed-large

# Verify the models are available
ollama list

8. Initialize the Application

Before first use, you'll need to initialize the application with:

# This will set up the necessary database schemas and indexes
python -m app.init

πŸš€ Quick Start

1. Start the Application

streamlit run app/ui.py

2. Upload Documents

  • Navigate to the web interface (usually http://localhost:8501)
  • Use the file uploader to add documents
  • Wait for processing to complete

3. Query Your Documents

  • Enter questions in the chat interface
  • The system will automatically route queries to the best retrieval method
  • View transparent results showing sources and reasoning

πŸ“ Project Structure

ragsistant/
β”œβ”€β”€ README.md                 # This file
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ setup.py                 # Package configuration
β”œβ”€β”€ .env.example             # Configuration template
β”œβ”€β”€ .gitignore              # Git ignore rules
β”œβ”€β”€ prd.txt                 # Product requirements
β”œβ”€β”€ app/                    # Main application
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ ui.py              # Streamlit interface
β”‚   β”œβ”€β”€ config.py          # Configuration management
β”‚   β”œβ”€β”€ models.py          # Data models
β”‚   β”œβ”€β”€ routing.py         # Query routing logic
β”‚   β”œβ”€β”€ embedding.py       # Embedding functionality
β”‚   β”œβ”€β”€ vectorstore.py     # Vector store operations
β”‚   β”œβ”€β”€ core/              # Core functionality
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ ingestion.py   # Document ingestion
β”‚   β”‚   β”œβ”€β”€ chunking.py    # Text chunking
β”‚   β”‚   └── serialization.py # Data serialization
β”‚   β”œβ”€β”€ db/                # Database connectors
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ connections.py # Database connections
β”‚   β”‚   β”œβ”€β”€ chroma.py     # ChromaDB operations
β”‚   β”‚   └── neo4j.py      # Neo4j operations
β”‚   β”œβ”€β”€ entity_extraction/ # Entity extraction
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ base.py       # Base extractor
β”‚   β”‚   β”œβ”€β”€ spacy_extractor.py
β”‚   β”‚   └── llm_extractor.py
β”‚   β”œβ”€β”€ graph/             # Graph operations
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ ingestion_core.py
β”‚   β”‚   β”œβ”€β”€ retrieval.py
β”‚   β”‚   β”œβ”€β”€ entity_coalescing.py
β”‚   β”‚   β”œβ”€β”€ relation_repair.py
β”‚   β”‚   β”œβ”€β”€ community_detection.py
β”‚   β”‚   └── gap_filling.py
β”‚   └── utils/             # Utilities
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ status.py     # Status tracking
β”‚       └── parallel.py   # Parallel processing
β”œβ”€β”€ tests/                 # Test suite
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_chunking.py
β”‚   β”œβ”€β”€ test_graph_ingest.py
β”‚   β”œβ”€β”€ test_graph_retrieval.py
β”‚   β”œβ”€β”€ test_routing.py
β”‚   └── test_vectorstore.py
β”œβ”€β”€ docs/                  # Documentation
β”œβ”€β”€ data/                  # Data storage
β”‚   β”œβ”€β”€ documents/         # Source documents
β”‚   └── chunks/           # Processed chunks
└── storage/              # Database storage
    β”œβ”€β”€ chroma_db/        # ChromaDB files
    └── neo4j_data/       # Neo4j data

βš™οΈ Configuration

The application uses environment variables for configuration. Copy .env.example to .env and customize:

Database Settings

  • NEO4J_URI: Neo4j connection URI
  • NEO4J_USERNAME/PASSWORD: Neo4j credentials
  • CHROMA_DB_PATH: ChromaDB storage path

Model Settings

  • OLLAMA_BASE_URL: Ollama server URL
  • OLLAMA_MODEL: Default LLM model
  • EMBEDDING_MODEL: Embedding model name

Processing Settings

  • DEFAULT_CHUNK_SIZE: Text chunk size
  • DEFAULT_CHUNK_OVERLAP: Chunk overlap size

πŸ§ͺ Testing

Run the test suite:

pytest tests/

Run specific tests:

pytest tests/test_chunking.py -v

πŸ”§ Development

Code Style

# Install development dependencies
pip install -e ".[dev]"

# Format code
black app/ tests/

# Lint code
flake8 app/ tests/

# Type checking
mypy app/

Adding New Features

  1. Create feature branch
  2. Add tests in tests/
  3. Implement functionality in appropriate module
  4. Update documentation
  5. Submit pull request

πŸ“Š Architecture

RAGsistant uses a hybrid approach:

  1. Document Ingestion: Files are processed, chunked, and stored
  2. Dual Storage: Text chunks go to ChromaDB, entities/relations to Neo4j
  3. Query Routing: Intelligent routing based on query type
  4. Retrieval: Vector similarity and graph traversal
  5. Response Generation: LLM synthesis with source attribution

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

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

πŸ†˜ Support

πŸ™ Acknowledgments

About

Hybrid RAG system combining Neo4j graph database and ChromaDB vector store for intelligent document querying with Streamlit UI. Features document processing, entity extraction, and knowledge graph enhancement.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages