mirror of
https://git.openapi.site/https://github.com/desirecore/config-center.git
synced 2026-07-23 01:53:18 +08:00
fix(compute): enforce reasoning effort boundaries (#60)
This commit is contained in:
@@ -324,6 +324,14 @@ describe('provider schema 反例(防 PR #1 重演)', () => {
|
||||
assert.equal(validate(duplicate), false)
|
||||
})
|
||||
|
||||
it('拒绝不在 supportedEfforts 中的 defaultEffort', () => {
|
||||
const data = makeValidProvider()
|
||||
data.models[0].extra = {
|
||||
reasoning: { supportedEfforts: ['low'], defaultEffort: 'high' },
|
||||
}
|
||||
assert.equal(validate(data), false)
|
||||
})
|
||||
|
||||
it('接受 defaultTemperature: 0.7(合法 number)', () => {
|
||||
const data = makeValidProvider()
|
||||
data.models[0].defaultTemperature = 0.7
|
||||
@@ -373,6 +381,34 @@ describe('provider schema 反例(防 PR #1 重演)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('model-spec schema 接入面边界', () => {
|
||||
const validate = compile('model-spec')
|
||||
|
||||
it('拒绝在模型内在规格中声明 reasoning effort', () => {
|
||||
const data = {
|
||||
specs: [{
|
||||
id: 'gpt-test',
|
||||
spec: {
|
||||
extra: {
|
||||
reasoning: {
|
||||
supportedEfforts: ['low', 'high'],
|
||||
defaultEffort: 'low',
|
||||
},
|
||||
},
|
||||
},
|
||||
}],
|
||||
}
|
||||
assert.equal(validate(data), false)
|
||||
})
|
||||
|
||||
it('仍允许模型内在扩展参数', () => {
|
||||
const data = {
|
||||
specs: [{ id: 'gpt-test', spec: { extra: { intrinsicBudgetHint: 8192 } } }],
|
||||
}
|
||||
assert.equal(validate(data), true, JSON.stringify(validate.errors))
|
||||
})
|
||||
})
|
||||
|
||||
// ==================== Manifest schema ====================
|
||||
|
||||
describe('manifest schema', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"presetDataVersion": 76,
|
||||
"presetDataVersion": 77,
|
||||
"updatedAt": "2026-07-19",
|
||||
"description": "DesireCore 官方配置中心"
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@
|
||||
},
|
||||
"extra": {
|
||||
"type": "object",
|
||||
"description": "模型特定附加配置(如 apiModelId 全名、推理预算等)。不含价格。",
|
||||
"description": "模型内在附加配置(如 apiModelId 全名、推理预算等)。不含价格,也不得声明 Provider/接入面的 reasoning effort 能力。",
|
||||
"not": { "required": ["reasoning"] },
|
||||
"additionalProperties": true
|
||||
},
|
||||
"releasedAt": {
|
||||
|
||||
@@ -274,6 +274,14 @@
|
||||
"description": "当前模型在此接入面的推荐显式默认档位,必须同时存在于 supportedEfforts。"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "minimal" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "minimal" } } } } },
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "low" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "low" } } } } },
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "medium" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "medium" } } } } },
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "high" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "high" } } } } },
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "xhigh" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "xhigh" } } } } },
|
||||
{ "if": { "required": ["defaultEffort"], "properties": { "defaultEffort": { "const": "max" } } }, "then": { "properties": { "supportedEfforts": { "contains": { "const": "max" } } } } }
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user