SyntaxilitY PyPi Response Manager for FAST APIs, REST APIs, Machine Learning, Deep Learning and AI responses
Project description
SyntaxilitY PyPi Response Manager & Decorators
A Unified response manager and decorators for FAST APIs, REST APIs, Machine Learning, Deep Learning, and AI inference outputs.
Example for REST & FAST APIs:
from syntaxility_pypi_response_manager import (
SyntaxilitYPyPiResponseManager,
SyntaxilitYPagination
)
@app.get("/HTTP_200_OK", tags=["HTTP"])
def ok():
# try-catch block
try:
# Build pagination response
response = SyntaxilitYPagination.build_pagination_response(
metadata=[],
total=1,
page=1,
limit=1
)
return SyntaxilitYPyPiResponseManager.HTTP_200_OK(data=response, message="Data fetched successfully")
except Exception as e:
return SyntaxilitYPyPiResponseManager.HTTP_500_INTERNAL_SERVER_ERROR(message=str(e))
from syntaxility_pypi_response_manager import (
SyntaxilitYPyPiResponseManager,
SyntaxilitYPagination
)
@app.get("/HTTP_201_CREATED", tags=["HTTP"])
def created():
# try-catch block
try:
# Build pagination response
response = SyntaxilitYPagination.build_pagination_response(
metadata=[],
total=1,
page=1,
limit=1
)
return SyntaxilitYPyPiResponseManager.HTTP_201_CREATED(data=response, message="Data created successfully")
except Exception as e:
return SyntaxilitYPyPiResponseManager.HTTP_500_INTERNAL_SERVER_ERROR(message=str(e))
from syntaxility_pypi_response_manager import (
SyntaxilitYPyPiResponseManager,
SyntaxilitYPagination,
TryCatch
)
@app.get("/HTTP_201_CREATED", tags=["HTTP"])
# TryCatch is a decorator: will handle all the exceptions
# and return the appropriate response
@TryCatch
def created():
# Build pagination response
response = SyntaxilitYPagination.build_pagination_response(
metadata=[],
total=1,
page=1,
limit=1
)
return SyntaxilitYPyPiResponseManager.HTTP_201_CREATED(data=response, message="Data created successfully")
Example for ML:
ml_results = [
{"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("/ml-ok", tags=["ML"])
def ml_ok(page: int = Query(1, ge=1), limit: int = Query(2, ge=1)):
# Pagination params
pagination_params = SyntaxilitYPagination.get_pagination_params({"page": page, "limit": limit})
page, limit, skip = pagination_params["page"], pagination_params["limit"], pagination_params["skip"]
# Slice dataset
paginated_predictions = ml_results[skip: skip + limit]
# Build metadata including pagination info
metadata = {
"model": "test_model",
"version": "1.0",
"pagination": SyntaxilitYPagination.build_pagination_response(
metadata={},
total=len(ml_results),
page=page,
limit=limit
)["pagination"]
}
return SyntaxilitYPyPiResponseManager.ML_INFERENCE_OK(
predictions=paginated_predictions,
probabilities=None,
metadata=metadata,
message="Paginated ML inference results"
)
Licenses: MIT Free
Copyright (c) 2026 SyntaxilitY
Developer: Tariq Mehmood
"""
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syntaxility_pypi_response_manager-1.0.0.tar.gz.
File metadata
- Download URL: syntaxility_pypi_response_manager-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0f93e5c2c0334e9605af49432d0a615f5fc5263684f0af44a574b6b8989cfe3
|
|
| MD5 |
45d776859e9795229175dd5fe42b3123
|
|
| BLAKE2b-256 |
2e619af73c9d0be526f4b9049cfd4d9fb1467d3799a41948b7d8ff35c0255fda
|
File details
Details for the file syntaxility_pypi_response_manager-1.0.0-py3-none-any.whl.
File metadata
- Download URL: syntaxility_pypi_response_manager-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d31531aa5a62f7cc82a58be44660b2a2d3483cf8e32f3cb1a105492a76600478
|
|
| MD5 |
ff2bf76596cdfb15b918a451b0bc47aa
|
|
| BLAKE2b-256 |
4a16012ebb28a6f67d7239cf99093a8d886bb43e683bc2cebe4e2efd055cafc2
|