isagellm-protocol 0.1.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isagellm_protocol-0.1.2.4/MANIFEST.in +8 -0
- isagellm_protocol-0.1.2.4/PKG-INFO +137 -0
- isagellm_protocol-0.1.2.4/README.md +116 -0
- isagellm_protocol-0.1.2.4/pyproject.toml +94 -0
- isagellm_protocol-0.1.2.4/setup.cfg +4 -0
- isagellm_protocol-0.1.2.4/setup.py +9 -0
- isagellm_protocol-0.1.2.4/src/isagellm_protocol.egg-info/PKG-INFO +137 -0
- isagellm_protocol-0.1.2.4/src/isagellm_protocol.egg-info/SOURCES.txt +41 -0
- isagellm_protocol-0.1.2.4/src/isagellm_protocol.egg-info/dependency_links.txt +1 -0
- isagellm_protocol-0.1.2.4/src/isagellm_protocol.egg-info/requires.txt +8 -0
- isagellm_protocol-0.1.2.4/src/isagellm_protocol.egg-info/top_level.txt +1 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__init__.py +111 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__init__.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/__init__.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/backend_types.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/errors.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/kv_hooks.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/openai_types.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/timestamps.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/__pycache__/types.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/backend_types.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/errors.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__init__.py +86 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__init__.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__pycache__/__init__.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__pycache__/enums.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__pycache__/errors.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__pycache__/metrics.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/__pycache__/types.cpython-311.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/enums.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/errors.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/metrics.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv/types.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/kv_hooks.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/openai_types.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/py.typed +2 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/timestamps.pyc +0 -0
- isagellm_protocol-0.1.2.4/src/sagellm_protocol/types.pyc +0 -0
- isagellm_protocol-0.1.2.4/tests/test_errors.py +60 -0
- isagellm_protocol-0.1.2.4/tests/test_kv_hooks.py +150 -0
- isagellm_protocol-0.1.2.4/tests/test_openai_types.py +301 -0
- isagellm_protocol-0.1.2.4/tests/test_timestamps.py +68 -0
- isagellm_protocol-0.1.2.4/tests/test_types.py +386 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: isagellm-protocol
|
|
3
|
+
Version: 0.1.2.4
|
|
4
|
+
Summary: sageLLM protocol types and validation (Protocol v0.1)
|
|
5
|
+
Author: IntelliStream Team
|
|
6
|
+
License: Proprietary - IntelliStream
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Python: ==3.11.*
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: pydantic>=2.0.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.8.0; extra == "dev"
|
|
19
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
20
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
21
|
+
|
|
22
|
+
# sagellm-protocol
|
|
23
|
+
|
|
24
|
+
## Protocol Compliance (Mandatory)
|
|
25
|
+
|
|
26
|
+
- This repository defines Protocol v0.1 as the source of truth.
|
|
27
|
+
- Any globally shared definitions (fields, error codes, metrics, IDs, schemas) MUST be added here before use.
|
|
28
|
+
|
|
29
|
+
[](https://github.com/intellistream/sagellm-protocol/actions/workflows/ci.yml)
|
|
30
|
+
[](https://www.python.org/downloads/)
|
|
31
|
+
[](https://docs.pydantic.dev/2.0/)
|
|
32
|
+
[](docs/TESTING.md)
|
|
33
|
+
|
|
34
|
+
Type definitions and validation for sageLLM inference engine.
|
|
35
|
+
|
|
36
|
+
- **Package**: `isagellm-protocol`
|
|
37
|
+
- **Import**: `sagellm_protocol`
|
|
38
|
+
- **Python**: 3.10+
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install isagellm-protocol
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For development:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone git@github.com:intellistream/sagellm-protocol.git
|
|
50
|
+
cd sagellm-protocol
|
|
51
|
+
pip install -e ".[dev]"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- Request/Response type definitions
|
|
57
|
+
- Streaming event types (start/delta/end)
|
|
58
|
+
- Performance metrics with validation
|
|
59
|
+
- Error types and error codes
|
|
60
|
+
- Timestamp tracking
|
|
61
|
+
- KV cache lifecycle hooks
|
|
62
|
+
- Pydantic v2 validation
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from sagellm_protocol import Request, Response, Metrics, ErrorCode
|
|
68
|
+
|
|
69
|
+
# 创建请求
|
|
70
|
+
req = Request(
|
|
71
|
+
request_id="req-001",
|
|
72
|
+
trace_id="trace-001",
|
|
73
|
+
model="llama2-7b",
|
|
74
|
+
prompt="Hello, world!",
|
|
75
|
+
max_tokens=128,
|
|
76
|
+
stream=False,
|
|
77
|
+
temperature=0.7,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# 创建响应
|
|
81
|
+
metrics = Metrics(
|
|
82
|
+
ttft_ms=45.2,
|
|
83
|
+
tbt_ms=12.5,
|
|
84
|
+
throughput_tps=80.0,
|
|
85
|
+
peak_mem_mb=24576,
|
|
86
|
+
error_rate=0.0,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
resp = Response(
|
|
90
|
+
request_id="req-001",
|
|
91
|
+
trace_id="trace-001",
|
|
92
|
+
output_text="Hi there!",
|
|
93
|
+
output_tokens=[42, 17],
|
|
94
|
+
finish_reason="stop",
|
|
95
|
+
metrics=metrics,
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For more examples, see [examples/basic_usage.py](examples/basic_usage.py).
|
|
100
|
+
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### Core Types
|
|
104
|
+
- `Request` / `Response` - Request and response objects
|
|
105
|
+
- `Metrics` - Performance metrics
|
|
106
|
+
- `StreamEvent` - Streaming event types
|
|
107
|
+
- `Error` / `ErrorCode` - Error handling
|
|
108
|
+
- `Timestamps` - Timestamp tracking
|
|
109
|
+
- `KVAllocateParams` / `KVHandle` - KV cache management
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
Run tests:
|
|
114
|
+
```bash
|
|
115
|
+
pytest tests/ -v
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Format and lint:
|
|
119
|
+
```bash
|
|
120
|
+
ruff format .
|
|
121
|
+
ruff check . --fix
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Type check:
|
|
125
|
+
```bash
|
|
126
|
+
mypy src/sagellm_protocol
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Documentation
|
|
130
|
+
|
|
131
|
+
For more details:
|
|
132
|
+
- [Testing Guide](docs/TESTING.md)
|
|
133
|
+
- [Contributing Guidelines](CONTRIBUTING.md)
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
Proprietary - IntelliStream
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# sagellm-protocol
|
|
2
|
+
|
|
3
|
+
## Protocol Compliance (Mandatory)
|
|
4
|
+
|
|
5
|
+
- This repository defines Protocol v0.1 as the source of truth.
|
|
6
|
+
- Any globally shared definitions (fields, error codes, metrics, IDs, schemas) MUST be added here before use.
|
|
7
|
+
|
|
8
|
+
[](https://github.com/intellistream/sagellm-protocol/actions/workflows/ci.yml)
|
|
9
|
+
[](https://www.python.org/downloads/)
|
|
10
|
+
[](https://docs.pydantic.dev/2.0/)
|
|
11
|
+
[](docs/TESTING.md)
|
|
12
|
+
|
|
13
|
+
Type definitions and validation for sageLLM inference engine.
|
|
14
|
+
|
|
15
|
+
- **Package**: `isagellm-protocol`
|
|
16
|
+
- **Import**: `sagellm_protocol`
|
|
17
|
+
- **Python**: 3.10+
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install isagellm-protocol
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For development:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone git@github.com:intellistream/sagellm-protocol.git
|
|
29
|
+
cd sagellm-protocol
|
|
30
|
+
pip install -e ".[dev]"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- Request/Response type definitions
|
|
36
|
+
- Streaming event types (start/delta/end)
|
|
37
|
+
- Performance metrics with validation
|
|
38
|
+
- Error types and error codes
|
|
39
|
+
- Timestamp tracking
|
|
40
|
+
- KV cache lifecycle hooks
|
|
41
|
+
- Pydantic v2 validation
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from sagellm_protocol import Request, Response, Metrics, ErrorCode
|
|
47
|
+
|
|
48
|
+
# 创建请求
|
|
49
|
+
req = Request(
|
|
50
|
+
request_id="req-001",
|
|
51
|
+
trace_id="trace-001",
|
|
52
|
+
model="llama2-7b",
|
|
53
|
+
prompt="Hello, world!",
|
|
54
|
+
max_tokens=128,
|
|
55
|
+
stream=False,
|
|
56
|
+
temperature=0.7,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# 创建响应
|
|
60
|
+
metrics = Metrics(
|
|
61
|
+
ttft_ms=45.2,
|
|
62
|
+
tbt_ms=12.5,
|
|
63
|
+
throughput_tps=80.0,
|
|
64
|
+
peak_mem_mb=24576,
|
|
65
|
+
error_rate=0.0,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
resp = Response(
|
|
69
|
+
request_id="req-001",
|
|
70
|
+
trace_id="trace-001",
|
|
71
|
+
output_text="Hi there!",
|
|
72
|
+
output_tokens=[42, 17],
|
|
73
|
+
finish_reason="stop",
|
|
74
|
+
metrics=metrics,
|
|
75
|
+
)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For more examples, see [examples/basic_usage.py](examples/basic_usage.py).
|
|
79
|
+
|
|
80
|
+
## API Reference
|
|
81
|
+
|
|
82
|
+
### Core Types
|
|
83
|
+
- `Request` / `Response` - Request and response objects
|
|
84
|
+
- `Metrics` - Performance metrics
|
|
85
|
+
- `StreamEvent` - Streaming event types
|
|
86
|
+
- `Error` / `ErrorCode` - Error handling
|
|
87
|
+
- `Timestamps` - Timestamp tracking
|
|
88
|
+
- `KVAllocateParams` / `KVHandle` - KV cache management
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
Run tests:
|
|
93
|
+
```bash
|
|
94
|
+
pytest tests/ -v
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Format and lint:
|
|
98
|
+
```bash
|
|
99
|
+
ruff format .
|
|
100
|
+
ruff check . --fix
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Type check:
|
|
104
|
+
```bash
|
|
105
|
+
mypy src/sagellm_protocol
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
For more details:
|
|
111
|
+
- [Testing Guide](docs/TESTING.md)
|
|
112
|
+
- [Contributing Guidelines](CONTRIBUTING.md)
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
Proprietary - IntelliStream
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel", "packaging>=24.2"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "isagellm-protocol"
|
|
7
|
+
version = "0.1.2.4"
|
|
8
|
+
description = "sageLLM protocol types and validation (Protocol v0.1)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = "==3.11.*"
|
|
11
|
+
authors = [{ name = "IntelliStream Team" }]
|
|
12
|
+
license = { text = "Proprietary - IntelliStream" }
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"pydantic>=2.0.0",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = [
|
|
26
|
+
"pytest>=7.0.0",
|
|
27
|
+
"pytest-cov>=4.0.0",
|
|
28
|
+
"ruff>=0.8.0",
|
|
29
|
+
"mypy>=1.0.0",
|
|
30
|
+
"pre-commit>=3.0.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
package-dir = {"" = "src"}
|
|
35
|
+
include-package-data = true
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["src"]
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.package-data]
|
|
41
|
+
sagellm_protocol = ["py.typed"]
|
|
42
|
+
"*" = ["*.pyc", "*.pyo", "__pycache__/*", "*.so", "*.pyd", "*.dylib"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
line-length = 100
|
|
46
|
+
target-version = "py310"
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = [
|
|
50
|
+
"E", # pycodestyle errors
|
|
51
|
+
"W", # pycodestyle warnings
|
|
52
|
+
"F", # pyflakes
|
|
53
|
+
"I", # isort
|
|
54
|
+
"B", # flake8-bugbear
|
|
55
|
+
"C4", # flake8-comprehensions
|
|
56
|
+
"UP", # pyupgrade
|
|
57
|
+
"ARG", # flake8-unused-arguments
|
|
58
|
+
"SIM", # flake8-simplify
|
|
59
|
+
]
|
|
60
|
+
ignore = [
|
|
61
|
+
"E501", # line too long (handled by formatter)
|
|
62
|
+
"B008", # function-call-in-default-argument (Pydantic uses Field())
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint.isort]
|
|
66
|
+
known-first-party = ["sagellm_protocol"]
|
|
67
|
+
|
|
68
|
+
[tool.mypy]
|
|
69
|
+
python_version = "3.10"
|
|
70
|
+
strict = true
|
|
71
|
+
show_error_codes = true
|
|
72
|
+
explicit_package_bases = true
|
|
73
|
+
plugins = ["pydantic.mypy"]
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
minversion = "7.0"
|
|
77
|
+
testpaths = ["tests"]
|
|
78
|
+
addopts = "-v --strict-markers"
|
|
79
|
+
markers = [
|
|
80
|
+
"unit: Unit tests",
|
|
81
|
+
"integration: Integration tests",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.coverage.run]
|
|
85
|
+
source = ["sagellm_protocol"]
|
|
86
|
+
branch = true
|
|
87
|
+
|
|
88
|
+
[tool.coverage.report]
|
|
89
|
+
exclude_lines = [
|
|
90
|
+
"pragma: no cover",
|
|
91
|
+
"if TYPE_CHECKING:",
|
|
92
|
+
"raise NotImplementedError",
|
|
93
|
+
"@abstractmethod",
|
|
94
|
+
]
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: isagellm-protocol
|
|
3
|
+
Version: 0.1.2.4
|
|
4
|
+
Summary: sageLLM protocol types and validation (Protocol v0.1)
|
|
5
|
+
Author: IntelliStream Team
|
|
6
|
+
License: Proprietary - IntelliStream
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Requires-Python: ==3.11.*
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Requires-Dist: pydantic>=2.0.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.8.0; extra == "dev"
|
|
19
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
20
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
21
|
+
|
|
22
|
+
# sagellm-protocol
|
|
23
|
+
|
|
24
|
+
## Protocol Compliance (Mandatory)
|
|
25
|
+
|
|
26
|
+
- This repository defines Protocol v0.1 as the source of truth.
|
|
27
|
+
- Any globally shared definitions (fields, error codes, metrics, IDs, schemas) MUST be added here before use.
|
|
28
|
+
|
|
29
|
+
[](https://github.com/intellistream/sagellm-protocol/actions/workflows/ci.yml)
|
|
30
|
+
[](https://www.python.org/downloads/)
|
|
31
|
+
[](https://docs.pydantic.dev/2.0/)
|
|
32
|
+
[](docs/TESTING.md)
|
|
33
|
+
|
|
34
|
+
Type definitions and validation for sageLLM inference engine.
|
|
35
|
+
|
|
36
|
+
- **Package**: `isagellm-protocol`
|
|
37
|
+
- **Import**: `sagellm_protocol`
|
|
38
|
+
- **Python**: 3.10+
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install isagellm-protocol
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For development:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone git@github.com:intellistream/sagellm-protocol.git
|
|
50
|
+
cd sagellm-protocol
|
|
51
|
+
pip install -e ".[dev]"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- Request/Response type definitions
|
|
57
|
+
- Streaming event types (start/delta/end)
|
|
58
|
+
- Performance metrics with validation
|
|
59
|
+
- Error types and error codes
|
|
60
|
+
- Timestamp tracking
|
|
61
|
+
- KV cache lifecycle hooks
|
|
62
|
+
- Pydantic v2 validation
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from sagellm_protocol import Request, Response, Metrics, ErrorCode
|
|
68
|
+
|
|
69
|
+
# 创建请求
|
|
70
|
+
req = Request(
|
|
71
|
+
request_id="req-001",
|
|
72
|
+
trace_id="trace-001",
|
|
73
|
+
model="llama2-7b",
|
|
74
|
+
prompt="Hello, world!",
|
|
75
|
+
max_tokens=128,
|
|
76
|
+
stream=False,
|
|
77
|
+
temperature=0.7,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# 创建响应
|
|
81
|
+
metrics = Metrics(
|
|
82
|
+
ttft_ms=45.2,
|
|
83
|
+
tbt_ms=12.5,
|
|
84
|
+
throughput_tps=80.0,
|
|
85
|
+
peak_mem_mb=24576,
|
|
86
|
+
error_rate=0.0,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
resp = Response(
|
|
90
|
+
request_id="req-001",
|
|
91
|
+
trace_id="trace-001",
|
|
92
|
+
output_text="Hi there!",
|
|
93
|
+
output_tokens=[42, 17],
|
|
94
|
+
finish_reason="stop",
|
|
95
|
+
metrics=metrics,
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For more examples, see [examples/basic_usage.py](examples/basic_usage.py).
|
|
100
|
+
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### Core Types
|
|
104
|
+
- `Request` / `Response` - Request and response objects
|
|
105
|
+
- `Metrics` - Performance metrics
|
|
106
|
+
- `StreamEvent` - Streaming event types
|
|
107
|
+
- `Error` / `ErrorCode` - Error handling
|
|
108
|
+
- `Timestamps` - Timestamp tracking
|
|
109
|
+
- `KVAllocateParams` / `KVHandle` - KV cache management
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
Run tests:
|
|
114
|
+
```bash
|
|
115
|
+
pytest tests/ -v
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Format and lint:
|
|
119
|
+
```bash
|
|
120
|
+
ruff format .
|
|
121
|
+
ruff check . --fix
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Type check:
|
|
125
|
+
```bash
|
|
126
|
+
mypy src/sagellm_protocol
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Documentation
|
|
130
|
+
|
|
131
|
+
For more details:
|
|
132
|
+
- [Testing Guide](docs/TESTING.md)
|
|
133
|
+
- [Contributing Guidelines](CONTRIBUTING.md)
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
Proprietary - IntelliStream
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/isagellm_protocol.egg-info/PKG-INFO
|
|
6
|
+
src/isagellm_protocol.egg-info/SOURCES.txt
|
|
7
|
+
src/isagellm_protocol.egg-info/dependency_links.txt
|
|
8
|
+
src/isagellm_protocol.egg-info/requires.txt
|
|
9
|
+
src/isagellm_protocol.egg-info/top_level.txt
|
|
10
|
+
src/sagellm_protocol/__init__.py
|
|
11
|
+
src/sagellm_protocol/__init__.pyc
|
|
12
|
+
src/sagellm_protocol/backend_types.pyc
|
|
13
|
+
src/sagellm_protocol/errors.pyc
|
|
14
|
+
src/sagellm_protocol/kv_hooks.pyc
|
|
15
|
+
src/sagellm_protocol/openai_types.pyc
|
|
16
|
+
src/sagellm_protocol/py.typed
|
|
17
|
+
src/sagellm_protocol/timestamps.pyc
|
|
18
|
+
src/sagellm_protocol/types.pyc
|
|
19
|
+
src/sagellm_protocol/__pycache__/__init__.cpython-311.pyc
|
|
20
|
+
src/sagellm_protocol/__pycache__/backend_types.cpython-311.pyc
|
|
21
|
+
src/sagellm_protocol/__pycache__/errors.cpython-311.pyc
|
|
22
|
+
src/sagellm_protocol/__pycache__/kv_hooks.cpython-311.pyc
|
|
23
|
+
src/sagellm_protocol/__pycache__/openai_types.cpython-311.pyc
|
|
24
|
+
src/sagellm_protocol/__pycache__/timestamps.cpython-311.pyc
|
|
25
|
+
src/sagellm_protocol/__pycache__/types.cpython-311.pyc
|
|
26
|
+
src/sagellm_protocol/kv/__init__.py
|
|
27
|
+
src/sagellm_protocol/kv/__init__.pyc
|
|
28
|
+
src/sagellm_protocol/kv/enums.pyc
|
|
29
|
+
src/sagellm_protocol/kv/errors.pyc
|
|
30
|
+
src/sagellm_protocol/kv/metrics.pyc
|
|
31
|
+
src/sagellm_protocol/kv/types.pyc
|
|
32
|
+
src/sagellm_protocol/kv/__pycache__/__init__.cpython-311.pyc
|
|
33
|
+
src/sagellm_protocol/kv/__pycache__/enums.cpython-311.pyc
|
|
34
|
+
src/sagellm_protocol/kv/__pycache__/errors.cpython-311.pyc
|
|
35
|
+
src/sagellm_protocol/kv/__pycache__/metrics.cpython-311.pyc
|
|
36
|
+
src/sagellm_protocol/kv/__pycache__/types.cpython-311.pyc
|
|
37
|
+
tests/test_errors.py
|
|
38
|
+
tests/test_kv_hooks.py
|
|
39
|
+
tests/test_openai_types.py
|
|
40
|
+
tests/test_timestamps.py
|
|
41
|
+
tests/test_types.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sagellm_protocol
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""sageLLM Protocol v0.1 类型定义。
|
|
2
|
+
|
|
3
|
+
本包提供 sageLLM 的公共契约类型,包括:
|
|
4
|
+
- 请求/响应类型
|
|
5
|
+
- Stream 事件类型
|
|
6
|
+
- 指标和错误类型
|
|
7
|
+
- Backend 能力类型(DType, KernelKind, CapabilityDescriptor)
|
|
8
|
+
- KV 生命周期钩子类型
|
|
9
|
+
- OpenAI 兼容类型(供 Gateway 使用)
|
|
10
|
+
|
|
11
|
+
所有类型定义严格遵循 Protocol v0.1 规范。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from sagellm_protocol.backend_types import CapabilityDescriptor, DType, KernelKind
|
|
17
|
+
from sagellm_protocol.errors import Error, ErrorCode
|
|
18
|
+
from sagellm_protocol.kv_hooks import (
|
|
19
|
+
KVAllocateParams,
|
|
20
|
+
KVDType,
|
|
21
|
+
KVEvictReason,
|
|
22
|
+
KVHandle,
|
|
23
|
+
KVLayout,
|
|
24
|
+
KVMigrateParams,
|
|
25
|
+
)
|
|
26
|
+
from sagellm_protocol.openai_types import (
|
|
27
|
+
ChatCompletionChoice,
|
|
28
|
+
ChatCompletionRequest,
|
|
29
|
+
ChatCompletionResponse,
|
|
30
|
+
ChatCompletionStreamChoice,
|
|
31
|
+
ChatCompletionStreamDelta,
|
|
32
|
+
ChatCompletionStreamResponse,
|
|
33
|
+
ChatCompletionUsage,
|
|
34
|
+
ChatMessage,
|
|
35
|
+
EmbeddingData,
|
|
36
|
+
EmbeddingRequest,
|
|
37
|
+
EmbeddingResponse,
|
|
38
|
+
EmbeddingUsage,
|
|
39
|
+
ModelInfo,
|
|
40
|
+
ModelListResponse,
|
|
41
|
+
OpenAIError,
|
|
42
|
+
OpenAIErrorResponse,
|
|
43
|
+
)
|
|
44
|
+
from sagellm_protocol.timestamps import Timestamps
|
|
45
|
+
from sagellm_protocol.types import (
|
|
46
|
+
Metrics,
|
|
47
|
+
Request,
|
|
48
|
+
Response,
|
|
49
|
+
StreamEvent,
|
|
50
|
+
StreamEventDelta,
|
|
51
|
+
StreamEventEnd,
|
|
52
|
+
StreamEventStart,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# 别名,用于向后兼容
|
|
56
|
+
StartEvent = StreamEventStart
|
|
57
|
+
DeltaEvent = StreamEventDelta
|
|
58
|
+
EndEvent = StreamEventEnd
|
|
59
|
+
|
|
60
|
+
__version__ = "0.1.2.4"
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
# Version
|
|
64
|
+
"__version__",
|
|
65
|
+
# Core types
|
|
66
|
+
"Request",
|
|
67
|
+
"Response",
|
|
68
|
+
"Metrics",
|
|
69
|
+
# Streaming
|
|
70
|
+
"StreamEvent",
|
|
71
|
+
"StreamEventStart",
|
|
72
|
+
"StreamEventDelta",
|
|
73
|
+
"StreamEventEnd",
|
|
74
|
+
# Streaming aliases
|
|
75
|
+
"StartEvent",
|
|
76
|
+
"DeltaEvent",
|
|
77
|
+
"EndEvent",
|
|
78
|
+
# Errors
|
|
79
|
+
"Error",
|
|
80
|
+
"ErrorCode",
|
|
81
|
+
# Observability
|
|
82
|
+
"Timestamps",
|
|
83
|
+
# Backend types
|
|
84
|
+
"DType",
|
|
85
|
+
"KernelKind",
|
|
86
|
+
"CapabilityDescriptor",
|
|
87
|
+
# KV hooks
|
|
88
|
+
"KVDType",
|
|
89
|
+
"KVLayout",
|
|
90
|
+
"KVAllocateParams",
|
|
91
|
+
"KVHandle",
|
|
92
|
+
"KVEvictReason",
|
|
93
|
+
"KVMigrateParams",
|
|
94
|
+
# OpenAI-compatible types (for Gateway)
|
|
95
|
+
"ChatMessage",
|
|
96
|
+
"ChatCompletionRequest",
|
|
97
|
+
"ChatCompletionResponse",
|
|
98
|
+
"ChatCompletionChoice",
|
|
99
|
+
"ChatCompletionUsage",
|
|
100
|
+
"ChatCompletionStreamResponse",
|
|
101
|
+
"ChatCompletionStreamChoice",
|
|
102
|
+
"ChatCompletionStreamDelta",
|
|
103
|
+
"EmbeddingRequest",
|
|
104
|
+
"EmbeddingResponse",
|
|
105
|
+
"EmbeddingData",
|
|
106
|
+
"EmbeddingUsage",
|
|
107
|
+
"ModelInfo",
|
|
108
|
+
"ModelListResponse",
|
|
109
|
+
"OpenAIError",
|
|
110
|
+
"OpenAIErrorResponse",
|
|
111
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|