Skip to main content

therag (Python) v0.10.0

Hosted RAG client + fully local RAG through Ollama / LM Studio / llama.cpp. pip install therag — only dependency is requests.

User-chosen embeddings (apne vectors do)

Agar user embedding model nahi chahata aur apne vectors khud deta hai:

rag = LocalRAG(
    llm="llama3.2",
    embed_provider="provided",   # user ne choose kiya
    store="rag.json",
)
rag.build_from_text("Pegasus Rs 11895", vectors=[[0.1, 0.2, 0.7]])
print(rag.ask("price?", vector=[0.1, 0.2, 0.7]))
# sawaal ka vector na do to keyword fallback chalega

build_from_folder(..., vectors=[...]) ya vectors={"file.py": [...]} bhi chalega. Bina vectors ke clear error aayega — tab embed_provider="builtin" ya embed_model chuno.

No embedding model needed (built-in embeddings)

embed_model na do to SDK khud word/bigram hashing se vectors banata hai — sirf LLM download karna padega, embedding model nahi:

rag = LocalRAG(llm="llama3.2", store="rag.json")  # embed_provider = "builtin"
rag.build_from_text("Air Zoom Pegasus Rs 11895, in stock")
print(rag.ask("price?"))

Explicit embed_model="nomic-embed-text" do to purana local embedding wala flow chalega. embed_provider="builtin" forcibly set bhi kar sakte ho.

Local RAG (no API key, no cloud)

ollama pull llama3.2
ollama pull nomic-embed-text
ollama serve                       # http://localhost:11434
from therag import LocalRAG

rag = LocalRAG(
    base_url="http://localhost:11434/v1",  # LM Studio: http://localhost:1234/v1
    llm="llama3.2",
    embed_model="nomic-embed-text",
    store="my-store.json",                # "" = memory only
)

rag.build_from_text("Air Zoom Pegasus Rs 11895, in stock")
rag.build_from_file("catalog.txt")
rag.build_from_url("https://example.com/help")

print(rag.ask("Pegasus ki price kya hai?"))
print(rag.ask_full("Kya stock hai?"))  # answer + sources + usage
print(rag.stats())
  • Embeddings fail ho to automatic keyword retrieval fallback.
  • JSON store local rehta hai — data kahin upload nahi hota.
  • Store format JS SDK ke saath same hai (dono SDKs ek hi file shared kar sakte hain).

Hugging Face provider (open models, serverless)

Ollama ke alava HF Inference Providers bhi chalte hain. Chat HF router par, embeddings HF feature-extraction endpoint par. Token HF_TOKEN env se bhi milta hai.

from therag import LocalRAG

rag = LocalRAG(
    provider="huggingface",
    llm="deepseek-ai/DeepSeek-V4.1-Flash:fastest",
    embed_model="sentence-transformers/all-MiniLM-L6-v2",
    # api_key="hf_..."  # optional — HF_TOKEN env sufficient
)
rag.build_from_text("Air Zoom Pegasus Rs 11895, in stock")
print(rag.ask("Pegasus ki price?"))

embed_url se custom embeddings endpoint bhi de sakte ho ({model} replace hota hai). HF serverless hai — internet + token chahiye; Ollama jaisa free/offline nahi.

Automated software flow (one call)

from therag import LocalRAG

# Software ko bas user ki scripts/data folder do — baaki auto:
rag = LocalRAG.auto(
    folder="./user-scripts",   # ya data=... ya text="..."
    llm="llama3.2",
    embed_model="nomic-embed-text",
    base_url="http://localhost:11434/v1",
    store="project-rag.json",
    install=True,              # missing models -> ollama pull (default)
)
print(rag.ask("is script me login kaise hota hai?"))

auto() pehle models check/pull karta hai, phir folder ki saari .py/.js/.ts/.md/.txt/.json/.csv files RAG me daalta hai. LM Studio ke liye install=False rakho aur models GUI se load karo.

Hosted API (as before)

from therag import RAG
rag = RAG(api_key="tk_live_...", rag="catalog.txt")
rag.build_from_text("Product: Pen, Rs 10")
print(rag.ask("cheapest product?"))

Metadata

Release files for therag 0.10.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 therag 0.10.0
File Size Uploaded Provenance Actions
therag-0.10.0.tar.gz 14.6 kB Without provenance Details for therag-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for therag 0.10.0
File Interpreter ABI Platform Actions
therag-0.10.0-py3-none-any.whl Python 3 none any Details for therag-0.10.0-py3-none-any.whl

Total release size: 27.9 kB

Release files / therag-0.10.0.tar.gz

Download URL therag-0.10.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3bf84444e4a1479d77448040a87b8a6455362022ce4cc746aac4e7815904942d
BLAKE2b-256 checksum
How to use checksums
549d4f4709dd7f5be2641c46fc2e7c76b134f0b44dd0816beddfde9124e2c712
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / therag-0.10.0-py3-none-any.whl

Download URL therag-0.10.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfd5f948ee04f8bbfaf7ff2e0669f123b2c810b2a8b4138aa43e75384961b225
BLAKE2b-256 checksum
How to use checksums
2cfc31ac3852641d7160877b2685ffd4db80a28c47634f6c78b144bb6cebd217
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for therag 0.10.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10.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