推荐预算、同合同补全和覆盖顺序
策略的具体实现如下。
ts
modelBudgetStrategies = Object.freeze({
small: Object.freeze({
maxCalls: 2,
maxInputChars: 8000,
maxOutputChars: 4000,
maxOutputTokens: 512,
callTimeoutMs: 15000,
}),
medium: Object.freeze({
maxCalls: 8,
maxInputChars: 32000,
maxOutputChars: 16000,
maxOutputTokens: 1024,
callTimeoutMs: 30000,
}),
large: Object.freeze({
maxCalls: 16,
maxInputChars: 64000,
maxOutputChars: 32000,
maxOutputTokens: 4096,
callTimeoutMs: 60000,
}),
})
settingKeys = {
...budgetSettingKeys,
provider: true,
execution: true,
transports: true,
sink: true,
errors: true,
} satisfies Record<keyof ModelRunnerOptions, true>
function settings(source: Partial<ModelRunnerOptions>): Partial<ModelRunnerOptions> {
const result: Record<string, unknown> = {};
for (const key of Object.keys(settingKeys) as (keyof ModelRunnerOptions)[])
if (key in source) result[key] = source[key];
return result;
}
export function createModelStrategy<const Options extends ModelStrategyOptions>(
options: Options,
): StrategyResult<Options>;