syrag 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- syrag-0.1.0/.env.example +12 -0
- syrag-0.1.0/.gitignore +20 -0
- syrag-0.1.0/CHANGELOG.md +42 -0
- syrag-0.1.0/CODE_OF_CONDUCT.md +30 -0
- syrag-0.1.0/CONTRIBUTING.md +40 -0
- syrag-0.1.0/LICENSE +21 -0
- syrag-0.1.0/PKG-INFO +248 -0
- syrag-0.1.0/README.md +209 -0
- syrag-0.1.0/SECURITY.md +26 -0
- syrag-0.1.0/docs/architecture.md +162 -0
- syrag-0.1.0/docs/component-contracts.md +158 -0
- syrag-0.1.0/docs/cookbook/index.md +22 -0
- syrag-0.1.0/docs/cookbook/langchain.md +201 -0
- syrag-0.1.0/docs/cookbook/langgraph.md +132 -0
- syrag-0.1.0/docs/cookbook/llamaindex.md +221 -0
- syrag-0.1.0/docs/cookbook/qdrant.md +249 -0
- syrag-0.1.0/docs/index.md +32 -0
- syrag-0.1.0/docs/mvp-roadmap.md +93 -0
- syrag-0.1.0/docs/overview.md +144 -0
- syrag-0.1.0/docs/provider-examples.md +115 -0
- syrag-0.1.0/docs/releasing.md +57 -0
- syrag-0.1.0/examples/integrations/langchain_qdrant_rag.py +77 -0
- syrag-0.1.0/examples/integrations/langchain_syrag_agent.py +49 -0
- syrag-0.1.0/examples/integrations/langgraph_syrag_rag.py +99 -0
- syrag-0.1.0/examples/integrations/llamaindex_qdrant_rag.py +44 -0
- syrag-0.1.0/examples/integrations/qdrant_syrag_app.py +185 -0
- syrag-0.1.0/examples/minimal_app.py +49 -0
- syrag-0.1.0/main.py +4 -0
- syrag-0.1.0/pyproject.toml +114 -0
- syrag-0.1.0/src/syrag/__init__.py +218 -0
- syrag-0.1.0/src/syrag/_optional.py +8 -0
- syrag-0.1.0/src/syrag/app.py +654 -0
- syrag-0.1.0/src/syrag/bootstrap.py +47 -0
- syrag-0.1.0/src/syrag/config.py +47 -0
- syrag-0.1.0/src/syrag/dependencies.py +89 -0
- syrag-0.1.0/src/syrag/errors.py +88 -0
- syrag-0.1.0/src/syrag/guardrails.py +198 -0
- syrag-0.1.0/src/syrag/hooks.py +54 -0
- syrag-0.1.0/src/syrag/main.py +22 -0
- syrag-0.1.0/src/syrag/observability.py +40 -0
- syrag-0.1.0/src/syrag/protocols.py +163 -0
- syrag-0.1.0/src/syrag/providers/__init__.py +35 -0
- syrag-0.1.0/src/syrag/providers/chroma.py +220 -0
- syrag-0.1.0/src/syrag/providers/chunking.py +26 -0
- syrag-0.1.0/src/syrag/providers/factories.py +32 -0
- syrag-0.1.0/src/syrag/providers/in_memory.py +210 -0
- syrag-0.1.0/src/syrag/providers/openai.py +283 -0
- syrag-0.1.0/src/syrag/providers/sqlite.py +233 -0
- syrag-0.1.0/src/syrag/registry.py +122 -0
- syrag-0.1.0/src/syrag/routing.py +390 -0
- syrag-0.1.0/src/syrag/schemas.py +104 -0
- syrag-0.1.0/src/syrag/services/__init__.py +15 -0
- syrag-0.1.0/src/syrag/services/assembly.py +48 -0
- syrag-0.1.0/src/syrag/services/generation.py +37 -0
- syrag-0.1.0/src/syrag/services/ingest.py +199 -0
- syrag-0.1.0/src/syrag/services/retrieval.py +95 -0
- syrag-0.1.0/src/syrag/services/runtime.py +227 -0
- syrag-0.1.0/src/syrag/structured_logging.py +101 -0
- syrag-0.1.0/src/syrag/testing.py +359 -0
- syrag-0.1.0/src/syrag/tracing.py +199 -0
- syrag-0.1.0/tests/test_app.py +28 -0
- syrag-0.1.0/tests/test_bootstrap.py +154 -0
- syrag-0.1.0/tests/test_chunking.py +25 -0
- syrag-0.1.0/tests/test_defaults.py +79 -0
- syrag-0.1.0/tests/test_dependencies.py +83 -0
- syrag-0.1.0/tests/test_error_handling.py +252 -0
- syrag-0.1.0/tests/test_errors.py +103 -0
- syrag-0.1.0/tests/test_guardrails.py +129 -0
- syrag-0.1.0/tests/test_in_memory_providers.py +124 -0
- syrag-0.1.0/tests/test_ingest_route.py +95 -0
- syrag-0.1.0/tests/test_ingestion_pipeline.py +17 -0
- syrag-0.1.0/tests/test_observability.py +115 -0
- syrag-0.1.0/tests/test_openapi.py +82 -0
- syrag-0.1.0/tests/test_packaging.py +54 -0
- syrag-0.1.0/tests/test_pipeline_service.py +283 -0
- syrag-0.1.0/tests/test_protocols.py +252 -0
- syrag-0.1.0/tests/test_provider_contracts.py +321 -0
- syrag-0.1.0/tests/test_provider_packages.py +339 -0
- syrag-0.1.0/tests/test_query_route.py +290 -0
- syrag-0.1.0/tests/test_registry.py +105 -0
- syrag-0.1.0/tests/test_request_context.py +182 -0
- syrag-0.1.0/tests/test_schemas.py +47 -0
- syrag-0.1.0/tests/test_structured_logging.py +201 -0
- syrag-0.1.0/tests/test_testing_toolkit.py +118 -0
- syrag-0.1.0/tests/test_tracing.py +187 -0
- syrag-0.1.0/uv.lock +1605 -0
syrag-0.1.0/.env.example
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SYRAG_APP_NAME=SyRAG
|
|
2
|
+
SYRAG_APP_VERSION=0.1.0
|
|
3
|
+
SYRAG_ENVIRONMENT=development
|
|
4
|
+
SYRAG_HOST=127.0.0.1
|
|
5
|
+
SYRAG_PORT=8000
|
|
6
|
+
SYRAG_RELOAD=true
|
|
7
|
+
SYRAG_DEFAULTS__EMBEDDER=default
|
|
8
|
+
SYRAG_DEFAULTS__VECTOR_STORE=memory
|
|
9
|
+
SYRAG_DEFAULTS__LLM=grounded
|
|
10
|
+
SYRAG_BOOTSTRAP__REGISTER_IN_MEMORY_DEFAULTS=true
|
|
11
|
+
SYRAG_PROVIDERS__IN_MEMORY__EMBEDDER_DIMENSIONS=16
|
|
12
|
+
SYRAG_PROVIDERS__IN_MEMORY__LLM_MAX_CONTEXT_DOCUMENTS=3
|
syrag-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# Tooling caches
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.ruff_cache/
|
|
16
|
+
|
|
17
|
+
# Local agent/editor metadata
|
|
18
|
+
.codex
|
|
19
|
+
.codex/
|
|
20
|
+
.gemini/
|
syrag-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to SyRAG will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-04-30
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Added the `SyRAG` application wrapper on top of FastAPI.
|
|
12
|
+
- Added typed ingest and query decorators.
|
|
13
|
+
- Added typed request, response, document, chunk, citation, and request-context schemas.
|
|
14
|
+
- Added protocol-based extension points for chunking, embedding, vector storage, retrieval, prompt assembly, generation policy, LLM generation, request context, auth, rate limiting, and safety validation.
|
|
15
|
+
- Added in-memory providers for local development and tests.
|
|
16
|
+
- Added optional Chroma vector store provider behind the `chroma` extra.
|
|
17
|
+
- Added `SQLiteVectorStore` for lightweight persistent vector storage.
|
|
18
|
+
- Added optional OpenAI embedder and LLM providers behind the `openai` extra.
|
|
19
|
+
- Added tenant-aware request context and tenant normalization.
|
|
20
|
+
- Added structured SyRAG error responses with stage and category metadata.
|
|
21
|
+
- Added OpenTelemetry-compatible tracing integration.
|
|
22
|
+
- Added structured logging and JSON log formatting.
|
|
23
|
+
- Added default rate limiting and safety guard implementations.
|
|
24
|
+
- Added OpenAPI examples and documented framework route responses.
|
|
25
|
+
- Added a downstream testing toolkit with fake providers and ASGI client helpers.
|
|
26
|
+
- Added provider contract tests across first-party provider implementations.
|
|
27
|
+
- Added cookbook documentation for Qdrant, LangChain, LangGraph, and LlamaIndex RAG integration patterns.
|
|
28
|
+
- Added package extras for `chroma`, `openai`, `testing`, `server`, and `all`.
|
|
29
|
+
- Added a minimal OpenAI and Chroma-backed application example.
|
|
30
|
+
- Added release, contribution, security, and community documentation for open-source use.
|
|
31
|
+
- Added CI for linting, type checking, tests, package building, and package metadata checks.
|
|
32
|
+
- Added tag-driven PyPI publishing workflow through PyPI Trusted Publishing.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Renamed the public package, import namespace, CLI, and framework branding to `syrag` / `SyRAG` before the first public release.
|
|
37
|
+
- Set supported Python versions to `3.12` and `3.13`.
|
|
38
|
+
- Updated first-time-user documentation to use OpenAI-backed generation and embeddings with a local vector store.
|
|
39
|
+
|
|
40
|
+
### Notes
|
|
41
|
+
|
|
42
|
+
- This is the first planned public release.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our standard
|
|
4
|
+
|
|
5
|
+
Participation in this project should remain respectful, direct, and constructive.
|
|
6
|
+
|
|
7
|
+
Expected behavior:
|
|
8
|
+
|
|
9
|
+
- discuss technical issues in good faith
|
|
10
|
+
- give clear, actionable feedback
|
|
11
|
+
- assume mistakes can be corrected without hostility
|
|
12
|
+
- keep criticism focused on ideas, code, and behavior
|
|
13
|
+
|
|
14
|
+
Unacceptable behavior:
|
|
15
|
+
|
|
16
|
+
- harassment or personal attacks
|
|
17
|
+
- discriminatory language
|
|
18
|
+
- doxxing, threats, or intimidation
|
|
19
|
+
- repeated bad-faith disruption of discussions or review
|
|
20
|
+
|
|
21
|
+
## Enforcement
|
|
22
|
+
|
|
23
|
+
Project maintainers may remove comments, issues, pull requests, or contributors
|
|
24
|
+
that violate these standards.
|
|
25
|
+
|
|
26
|
+
## Reporting
|
|
27
|
+
|
|
28
|
+
Until a public project contact is published, report serious conduct concerns
|
|
29
|
+
privately to the maintainer through the repository host once the project is
|
|
30
|
+
public.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for contributing to SyRAG.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
1. Install Python `3.12` or `3.13`.
|
|
8
|
+
2. Install dependencies with `uv sync`.
|
|
9
|
+
3. Run checks before opening a change:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
env UV_CACHE_DIR=/tmp/uv-cache uv run ruff check .
|
|
13
|
+
env UV_CACHE_DIR=/tmp/uv-cache uv run mypy .
|
|
14
|
+
env UV_CACHE_DIR=/tmp/uv-cache uv run pytest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Scope
|
|
18
|
+
|
|
19
|
+
Contributions should preserve these project constraints:
|
|
20
|
+
|
|
21
|
+
- keep the public framework surface explicit and typed
|
|
22
|
+
- avoid adding heavy provider-specific dependencies to the core package
|
|
23
|
+
- prefer small, well-tested changes over large speculative rewrites
|
|
24
|
+
|
|
25
|
+
## Pull requests
|
|
26
|
+
|
|
27
|
+
- include tests for behavior changes
|
|
28
|
+
- update docs when the public API or package behavior changes
|
|
29
|
+
- avoid unrelated refactors in the same change
|
|
30
|
+
- keep compatibility claims aligned with the actual tested runtime matrix
|
|
31
|
+
|
|
32
|
+
## Reporting issues
|
|
33
|
+
|
|
34
|
+
When reporting a bug, include:
|
|
35
|
+
|
|
36
|
+
- Python version
|
|
37
|
+
- installed extras, if any
|
|
38
|
+
- minimal reproduction steps
|
|
39
|
+
- expected behavior
|
|
40
|
+
- actual behavior
|
syrag-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abdelaziz Marzoug
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
syrag-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: syrag
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Production-oriented Python framework for building RAG services on top of FastAPI.
|
|
5
|
+
Project-URL: Repository, https://github.com/a-marzoug/syrag
|
|
6
|
+
Project-URL: Issues, https://github.com/a-marzoug/syrag/issues
|
|
7
|
+
Project-URL: Documentation, https://github.com/a-marzoug/syrag/tree/main/docs
|
|
8
|
+
Author: A. Marzoug
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,fastapi,llm,rag,retrieval-augmented-generation
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: FastAPI
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: <3.14,>=3.12
|
|
23
|
+
Requires-Dist: fastapi>=0.136.0
|
|
24
|
+
Requires-Dist: opentelemetry-api>=1.0.0
|
|
25
|
+
Requires-Dist: pydantic-settings>=2.13.1
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: chromadb>=1.0.0; extra == 'all'
|
|
28
|
+
Requires-Dist: httpx>=0.28.1; extra == 'all'
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.44.0; extra == 'all'
|
|
30
|
+
Provides-Extra: chroma
|
|
31
|
+
Requires-Dist: chromadb>=1.0.0; extra == 'chroma'
|
|
32
|
+
Provides-Extra: openai
|
|
33
|
+
Requires-Dist: httpx>=0.28.1; extra == 'openai'
|
|
34
|
+
Provides-Extra: server
|
|
35
|
+
Requires-Dist: uvicorn[standard]>=0.44.0; extra == 'server'
|
|
36
|
+
Provides-Extra: testing
|
|
37
|
+
Requires-Dist: httpx>=0.28.1; extra == 'testing'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# SyRAG
|
|
41
|
+
|
|
42
|
+
SyRAG is a production-oriented Python framework for building Retrieval-Augmented Generation services with a small, typed API on top of FastAPI.
|
|
43
|
+
|
|
44
|
+
Supported Python versions: `3.12` and `3.13`.
|
|
45
|
+
|
|
46
|
+
It currently ships:
|
|
47
|
+
|
|
48
|
+
- `SyRAG` application wrapper plus `create_app()`
|
|
49
|
+
- `@app.ingest(...)` and `@app.query(...)` decorators
|
|
50
|
+
- typed request and response schemas
|
|
51
|
+
- in-memory providers for local development
|
|
52
|
+
- Chroma vector store behind the `chroma` extra
|
|
53
|
+
- SQLite vector store in core and OpenAI providers behind the `openai` extra
|
|
54
|
+
- request context, auth hooks, tenant scoping, rate limiting, and safety guards
|
|
55
|
+
- OpenAPI docs, structured logging, and OpenTelemetry-compatible tracing
|
|
56
|
+
- a testing toolkit with fake providers and ASGI client helpers
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
Core package:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install syrag
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Optional integrations:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install "syrag[chroma]"
|
|
70
|
+
pip install "syrag[openai]"
|
|
71
|
+
pip install "syrag[testing]"
|
|
72
|
+
pip install "syrag[server]"
|
|
73
|
+
pip install "syrag[all]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start
|
|
77
|
+
|
|
78
|
+
Install the runtime integrations used in this example:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install "syrag[chroma,openai,server]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Set `OPENAI_API_KEY` in your environment before starting the app.
|
|
85
|
+
|
|
86
|
+
Create `main.py`:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import os
|
|
90
|
+
from pathlib import Path
|
|
91
|
+
|
|
92
|
+
from syrag import (
|
|
93
|
+
SyRAG,
|
|
94
|
+
ChromaVectorStore,
|
|
95
|
+
IngestRequest,
|
|
96
|
+
OpenAIEmbedder,
|
|
97
|
+
OpenAILLM,
|
|
98
|
+
QueryRequest,
|
|
99
|
+
Settings,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
app = SyRAG(
|
|
103
|
+
title="Support Bot",
|
|
104
|
+
version="0.1.0",
|
|
105
|
+
description="Internal support assistant",
|
|
106
|
+
settings=Settings(),
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
app.register_embedder(
|
|
110
|
+
"default",
|
|
111
|
+
OpenAIEmbedder(
|
|
112
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
113
|
+
model="text-embedding-3-small",
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
app.register_vector_store(
|
|
117
|
+
"default",
|
|
118
|
+
ChromaVectorStore(path=Path(".syrag/chroma"), collection_name="support_docs"),
|
|
119
|
+
)
|
|
120
|
+
app.register_llm(
|
|
121
|
+
"default",
|
|
122
|
+
OpenAILLM(api_key=os.environ["OPENAI_API_KEY"], model="gpt-4.1-mini"),
|
|
123
|
+
)
|
|
124
|
+
app.configure_defaults(
|
|
125
|
+
embedder="default",
|
|
126
|
+
vector_store="default",
|
|
127
|
+
llm="default",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@app.ingest("/ingest")
|
|
132
|
+
async def ingest(request: IngestRequest) -> IngestRequest:
|
|
133
|
+
return request
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@app.query("/query")
|
|
137
|
+
async def query(request: QueryRequest) -> QueryRequest:
|
|
138
|
+
return request
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Serve the app with any ASGI server. With the `server` extra installed:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uvicorn main:app.api --reload
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The framework exposes:
|
|
148
|
+
|
|
149
|
+
- `POST /ingest`
|
|
150
|
+
- `POST /query`
|
|
151
|
+
- `GET /health`
|
|
152
|
+
- OpenAPI docs at `/docs`
|
|
153
|
+
|
|
154
|
+
Ingest a document:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
curl -X POST http://127.0.0.1:8000/ingest \
|
|
158
|
+
-H "content-type: application/json" \
|
|
159
|
+
-d '{"documents":["SyRAG builds typed RAG services."],"collection":"demo"}'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Query it:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
curl -X POST http://127.0.0.1:8000/query \
|
|
166
|
+
-H "content-type: application/json" \
|
|
167
|
+
-d '{"query":"What does SyRAG build?","collection":"demo","top_k":1}'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Extension Points
|
|
171
|
+
|
|
172
|
+
SyRAG keeps the pipeline explicit. You can swap or extend:
|
|
173
|
+
|
|
174
|
+
- `Chunker`
|
|
175
|
+
- `Embedder`
|
|
176
|
+
- `VectorStore`
|
|
177
|
+
- `RetrievalStrategy`
|
|
178
|
+
- `PromptAssembler`
|
|
179
|
+
- `GenerationPolicy`
|
|
180
|
+
- `LLM`
|
|
181
|
+
- `RequestContextHook`
|
|
182
|
+
- `AuthHook`
|
|
183
|
+
- `RateLimiter`
|
|
184
|
+
- `SafetyGuard`
|
|
185
|
+
|
|
186
|
+
## First-Party Providers
|
|
187
|
+
|
|
188
|
+
Core:
|
|
189
|
+
|
|
190
|
+
- `InMemoryEmbedder`
|
|
191
|
+
- `InMemoryVectorStore`
|
|
192
|
+
- `InMemoryLLM`
|
|
193
|
+
- `PassThroughChunker`
|
|
194
|
+
- `SQLiteVectorStore`
|
|
195
|
+
|
|
196
|
+
Optional `chroma` extra:
|
|
197
|
+
|
|
198
|
+
- `ChromaVectorStore`
|
|
199
|
+
|
|
200
|
+
Optional `openai` extra:
|
|
201
|
+
|
|
202
|
+
- `OpenAIEmbedder`
|
|
203
|
+
- `OpenAILLM`
|
|
204
|
+
|
|
205
|
+
## Observability And Operations
|
|
206
|
+
|
|
207
|
+
SyRAG includes:
|
|
208
|
+
|
|
209
|
+
- structured error responses with stage information
|
|
210
|
+
- request-scoped `RequestContext` with request IDs and tenant IDs
|
|
211
|
+
- `StructuredLogging` and `JSONLogFormatter`
|
|
212
|
+
- `OpenTelemetryTracing` built on the OpenTelemetry API package
|
|
213
|
+
- request throttling via `InMemoryRateLimiter`
|
|
214
|
+
- payload validation via `DefaultSafetyGuard`
|
|
215
|
+
|
|
216
|
+
## Testing
|
|
217
|
+
|
|
218
|
+
Install the `testing` extra to use:
|
|
219
|
+
|
|
220
|
+
- `create_test_app(...)`
|
|
221
|
+
- `create_test_client(...)`
|
|
222
|
+
- `seed_documents(...)`
|
|
223
|
+
- fake providers such as `FakeEmbedder`, `FakeVectorStore`, and `FakeLLM`
|
|
224
|
+
|
|
225
|
+
## Docs
|
|
226
|
+
|
|
227
|
+
- [Docs index](docs/index.md)
|
|
228
|
+
- [Overview](docs/overview.md)
|
|
229
|
+
- [Architecture](docs/architecture.md)
|
|
230
|
+
- [Component contracts](docs/component-contracts.md)
|
|
231
|
+
- [Cookbook](docs/cookbook/index.md)
|
|
232
|
+
- [Provider examples](docs/provider-examples.md)
|
|
233
|
+
- [Releasing](docs/releasing.md)
|
|
234
|
+
- [MVP status](docs/mvp-roadmap.md)
|
|
235
|
+
|
|
236
|
+
## Examples
|
|
237
|
+
|
|
238
|
+
- [Minimal app](examples/minimal_app.py)
|
|
239
|
+
|
|
240
|
+
## Cookbook
|
|
241
|
+
|
|
242
|
+
- [Qdrant vector store pipeline](docs/cookbook/qdrant.md)
|
|
243
|
+
- [LangChain + Qdrant RAG](docs/cookbook/langchain.md)
|
|
244
|
+
- [LangChain agent with SyRAG tool](examples/integrations/langchain_syrag_agent.py)
|
|
245
|
+
- [LangGraph + SyRAG RAG workflow](docs/cookbook/langgraph.md)
|
|
246
|
+
- [LlamaIndex + Qdrant RAG](docs/cookbook/llamaindex.md)
|
|
247
|
+
|
|
248
|
+
Full example scripts live in [examples/integrations](examples/integrations).
|
syrag-0.1.0/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# SyRAG
|
|
2
|
+
|
|
3
|
+
SyRAG is a production-oriented Python framework for building Retrieval-Augmented Generation services with a small, typed API on top of FastAPI.
|
|
4
|
+
|
|
5
|
+
Supported Python versions: `3.12` and `3.13`.
|
|
6
|
+
|
|
7
|
+
It currently ships:
|
|
8
|
+
|
|
9
|
+
- `SyRAG` application wrapper plus `create_app()`
|
|
10
|
+
- `@app.ingest(...)` and `@app.query(...)` decorators
|
|
11
|
+
- typed request and response schemas
|
|
12
|
+
- in-memory providers for local development
|
|
13
|
+
- Chroma vector store behind the `chroma` extra
|
|
14
|
+
- SQLite vector store in core and OpenAI providers behind the `openai` extra
|
|
15
|
+
- request context, auth hooks, tenant scoping, rate limiting, and safety guards
|
|
16
|
+
- OpenAPI docs, structured logging, and OpenTelemetry-compatible tracing
|
|
17
|
+
- a testing toolkit with fake providers and ASGI client helpers
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Core package:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install syrag
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Optional integrations:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install "syrag[chroma]"
|
|
31
|
+
pip install "syrag[openai]"
|
|
32
|
+
pip install "syrag[testing]"
|
|
33
|
+
pip install "syrag[server]"
|
|
34
|
+
pip install "syrag[all]"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
Install the runtime integrations used in this example:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install "syrag[chroma,openai,server]"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Set `OPENAI_API_KEY` in your environment before starting the app.
|
|
46
|
+
|
|
47
|
+
Create `main.py`:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import os
|
|
51
|
+
from pathlib import Path
|
|
52
|
+
|
|
53
|
+
from syrag import (
|
|
54
|
+
SyRAG,
|
|
55
|
+
ChromaVectorStore,
|
|
56
|
+
IngestRequest,
|
|
57
|
+
OpenAIEmbedder,
|
|
58
|
+
OpenAILLM,
|
|
59
|
+
QueryRequest,
|
|
60
|
+
Settings,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
app = SyRAG(
|
|
64
|
+
title="Support Bot",
|
|
65
|
+
version="0.1.0",
|
|
66
|
+
description="Internal support assistant",
|
|
67
|
+
settings=Settings(),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
app.register_embedder(
|
|
71
|
+
"default",
|
|
72
|
+
OpenAIEmbedder(
|
|
73
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
74
|
+
model="text-embedding-3-small",
|
|
75
|
+
),
|
|
76
|
+
)
|
|
77
|
+
app.register_vector_store(
|
|
78
|
+
"default",
|
|
79
|
+
ChromaVectorStore(path=Path(".syrag/chroma"), collection_name="support_docs"),
|
|
80
|
+
)
|
|
81
|
+
app.register_llm(
|
|
82
|
+
"default",
|
|
83
|
+
OpenAILLM(api_key=os.environ["OPENAI_API_KEY"], model="gpt-4.1-mini"),
|
|
84
|
+
)
|
|
85
|
+
app.configure_defaults(
|
|
86
|
+
embedder="default",
|
|
87
|
+
vector_store="default",
|
|
88
|
+
llm="default",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@app.ingest("/ingest")
|
|
93
|
+
async def ingest(request: IngestRequest) -> IngestRequest:
|
|
94
|
+
return request
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@app.query("/query")
|
|
98
|
+
async def query(request: QueryRequest) -> QueryRequest:
|
|
99
|
+
return request
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Serve the app with any ASGI server. With the `server` extra installed:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
uvicorn main:app.api --reload
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The framework exposes:
|
|
109
|
+
|
|
110
|
+
- `POST /ingest`
|
|
111
|
+
- `POST /query`
|
|
112
|
+
- `GET /health`
|
|
113
|
+
- OpenAPI docs at `/docs`
|
|
114
|
+
|
|
115
|
+
Ingest a document:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
curl -X POST http://127.0.0.1:8000/ingest \
|
|
119
|
+
-H "content-type: application/json" \
|
|
120
|
+
-d '{"documents":["SyRAG builds typed RAG services."],"collection":"demo"}'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Query it:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
curl -X POST http://127.0.0.1:8000/query \
|
|
127
|
+
-H "content-type: application/json" \
|
|
128
|
+
-d '{"query":"What does SyRAG build?","collection":"demo","top_k":1}'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Extension Points
|
|
132
|
+
|
|
133
|
+
SyRAG keeps the pipeline explicit. You can swap or extend:
|
|
134
|
+
|
|
135
|
+
- `Chunker`
|
|
136
|
+
- `Embedder`
|
|
137
|
+
- `VectorStore`
|
|
138
|
+
- `RetrievalStrategy`
|
|
139
|
+
- `PromptAssembler`
|
|
140
|
+
- `GenerationPolicy`
|
|
141
|
+
- `LLM`
|
|
142
|
+
- `RequestContextHook`
|
|
143
|
+
- `AuthHook`
|
|
144
|
+
- `RateLimiter`
|
|
145
|
+
- `SafetyGuard`
|
|
146
|
+
|
|
147
|
+
## First-Party Providers
|
|
148
|
+
|
|
149
|
+
Core:
|
|
150
|
+
|
|
151
|
+
- `InMemoryEmbedder`
|
|
152
|
+
- `InMemoryVectorStore`
|
|
153
|
+
- `InMemoryLLM`
|
|
154
|
+
- `PassThroughChunker`
|
|
155
|
+
- `SQLiteVectorStore`
|
|
156
|
+
|
|
157
|
+
Optional `chroma` extra:
|
|
158
|
+
|
|
159
|
+
- `ChromaVectorStore`
|
|
160
|
+
|
|
161
|
+
Optional `openai` extra:
|
|
162
|
+
|
|
163
|
+
- `OpenAIEmbedder`
|
|
164
|
+
- `OpenAILLM`
|
|
165
|
+
|
|
166
|
+
## Observability And Operations
|
|
167
|
+
|
|
168
|
+
SyRAG includes:
|
|
169
|
+
|
|
170
|
+
- structured error responses with stage information
|
|
171
|
+
- request-scoped `RequestContext` with request IDs and tenant IDs
|
|
172
|
+
- `StructuredLogging` and `JSONLogFormatter`
|
|
173
|
+
- `OpenTelemetryTracing` built on the OpenTelemetry API package
|
|
174
|
+
- request throttling via `InMemoryRateLimiter`
|
|
175
|
+
- payload validation via `DefaultSafetyGuard`
|
|
176
|
+
|
|
177
|
+
## Testing
|
|
178
|
+
|
|
179
|
+
Install the `testing` extra to use:
|
|
180
|
+
|
|
181
|
+
- `create_test_app(...)`
|
|
182
|
+
- `create_test_client(...)`
|
|
183
|
+
- `seed_documents(...)`
|
|
184
|
+
- fake providers such as `FakeEmbedder`, `FakeVectorStore`, and `FakeLLM`
|
|
185
|
+
|
|
186
|
+
## Docs
|
|
187
|
+
|
|
188
|
+
- [Docs index](docs/index.md)
|
|
189
|
+
- [Overview](docs/overview.md)
|
|
190
|
+
- [Architecture](docs/architecture.md)
|
|
191
|
+
- [Component contracts](docs/component-contracts.md)
|
|
192
|
+
- [Cookbook](docs/cookbook/index.md)
|
|
193
|
+
- [Provider examples](docs/provider-examples.md)
|
|
194
|
+
- [Releasing](docs/releasing.md)
|
|
195
|
+
- [MVP status](docs/mvp-roadmap.md)
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
- [Minimal app](examples/minimal_app.py)
|
|
200
|
+
|
|
201
|
+
## Cookbook
|
|
202
|
+
|
|
203
|
+
- [Qdrant vector store pipeline](docs/cookbook/qdrant.md)
|
|
204
|
+
- [LangChain + Qdrant RAG](docs/cookbook/langchain.md)
|
|
205
|
+
- [LangChain agent with SyRAG tool](examples/integrations/langchain_syrag_agent.py)
|
|
206
|
+
- [LangGraph + SyRAG RAG workflow](docs/cookbook/langgraph.md)
|
|
207
|
+
- [LlamaIndex + Qdrant RAG](docs/cookbook/llamaindex.md)
|
|
208
|
+
|
|
209
|
+
Full example scripts live in [examples/integrations](examples/integrations).
|
syrag-0.1.0/SECURITY.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please do not open a public issue for suspected security vulnerabilities.
|
|
6
|
+
|
|
7
|
+
Until a dedicated security contact is published, report vulnerabilities
|
|
8
|
+
privately to the maintainer through the repository host once the project is
|
|
9
|
+
public.
|
|
10
|
+
|
|
11
|
+
When reporting a vulnerability, include:
|
|
12
|
+
|
|
13
|
+
- affected version
|
|
14
|
+
- impact summary
|
|
15
|
+
- reproduction steps or proof of concept
|
|
16
|
+
- any suggested mitigation if available
|
|
17
|
+
|
|
18
|
+
## Scope
|
|
19
|
+
|
|
20
|
+
Security reports are most useful when they affect:
|
|
21
|
+
|
|
22
|
+
- request authentication and authorization hooks
|
|
23
|
+
- tenant isolation
|
|
24
|
+
- provider request handling
|
|
25
|
+
- data leakage across query or ingest boundaries
|
|
26
|
+
- denial-of-service or resource exhaustion paths
|