Skip to main content

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

Metadata

Release files for multi-provider-rag-assistant 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multi-provider-rag-assistant 1.0.0
File Size Uploaded Provenance
multi_provider_rag_assistant-1.0.0.tar.gz 3.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for multi-provider-rag-assistant 1.0.0
File Interpreter ABI Platform
multi_provider_rag_assistant-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / multi_provider_rag_assistant-1.0.0.tar.gz

Download URL multi_provider_rag_assistant-1.0.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
79c7bc6a83a1867d48f54d9b4deb18c0662cab55962cc0e430ddac34a352a508
BLAKE2b-256 checksum
How to use checksums
baf2ec2484b22e876623242b0b8b2aed0d13a7995f306088ae52b87c8de04305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / multi_provider_rag_assistant-1.0.0-py3-none-any.whl

Download URL multi_provider_rag_assistant-1.0.0-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3113fbcf7a6edac279ec73d82b9b12a254036d2e048304beda75023fcbce00fa
BLAKE2b-256 checksum
How to use checksums
b12402ba5590c65185e634932ec73928f01e7459631ceda2603e28c71b987c1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for multi-provider-rag-assistant 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page