mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 21:15:57 +03:00
fix(core): seed configured limits before model transforms (#55778)
Co-authored-by: Daniel Smolsky <dannysmo@gmail.com>
This commit is contained in:
@@ -90,6 +90,14 @@ export const Plugin = define({
|
||||
}
|
||||
next.set(item, { providerID, models: definitions })
|
||||
}
|
||||
for (const [item, definition] of next) {
|
||||
for (const [id, config] of Object.entries(item.models ?? {})) {
|
||||
if (config.limit === undefined) continue
|
||||
providers.models.update(definition.providerID, id, (model) => {
|
||||
model.limit = { ...model.limit, ...config.limit }
|
||||
})
|
||||
}
|
||||
}
|
||||
sources.defaultModel = Config.latest(loaded.entries, "model")
|
||||
sources.models = next
|
||||
})
|
||||
|
||||
@@ -889,7 +889,15 @@ describe("ConfigProviderPlugin.Plugin", () => {
|
||||
model.variants = [{ id: Model.VariantID.make("fast"), settings: { effort: "high" } }]
|
||||
})
|
||||
})
|
||||
let transformed: Model.Info["limit"] | undefined
|
||||
yield* models.transform((editor) => {
|
||||
const model = editor.get(providerID, modelID)
|
||||
if (!model) return
|
||||
transformed = { ...model.limit }
|
||||
model.limit = { context: 10, output: 1 }
|
||||
})
|
||||
yield* addPlugin(entries)
|
||||
expect(transformed).toEqual({ context: 100, output: 75 })
|
||||
|
||||
const provider = required(yield* providers.get(providerID))
|
||||
const model = required(yield* models.get(providerID, modelID))
|
||||
|
||||
Reference in New Issue
Block a user