Skip to main content

Retrieval-first, deterministic RAG infrastructure

Project description

Scaraflow

Scaraflow is a retrieval-first RAG infrastructure designed for deterministic, production-grade Retrieval-Augmented Generation.

Scaraflow is not an agent framework, not a prompt playground, and not a demo SDK. It focuses on one thing and does it rigorously:

Correct, explicit, and scalable retrieval for LLM systems


Why Scaraflow

Most RAG frameworks prioritize orchestration and abstraction. Scaraflow prioritizes retrieval correctness, predictability, and streaming readiness.

Design Principles

  • Retrieval before generation
  • Explicit contracts over magic
  • Deterministic behavior
  • Low-variance latency
  • Streaming-ready by design
  • Infrastructure consistency across dev, notebooks, and production

Architecture Overview

scaraflow/
├── scara-core        # strict contracts & invariants
├── scara-index       # vector store backends (Qdrant)
├── scara-rag         # deterministic RAG engine
├── scara-live        # streaming / temporal RAG (planned)
├── scara-graph       # graph-based RAG (planned)
└── scara-llm         # thin LLM adapters (planned)

Installation

pip install scaraflow

Note: Scaraflow depends on qdrant-client and standard scientific stack libraries.


Quick Start (Run in 30 Seconds)

The fastest way to try Scaraflow is with the In-Memory setup. No Docker or external database required.

1. Create a script demo.py

import uuid
from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
from scara_index.qdrant_store import QdrantVectorStore
from scara_index.config import QdrantConfig
from scara_rag.engine import RAGEngine
from scara_rag.policies import RetrievalPolicy

# 1. Setup Components
# Use in-memory Qdrant for instant setup
client = QdrantClient(":memory:")
store = QdrantVectorStore(
    QdrantConfig(collection="demo", vector_dim=384),
    client=client
)

model = SentenceTransformer("all-MiniLM-L6-v2")

# Wrap embedder to match protocol
class LocalEmbedder:
    def embed(self, text):
        return model.encode(text).tolist()

embedder = LocalEmbedder()

# 2. Initialize Engine
rag = RAGEngine(
    embedder=embedder,
    store=store,
    llm=lambda prompt: f"Generated answer based on: {len(prompt)} chars of context.",
)

# 3. Index Data
documents = [
    "Scaraflow is a retrieval-first RAG infrastructure.",
    "It prioritizes deterministic behavior and explicit contracts.",
    "Qdrant is the recommended vector backend for Scaraflow.",
]

vectors = model.encode(documents).tolist()
ids = [str(uuid.uuid4()) for _ in documents]

store.upsert(
    ids=ids,
    vectors=vectors,
    metadata=[{"content": doc} for doc in documents]
)

# 4. Query
response = rag.query(
    "What are the design principles of Scaraflow?",
    policy=RetrievalPolicy(top_k=2)
)

print(response.answer)

Option 2 — No Docker (In-Process Qdrant)

from qdrant_client import QdrantClient
from sentence_transformers import SentenceTransformer
from scara_index.qdrant_store import QdrantVectorStore
from scara_index.config import QdrantConfig
from scara_rag.engine import RAGEngine

client = QdrantClient(path="./qdrant_data")

store = QdrantVectorStore(
    QdrantConfig(
        collection="local_demo",
        vector_dim=384,
    ),
    client=client,
)

model = SentenceTransformer("all-MiniLM-L6-v2")
embedder = type("E", (), {"embed": lambda t: model.encode(t).tolist()})

rag = RAGEngine(
    embedder=embedder,
    store=store,
    llm=lambda _: "Demo answer",
)

store.upsert(
    ids=[0],
    vectors=[model.encode("Scaraflow works without Docker").tolist()],
    metadata=[{"mode": "local"}],
)

print(rag.query("How does Scaraflow run locally?").answer)

Production Setup (Docker / Cloud)

For production, connect Scaraflow to a persistent Qdrant instance.

# Start Qdrant locally
docker run -p 6333:6333 qdrant/qdrant
# Connect to local Docker or Qdrant Cloud
store = QdrantVectorStore(
    QdrantConfig(
        url="http://localhost:6333", # or your Cloud URL
        collection="prod_v1",
        vector_dim=384,
    )
)

Benchmarks

Scaraflow includes a built-in benchmarking suite to verify infrastructure performance.

Benchmarks can be run using:

python testing/benchmarks.py

License

MIT License


Author

Built and maintained by Ganesh (K. S. N. Ganesh).

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

scaraflow-0.1.4.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

scaraflow-0.1.4-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file scaraflow-0.1.4.tar.gz.

File metadata

  • Download URL: scaraflow-0.1.4.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for scaraflow-0.1.4.tar.gz
Algorithm Hash digest
SHA256 82753c4bacb765694afe285be527007261bb8eac549a9a5c0acd95d03ae1c7ea
MD5 c4145ae6e362c07e381a8a3c8b70cf93
BLAKE2b-256 2d60cbfa6d2afd8830e2f1a545889cd5afedc3d91b4b9f4926098de6203a710c

See more details on using hashes here.

File details

Details for the file scaraflow-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: scaraflow-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for scaraflow-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a4afd607062587f1e756eca16ca6e07c8d80c421dd8ac8c5b7eed850b293326
MD5 82706d4e4bc456b3a813665aa70e536a
BLAKE2b-256 4c6baf2c7f21fb5bbd181029d19ac3ded2e81f78a4c8334cd7ebd6bbd66a9bfa

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