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

🔄 贡献指南

请遵循以下工作流程:

  1. 创建 Issue - 描述问题/需求

    gh issue create --title "[Bug] 描述" --label "bug,sagellm-protocol"
    
  2. 开发修复 - 在本地 fix/#123-xxx 分支解决

    git checkout -b fix/#123-xxx origin/main-dev
    # 开发、测试...
    pytest -v
    ruff format . && ruff check . --fix
    
  3. 发起 PR - 提交到 main-dev 分支

    gh pr create --base main-dev --title "Fix: 描述" --body "Closes #123"
    
  4. 合并 - 审批后合并到 main-dev

更多详情见 .github/copilot-instructions.md

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

Uploaded Source

Built Distribution

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

isagellm_protocol-0.4.0.7-py2.py3-none-any.whl (87.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for isagellm_protocol-0.4.0.7.tar.gz
Algorithm Hash digest
SHA256 c5efde6382a25813f3c708b0c1165d9575a815d85658a2a2a21dca9d9375f33f
MD5 03c64de3377b15a00ad7051d1601f8f7
BLAKE2b-256 f0bae5f170662fb7af860f543039e4c3592c416ce91285b7340954edee545016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isagellm_protocol-0.4.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9cc8486767f8b950d0824e2fc67b3b0d7b2b2f3e3d7a706769d7ce954b80f80f
MD5 09d5d149cc729c865ec34ae18350a9d8
BLAKE2b-256 af29b8eea227c87273cef39f8e68e981bdfa198d7ce66a595518344dfcef0bde

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