fix(runtime): preserve model capacity history and cache evidence with resumable file proposals
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import { CAPACITY_RANGES, capacityMode } from '../../shared/contracts/model-capacity.mjs';
|
||||
|
||||
const ranges = {
|
||||
contextLimit: [1000, 200000], maxOutputTokens: [256, 16000], maxSteps: [1, 30],
|
||||
...CAPACITY_RANGES, maxSteps: [1, 30],
|
||||
maxRunDurationMs: [1000, 3600000], maxRunTokens: [1000, 2000000], maxTaskTokens: [1000, 10000000],
|
||||
};
|
||||
|
||||
// Budget-only edits cannot change the selected route, endpoint or credential.
|
||||
export function validateRuntimeBudgets(input) {
|
||||
if (!input || typeof input !== 'object' || Array.isArray(input) || !Object.keys(input).length
|
||||
|| Object.keys(input).some(key => !Object.hasOwn(ranges, key))) throw new Error('只接受运行预算字段;模型连接请在模型选择中切换。');
|
||||
|| Object.keys(input).some(key => !['capacityMode', 'historyPolicy'].includes(key) && !Object.hasOwn(ranges, key))) throw new Error('只接受运行预算字段;模型连接请在模型选择中切换。');
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (key === 'capacityMode') { capacityMode(value); continue; }
|
||||
if (key === 'historyPolicy') { if (!['preserve', 'compact'].includes(value)) throw new Error('请选择完整传递或允许整理历史。'); continue; }
|
||||
const [min, max] = ranges[key];
|
||||
if (!Number.isSafeInteger(value) || value < min || value > max) throw new Error(key + ' 需填写范围内的整数。');
|
||||
}
|
||||
return { ...input };
|
||||
return { ...input, ...(!Object.hasOwn(input, 'capacityMode') && ['contextLimit', 'maxOutputTokens'].some(key => Object.hasOwn(input, key)) ? { capacityMode: 'manual' } : {}) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user