@dsh-plus/llm-pi 0.1.15 → 0.1.16
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/lib/index.js +8 -10
- package/package.json +1 -1
- package/src/profiles.ts +9 -11
package/lib/index.js
CHANGED
|
@@ -810,10 +810,6 @@ const GATES_BY_PROTOCOL = {
|
|
|
810
810
|
supportsToolReferences: "withhold"
|
|
811
811
|
}
|
|
812
812
|
};
|
|
813
|
-
/** 某协议某字段的可配性('offer'/'withhold';未列出 = 无此字段)。 */
|
|
814
|
-
function compatDispositionOf(api, field) {
|
|
815
|
-
return GATES_BY_PROTOCOL[api][field];
|
|
816
|
-
}
|
|
817
813
|
/**
|
|
818
814
|
* 字段取值约束(对齐官方 config.ts compatProfile schema):
|
|
819
815
|
* boolean 字段 → 'boolean';maxTokensField/thinkingFormat/cacheControlFormat
|
|
@@ -1395,14 +1391,16 @@ function resolveModelReasoning(entry) {
|
|
|
1395
1391
|
thinkingLevelMap: map
|
|
1396
1392
|
};
|
|
1397
1393
|
}
|
|
1398
|
-
/**
|
|
1399
|
-
|
|
1394
|
+
/**
|
|
1395
|
+
* 官方 resolveModelCompat 的插件侧镜像(fallback 专用):透传物化条目的 compat。
|
|
1396
|
+
* 与官方的差异是有意的:官方校验的是用户原始条目(写时拒绝非 offer 字段),
|
|
1397
|
+
* 而本 fallback 收到的条目已经归一化物化(继承值落定、用户层在 materializeModel
|
|
1398
|
+
* 经 validateCompat 门控校验过)——compat 里可能合法携带内置目录的 withhold 键
|
|
1399
|
+
* (如 supportsOpenAIGrammarTools),再做门控只会误杀目录继承值。
|
|
1400
|
+
*/
|
|
1401
|
+
function resolveModelCompat(provider, entry, _api) {
|
|
1400
1402
|
const configured = {};
|
|
1401
1403
|
for (const [field, value] of Object.entries(entry.compat ?? {})) {
|
|
1402
|
-
if (compatDispositionOf(api, field) !== "offer") {
|
|
1403
|
-
const offered = compatFieldsOf(api);
|
|
1404
|
-
invalid(provider, `model "${entry.id}" 的 compat.${field} 不适用于协议 ${api};该协议可配置字段:${offered.length === 0 ? "无" : offered.join(", ")}`);
|
|
1405
|
-
}
|
|
1406
1404
|
if (value === void 0 || value === null) invalid(provider, `model "${entry.id}" 的 compat.${field} 未设置值;给出值或移除该键`);
|
|
1407
1405
|
configured[field] = value;
|
|
1408
1406
|
}
|
package/package.json
CHANGED
package/src/profiles.ts
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
type ModelBase,
|
|
40
40
|
} from './catalog/builtin.ts'
|
|
41
41
|
import type { ModelsDevSource } from './catalog/models-dev.ts'
|
|
42
|
-
import {
|
|
42
|
+
import { mergeCompat, validateCompat } from './compat.ts'
|
|
43
43
|
import {
|
|
44
44
|
DEFAULT_CONTEXT_WINDOW,
|
|
45
45
|
DEFAULT_MAX_REQUEST_IMAGE_BYTES,
|
|
@@ -481,22 +481,20 @@ function resolveModelReasoning(entry: PiAiModelProfile): {
|
|
|
481
481
|
return { reasoning: true, thinkingLevelMap: map }
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
/**
|
|
484
|
+
/**
|
|
485
|
+
* 官方 resolveModelCompat 的插件侧镜像(fallback 专用):透传物化条目的 compat。
|
|
486
|
+
* 与官方的差异是有意的:官方校验的是用户原始条目(写时拒绝非 offer 字段),
|
|
487
|
+
* 而本 fallback 收到的条目已经归一化物化(继承值落定、用户层在 materializeModel
|
|
488
|
+
* 经 validateCompat 门控校验过)——compat 里可能合法携带内置目录的 withhold 键
|
|
489
|
+
* (如 supportsOpenAIGrammarTools),再做门控只会误杀目录继承值。
|
|
490
|
+
*/
|
|
485
491
|
function resolveModelCompat(
|
|
486
492
|
provider: string,
|
|
487
493
|
entry: PiAiModelProfile,
|
|
488
|
-
|
|
494
|
+
_api: string,
|
|
489
495
|
): { compat: Record<string, unknown> } | Record<string, never> {
|
|
490
496
|
const configured: Record<string, unknown> = {}
|
|
491
497
|
for (const [field, value] of Object.entries(entry.compat ?? {})) {
|
|
492
|
-
if (compatDispositionOf(api as never, field) !== 'offer') {
|
|
493
|
-
const offered = compatFieldsOf(api as never)
|
|
494
|
-
invalid(
|
|
495
|
-
provider,
|
|
496
|
-
`model "${entry.id}" 的 compat.${field} 不适用于协议 ${api};` +
|
|
497
|
-
`该协议可配置字段:${offered.length === 0 ? '无' : offered.join(', ')}`,
|
|
498
|
-
)
|
|
499
|
-
}
|
|
500
498
|
if (value === undefined || value === null) {
|
|
501
499
|
invalid(provider, `model "${entry.id}" 的 compat.${field} 未设置值;给出值或移除该键`)
|
|
502
500
|
}
|