tgai-go 1.0.0__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.
tgai_go-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TGAI / JXW
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
tgai_go-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,260 @@
1
+ Metadata-Version: 2.4
2
+ Name: tgai-go
3
+ Version: 1.0.0
4
+ Summary: TGAI GO —— 纯 Python 的 TGAI 模型推理库(CPU 引擎,零编译安装)
5
+ Author: TGAI
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/tgai/tgai-go
8
+ Project-URL: Documentation, https://github.com/tgai/tgai-go#readme
9
+ Keywords: tgai,llm,inference,moe,chinese,llama
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: C
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Classifier: Intended Audience :: Developers
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: numpy>=1.20
20
+ Provides-Extra: tokenizer
21
+ Requires-Dist: tokenizers>=0.15; extra == "tokenizer"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # TGAI GO
27
+
28
+ **纯 Python 的 TGAI 模型推理库** —— `pip install` 后即可加载 `.TG` 模型推理,无需编译、无需 CUDA、无需 Vulkan SDK。
29
+
30
+ ```python
31
+ import tgai_go
32
+
33
+ m = tgai_go.load("v27_merged_bf16.TG")
34
+ print(m.generate("什么是机器学习?", max_tokens=128))
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 特性
40
+
41
+ | 特性 | 说明 |
42
+ |---|---|
43
+ | **零编译安装** | 原生引擎(C + OpenMP)以预编译库随包分发,`pip install tgai-go` 即可用 |
44
+ | **无外部依赖** | 引擎只依赖系统 `kernel32`(静态链接 CRT);Python 侧只要 `numpy` |
45
+ | **CPU 推理** | 纯 CPU,8 线程实测 **12.0 tok/s**(28 层 MoE,5.6 GB BF16 权重) |
46
+ | **多轮对话** | 内置 KV cache 复用,跨轮只算新增 token |
47
+ | **配置随模型走** | `.TG` 可内嵌对话模板(九标记 / ChatML / 纯文本),库自动读取 |
48
+ | **流式输出** | `for chunk in m.stream(...)` 逐段拿文本 |
49
+ | **CPU 友好** | 不需要独显;核显机器、笔记本、服务器都能跑 |
50
+
51
+ ---
52
+
53
+ ## 安装
54
+
55
+ ```bash
56
+ pip install tgai-go
57
+ ```
58
+
59
+ > 平台:Windows x64 已实测;Linux/macOS 需自行编译原生库(见文末)。
60
+
61
+ ---
62
+
63
+ ## 快速开始
64
+
65
+ ### 单轮生成
66
+
67
+ ```python
68
+ import tgai_go
69
+
70
+ m = tgai_go.load("v27.TG")
71
+
72
+ print(m.generate("什么是人工智能?"))
73
+ print(m.generate("写一句关于春天的话。", max_tokens=64, stop=["。"]))
74
+ ```
75
+
76
+ ### 多轮对话(自动带历史)
77
+
78
+ ```python
79
+ with tgai_go.load("v27.TG") as m:
80
+ s = m.session(system="你是 TGAI,一个中文助手")
81
+ print(s.chat("我叫小明,今年8岁。"))
82
+ print(s.chat("我叫什么名字?")) # → "你叫小明,今年8岁。"
83
+ print(s.chat("我几岁了?")) # → "8岁"
84
+ ```
85
+
86
+ ### 流式输出
87
+
88
+ ```python
89
+ with tgai_go.load("v27.TG") as m:
90
+ for chunk in m.stream("讲个短故事", max_tokens=200):
91
+ print(chunk, end="", flush=True)
92
+ ```
93
+
94
+ ### 性能调节
95
+
96
+ ```python
97
+ m = tgai_go.load("v27.TG", threads=8, preload=True)
98
+ print(m.threads) # 8
99
+
100
+ # 实测(Ryzen 7 7730U, 8C/16T, V2.7 28层 MoE):
101
+ # 4 线程 → 7.7 tok/s
102
+ # 8 线程 → 12.0 tok/s ← 最优
103
+ # 16 线程 → 10.7 tok/s (超线程反而变慢)
104
+ ```
105
+
106
+ ---
107
+
108
+ ## API
109
+
110
+ ### `tgai_go.load(path, *, dll=None, extend_ctx=0, threads=None, preload=False)`
111
+
112
+ | 参数 | 说明 |
113
+ |---|---|
114
+ | `path` | `.TG` 模型路径 |
115
+ | `dll` | 指定引擎库(默认用包内 `_native/`) |
116
+ | `extend_ctx` | 扩展上下文(NTK-by-parts / YaRN),0 = 用模型自带 `max_seq` |
117
+ | `threads` | CPU 线程数;`None` = 引擎默认,`0` = 全部逻辑核 |
118
+ | `preload` | `True` = 预解码全部权重(首次推理不卡顿,但占更多内存) |
119
+
120
+ 返回 `Model` 对象,支持 `with` 语句自动释放。
121
+
122
+ ### `Model`
123
+
124
+ | 成员 | 说明 |
125
+ |---|---|
126
+ | `generate(prompt, **kw)` | 单轮生成,返回字符串 |
127
+ | `stream(prompt, **kw)` | 流式生成,逐段 yield |
128
+ | `session(system="")` | 开多轮会话,返回 `ChatSession` |
129
+ | `encode(text)` / `decode(id)` | 分词 / 反分词 |
130
+ | `set_threads(n)` / `threads` | 线程数 |
131
+ | `preload()` | 预加载权重 |
132
+ | `n_layers` / `d_model` / `vocab_size` / `max_seq_len` | 模型信息 |
133
+ | `chat_meta` | 模型内嵌的对话配置 |
134
+ | `close()` | 释放(`with` 会自动调) |
135
+
136
+ ### `ChatSession`
137
+
138
+ | 成员 | 说明 |
139
+ |---|---|
140
+ | `chat(msg, **kw)` | 一轮对话,返回完整回答 |
141
+ | `stream(msg, **kw)` | 流式一轮 |
142
+ | `chat_with_prompt(msg)` | 返回 `(回答, 实际 prompt)`,排查格式用 |
143
+ | `history` | `[(q, a), ...]`,可直接改 |
144
+ | `clear()` | 清历史 + 重置 KV cache |
145
+ | `max_turns` | 进 prompt 的历史轮数(默认 8) |
146
+
147
+ ### 生成参数(`**kw`)
148
+
149
+ | 参数 | 默认 | 说明 |
150
+ |---|---|---|
151
+ | `max_tokens` | 256 | 最大生成长度 |
152
+ | `temperature` | 0.6 | 随机性(0 = 贪心) |
153
+ | `top_k` | 40 | 前 K 个采样 |
154
+ | `top_p` | 0.9 | 核采样 |
155
+ | `min_p` | 0.0 | 最小概率阈值 |
156
+ | `min_tokens` | 4 | 至少生成 N 个 token 才允许停止(防空回复) |
157
+ | `repeat_penalty` | 1.05 | 重复惩罚 |
158
+ | `frequency_penalty` | 0.0 | 频率惩罚 |
159
+ | `dry_multiplier` | 0.8 | DRY 防复读强度 |
160
+ | `stop` | `None` | **自定义停止串**,如 `stop=["。", "<用户>"]` |
161
+ | `seed` | -1 | 随机种子(-1 = 随机) |
162
+
163
+ **参数优先级**:函数参数 > `.TG` 内嵌默认值 > 库内置默认值
164
+
165
+ ---
166
+
167
+ ## `.TG` 模型内嵌对话配置
168
+
169
+ `.TG` 文件可以自带对话模板,让库知道"怎么跟这个模型说话"。
170
+ 第三方模型只要打包时带上配置,**不用改库的代码**。
171
+
172
+ ```bash
173
+ # 查看配置
174
+ python -m tgai_go.tools.write_chat_meta model.TG --show
175
+
176
+ # 写内置预设: v27(TGAI 九标记) / chatml(Qwen2 等) / plain(纯文本)
177
+ python -m tgai_go.tools.write_chat_meta model.TG --preset v27
178
+ ```
179
+
180
+ 配置内容:
181
+
182
+ ```
183
+ render_mode markers | chatml | plain
184
+ chat_template {SYS}{HIST}<用户>\n{Q}\n<TGAI>{TAIL}\n
185
+ template_turn <用户>\n{Q}\n<TGAI><回答>\n{A}
186
+ special_tokens <用户> <TGAI> <思考> <回答> ...
187
+ turn_markers <用户> <TGAI> <系统> ... (生成到它即停)
188
+ stop_strings ... (停止串)
189
+ gen_defaults temperature=0.6 top_k=40 ...
190
+ ```
191
+
192
+ 只读查看(不加载权重,很快):
193
+
194
+ ```python
195
+ import tgai_go
196
+ print(tgai_go.chat_meta_of("v27.TG"))
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 内存
202
+
203
+ | 模型 | 权重(BF16) | 运行峰值 |
204
+ |---|---|---|
205
+ | TGAI V2.7(28 层 MoE) | 5.6 GB | 约 3.6 GB(开启 BF16 直算)|
206
+
207
+ `preload=True` 会额外占用(用于缓存解码后的权重),内存紧张时不要开。
208
+
209
+ ---
210
+
211
+ ## 常见问题
212
+
213
+ **Q: 生成结果是空的?**
214
+ 调大 `min_tokens`(默认 4)。某些模型的首选 token 是停止符,不禁就会立即停。
215
+
216
+ **Q: 一直复读不停止?**
217
+ 加自定义停止串:`m.generate(q, stop=["<用户>", "\n\n"])`。
218
+ 或降低 `temperature`、调高 `dry_multiplier`。
219
+
220
+ **Q: 多轮对话记不住前文?**
221
+ 检查 `.TG` 是否带对话配置(`tgai_go.chat_meta_of(path)`)。
222
+ 没有配置时库会按 `arch_type` 猜,可能不匹配。
223
+
224
+ **Q: 加载很慢?**
225
+ 首次加载要 mmap 权重。加 `preload=True` 把首次推理的卡顿提前。
226
+
227
+ **Q: 支持 GPU 吗?**
228
+ 当前包是纯 CPU 引擎。GPU 桥接版本仍在验证(实测核显不如 CPU,
229
+ 原因见主仓文档)。
230
+
231
+ ---
232
+
233
+ ## 从源码构建原生库(Linux/macOS)
234
+
235
+ ```bash
236
+ git clone <repo>
237
+ cd "TGAI GO"
238
+ # Linux
239
+ gcc -O3 -fopenmp -mavx2 -shared -fPIC -o cpu/build/libtgai_engine.so \
240
+ src/tgai_engine.c
241
+ # macOS
242
+ clang -O3 -Xpreprocessor -fopenmp -shared -o cpu/build/libtgai_engine.dylib \
243
+ src/tgai_engine.c
244
+ ```
245
+
246
+ 然后把产物放到 `tgai_go/_native/`。
247
+
248
+ ---
249
+
250
+ ## License
251
+
252
+ MIT
253
+
254
+ ---
255
+
256
+ ## 相关
257
+
258
+ - `.TG` 格式:128 字节头 + 分词器段 + 权重表 + 权重数据(+ 可选对话配置段)
259
+ - 支持的架构:TGAI MoE / Llama / Mistral(按 `arch_type` 字段区分)
260
+ - 量化:FP32 / FP16 / BF16 / INT8 / Q8_0 / Q4_0 / Q4K
@@ -0,0 +1,235 @@
1
+ # TGAI GO
2
+
3
+ **纯 Python 的 TGAI 模型推理库** —— `pip install` 后即可加载 `.TG` 模型推理,无需编译、无需 CUDA、无需 Vulkan SDK。
4
+
5
+ ```python
6
+ import tgai_go
7
+
8
+ m = tgai_go.load("v27_merged_bf16.TG")
9
+ print(m.generate("什么是机器学习?", max_tokens=128))
10
+ ```
11
+
12
+ ---
13
+
14
+ ## 特性
15
+
16
+ | 特性 | 说明 |
17
+ |---|---|
18
+ | **零编译安装** | 原生引擎(C + OpenMP)以预编译库随包分发,`pip install tgai-go` 即可用 |
19
+ | **无外部依赖** | 引擎只依赖系统 `kernel32`(静态链接 CRT);Python 侧只要 `numpy` |
20
+ | **CPU 推理** | 纯 CPU,8 线程实测 **12.0 tok/s**(28 层 MoE,5.6 GB BF16 权重) |
21
+ | **多轮对话** | 内置 KV cache 复用,跨轮只算新增 token |
22
+ | **配置随模型走** | `.TG` 可内嵌对话模板(九标记 / ChatML / 纯文本),库自动读取 |
23
+ | **流式输出** | `for chunk in m.stream(...)` 逐段拿文本 |
24
+ | **CPU 友好** | 不需要独显;核显机器、笔记本、服务器都能跑 |
25
+
26
+ ---
27
+
28
+ ## 安装
29
+
30
+ ```bash
31
+ pip install tgai-go
32
+ ```
33
+
34
+ > 平台:Windows x64 已实测;Linux/macOS 需自行编译原生库(见文末)。
35
+
36
+ ---
37
+
38
+ ## 快速开始
39
+
40
+ ### 单轮生成
41
+
42
+ ```python
43
+ import tgai_go
44
+
45
+ m = tgai_go.load("v27.TG")
46
+
47
+ print(m.generate("什么是人工智能?"))
48
+ print(m.generate("写一句关于春天的话。", max_tokens=64, stop=["。"]))
49
+ ```
50
+
51
+ ### 多轮对话(自动带历史)
52
+
53
+ ```python
54
+ with tgai_go.load("v27.TG") as m:
55
+ s = m.session(system="你是 TGAI,一个中文助手")
56
+ print(s.chat("我叫小明,今年8岁。"))
57
+ print(s.chat("我叫什么名字?")) # → "你叫小明,今年8岁。"
58
+ print(s.chat("我几岁了?")) # → "8岁"
59
+ ```
60
+
61
+ ### 流式输出
62
+
63
+ ```python
64
+ with tgai_go.load("v27.TG") as m:
65
+ for chunk in m.stream("讲个短故事", max_tokens=200):
66
+ print(chunk, end="", flush=True)
67
+ ```
68
+
69
+ ### 性能调节
70
+
71
+ ```python
72
+ m = tgai_go.load("v27.TG", threads=8, preload=True)
73
+ print(m.threads) # 8
74
+
75
+ # 实测(Ryzen 7 7730U, 8C/16T, V2.7 28层 MoE):
76
+ # 4 线程 → 7.7 tok/s
77
+ # 8 线程 → 12.0 tok/s ← 最优
78
+ # 16 线程 → 10.7 tok/s (超线程反而变慢)
79
+ ```
80
+
81
+ ---
82
+
83
+ ## API
84
+
85
+ ### `tgai_go.load(path, *, dll=None, extend_ctx=0, threads=None, preload=False)`
86
+
87
+ | 参数 | 说明 |
88
+ |---|---|
89
+ | `path` | `.TG` 模型路径 |
90
+ | `dll` | 指定引擎库(默认用包内 `_native/`) |
91
+ | `extend_ctx` | 扩展上下文(NTK-by-parts / YaRN),0 = 用模型自带 `max_seq` |
92
+ | `threads` | CPU 线程数;`None` = 引擎默认,`0` = 全部逻辑核 |
93
+ | `preload` | `True` = 预解码全部权重(首次推理不卡顿,但占更多内存) |
94
+
95
+ 返回 `Model` 对象,支持 `with` 语句自动释放。
96
+
97
+ ### `Model`
98
+
99
+ | 成员 | 说明 |
100
+ |---|---|
101
+ | `generate(prompt, **kw)` | 单轮生成,返回字符串 |
102
+ | `stream(prompt, **kw)` | 流式生成,逐段 yield |
103
+ | `session(system="")` | 开多轮会话,返回 `ChatSession` |
104
+ | `encode(text)` / `decode(id)` | 分词 / 反分词 |
105
+ | `set_threads(n)` / `threads` | 线程数 |
106
+ | `preload()` | 预加载权重 |
107
+ | `n_layers` / `d_model` / `vocab_size` / `max_seq_len` | 模型信息 |
108
+ | `chat_meta` | 模型内嵌的对话配置 |
109
+ | `close()` | 释放(`with` 会自动调) |
110
+
111
+ ### `ChatSession`
112
+
113
+ | 成员 | 说明 |
114
+ |---|---|
115
+ | `chat(msg, **kw)` | 一轮对话,返回完整回答 |
116
+ | `stream(msg, **kw)` | 流式一轮 |
117
+ | `chat_with_prompt(msg)` | 返回 `(回答, 实际 prompt)`,排查格式用 |
118
+ | `history` | `[(q, a), ...]`,可直接改 |
119
+ | `clear()` | 清历史 + 重置 KV cache |
120
+ | `max_turns` | 进 prompt 的历史轮数(默认 8) |
121
+
122
+ ### 生成参数(`**kw`)
123
+
124
+ | 参数 | 默认 | 说明 |
125
+ |---|---|---|
126
+ | `max_tokens` | 256 | 最大生成长度 |
127
+ | `temperature` | 0.6 | 随机性(0 = 贪心) |
128
+ | `top_k` | 40 | 前 K 个采样 |
129
+ | `top_p` | 0.9 | 核采样 |
130
+ | `min_p` | 0.0 | 最小概率阈值 |
131
+ | `min_tokens` | 4 | 至少生成 N 个 token 才允许停止(防空回复) |
132
+ | `repeat_penalty` | 1.05 | 重复惩罚 |
133
+ | `frequency_penalty` | 0.0 | 频率惩罚 |
134
+ | `dry_multiplier` | 0.8 | DRY 防复读强度 |
135
+ | `stop` | `None` | **自定义停止串**,如 `stop=["。", "<用户>"]` |
136
+ | `seed` | -1 | 随机种子(-1 = 随机) |
137
+
138
+ **参数优先级**:函数参数 > `.TG` 内嵌默认值 > 库内置默认值
139
+
140
+ ---
141
+
142
+ ## `.TG` 模型内嵌对话配置
143
+
144
+ `.TG` 文件可以自带对话模板,让库知道"怎么跟这个模型说话"。
145
+ 第三方模型只要打包时带上配置,**不用改库的代码**。
146
+
147
+ ```bash
148
+ # 查看配置
149
+ python -m tgai_go.tools.write_chat_meta model.TG --show
150
+
151
+ # 写内置预设: v27(TGAI 九标记) / chatml(Qwen2 等) / plain(纯文本)
152
+ python -m tgai_go.tools.write_chat_meta model.TG --preset v27
153
+ ```
154
+
155
+ 配置内容:
156
+
157
+ ```
158
+ render_mode markers | chatml | plain
159
+ chat_template {SYS}{HIST}<用户>\n{Q}\n<TGAI>{TAIL}\n
160
+ template_turn <用户>\n{Q}\n<TGAI><回答>\n{A}
161
+ special_tokens <用户> <TGAI> <思考> <回答> ...
162
+ turn_markers <用户> <TGAI> <系统> ... (生成到它即停)
163
+ stop_strings ... (停止串)
164
+ gen_defaults temperature=0.6 top_k=40 ...
165
+ ```
166
+
167
+ 只读查看(不加载权重,很快):
168
+
169
+ ```python
170
+ import tgai_go
171
+ print(tgai_go.chat_meta_of("v27.TG"))
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 内存
177
+
178
+ | 模型 | 权重(BF16) | 运行峰值 |
179
+ |---|---|---|
180
+ | TGAI V2.7(28 层 MoE) | 5.6 GB | 约 3.6 GB(开启 BF16 直算)|
181
+
182
+ `preload=True` 会额外占用(用于缓存解码后的权重),内存紧张时不要开。
183
+
184
+ ---
185
+
186
+ ## 常见问题
187
+
188
+ **Q: 生成结果是空的?**
189
+ 调大 `min_tokens`(默认 4)。某些模型的首选 token 是停止符,不禁就会立即停。
190
+
191
+ **Q: 一直复读不停止?**
192
+ 加自定义停止串:`m.generate(q, stop=["<用户>", "\n\n"])`。
193
+ 或降低 `temperature`、调高 `dry_multiplier`。
194
+
195
+ **Q: 多轮对话记不住前文?**
196
+ 检查 `.TG` 是否带对话配置(`tgai_go.chat_meta_of(path)`)。
197
+ 没有配置时库会按 `arch_type` 猜,可能不匹配。
198
+
199
+ **Q: 加载很慢?**
200
+ 首次加载要 mmap 权重。加 `preload=True` 把首次推理的卡顿提前。
201
+
202
+ **Q: 支持 GPU 吗?**
203
+ 当前包是纯 CPU 引擎。GPU 桥接版本仍在验证(实测核显不如 CPU,
204
+ 原因见主仓文档)。
205
+
206
+ ---
207
+
208
+ ## 从源码构建原生库(Linux/macOS)
209
+
210
+ ```bash
211
+ git clone <repo>
212
+ cd "TGAI GO"
213
+ # Linux
214
+ gcc -O3 -fopenmp -mavx2 -shared -fPIC -o cpu/build/libtgai_engine.so \
215
+ src/tgai_engine.c
216
+ # macOS
217
+ clang -O3 -Xpreprocessor -fopenmp -shared -o cpu/build/libtgai_engine.dylib \
218
+ src/tgai_engine.c
219
+ ```
220
+
221
+ 然后把产物放到 `tgai_go/_native/`。
222
+
223
+ ---
224
+
225
+ ## License
226
+
227
+ MIT
228
+
229
+ ---
230
+
231
+ ## 相关
232
+
233
+ - `.TG` 格式:128 字节头 + 分词器段 + 权重表 + 权重数据(+ 可选对话配置段)
234
+ - 支持的架构:TGAI MoE / Llama / Mistral(按 `arch_type` 字段区分)
235
+ - 量化:FP32 / FP16 / BF16 / INT8 / Q8_0 / Q4_0 / Q4K
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tgai-go"
7
+ version = "1.0.0"
8
+ description = "TGAI GO —— 纯 Python 的 TGAI 模型推理库(CPU 引擎,零编译安装)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ # ★ license 用 SPDX 字符串(2026-10-11 改)
12
+ # 原来写的是 license = { text = "MIT" }(TOML 表形式),
13
+ # setuptools >= 77 已弃用,构建时会刷一大段警告并声明
14
+ # 2027-02-18 后不再支持。改成 SPDX 表达式即可(加 license-files 更规范)。
15
+ license = "MIT"
16
+ license-files = ["LICENSE"]
17
+ authors = [{ name = "TGAI" }]
18
+ keywords = ["tgai", "llm", "inference", "moe", "chinese", "llama"]
19
+ classifiers = [
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: C",
22
+ "Operating System :: Microsoft :: Windows",
23
+ "Operating System :: POSIX :: Linux",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ "Intended Audience :: Developers",
26
+ ]
27
+ dependencies = [
28
+ # 只有 numpy:采样与张量运算用
29
+ "numpy>=1.20",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ # 外部分词器(大词表模型的兜底方案;不装也能跑内置分词器)
34
+ tokenizer = ["tokenizers>=0.15"]
35
+ # 开发/测试
36
+ dev = ["pytest>=7"]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/tgai/tgai-go"
40
+ Documentation = "https://github.com/tgai/tgai-go#readme"
41
+
42
+ [project.scripts]
43
+ # 命令行入口(可选):tgai-go chat -m model.TG
44
+ # 注意这只是薄封装,主要用法是 import tgai_go
45
+ tgai-go = "tgai_go.__main__:main"
46
+
47
+ [tool.setuptools]
48
+ # ★ _native 必须显式列出(2026-10-11 修)
49
+ # 它是只装 .dll 的数据目录、没有 __init__.py,但仍被 Python 视为
50
+ # "可导入的包"。只写 packages = ["tgai_go"] 时 setuptools 会警告:
51
+ # Package 'tgai_go._native' is absent from the `packages` configuration
52
+ # -> Package would be ignored
53
+ # 虽然实测 DLL 仍被打进 wheel(靠 package-data),但该警告属"配置含糊",
54
+ # 随时可能在某个 setuptools 版本变成真的丢文件。显式列出最稳。
55
+ packages = ["tgai_go", "tgai_go._native"]
56
+ include-package-data = true
57
+ zip-safe = false
58
+
59
+ [tool.setuptools.package-data]
60
+ # ★ 原生引擎随包分发:用户 pip install 后无需编译
61
+ # 文件名由 build_wheel.py 按平台放置
62
+ "tgai_go" = ["_native/*.dll", "_native/*.so", "_native/*.dylib", "_native/README.md"]
63
+
64
+ [tool.setuptools.exclude-package-data]
65
+ "*" = ["*.pyc", "__pycache__/*", "*.c", "*.obj", "*.lib", "*.exp"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+