fix(llm-replay): reject undeclared minimum efforts
This commit is contained in:
1 parent
ffb88d331e
commit
6e894e4bea
2 files changed
+25
-1
No files matched your search
@@ -1151,6 +1151,13 @@ export interface Config {
|
||||
function validateConfiguredModels(providers: ReplayProviderConfig[] | undefined): void {
|
||||
for (const provider of providers ?? []) {
|
||||
for (const model of provider.models ?? []) {
|
||||
if (model.floorReasoningEffort !== undefined
|
||||
&& !model.reasoningEfforts?.includes(model.floorReasoningEffort)) {
|
||||
throw new Error(
|
||||
`llm-replay: provider "${provider.id}" model "${model.id}" floorReasoningEffort `
|
||||
+ 'must appear in reasoningEfforts',
|
||||
)
|
||||
}
|
||||
const modalities: unknown = model.inputModalities
|
||||
if (modalities !== undefined && (!Array.isArray(modalities)
|
||||
|| !modalities.every((modality: unknown) => modality === 'text' || modality === 'image'))) {
|
||||
|
||||
@@ -2161,7 +2161,13 @@ describe('apply (the plugin entry)', () => {
|
||||
apply(ctx, {
|
||||
file,
|
||||
providers: [
|
||||
{ id: 'm', models: [{ id: 'm', inputModalities: ['image'] }, { id: 'text' }] },
|
||||
{
|
||||
id: 'm',
|
||||
models: [
|
||||
{ id: 'm', inputModalities: ['image'], reasoningEfforts: ['low'], floorReasoningEffort: 'low' },
|
||||
{ id: 'text' },
|
||||
],
|
||||
},
|
||||
{ id: 'empty' },
|
||||
],
|
||||
paceMs: 1,
|
||||
@@ -2204,6 +2210,17 @@ describe('apply (the plugin entry)', () => {
|
||||
expect(ctx.llm.imageRequestPricing('deepseek', 'plain')).toBeUndefined()
|
||||
})
|
||||
|
||||
it.each([undefined, [], ['high']])('rejects a floor absent from configured efforts %s', (reasoningEfforts) => {
|
||||
const ctx = new Context()
|
||||
const model = {
|
||||
id: 'm', floorReasoningEffort: 'low',
|
||||
...reasoningEfforts === undefined ? {} : { reasoningEfforts },
|
||||
}
|
||||
expect(() => { apply(ctx, { file, providers: [{ id: 'm', models: [model] }] }) }).toThrow(
|
||||
'llm-replay: provider "m" model "m" floorReasoningEffort must appear in reasoningEfforts',
|
||||
)
|
||||
})
|
||||
|
||||
it('rejects imageRequestTokens on a model without the image modality during load', () => {
|
||||
const ctx = new Context()
|
||||
const providers = [{ id: 'm', models: [{ id: 'm', imageRequestTokens: 384 }] }] as
|
||||
|
||||
Reference in new issue
Block a user