Skip to main content

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.

CI Python Pydantic v2 Code Coverage

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 objects
  • Metrics - Performance metrics
  • StreamEvent - Streaming event types
  • Error / ErrorCode - Error handling
  • Timestamps - Timestamp tracking
  • KVAllocateParams / 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


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.3.0.tar.gz (64.3 kB view details)

Uploaded Source

Built Distributions

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

isagellm_protocol-0.3.0.0-py2.py3-none-any.whl (76.7 kB view details)

Uploaded Python 2Python 3

isagellm_protocol-0.3.0-py2.py3-none-any.whl (76.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file isagellm_protocol-0.3.0.tar.gz.

File metadata

  • Download URL: isagellm_protocol-0.3.0.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for isagellm_protocol-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d16b772afacfb4ed700ea84d6cd42e7c171eef498019a661570300811d0a2ce3
MD5 ebd00c7a7c9060fb00388141811196c1
BLAKE2b-256 bb67d734597eb518a984d3d925c3628573a9ab9015030619511aab224769ba3c

See more details on using hashes here.

File details

Details for the file isagellm_protocol-0.3.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for isagellm_protocol-0.3.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c4396aca787499823ab0dc3ce8709b0bacfa1962347ae44ea30fd52f6eefcbc1
MD5 afd6180e584eb6632b50198ea690ac49
BLAKE2b-256 549e2e304dc880aea2fdae0ec4aac4e5bd04690bf3cb4aeebc09dc5653b43b3f

See more details on using hashes here.

File details

Details for the file isagellm_protocol-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for isagellm_protocol-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f8418ba59adce06871416377e5ab718fdf5b29c8ca34d37d81abac8ad9414fa0
MD5 6bc2e2604e218b35163de6f07010b18d
BLAKE2b-256 66b74eca9afc736b30a86a1b1b71a91d16f1232ae627cdbe7580199e668537d2

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