Skip to main content

SyntaxilitY Response Manager for FastAPI, Flask, Django, Machine Learning, Deep Learning and Artificial Intelligence responses, and powerful decorators.

Project description

SyntaxilitY Response Manager

A unified response manager and decorators for FastAPI, Flask, Django, Machine Learning, Deep Learning, and AI inference outputs.


Installation

# FastAPI
pip install syntaxility-response-manager[fastapi]

# Flask
pip install syntaxility-response-manager[flask]

# Django / DRF
pip install syntaxility-response-manager[django]

# ML / NumPy extras
pip install syntaxility-response-manager[ml]

# Everything
pip install syntaxility-response-manager[all]

FastAPI Examples

HTTP 200 OK

from fastapi import FastAPI
from syntaxility_response_manager import SyntaxilitYResponseManager, SyntaxilitYPagination

app = FastAPI()

@app.get("/users", tags=["HTTP"])
def list_users():
    try:
        response = SyntaxilitYPagination.build_pagination_response(
            metadata=[],
            total=1,
            page=1,
            limit=10,
        )
        return SyntaxilitYResponseManager.HTTP_200_OK(
            data=response,
            message="Users fetched successfully",
        )
    except Exception as e:
        return SyntaxilitYResponseManager.HTTP_500_INTERNAL_SERVER_ERROR(
            message=str(e)
        )

HTTP 201 Created with @TryCatch

from syntaxility_response_manager import SyntaxilitYResponseManager, TryCatch

@app.post("/users", tags=["HTTP"])
@TryCatch
def create_user():
    return SyntaxilitYResponseManager.HTTP_201_CREATED(
        data={"id": 1, "name": "Alice"},
        message="User created successfully",
    )

Flask Examples

from flask import Flask
from syntaxility_response_manager import SyntaxilitYResponseManager, TryCatch

app = Flask(__name__)

@app.route("/users")
@TryCatch
def list_users():
    return SyntaxilitYResponseManager.HTTP_200_OK(
        data={"users": []},
        message="Users fetched",
    )

Django Examples

# views.py
from syntaxility_response_manager import SyntaxilitYResponseManager, TryCatch

@TryCatch
def list_users(request):
    return SyntaxilitYResponseManager.HTTP_200_OK(
        data={"users": []},
        message="Users fetched",
    )

ML / AI Examples

Paginated ML Inference

from fastapi import FastAPI, Query
from syntaxility_response_manager import SyntaxilitYResponseManager, SyntaxilitYPagination

app  = FastAPI()
data = [
    {"input": [1, 2],  "prediction": 0},
    {"input": [3, 4],  "prediction": 1},
    {"input": [5, 6],  "prediction": 1},
    {"input": [7, 8],  "prediction": 0},
    {"input": [9, 10], "prediction": 1},
]

@app.post("/predict", tags=["ML"])
def predict(page: int = Query(1, ge=1), limit: int = Query(2, ge=1)):
    params  = SyntaxilitYPagination.get_pagination_params(
        {"page": page, "limit": limit}
    )
    page, limit, skip = params["page"], params["limit"], params["skip"]
    batch  = data[skip: skip + limit]
    paging = SyntaxilitYPagination.build_pagination_response(
        metadata={}, total=len(data), page=page, limit=limit
    )
    return SyntaxilitYResponseManager.ML_INFERENCE_OK(
        predictions=batch,
        metadata={"model": "clf_v1", "version": "1.0", "pagination": paging["pagination"]},
        message="Paginated inference results",
    )

ML Error Responses

SyntaxilitYResponseManager.ML_INFERENCE_FAILED(message="GPU OOM")
SyntaxilitYResponseManager.ML_INFERENCE_PARTIAL(predictions=[0, None, 1])
SyntaxilitYResponseManager.ML_MODEL_NOT_FOUND(message="Model 'clf_v3' not found")
SyntaxilitYResponseManager.ML_INVALID_INPUT(message="Expected shape (N, 4), got (N, 3)")

Using Individual Services Directly

from syntaxility_response_manager.services import (
    FastAPIResponseService,
    FlaskResponseService,
    DjangoResponseService,
    MLResponseService,
)

# FastAPI
fastapi_svc = FastAPIResponseService()
fastapi_svc.HTTP_200_OK(data={...})

# Flask
flask_svc = FlaskResponseService()
flask_svc.HTTP_404_NOT_FOUND(message="Item not found")

# Django
django_svc = DjangoResponseService()
django_svc.HTTP_201_CREATED(data={...})

# ML
ml_svc = MLResponseService()
ml_svc.ML_INFERENCE_OK(predictions=[0, 1, 1])

License

MIT — Copyright © 2026 SyntaxilitY

Developer: Tariq Mehmood
GitHub: SyntaxilitY
LinkedIn: Tariq Mehmood

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

syntaxility_response_manager-2.0.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

syntaxility_response_manager-2.0.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file syntaxility_response_manager-2.0.0.tar.gz.

File metadata

File hashes

Hashes for syntaxility_response_manager-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0eccebfc44902a564fb069eefceadde2012877fb2aa8ccc962dcfaede65cc95b
MD5 e09d1fc6206d868410976f0464d3d890
BLAKE2b-256 bbf33b7ecf1387c86c73dde98955633641085086d448d6129fa9e0ec2bff8546

See more details on using hashes here.

File details

Details for the file syntaxility_response_manager-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for syntaxility_response_manager-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff21d7525287268bb6b743b8e3a344a3a39f977dec22637189124522c8961f97
MD5 d9ab8a34bf0e5efb4edb9ec6cbbe7501
BLAKE2b-256 e42519c6623445b5ec472f10385ad9184f8faf68abe2704af345eabef41c1e64

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