Metadata-Version: 2.4
Name: multi-provider-rag-assistant
Version: 1.0.0
Summary: A hybrid LangChain RAG assistant supporting OpenAI, GROQ, and HuggingFace providers
Author-email: Enes Ekinci <enes.ekinci.dev@gmail.com>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0.0
Requires-Dist: faiss-cpu>=1.7.0
Requires-Dist: langchain>=0.1.0
Requires-Dist: langchain-community>=0.0.20
Requires-Dist: langchain-core>=0.1.0
Requires-Dist: langchain-groq>=0.1.0
Requires-Dist: langchain-huggingface>=0.0.1
Requires-Dist: langchain-openai>=0.0.7
Requires-Dist: langchain-text-splitters>=0.0.1
Requires-Dist: numpy>=1.24.0
Requires-Dist: python-dotenv>=0.19.0
Requires-Dist: rich>=13.0.0
Requires-Dist: sentence-transformers>=2.2.0
Requires-Dist: tiktoken>=0.5.0
Requires-Dist: torch>=2.0.0
Requires-Dist: transformers>=4.30.0
Dynamic: license-file

# Hybrid LangChain RAG Assistant

A command-line RAG system supporting OpenAI, GROQ, and HuggingFace providers with automatic document ingestion.

## How It Works

The system uses two separate providers:

- **`--embedding-provider`**: Creates vector embeddings from documents and queries
  - `openai`: Uses OpenAI text-embedding-3-small (1536 dimensions)
  - `huggingface`: Uses sentence-transformers/all-MiniLM-L6-v2 (384 dimensions)

- **`--llm-provider`**: Generates the final answer from retrieved context
  - `openai`: Uses OpenAI gpt-4o-mini (API-based)
  - `groq`: Uses GROQ openai/gpt-oss-120b (API-based)
  - `huggingface`: Uses local models like google/flan-t5-small (local inference)

## Setup

```bash
pip install -r requirements.txt
echo "OPENAI_API_KEY=your_key_here" > .env
echo "GROQ_API_KEY=your_groq_key_here" >> .env
```

**Note**: API keys are optional! The system automatically falls back to HuggingFace (local) when API keys are missing.

## Provider Combinations

### 1. OpenAI Embeddings + OpenAI LLM (Default)
**Embeddings**: OpenAI text-embedding-3-small | **LLM**: OpenAI gpt-4o-mini
```bash
python qa.py --question "How do I reset my password?"
python qa.py --question "What are the API endpoints?"
python qa.py --question "How do I configure webhooks?" 
python qa.py --question "What user roles are supported?"
```

### 2. OpenAI Embeddings + GROQ LLM
**Embeddings**: OpenAI text-embedding-3-small | **LLM**: GROQ openai/gpt-oss-120b
```bash
python qa.py --question "How do I reset my password?" --llm-provider groq
python qa.py --question "What are the API endpoints?" --llm-provider groq
python qa.py --question "How do I configure webhooks?" --llm-provider groq
python qa.py --question "What user roles are supported?" --llm-provider groq
```

### 3. OpenAI Embeddings + HuggingFace LLM
**Embeddings**: OpenAI text-embedding-3-small | **LLM**: Local HuggingFace models
```bash
python qa.py --question "How do I reset my password?" --llm-provider huggingface --hf-model google/flan-t5-small
python qa.py --question "What are the API endpoints?" --llm-provider huggingface --hf-model distilgpt2
python qa.py --question "How do I configure webhooks?" --llm-provider huggingface --hf-model microsoft/DialoGPT-small
python qa.py --question "What user roles are supported?" --llm-provider huggingface --hf-model google/flan-t5-base
```

### 4. HuggingFace Embeddings + OpenAI LLM
**Embeddings**: HuggingFace sentence-transformers/all-MiniLM-L6-v2 | **LLM**: OpenAI gpt-4o-mini
```bash
python qa.py --question "How do I reset my password?" --embedding-provider huggingface
python qa.py --question "What are the API endpoints?" --embedding-provider huggingface --k 5
python qa.py --question "How do I configure webhooks?" --embedding-provider huggingface
python qa.py --question "What user roles are supported?" --embedding-provider huggingface
```

### 5. HuggingFace Embeddings + HuggingFace LLM (Fully Local)
**Embeddings**: HuggingFace sentence-transformers/all-MiniLM-L6-v2 | **LLM**: Local HuggingFace models
```bash
python qa.py --question "How do I reset my password?" --embedding-provider huggingface --llm-provider huggingface
python qa.py --question "What are the API endpoints?" --embedding-provider huggingface --llm-provider huggingface --hf-model google/flan-t5-small
python qa.py --question "How do I configure webhooks?" --embedding-provider huggingface --llm-provider huggingface --hf-model distilgpt2
python qa.py --question "What user roles are supported?" --embedding-provider huggingface --llm-provider huggingface --hf-model google/flan-t5-base
```

## Automatic Fallback System

The system automatically falls back to HuggingFace when API keys are missing:

- **Missing OpenAI key**: Falls back to `huggingface` for embeddings/LLM
- **Missing GROQ key**: Falls back to `huggingface` for LLM  
- **No API keys needed**: Use `--embedding-provider huggingface --llm-provider huggingface` for fully local operation

**Example without any API keys:**
```bash
# This works even without .env file
python qa.py --question "How do I reset my password?"
# WARNING: OpenAI API key not found for embeddings. Falling back to HuggingFace embeddings.
# WARNING: OpenAI API key not found for LLM. Falling back to HuggingFace LLM.
# Using providers: embeddings=huggingface, llm=huggingface
```

## Troubleshooting

If you get dimension errors, clear the vector store:
```bash
python clear_vectorstore.py
```
