sageLLM protocol types and validation (Protocol v0.1)
Project description
sagellm-protocol
Protocol Compliance (Mandatory)
- This repository defines Protocol v0.1 as the source of truth.
- Any globally shared definitions (fields, error codes, metrics, IDs, schemas) MUST be added here before use.
Type definitions and validation for sageLLM inference engine.
- Package:
isagellm-protocol - Import:
sagellm_protocol - Python: 3.10+
Installation
pip install isagellm-protocol
For development:
git clone git@github.com:intellistream/sagellm-protocol.git
cd sagellm-protocol
pip install -e ".[dev]"
Features
- Request/Response type definitions
- Streaming event types (start/delta/end)
- Performance metrics with validation
- Error types and error codes
- Timestamp tracking
- KV cache lifecycle hooks
- Pydantic v2 validation
Quick Start
from sagellm_protocol import Request, Response, Metrics, ErrorCode
# 创建请求
req = Request(
request_id="req-001",
trace_id="trace-001",
model="llama2-7b",
prompt="Hello, world!",
max_tokens=128,
stream=False,
temperature=0.7,
)
# 创建响应
metrics = Metrics(
ttft_ms=45.2,
tbt_ms=12.5,
throughput_tps=80.0,
peak_mem_mb=24576,
error_rate=0.0,
)
resp = Response(
request_id="req-001",
trace_id="trace-001",
output_text="Hi there!",
output_tokens=[42, 17],
finish_reason="stop",
metrics=metrics,
)
For more examples, see examples/basic_usage.py.
API Reference
Core Types
Request/Response- Request and response objectsMetrics- Performance metricsStreamEvent- Streaming event typesError/ErrorCode- Error handlingTimestamps- Timestamp trackingKVAllocateParams/KVHandle- KV cache management
Development
Run tests:
pytest tests/ -v
Format and lint:
ruff format .
ruff check . --fix
Type check:
mypy src/sagellm_protocol
Documentation
For more details:
License
Proprietary - IntelliStream
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
isagellm_protocol-0.4.0.1.tar.gz
(64.7 kB
view details)
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 isagellm_protocol-0.4.0.1.tar.gz.
File metadata
- Download URL: isagellm_protocol-0.4.0.1.tar.gz
- Upload date:
- Size: 64.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf5616859dbd5220996c690f88fd67f594b3852ac7b714e0412f396e87a94640
|
|
| MD5 |
6fc4d9de79b2f588454513defbe0c675
|
|
| BLAKE2b-256 |
a832a66b463d4c18d5c18b59ad311319fda92afb6680a6755c69c8f39d61545f
|
File details
Details for the file isagellm_protocol-0.4.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: isagellm_protocol-0.4.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 77.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee21fc993677e7a33e483df77cb899d952b484fa9b3848e9d4481ffb1dca8482
|
|
| MD5 |
24763ba515d3429778ca2faf539759eb
|
|
| BLAKE2b-256 |
8140ff395afa9be056fc3bbf8b87f2370783cdc449dc29177fb17b9626e8ad5a
|