Skip to main content

Production-oriented Python framework for building RAG services on top of FastAPI.

Project description

SyRAG

SyRAG is a production-oriented Python framework for building Retrieval-Augmented Generation services with a small, typed API on top of FastAPI.

Supported Python versions: 3.12 and 3.13.

It currently ships:

  • SyRAG application wrapper plus create_app()
  • @app.ingest(...) and @app.query(...) decorators
  • typed request and response schemas
  • in-memory providers for local development
  • Chroma vector store behind the chroma extra
  • SQLite vector store in core and OpenAI providers behind the openai extra
  • request context, auth hooks, tenant scoping, rate limiting, and safety guards
  • OpenAPI docs, structured logging, and OpenTelemetry-compatible tracing
  • a testing toolkit with fake providers and ASGI client helpers

Installation

Core package:

pip install syrag

Optional integrations:

pip install "syrag[chroma]"
pip install "syrag[openai]"
pip install "syrag[testing]"
pip install "syrag[server]"
pip install "syrag[all]"

Quick Start

Install the runtime integrations used in this example:

pip install "syrag[chroma,openai,server]"

Set OPENAI_API_KEY in your environment before starting the app.

Create main.py:

import os
from pathlib import Path

from syrag import (
    SyRAG,
    ChromaVectorStore,
    IngestRequest,
    OpenAIEmbedder,
    OpenAILLM,
    QueryRequest,
    Settings,
)

app = SyRAG(
    title="Support Bot",
    version="0.1.0",
    description="Internal support assistant",
    settings=Settings(),
)

app.register_embedder(
    "default",
    OpenAIEmbedder(
        api_key=os.environ["OPENAI_API_KEY"],
        model="text-embedding-3-small",
    ),
)
app.register_vector_store(
    "default",
    ChromaVectorStore(path=Path(".syrag/chroma"), collection_name="support_docs"),
)
app.register_llm(
    "default",
    OpenAILLM(api_key=os.environ["OPENAI_API_KEY"], model="gpt-4.1-mini"),
)
app.configure_defaults(
    embedder="default",
    vector_store="default",
    llm="default",
)


@app.ingest("/ingest")
async def ingest(request: IngestRequest) -> IngestRequest:
    return request


@app.query("/query")
async def query(request: QueryRequest) -> QueryRequest:
    return request

Serve the app with any ASGI server. With the server extra installed:

uvicorn main:app.api --reload

The framework exposes:

  • POST /ingest
  • POST /query
  • GET /health
  • OpenAPI docs at /docs

Ingest a document:

curl -X POST http://127.0.0.1:8000/ingest \
  -H "content-type: application/json" \
  -d '{"documents":["SyRAG builds typed RAG services."],"collection":"demo"}'

Query it:

curl -X POST http://127.0.0.1:8000/query \
  -H "content-type: application/json" \
  -d '{"query":"What does SyRAG build?","collection":"demo","top_k":1}'

Extension Points

SyRAG keeps the pipeline explicit. You can swap or extend:

  • Chunker
  • Embedder
  • VectorStore
  • RetrievalStrategy
  • PromptAssembler
  • GenerationPolicy
  • LLM
  • RequestContextHook
  • AuthHook
  • RateLimiter
  • SafetyGuard

First-Party Providers

Core:

  • InMemoryEmbedder
  • InMemoryVectorStore
  • InMemoryLLM
  • PassThroughChunker
  • SQLiteVectorStore

Optional chroma extra:

  • ChromaVectorStore

Optional openai extra:

  • OpenAIEmbedder
  • OpenAILLM

Observability And Operations

SyRAG includes:

  • structured error responses with stage information
  • request-scoped RequestContext with request IDs and tenant IDs
  • StructuredLogging and JSONLogFormatter
  • OpenTelemetryTracing built on the OpenTelemetry API package
  • request throttling via InMemoryRateLimiter
  • payload validation via DefaultSafetyGuard

Testing

Install the testing extra to use:

  • create_test_app(...)
  • create_test_client(...)
  • seed_documents(...)
  • fake providers such as FakeEmbedder, FakeVectorStore, and FakeLLM

Docs

Examples

Cookbook

Full example scripts live in examples/integrations.

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

syrag-0.1.0.tar.gz (140.8 kB view details)

Uploaded Source

Built Distribution

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

syrag-0.1.0-py3-none-any.whl (45.8 kB view details)

Uploaded Python 3

File details

Details for the file syrag-0.1.0.tar.gz.

File metadata

  • Download URL: syrag-0.1.0.tar.gz
  • Upload date:
  • Size: 140.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for syrag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef3a4c050056602d1a8d854700f791a713985d9f8a592d89303dbf3a31bc0af0
MD5 409a75db97065702074c1c581593443d
BLAKE2b-256 6fb4f9581a3b4f6f329d53c45dba7dfd6d2508337f8d2f81c99ebc1b2c0d85b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for syrag-0.1.0.tar.gz:

Publisher: publish.yml on a-marzoug/syrag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file syrag-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: syrag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for syrag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82bfa2ea107baa40c62576e0ea2db24d519ed03585218bcf14b7f605631e0bae
MD5 98200931882d59f4686da462fe587e0d
BLAKE2b-256 afff16ee85e5c76a594e41ad5b2e6124cb53e63a0650514f1624633ba157f75e

See more details on using hashes here.

Provenance

The following attestation bundles were made for syrag-0.1.0-py3-none-any.whl:

Publisher: publish.yml on a-marzoug/syrag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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