Skip to main content

Ragrails

PyPI Python Downloads License

Ragrails is a modular RAG toolkit for turning URLs, local documents, and REST API responses into retrieval-ready vector indexes.

It is organized in layers:

core -> SDK -> CLI -> REST API

Most users should use the SDK, CLI, or REST API. The core modules are the shared foundation that the public interfaces build on.

Install

Ragrails requires Python 3.10 or newer.

pip install ragrails

The base install includes the SDK, CLI, REST API server, document ingestion, API ingestion, chunking, embedding orchestration, vector storage orchestration, retrieval, chat orchestration, and pipeline helpers.

Install extras for URL scraping, model providers, reranking, and vector database clients:

Need Install
URL ingestion pip install "ragrails[url]"
Store in Qdrant pip install "ragrails[store-qdrant]"
Store in Pinecone pip install "ragrails[store-pinecone]"
Store in Weaviate pip install "ragrails[store-weaviate]"
REST API with Qdrant stack pip install "ragrails[server-qdrant]"
REST API with Pinecone stack pip install "ragrails[server-pinecone]"
REST API with Weaviate stack pip install "ragrails[server-weaviate]"
Everything pip install "ragrails[all]"

Provider extras are also available separately:

Provider Install
Voyage embeddings pip install "ragrails[voyage]"
Qdrant pip install "ragrails[qdrant]"
Pinecone pip install "ragrails[pinecone]"
Weaviate pip install "ragrails[weaviate]"
OpenAI pip install "ragrails[openai]"
Anthropic pip install "ragrails[anthropic]"
Reranking pip install "ragrails[rerank]"

SDK Quick Start

from ragrails import RagRails

rag = RagRails()

Ingest and Store

Run ingestion, chunking, embedding, and vector storage in one call:

from ragrails import RagRails

rag = RagRails()

result = rag.ingest(
    markdown="# Guide\n\nRagrails builds modular RAG workflows.",
    embedding={
        "provider": "voyage",
        "model": "voyage-3",
    },
    storage={
        "vector_db": "qdrant",
        "collection": "docs",
        "url": "http://localhost:6333",
    },
)

print(result.stored)

You can also provide docs, urls, or api sources:

rag.ingest(
    docs=["files/guide.pdf"],
    ingestion={"docs": {"mode": "single"}},
    embedding={"provider": "voyage", "model": "voyage-3"},
    storage={"vector_db": "qdrant", "collection": "docs"},
)

URL ingestion uses Playwright through crawl4ai. Install the URL extra and run browser setup once in the target environment:

pip install "ragrails[url,voyage,qdrant]"
RagRails().setup_url()

Query

Run query embedding and retrieval in one call:

result = rag.query(
    "What does the guide cover?",
    embedding={
        "provider": "voyage",
        "model": "voyage-3",
    },
    retrieval={
        "vector_db": "qdrant",
        "collection": "docs",
        "url": "http://localhost:6333",
        "top_k": 5,
    },
)

for chunk in result.items:
    print(chunk.text)

Chat

Chat is stateless. Pass history explicitly and persist the returned result.history in your app session.

from ragrails import QueryRewriteConfig, RagRails

rag = RagRails()

llm = rag.llm(provider="openai", model="gpt-4.1-mini")
embedder = rag.embedder(provider="voyage", model="voyage-3", input_type="query")

history = []

result = rag.chat(
    "How do I authenticate?",
    llm=llm,
    embedder=embedder,
    vector_db="qdrant",
    collection="docs",
    url="http://localhost:6333",
    history=history,
    query_rewrite=QueryRewriteConfig(enabled=True),
)

print(result.answer)
history = result.history

Edit and Delete Stored Chunks

Edit and delete operations are vector database agnostic at the SDK layer.

edit_result = rag.edit(
    chunks=[
        {
            "id": "chunk-id",
            "text": "Updated chunk text",
            "source": "files/guide.pdf",
            "metadata": {"title": "Guide"},
        }
    ],
    embedder=rag.embedder(provider="voyage", model="voyage-3"),
    vector_db="qdrant",
    collection="docs",
    url="http://localhost:6333",
)

delete_result = rag.delete(
    ids=["chunk-id"],
    vector_db="qdrant",
    collection="docs",
    url="http://localhost:6333",
)

CLI

Ragrails ships with a CLI for local workflows and smoke tests.

ragrails --help

Examples:

ragrails ingest \
  --markdown "# Guide\n\nUse Ragrails for RAG workflows." \
  --vector-db qdrant \
  --collection docs
ragrails query "What does the guide cover?" \
  --vector-db qdrant \
  --collection docs

CLI docs live in ragrails/interfaces/cli/README.md.

REST API

Ragrails ships a FastAPI server on top of the SDK.

ragrails-api

Swagger UI is available at http://127.0.0.1:8000/docs when the server is running. The OpenAPI schema is available at /v1/openapi.json.

REST docs live in ragrails/interfaces/server/README.md.

Package Structure

ragrails/
  core/
    stg_01_ingestors/
    stg_02_chunker/
    stg_03_embedder/
    stg_04_storing/
    stg_05_retriever/
    stg_06_chat/
  interfaces/
    sdk/
    cli/
    server/

Interface Docs

Interface Docs
SDK chunking ragrails/interfaces/sdk/chunking/README.md
SDK embedding ragrails/interfaces/sdk/embedding/README.md
SDK storing ragrails/interfaces/sdk/storing/README.md
SDK retrieval ragrails/interfaces/sdk/retrieval/README.md
SDK chat ragrails/interfaces/sdk/chat/README.md
CLI ragrails/interfaces/cli/README.md
REST API ragrails/interfaces/server/README.md

Specialized SDK ingestion docs:

Development Checks

Run local interface checks:

scripts/test-core.sh
scripts/test-sdk.sh
scripts/test-cli.sh
scripts/test-rest.sh

The repo uses .githooks/pre-push, so git push runs the same checks and blocks the push if any interface test fails.

Build and validate release artifacts:

uv build
uvx twine check dist/*

Publish only after the checks pass:

uv publish

Status

The public SDK currently covers ingestion, chunking, embedding, vector storage, retrieval, chat, vector edit/delete, and end-to-end ingestion/query pipeline helpers. CLI and REST API interfaces are built on top of the SDK.

Metadata

Release files for ragrails 0.2.1

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

Source distribution (sdist)

Source distribution for ragrails 0.2.1
File Size Uploaded
ragrails-0.2.1.tar.gz 502.0 kB Details

Built distribution (wheel)

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

Total release size: 763.3 kB

Release files / ragrails-0.2.1.tar.gz

Download URL ragrails-0.2.1.tar.gz
Size 502.0 kB
Tags Source
SHA-256 checksum
How to use checksums
96498dd3b32ab5990610984096063b3d42448ab7ea3a274b4f23c5c03fe8a904
BLAKE2b-256 checksum
How to use checksums
04a653ee140b345d5512d2716755d8f88cd21de99b2b6a5c80c5dbd26f6c16cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ragrails-0.2.1-py3-none-any.whl

Download URL ragrails-0.2.1-py3-none-any.whl
Size 261.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9bf8d7e25f21bfadff6ac26a4f9d0294cc14899be9db211391dcff0c5d38ae2
BLAKE2b-256 checksum
How to use checksums
e41d5acfd8f403e6a66d98f51b28d05a4636c992c0603c63db7ac708bef1f76c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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