Skip to content

Commit 4e9c00a

Browse files
authored
fix(core): keep custom providers whose model sets only part of limit (#62240)
1 parent f270347 commit 4e9c00a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/core/src/v1/config/migrate.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ function migrateModel(info: typeof ConfigProviderV1.Model.Type, npm: string | un
250250
cost: costs,
251251
disabled: info.status === "deprecated" ? true : undefined,
252252
limit: info.limit && {
253-
context: int(info.limit.context),
253+
context: info.limit.context === undefined ? undefined : int(info.limit.context),
254254
input: info.limit.input === undefined ? undefined : int(info.limit.input),
255-
output: int(info.limit.output),
255+
output: info.limit.output === undefined ? undefined : int(info.limit.output),
256256
},
257257
}
258258
}

‎packages/core/src/v1/config/provider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export const Model = Schema.Struct({
4141
),
4242
limit: Schema.optional(
4343
Schema.Struct({
44-
context: Schema.Finite,
44+
context: Schema.optional(Schema.Finite),
4545
input: Schema.optional(Schema.Finite),
46-
output: Schema.Finite,
46+
output: Schema.optional(Schema.Finite),
4747
}),
4848
),
4949
modalities: Schema.optional(

‎packages/core/test/config/provider.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,11 @@ describe("ConfigProviderPlugin.Plugin", () => {
694694
legacy: { models: { chat: { cost: { input: 0, output: 0 } } } },
695695
native: { models: { chat: { cost: { input: 0, output: 0 } } } },
696696
},
697+
{
698+
name: "context-only limits",
699+
legacy: { models: { chat: { limit: { context: 1000000 } } } },
700+
native: { models: { chat: { limit: { context: 1000000 } } } },
701+
},
697702
]) {
698703
it.effect(`matches native configuration for migrated ${scenario.name}`, () =>
699704
Effect.gen(function* () {

0 commit comments

Comments
 (0)