magpie-modelscope-hub 0.1.4 → 0.1.5

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.
package/README.md CHANGED
@@ -122,6 +122,17 @@ supported" 的条目)标成 `deprecated`,magpie 会把它们从选择器和
122
122
  2026-11-18 对国内站 38 个模型逐个核过 pipeline 标签。表里没有的新 id 只报文本、
123
123
  不声明图片能力,将来上的视觉模型仍能收到图,不会被本地网关先挡掉。
124
124
 
125
+ ### 上下文窗口
126
+
127
+ `/v1/models` 不报窗口大小。之前所有线上模型吃默认 128K,对 1M 窗口的
128
+ DeepSeek-V4.1 / GLM-5.2 是错的:dsh 按「窗口 − 72K」当压缩阈值,128K 只剩
129
+ 54272 令牌,一条 66K 的对话就会「压缩失败、切不过去」。现在 `src/limits.mjs`
130
+ 按模型仓库 `config.json` 的 `max_position_embeddings`(含 `text_config` /
131
+ `llm_config` 里的)逐个补:DeepSeek 四兄弟 1M、GLM-5.2 1M、Qwen3.5/3.8 全系
132
+ 256K、GLM-4.7-Flash 202752、Intern-S1 64K。查不到的仍按 128K,不乱报。
133
+
134
+ 输出上限没有按模型的可靠来源,统一 8192。
135
+
125
136
  ### 推理强度
126
137
 
127
138
  `/v1/models` 只给 id,给不了「是不是思考模型」「支持哪几档推理强度」。不补这张
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie-modelscope-hub",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "魔搭 ModelScope 合一插件:国内站与国际站各自提供模型调用、魔粒用量卡和每日签到",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
package/src/limits.mjs ADDED
@@ -0,0 +1,59 @@
1
+ // 每个模型能吃多长的上下文。
2
+ //
3
+ // /v1/models 只回 id,模型详情接口也不说窗口大小。之前所有线上模型的
4
+ // limit.context 都吃默认 128000 —— 对 DeepSeek-V4.1 / GLM-5.2 这种 1M
5
+ // 窗口的模型,等于骗了客户端:magpie 的 dsh 按「窗口 - 72K」当压缩阈值,
6
+ // 128K 窗口只剩 54272 令牌,一条 66K 的对话就压不动、切不过去(2026-11-19
7
+ // 用户报的错)。窗口按模型仓库里的 config.json 读:
8
+ // max_position_embeddings,或 text_config / llm_config 里的同名键。
9
+ //
10
+ // 只有 config 里读得到的才写;读不到的不猜。MiniMax-M1-80k 的 config 写
11
+ // 10M(外推位置),实际服务窗口按名字是 80K,单独按 81920 算。
12
+ // 输出上限没有可靠的按模型来源,统一留 8192。
13
+
14
+ export const CONTEXTS = {
15
+ "deepseek-ai/DeepSeek-V4-Flash-0731": 1048576,
16
+ "deepseek-ai/DeepSeek-V4-Pro": 1048576,
17
+ "deepseek-ai/DeepSeek-V4-Pro-0813": 1048576,
18
+ "deepseek-ai/DeepSeek-V4.1-Flash": 1048576,
19
+ "deepseek-ai/DeepSeek-V4.1-Flash-1017": 1048576,
20
+
21
+ "MiniMax/MiniMax-M1-80k": 81920,
22
+ "MiniMax/MiniMax-M3": 1048576,
23
+ "mistralai/Mistral-Large-Instruct-2407": 131072,
24
+ "moonshotai/Kimi-K3.1-Pro": 1048576,
25
+
26
+ "nex-agi/Nex-N2.5-mini": 262144,
27
+ "nex-agi/Nex-N2.5-Pro": 262144,
28
+ "opencompass/CompassJudger-1-32B-Instruct": 32768,
29
+ "OpenGVLab/InternVL3_5-241B-A28B": 40960,
30
+
31
+ "PaddlePaddle/ERNIE-4.5-0.3B-PT": 131072,
32
+ "PaddlePaddle/ERNIE-4.5-21B-A3B-PT": 131072,
33
+ "PaddlePaddle/ERNIE-4.5-300B-A47B-PT": 131072,
34
+ "PaddlePaddle/ERNIE-4.5-VL-28B-A3B-PT": 131072,
35
+
36
+ "Qwen/Qwen3.5-122B-A10B": 262144,
37
+ "Qwen/Qwen3.5-27B": 262144,
38
+ "Qwen/Qwen3.5-35B-A3B": 262144,
39
+ "Qwen/Qwen3.5-397B-A17B": 262144,
40
+ "Qwen/Qwen3.8-27B": 262144,
41
+ "Qwen/Qwen3.8-Flash-Next": 262144,
42
+
43
+ "Shanghai_AI_Laboratory/Intern-S1": 65536,
44
+ "Shanghai_AI_Laboratory/Intern-S1-mini": 65536,
45
+ "Shanghai_AI_Laboratory/Intern-S2-Preview": 262144,
46
+
47
+ "stepfun-ai/Step-3.5-Flash": 262144,
48
+ "stepfun-ai/Step-3.7-Flash": 262144,
49
+ "stepfun-ai/Step-5-Preview": 1048576,
50
+
51
+ "XGenerationLab/XiYanSQL-QwenCoder-32B-2412": 32768,
52
+ "XGenerationLab/XiYanSQL-QwenCoder-32B-2504": 32768,
53
+ "ZhipuAI/GLM-4.7-Flash": 202752,
54
+ "ZhipuAI/GLM-5.2": 1048576,
55
+ }
56
+
57
+ export function contextOf(id) {
58
+ return CONTEXTS[id]
59
+ }
package/src/models.mjs CHANGED
@@ -12,6 +12,7 @@ import { expiredError } from "./net.mjs"
12
12
  import { familyOf, variantsOf } from "./capabilities.mjs"
13
13
  import { modalitiesOf } from "./modalities.mjs"
14
14
  import { rateOf } from "./rates.mjs"
15
+ import { contextOf } from "./limits.mjs"
15
16
 
16
17
  const MODELS_TTL_MS = 30 * 60 * 1000
17
18
  const STATE_MAX = 256
@@ -58,7 +59,7 @@ export function modelEntry(profile, id, created) {
58
59
  name: known?.name ?? displayName(id),
59
60
  api: { id, url: apiBase(profile), npm: "@ai-sdk/openai-compatible" },
60
61
  status: isDeprecated(profile, id) ? "deprecated" : "active",
61
- limit: known?.limit ?? { context: 128000, output: 8192 },
62
+ limit: known?.limit ?? { context: contextOf(id) ?? 128000, output: 8192 },
62
63
  // 计费是魔粒按次扣,不按 token,所以成本字段报 0(和上游两个插件一致)。
63
64
  cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
64
65
  options: {},