Skip to main content

A hybrid LangChain RAG assistant supporting OpenAI, GROQ, and HuggingFace providers

Project description

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

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

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

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

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

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

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:

# 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:

python clear_vectorstore.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multi_provider_rag_assistant-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multi_provider_rag_assistant-1.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file multi_provider_rag_assistant-1.0.0.tar.gz.

File metadata

File hashes

Hashes for multi_provider_rag_assistant-1.0.0.tar.gz
Algorithm Hash digest
SHA256 79c7bc6a83a1867d48f54d9b4deb18c0662cab55962cc0e430ddac34a352a508
MD5 e50b3fbce0249dc5219004803e349023
BLAKE2b-256 baf2ec2484b22e876623242b0b8b2aed0d13a7995f306088ae52b87c8de04305

See more details on using hashes here.

File details

Details for the file multi_provider_rag_assistant-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for multi_provider_rag_assistant-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3113fbcf7a6edac279ec73d82b9b12a254036d2e048304beda75023fcbce00fa
MD5 88cc9a4909bdc92287ec335705389cea
BLAKE2b-256 b12402ba5590c65185e634932ec73928f01e7459631ceda2603e28c71b987c1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page