isagellm-core 0.1.0.2__cp311-none-any.whl → 0.2.0.0__cp311-none-any.whl
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_core-0.1.0.2.dist-info → isagellm_core-0.2.0.0.dist-info}/METADATA +75 -105
- isagellm_core-0.2.0.0.dist-info/RECORD +42 -0
- sagellm_core/__init__.py +45 -4
- sagellm_core/__init__.pyc +0 -0
- sagellm_core/__pycache__/__init__.cpython-311.pyc +0 -0
- sagellm_core/__pycache__/base_engine.cpython-311.pyc +0 -0
- sagellm_core/__pycache__/engine.cpython-311.pyc +0 -0
- sagellm_core/__pycache__/engine_factory.cpython-311.pyc +0 -0
- sagellm_core/base_engine.pyc +0 -0
- sagellm_core/engine.pyc +0 -0
- sagellm_core/engine_factory.pyc +0 -0
- sagellm_core/engines/__init__.py +37 -2
- sagellm_core/engines/__init__.pyc +0 -0
- sagellm_core/engines/__pycache__/__init__.cpython-311.pyc +0 -0
- sagellm_core/engines/__pycache__/cpu.cpython-311.pyc +0 -0
- sagellm_core/engines/__pycache__/embedding.cpython-311.pyc +0 -0
- sagellm_core/engines/__pycache__/hf_cuda.cpython-311.pyc +0 -0
- sagellm_core/engines/__pycache__/mock.cpython-311.pyc +0 -0
- sagellm_core/engines/cpu.pyc +0 -0
- sagellm_core/engines/embedding.pyc +0 -0
- sagellm_core/engines/hf_cuda.pyc +0 -0
- sagellm_core/engines/mock.pyc +0 -0
- isagellm_core-0.1.0.2.dist-info/RECORD +0 -32
- {isagellm_core-0.1.0.2.dist-info → isagellm_core-0.2.0.0.dist-info}/WHEEL +0 -0
- {isagellm_core-0.1.0.2.dist-info → isagellm_core-0.2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: isagellm-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0.0
|
|
4
4
|
Summary: sageLLM core runtime (config/observability/registries), plugin-ready
|
|
5
5
|
Author: IntelliStream Team
|
|
6
6
|
License: Proprietary - IntelliStream
|
|
@@ -14,7 +14,7 @@ Description-Content-Type: text/markdown
|
|
|
14
14
|
Requires-Dist: pydantic>=2.0.0
|
|
15
15
|
Requires-Dist: pyyaml>=6.0.0
|
|
16
16
|
Requires-Dist: isagellm-protocol<0.2.0,>=0.1.0
|
|
17
|
-
Requires-Dist: isagellm-backend<0.
|
|
17
|
+
Requires-Dist: isagellm-backend<0.3.0,>=0.2.0.0
|
|
18
18
|
Provides-Extra: dev
|
|
19
19
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
20
20
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -32,23 +32,50 @@ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
|
32
32
|
[](https://github.com/intellistream/sagellm-core/blob/main/LICENSE)
|
|
33
33
|
[](https://github.com/astral-sh/ruff)
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
sageLLM Core - 引擎协调层与运行时系统
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
- PyPI 包名:`isagellm-core`
|
|
39
|
-
- import 名:`sagellm_core`
|
|
37
|
+
## 架构定位
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
```
|
|
40
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
41
|
+
│ sagellm-core (引擎协调层) ← 本仓库 │
|
|
42
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
43
|
+
│ │ Engine Abstraction (BaseEngine, EngineFactory) │ │
|
|
44
|
+
│ │ • MockEngine, CPUEngine, HFCudaEngine │ │
|
|
45
|
+
│ │ • 自描述架构 (is_available, priority) │ │
|
|
46
|
+
│ │ • 引擎自动发现与注册 │ │
|
|
47
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
48
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
49
|
+
│ │ Configuration System (config.py) │ │
|
|
50
|
+
│ │ • YAML/JSON 配置解析 │ │
|
|
51
|
+
│ │ • Pydantic v2 类型验证 │ │
|
|
52
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
53
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
54
|
+
│ │ Demo Runner (runner.py) │ │
|
|
55
|
+
│ │ • 协调 backend + engine + workload │ │
|
|
56
|
+
│ │ • Year 1 Demo Contract 验证 │ │
|
|
57
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
58
|
+
├─────────────────────────────────────────────────────────────┤
|
|
59
|
+
│ sagellm-backend (硬件抽象层) │
|
|
60
|
+
│ • BackendProvider (CUDA/Ascend/Mock) │
|
|
61
|
+
│ • Stream/Event/KVBlock 管理 │
|
|
62
|
+
└─────────────────────────────────────────────────────────────┘
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**职责分离**:
|
|
66
|
+
- ❌ **Backend 不再包含**:BaseEngine, EngineFactory(已移至 core)
|
|
67
|
+
- ✅ **Core 负责**:引擎接口、工厂、运行时、配置、协调
|
|
68
|
+
- ✅ **Backend 负责**:硬件抽象、设备管理、内存原语
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
- **Level 0**: `isagellm-protocol` (协议定义)
|
|
45
|
-
- **Level 1**: `isagellm-backend` (后端抽象,包含 BackendProvider)
|
|
70
|
+
## Features
|
|
46
71
|
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
72
|
+
- 🔧 引擎抽象层与自描述架构
|
|
73
|
+
- 🏭 EngineFactory - 支持自动发现与优先级选择
|
|
74
|
+
- 🎯 内置引擎实现(Mock/CPU/CUDA/Embedding)
|
|
75
|
+
- 🔌 插件系统 - 扩展引擎与后端
|
|
76
|
+
- 📊 Demo Runner - Year 1 验证框架
|
|
77
|
+
- ⚙️ 配置系统 - YAML/JSON + Pydantic v2
|
|
78
|
+
- ✅ Mock-First - 无 GPU 测试支持
|
|
52
79
|
|
|
53
80
|
## 安装
|
|
54
81
|
|
|
@@ -85,14 +112,7 @@ python -m sagellm_core.demo --mock --segments short
|
|
|
85
112
|
> pip install -e ../sagellm-backend
|
|
86
113
|
> ```
|
|
87
114
|
|
|
88
|
-
##
|
|
89
|
-
|
|
90
|
-
- backends:`sagellm.backends`(由 sagellm-backend 提供基础实现)
|
|
91
|
-
- engines:`sagellm.engines`(由各 engine 包提供实现)
|
|
92
|
-
|
|
93
|
-
core 在运行时扫描 entry points;当配置指定 kind 但未安装插件时必须 fail-fast,并给出安装提示。
|
|
94
|
-
|
|
95
|
-
## 配置系统(Task0.02)
|
|
115
|
+
## Configuration System
|
|
96
116
|
|
|
97
117
|
### 使用方法
|
|
98
118
|
|
|
@@ -107,20 +127,15 @@ backend = create_backend(config.backend)
|
|
|
107
127
|
engine = create_engine(config.engine, backend)
|
|
108
128
|
```
|
|
109
129
|
|
|
110
|
-
###
|
|
111
|
-
|
|
112
|
-
所有配置类均使用 pydantic v2 实现严格校验:
|
|
113
|
-
- 缺失必填字段立即抛出 `ValidationError`
|
|
114
|
-
- 未知字段被拒绝(`extra="forbid"`)
|
|
115
|
-
- 数值约束被强制执行
|
|
130
|
+
### Configuration Structure
|
|
116
131
|
|
|
117
|
-
|
|
118
|
-
- `BackendConfig`:
|
|
119
|
-
- `EngineConfig`:
|
|
120
|
-
- `WorkloadConfig`:
|
|
121
|
-
- `OutputConfig`:
|
|
122
|
-
- `MockConfig`:
|
|
123
|
-
- `DemoConfig`:
|
|
132
|
+
Main configuration components:
|
|
133
|
+
- `BackendConfig`: Device and backend settings
|
|
134
|
+
- `EngineConfig`: Inference engine configuration
|
|
135
|
+
- `WorkloadConfig`: Workload parameters
|
|
136
|
+
- `OutputConfig`: Output paths and logging
|
|
137
|
+
- `MockConfig`: Mock mode settings for testing
|
|
138
|
+
- `DemoConfig`: Top-level demo configuration
|
|
124
139
|
|
|
125
140
|
### 配置示例
|
|
126
141
|
|
|
@@ -224,18 +239,7 @@ output:
|
|
|
224
239
|
report_path: ./output/report.md
|
|
225
240
|
```
|
|
226
241
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
- [x] `python -m sagellm_core.demo --help` 输出帮助信息
|
|
230
|
-
- [x] `python -m sagellm_core.demo --config examples/demo_config.yaml --mock` 可运行
|
|
231
|
-
- [x] 缺少 --config 参数时报错
|
|
232
|
-
- [x] 配置文件不存在时报错
|
|
233
|
-
- [x] 无效的 segment 值时报错
|
|
234
|
-
- [x] `ruff check` 和 `mypy` 通过
|
|
235
|
-
|
|
236
|
-
**注意**:实际 workload 执行逻辑在 task0_10 实现,当前阶段运行会输出 `NotImplementedError`。
|
|
237
|
-
|
|
238
|
-
## 开发指南
|
|
242
|
+
## Development Guide
|
|
239
243
|
|
|
240
244
|
### 快速开始
|
|
241
245
|
|
|
@@ -254,11 +258,9 @@ pre-commit install
|
|
|
254
258
|
pytest tests/ -v
|
|
255
259
|
```
|
|
256
260
|
|
|
257
|
-
###
|
|
261
|
+
### Testing and Quality
|
|
258
262
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
#### 1. Pre-commit Hooks(提交前自动检查)
|
|
263
|
+
#### Pre-commit Hooks
|
|
262
264
|
|
|
263
265
|
安装后,每次 `git commit` 会自动运行:
|
|
264
266
|
- **Ruff**: 代码格式化 + Lint 检查
|
|
@@ -273,57 +275,34 @@ pre-commit run --all-files
|
|
|
273
275
|
git commit --no-verify
|
|
274
276
|
```
|
|
275
277
|
|
|
276
|
-
####
|
|
278
|
+
#### Running Tests
|
|
277
279
|
|
|
278
280
|
```bash
|
|
279
|
-
#
|
|
281
|
+
# Run all tests
|
|
280
282
|
pytest tests/ -v
|
|
281
283
|
|
|
282
|
-
#
|
|
284
|
+
# Run specific test module
|
|
283
285
|
pytest tests/unit/test_demo.py -v
|
|
284
|
-
pytest tests/unit/test_config.py -v
|
|
285
286
|
|
|
286
|
-
#
|
|
287
|
+
# Generate coverage report
|
|
287
288
|
pytest tests/ --cov=sagellm_core --cov-report=html
|
|
288
|
-
open htmlcov/index.html
|
|
289
289
|
```
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
- ✅ 新功能必须有对应单元测试
|
|
293
|
-
- ✅ 覆盖率不低于现有水平
|
|
294
|
-
- ✅ 所有测试必须支持 mock 模式(无需 GPU)
|
|
295
|
-
|
|
296
|
-
#### 3. CI/CD(自动化验证)
|
|
297
|
-
|
|
298
|
-
每次 PR 触发 GitHub Actions 自动运行:
|
|
299
|
-
- **Lint Job**: Ruff + Mypy 检查
|
|
300
|
-
- **Test Job**: 多 Python 版本矩阵测试(3.10, 3.11, 3.12)
|
|
301
|
-
- **Protocol Job**: 验证与 Protocol v0.1 对齐
|
|
302
|
-
- **Build Job**: 验证包构建
|
|
291
|
+
#### Continuous Integration
|
|
303
292
|
|
|
304
|
-
|
|
293
|
+
GitHub Actions automatically runs on each PR:
|
|
294
|
+
- Code linting and formatting checks
|
|
295
|
+
- Tests across Python 3.10, 3.11, 3.12
|
|
296
|
+
- Package build verification
|
|
305
297
|
|
|
306
|
-
###
|
|
298
|
+
### Code Style
|
|
307
299
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
4. **Type-safe** - 所有函数必须有类型注解
|
|
300
|
+
This project uses:
|
|
301
|
+
- **Ruff** for formatting and linting
|
|
302
|
+
- **Mypy** for type checking
|
|
303
|
+
- **Type hints** are required for all functions
|
|
313
304
|
|
|
314
|
-
|
|
315
|
-
# ✅ 正确示例
|
|
316
|
-
def create_backend(config: BackendConfig) -> BaseBackend:
|
|
317
|
-
if config.kind == "mock":
|
|
318
|
-
return MockBackend(config)
|
|
319
|
-
raise PluginResolutionError(f"Unknown backend: {config.kind}")
|
|
320
|
-
|
|
321
|
-
# ❌ 错误示例
|
|
322
|
-
def create_backend(config): # 缺少类型注解
|
|
323
|
-
return MockBackend(config.get("kind", "mock")) # 隐式默认值
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
详细规范参见 [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
305
|
+
For detailed guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
327
306
|
|
|
328
307
|
### 代码检查
|
|
329
308
|
|
|
@@ -348,19 +327,10 @@ pre-commit run --all-files
|
|
|
348
327
|
- `isagellm-protocol>=0.1.0,<0.2.0`: 协议定义(Level 0)
|
|
349
328
|
- `isagellm-backend>=0.1.0,<0.2.0`: 后端抽象(Level 1)
|
|
350
329
|
|
|
351
|
-
##
|
|
330
|
+
## Related Packages
|
|
352
331
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
Level 2: isagellm-core (依赖 protocol + backend) ← 当前包
|
|
359
|
-
↓
|
|
360
|
-
Level 3: 功能模块(依赖 protocol + backend + core)
|
|
361
|
-
├─ isagellm-kv-cache
|
|
362
|
-
├─ isagellm-comm
|
|
363
|
-
└─ isagellm-compression
|
|
364
|
-
↓
|
|
365
|
-
Level 4: isagellm-demo (依赖所有模块)
|
|
366
|
-
```
|
|
332
|
+
- `isagellm-protocol` - Protocol definitions
|
|
333
|
+
- `isagellm-backend` - Backend abstraction layer
|
|
334
|
+
- `isagellm` - Main package with CLI
|
|
335
|
+
|
|
336
|
+
For more packages, see the [sageLLM ecosystem](https://github.com/intellistream/sagellm)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
sagellm_core/__init__.py,sha256=XQwsAH6UV2dIxiLASks_Ka2DPYviHtU7Xm8f9A_raMs,2362
|
|
2
|
+
sagellm_core/__init__.pyc,sha256=L6uVckWOqO5Xr3A5lKzadtb46EpTyshtCBF1_U11tok,2445
|
|
3
|
+
sagellm_core/__main__.pyc,sha256=4wEXHFB0JVZaI6wLACU59_b-LfEbujTQZyzONaalAYA,384
|
|
4
|
+
sagellm_core/base_engine.pyc,sha256=XANZ2YIQGyhI6GqBvoZdmYkMblO3N2eMWHhU4waJZIg,9823
|
|
5
|
+
sagellm_core/config.pyc,sha256=8gGOOBcHRSSv883bDIJNXzB069ntBc0yYEf-PFAeWdU,9617
|
|
6
|
+
sagellm_core/demo.pyc,sha256=MAeTgokTW8kW906wjvTLN1yNLfOOl3_hokpVzJ-Lt4I,6377
|
|
7
|
+
sagellm_core/engine.pyc,sha256=-qUIh257hxKfcrT_usrrD1Bs9YYjeUNTGyXnB1Cxec8,747
|
|
8
|
+
sagellm_core/engine_factory.pyc,sha256=QeKOE607E_xf2cOKbPKZ4NLwXY8sXNsi66nm890R9qg,16172
|
|
9
|
+
sagellm_core/factory.pyc,sha256=PF-xQQn-fYn25GO5muzf9rCdHKQ3NhQYiCKOnkHBjxY,2692
|
|
10
|
+
sagellm_core/health.pyc,sha256=oEWyaaTix4YXhyu8JSYOQAy9KBySxbIcHt2hNpchi-w,684
|
|
11
|
+
sagellm_core/mock_engine.pyc,sha256=iadJef1bNdQXdXJLFo_FE9aVglecothXLhxMoMtzEv0,532
|
|
12
|
+
sagellm_core/plugins.pyc,sha256=rhdewQ_zJxnmRFBjUozBlhQtIwFg0C1rFD8zMT7ZeKI,2618
|
|
13
|
+
sagellm_core/py.typed,sha256=ixa8YukDZ3kLo0WsFJRGohLMyHzbMur1ALmmASML2cs,64
|
|
14
|
+
sagellm_core/runner.pyc,sha256=kUPITl68dX1rOY5Fg5o6KRBMjMhMAQFNizEuRF44PgM,14248
|
|
15
|
+
sagellm_core/workload.pyc,sha256=LDuZAdimFAd3pHn8E9WG7LjwU_1IKABZ-gaMCMjOTus,4118
|
|
16
|
+
sagellm_core/__pycache__/__init__.cpython-311.pyc,sha256=ry1xuui3JKKKwFfT-EKRMqQNj-iTz7PewMEzdoE3Dxg,2475
|
|
17
|
+
sagellm_core/__pycache__/base_engine.cpython-311.pyc,sha256=L5Al-v9E7_wvO_wCzwy-uogVGhcREnrEhWOPY8CMEdQ,9853
|
|
18
|
+
sagellm_core/__pycache__/config.cpython-311.pyc,sha256=4c_gjzVmxIRApzmUq8LCboOG3wPqmmwWVFxZS3JOHOg,9647
|
|
19
|
+
sagellm_core/__pycache__/demo.cpython-311.pyc,sha256=yOMGCRRQigl8sclMTcg-iHThQoxrRTPWSUdgDYJ3hgU,6407
|
|
20
|
+
sagellm_core/__pycache__/engine.cpython-311.pyc,sha256=a9K-RsPxh1XlyXRvSUEwUgyMXZcjFURlnbUU439vqj8,777
|
|
21
|
+
sagellm_core/__pycache__/engine_factory.cpython-311.pyc,sha256=ajVs8bvnRjQz0nDctWkDgKoWgQIVPPkRSouUDlUgEbQ,16202
|
|
22
|
+
sagellm_core/__pycache__/factory.cpython-311.pyc,sha256=Dl6w_PHlzEVr62cT6D11_gm9F-MAcqouBNNHZEHCjqw,2722
|
|
23
|
+
sagellm_core/__pycache__/health.cpython-311.pyc,sha256=t8l6F_O808YWsFBDQfdJU6_Ps8H-nnE6k0fdLxYwLJk,714
|
|
24
|
+
sagellm_core/__pycache__/mock_engine.cpython-311.pyc,sha256=KcHBGI1dVIEKm7rhZOkPWQ27rzNVEhmXDYsiQ_5Lfe8,562
|
|
25
|
+
sagellm_core/__pycache__/plugins.cpython-311.pyc,sha256=K6-SC0yOVvT-qVh7Fp2GC-O0GloaWY00W9_8y_jrBnk,2648
|
|
26
|
+
sagellm_core/__pycache__/runner.cpython-311.pyc,sha256=aZCGktjzcGBqNB7tJahEHfUgbTOYPCn-TyKp6yzpD6s,14278
|
|
27
|
+
sagellm_core/__pycache__/workload.cpython-311.pyc,sha256=ah0QMR3-t_EdjS6km5zi64LLn0FB3XgN7ALa1rVlDYY,4148
|
|
28
|
+
sagellm_core/engines/__init__.py,sha256=e8UeuSNOx4pHFGp-RAQMwdqbuaQ-owAC2QCnIHB40KI,1155
|
|
29
|
+
sagellm_core/engines/__init__.pyc,sha256=OuSihHfkoY7noliHKvmb8chxuk8qMKmVNJArSyUe41Q,1180
|
|
30
|
+
sagellm_core/engines/cpu.pyc,sha256=bvSyz1Rxu2T38_m3BjeP2stzcGrT6gwKBxnddLKw_V0,20190
|
|
31
|
+
sagellm_core/engines/embedding.pyc,sha256=0cT3ODDmp-1aJlb6VthnzeKd09stAnITdTHuSaAssiA,11476
|
|
32
|
+
sagellm_core/engines/hf_cuda.pyc,sha256=N6Pk-Vhj_5zOCdWiXLTasO3BU-7mNO5F0-HK4TaRn1g,50838
|
|
33
|
+
sagellm_core/engines/mock.pyc,sha256=aOvuEPng6SUqQIB1Mpxcbb-8vzbrrwZSwal1atgSn3w,14611
|
|
34
|
+
sagellm_core/engines/__pycache__/__init__.cpython-311.pyc,sha256=axxxDoJnQ0TF7xv3FAdj4pkc9BVpKZdiIWdQh8Rsnao,1210
|
|
35
|
+
sagellm_core/engines/__pycache__/cpu.cpython-311.pyc,sha256=gGjhwViirf7jzzFgcKqKo4ciiDJwWxNoBOC04vWL4dQ,20220
|
|
36
|
+
sagellm_core/engines/__pycache__/embedding.cpython-311.pyc,sha256=-kRmbxPN1IsSmNUi9FA3vp-zpOBiqLXf67gWVOU1wZg,11506
|
|
37
|
+
sagellm_core/engines/__pycache__/hf_cuda.cpython-311.pyc,sha256=RjPewreHvv_9N_iSt8wAxlhTJ_kM-FsoaDWplYAf-cc,50868
|
|
38
|
+
sagellm_core/engines/__pycache__/mock.cpython-311.pyc,sha256=O5j1RVjz8mAgoA0Aogt_3bVmChAtuJSrjMgDFB8YTAI,14641
|
|
39
|
+
isagellm_core-0.2.0.0.dist-info/METADATA,sha256=X3MYU60lAf7XN9_kZaxigI5ASZ600mojmoUzQwGQTZY,10597
|
|
40
|
+
isagellm_core-0.2.0.0.dist-info/WHEEL,sha256=ZJeWpR6hcCRGwxVKXlDk-HsGwijNyTq4fszaDj4Ycyo,93
|
|
41
|
+
isagellm_core-0.2.0.0.dist-info/top_level.txt,sha256=wcgdWrvkaoYYh_dWSFI5Toi8PZsHutVqfhTB2tb0K6g,13
|
|
42
|
+
isagellm_core-0.2.0.0.dist-info/RECORD,,
|
sagellm_core/__init__.py
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
本包提供 sageLLM 的核心运行时组件:
|
|
4
4
|
- 配置 schema 与校验
|
|
5
5
|
- Engine 抽象接口与实现
|
|
6
|
-
-
|
|
6
|
+
- Engine 工厂函数
|
|
7
7
|
- 插件系统
|
|
8
8
|
- Demo Runner
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
from sagellm_core.base_engine import BaseEngine, EngineInstanceConfig
|
|
13
14
|
from sagellm_core.config import (
|
|
14
15
|
BackendConfig,
|
|
15
16
|
DemoConfig,
|
|
@@ -21,18 +22,47 @@ from sagellm_core.config import (
|
|
|
21
22
|
load_config,
|
|
22
23
|
)
|
|
23
24
|
from sagellm_core.demo import main as demo_main
|
|
24
|
-
from sagellm_core.
|
|
25
|
+
from sagellm_core.engine_factory import EngineFactory
|
|
26
|
+
from sagellm_core.engines import (
|
|
27
|
+
CPUEngine,
|
|
28
|
+
EmbeddingEngine,
|
|
29
|
+
EmbeddingEngineConfig,
|
|
30
|
+
HFCudaEngine,
|
|
31
|
+
HFCudaEngineConfig,
|
|
32
|
+
MockEngine,
|
|
33
|
+
MockEngineConfig,
|
|
34
|
+
create_mock_engine,
|
|
35
|
+
)
|
|
25
36
|
from sagellm_core.factory import create_backend, create_engine
|
|
26
37
|
from sagellm_core.health import HealthStatus
|
|
27
38
|
from sagellm_core.plugins import PluginResolutionError, list_entry_points, resolve_kind
|
|
28
39
|
from sagellm_core.runner import DemoRunner, RunnerContext
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
# Auto-register built-in engines
|
|
42
|
+
EngineFactory.register(MockEngine)
|
|
43
|
+
|
|
44
|
+
# Conditional registration for engines with optional dependencies
|
|
45
|
+
try:
|
|
46
|
+
EngineFactory.register(CPUEngine)
|
|
47
|
+
except Exception:
|
|
48
|
+
pass # torch not available
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
EngineFactory.register(HFCudaEngine)
|
|
52
|
+
except Exception:
|
|
53
|
+
pass # torch or CUDA not available
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
EngineFactory.register(EmbeddingEngine)
|
|
57
|
+
except Exception:
|
|
58
|
+
pass # sentence-transformers not available
|
|
59
|
+
|
|
60
|
+
__version__ = "0.2.0.0"
|
|
31
61
|
|
|
32
62
|
__all__ = [
|
|
33
63
|
# Version
|
|
34
64
|
"__version__",
|
|
35
|
-
# Configuration
|
|
65
|
+
# Configuration (for YAML/config files)
|
|
36
66
|
"BackendConfig",
|
|
37
67
|
"DemoConfig",
|
|
38
68
|
"EngineConfig",
|
|
@@ -43,10 +73,21 @@ __all__ = [
|
|
|
43
73
|
"load_config",
|
|
44
74
|
# Engine abstraction
|
|
45
75
|
"BaseEngine",
|
|
76
|
+
"EngineInstanceConfig", # For runtime engine instantiation
|
|
46
77
|
"HealthStatus",
|
|
78
|
+
# Engine implementations
|
|
79
|
+
"MockEngine",
|
|
80
|
+
"MockEngineConfig",
|
|
81
|
+
"create_mock_engine",
|
|
82
|
+
"CPUEngine",
|
|
83
|
+
"HFCudaEngine",
|
|
84
|
+
"HFCudaEngineConfig",
|
|
85
|
+
"EmbeddingEngine",
|
|
86
|
+
"EmbeddingEngineConfig",
|
|
47
87
|
# Factory functions
|
|
48
88
|
"create_backend",
|
|
49
89
|
"create_engine",
|
|
90
|
+
"EngineFactory",
|
|
50
91
|
# Plugin system
|
|
51
92
|
"PluginResolutionError",
|
|
52
93
|
"list_entry_points",
|
sagellm_core/__init__.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
sagellm_core/engine.pyc
CHANGED
|
Binary file
|
|
Binary file
|
sagellm_core/engines/__init__.py
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
"""Engine implementations
|
|
1
|
+
"""Engine implementations for sageLLM Core.
|
|
2
|
+
|
|
3
|
+
This module provides built-in engine implementations:
|
|
4
|
+
- MockEngine: GPU-free mock engine for testing
|
|
5
|
+
- CPUEngine: CPU-only inference with HuggingFace Transformers
|
|
6
|
+
- HFCudaEngine: CUDA inference with HuggingFace Transformers
|
|
7
|
+
- EmbeddingEngine: Embedding model inference
|
|
8
|
+
"""
|
|
2
9
|
|
|
3
10
|
from __future__ import annotations
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
from sagellm_core.engines.cpu import CPUEngine
|
|
13
|
+
from sagellm_core.engines.embedding import EmbeddingEngine, EmbeddingEngineConfig
|
|
14
|
+
from sagellm_core.engines.hf_cuda import HFCudaEngine, HFCudaEngineInstanceConfig
|
|
15
|
+
from sagellm_core.engines.mock import (
|
|
16
|
+
MockEngine,
|
|
17
|
+
MockEngineInstanceConfig,
|
|
18
|
+
create_mock_engine,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Export aliases for backward compatibility
|
|
22
|
+
HFCudaEngineConfig = HFCudaEngineInstanceConfig
|
|
23
|
+
MockEngineConfig = MockEngineInstanceConfig
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
# Mock engine
|
|
27
|
+
"MockEngine",
|
|
28
|
+
"MockEngineConfig",
|
|
29
|
+
"MockEngineInstanceConfig",
|
|
30
|
+
"create_mock_engine",
|
|
31
|
+
# CPU engine
|
|
32
|
+
"CPUEngine",
|
|
33
|
+
# CUDA engine
|
|
34
|
+
"HFCudaEngine",
|
|
35
|
+
"HFCudaEngineConfig",
|
|
36
|
+
"HFCudaEngineInstanceConfig",
|
|
37
|
+
# Embedding engine
|
|
38
|
+
"EmbeddingEngine",
|
|
39
|
+
"EmbeddingEngineConfig",
|
|
40
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
sagellm_core/engines/mock.pyc
CHANGED
|
Binary file
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
sagellm_core/__init__.py,sha256=LpmwcJlxM8ykr8CiVjF1P3KfjQnX-DlWC0z6cBdFbII,1318
|
|
2
|
-
sagellm_core/__init__.pyc,sha256=Udt8y0HGtcHO-8ELYg_qX-FmAlhiJe__5RCursK7wCE,1462
|
|
3
|
-
sagellm_core/__main__.pyc,sha256=4wEXHFB0JVZaI6wLACU59_b-LfEbujTQZyzONaalAYA,384
|
|
4
|
-
sagellm_core/config.pyc,sha256=8gGOOBcHRSSv883bDIJNXzB069ntBc0yYEf-PFAeWdU,9617
|
|
5
|
-
sagellm_core/demo.pyc,sha256=MAeTgokTW8kW906wjvTLN1yNLfOOl3_hokpVzJ-Lt4I,6377
|
|
6
|
-
sagellm_core/engine.pyc,sha256=8Et-gI0pYOpDPRCz8IrWMDYKWs_-K31jAAnYoe-HnF8,584
|
|
7
|
-
sagellm_core/factory.pyc,sha256=PF-xQQn-fYn25GO5muzf9rCdHKQ3NhQYiCKOnkHBjxY,2692
|
|
8
|
-
sagellm_core/health.pyc,sha256=oEWyaaTix4YXhyu8JSYOQAy9KBySxbIcHt2hNpchi-w,684
|
|
9
|
-
sagellm_core/mock_engine.pyc,sha256=iadJef1bNdQXdXJLFo_FE9aVglecothXLhxMoMtzEv0,532
|
|
10
|
-
sagellm_core/plugins.pyc,sha256=rhdewQ_zJxnmRFBjUozBlhQtIwFg0C1rFD8zMT7ZeKI,2618
|
|
11
|
-
sagellm_core/py.typed,sha256=ixa8YukDZ3kLo0WsFJRGohLMyHzbMur1ALmmASML2cs,64
|
|
12
|
-
sagellm_core/runner.pyc,sha256=kUPITl68dX1rOY5Fg5o6KRBMjMhMAQFNizEuRF44PgM,14248
|
|
13
|
-
sagellm_core/workload.pyc,sha256=LDuZAdimFAd3pHn8E9WG7LjwU_1IKABZ-gaMCMjOTus,4118
|
|
14
|
-
sagellm_core/__pycache__/__init__.cpython-311.pyc,sha256=R2nIc2MOizHOtAi3qteyJyfWIPxXbBQgZtp2jvYiJhg,1492
|
|
15
|
-
sagellm_core/__pycache__/config.cpython-311.pyc,sha256=4c_gjzVmxIRApzmUq8LCboOG3wPqmmwWVFxZS3JOHOg,9647
|
|
16
|
-
sagellm_core/__pycache__/demo.cpython-311.pyc,sha256=yOMGCRRQigl8sclMTcg-iHThQoxrRTPWSUdgDYJ3hgU,6407
|
|
17
|
-
sagellm_core/__pycache__/engine.cpython-311.pyc,sha256=6wUoB2Rz8YqoVpefE28b_vqxAozdXFiCYJZ_gn5Vi9A,614
|
|
18
|
-
sagellm_core/__pycache__/factory.cpython-311.pyc,sha256=Dl6w_PHlzEVr62cT6D11_gm9F-MAcqouBNNHZEHCjqw,2722
|
|
19
|
-
sagellm_core/__pycache__/health.cpython-311.pyc,sha256=t8l6F_O808YWsFBDQfdJU6_Ps8H-nnE6k0fdLxYwLJk,714
|
|
20
|
-
sagellm_core/__pycache__/mock_engine.cpython-311.pyc,sha256=KcHBGI1dVIEKm7rhZOkPWQ27rzNVEhmXDYsiQ_5Lfe8,562
|
|
21
|
-
sagellm_core/__pycache__/plugins.cpython-311.pyc,sha256=K6-SC0yOVvT-qVh7Fp2GC-O0GloaWY00W9_8y_jrBnk,2648
|
|
22
|
-
sagellm_core/__pycache__/runner.cpython-311.pyc,sha256=aZCGktjzcGBqNB7tJahEHfUgbTOYPCn-TyKp6yzpD6s,14278
|
|
23
|
-
sagellm_core/__pycache__/workload.cpython-311.pyc,sha256=ah0QMR3-t_EdjS6km5zi64LLn0FB3XgN7ALa1rVlDYY,4148
|
|
24
|
-
sagellm_core/engines/__init__.py,sha256=Pz_6hPpdL9aZqFSZnP_3Hdo_oOhMgygp8fYDUq60eoM,99
|
|
25
|
-
sagellm_core/engines/__init__.pyc,sha256=F8_ZNvo0w79MF136pvCmRArLhPjae6uGsds7v9OUAEo,331
|
|
26
|
-
sagellm_core/engines/mock.pyc,sha256=D0kWj50DsPdaZAM_2W-vyTW11ofNsSF02knRGtfKEJA,586
|
|
27
|
-
sagellm_core/engines/__pycache__/__init__.cpython-311.pyc,sha256=Y36wU_L1T0NqaGBb-oqt38qVk38lunfTWTv5n-TkCLI,361
|
|
28
|
-
sagellm_core/engines/__pycache__/mock.cpython-311.pyc,sha256=bt1MKmriqKcL_HF2gvQQ5JfxI-ij24G4fZvgFXjBAmM,616
|
|
29
|
-
isagellm_core-0.1.0.2.dist-info/METADATA,sha256=nSW2I1mm63Y-KwzgrnbQmzglGjtRR3NcIHzehUZGj1w,9949
|
|
30
|
-
isagellm_core-0.1.0.2.dist-info/WHEEL,sha256=ZJeWpR6hcCRGwxVKXlDk-HsGwijNyTq4fszaDj4Ycyo,93
|
|
31
|
-
isagellm_core-0.1.0.2.dist-info/top_level.txt,sha256=wcgdWrvkaoYYh_dWSFI5Toi8PZsHutVqfhTB2tb0K6g,13
|
|
32
|
-
isagellm_core-0.1.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|