mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
fix(core): keep prompt cache settings out of model variants (#59500)
This commit is contained in:
committed by
GitHub
Unverified
parent
7b1e54a74f
commit
24bf4d488a
+32
-24
@@ -369,6 +369,14 @@ export type ModelRef = { id: string; providerID: ProviderID; variant?: string }
|
||||
|
||||
export type ProviderCache = { ttl?: ProviderCacheTTL }
|
||||
|
||||
export type ModelVariantSettings = { compaction?: ProviderCompaction; encoding?: ProviderEncoding } & {
|
||||
[x: string]: any
|
||||
}
|
||||
|
||||
export type ConfigModelVariantSettings = { compaction?: ProviderCompaction; encoding?: ProviderEncoding } & {
|
||||
[x: string]: JsonValue | null
|
||||
}
|
||||
|
||||
export type PermissionRule = { action: string; resource: string; effect: PermissionEffect }
|
||||
|
||||
export type PluginInfo = { id?: PluginID; source: PluginSource; features: PluginFeatures; state: PluginState }
|
||||
@@ -982,6 +990,13 @@ export type ConfigModelSettings = {
|
||||
encoding?: ProviderEncoding
|
||||
} & { [x: string]: JsonValue | null }
|
||||
|
||||
export type ModelVariant = {
|
||||
id: string
|
||||
settings?: ModelVariantSettings
|
||||
headers?: { [x: string]: string }
|
||||
body?: { [x: string]: any }
|
||||
}
|
||||
|
||||
export type PermissionRuleset = Array<PermissionRule>
|
||||
|
||||
export type UsageLimitsBudget = {
|
||||
@@ -2163,11 +2178,26 @@ export type ProviderInfo = {
|
||||
body?: { [x: string]: any }
|
||||
}
|
||||
|
||||
export type ModelVariant = {
|
||||
export type ModelInfo = {
|
||||
id: string
|
||||
modelID: string
|
||||
providerID: ProviderID
|
||||
canonical?: ProviderID
|
||||
type?: ModelType
|
||||
family?: string
|
||||
name: string
|
||||
compatibility?: ModelCompatibility
|
||||
package?: string
|
||||
settings?: ModelSettings
|
||||
headers?: { [x: string]: string }
|
||||
body?: { [x: string]: any }
|
||||
capabilities: ModelCapabilities
|
||||
variants: Array<ModelVariant>
|
||||
time: { released: number }
|
||||
cost: Array<ModelCost>
|
||||
status: "alpha" | "beta" | "deprecated" | "active"
|
||||
enabled: boolean
|
||||
limit: { context: number; input?: number; output: number }
|
||||
}
|
||||
|
||||
export type SessionInfo = {
|
||||
@@ -2367,7 +2397,7 @@ export type ConfigEntry =
|
||||
capabilities?: ConfigModelCapabilities
|
||||
variants?: Array<{
|
||||
id: string
|
||||
settings?: ConfigModelSettings
|
||||
settings?: ConfigModelVariantSettings
|
||||
headers?: { [x: string]: string }
|
||||
body?: { [x: string]: JsonValue }
|
||||
}>
|
||||
@@ -2491,28 +2521,6 @@ export type AgentInfo = {
|
||||
permissions: PermissionRuleset
|
||||
}
|
||||
|
||||
export type ModelInfo = {
|
||||
id: string
|
||||
modelID: string
|
||||
providerID: ProviderID
|
||||
canonical?: ProviderID
|
||||
type?: ModelType
|
||||
family?: string
|
||||
name: string
|
||||
compatibility?: ModelCompatibility
|
||||
package?: string
|
||||
settings?: ModelSettings
|
||||
headers?: { [x: string]: string }
|
||||
body?: { [x: string]: any }
|
||||
capabilities: ModelCapabilities
|
||||
variants: Array<ModelVariant>
|
||||
time: { released: number }
|
||||
cost: Array<ModelCost>
|
||||
status: "alpha" | "beta" | "deprecated" | "active"
|
||||
enabled: boolean
|
||||
limit: { context: number; input?: number; output: number }
|
||||
}
|
||||
|
||||
export type SessionsResponse = {
|
||||
data: Array<SessionInfo>
|
||||
cursor: { previous?: SessionsCursor | null; next?: SessionsCursor | null }
|
||||
|
||||
@@ -175,7 +175,11 @@ export const withVariant = (
|
||||
variant
|
||||
? {
|
||||
...model,
|
||||
settings: Provider.mergeOverlay(model.settings, Provider.modelSettings(variant.settings)),
|
||||
// Config accepts unknown variant keys, so drop `cache` here too; a variant can't change the prompt cache.
|
||||
settings: Provider.mergeOverlay(
|
||||
model.settings,
|
||||
Provider.modelSettings(variant.settings && Struct.omit(variant.settings, ["cache"])),
|
||||
),
|
||||
headers: Provider.mergeHeaders(model.headers, variant.headers),
|
||||
body: Provider.mergeOverlay(model.body, variant.body),
|
||||
}
|
||||
|
||||
Generated
+43
-2
@@ -16000,6 +16000,30 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"Config.Model.VariantSettings": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"compaction": {
|
||||
"$ref": "#/components/schemas/Provider.Compaction"
|
||||
},
|
||||
"encoding": {
|
||||
"$ref": "#/components/schemas/Provider.Encoding"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"Config.ModelEncoded": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -16050,7 +16074,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"settings": {
|
||||
"$ref": "#/components/schemas/Config.Model.Settings"
|
||||
"$ref": "#/components/schemas/Config.Model.VariantSettings"
|
||||
},
|
||||
"headers": {
|
||||
"type": "object",
|
||||
@@ -19205,7 +19229,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"settings": {
|
||||
"$ref": "#/components/schemas/Model.Settings"
|
||||
"$ref": "#/components/schemas/Model.VariantSettings"
|
||||
},
|
||||
"headers": {
|
||||
"type": "object",
|
||||
@@ -19220,6 +19244,23 @@
|
||||
"required": ["id"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"Model.VariantSettings": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"compaction": {
|
||||
"$ref": "#/components/schemas/Provider.Compaction"
|
||||
},
|
||||
"encoding": {
|
||||
"$ref": "#/components/schemas/Provider.Encoding"
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModelNotFoundErrorEncoded": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export * as ConfigProvider from "./provider.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { Schema, Struct } from "effect"
|
||||
import { Money } from "../money.js"
|
||||
import { Capabilities, Compatibility, Family, ID, Model, Type, VariantID } from "../model.js"
|
||||
import { ProviderCompatibility } from "../model-compatibility.js"
|
||||
@@ -96,6 +96,13 @@ class ModelConfig extends Schema.Class<ModelConfig>("Config.Model")({
|
||||
variants: Schema.Struct({
|
||||
id: VariantID,
|
||||
...ModelOverlays,
|
||||
// The prompt cache belongs to the model, so a variant can't change it.
|
||||
settings: Schema.StructWithRest(
|
||||
Schema.Struct(Struct.omit(ModelSettings.schema.fields, ["cache"])),
|
||||
ModelSettings.records,
|
||||
)
|
||||
.annotate({ identifier: "Config.Model.VariantSettings" })
|
||||
.pipe(optional),
|
||||
}).pipe(Schema.Array, optional),
|
||||
cost: Schema.Union([Cost, Cost.pipe(Schema.Array)]).pipe(optional),
|
||||
disabled: Schema.Boolean.pipe(optional),
|
||||
|
||||
@@ -62,6 +62,12 @@ export const Settings = Schema.StructWithRest(
|
||||
).annotate({ identifier: "Model.Settings" })
|
||||
export type Settings = typeof Settings.Type
|
||||
|
||||
// Variants switch request settings. The prompt cache belongs to the model, so a variant can't change it.
|
||||
const VariantSettings = Schema.StructWithRest(
|
||||
Schema.Struct(Struct.omit(Settings.schema.fields, ["cache"])),
|
||||
Settings.records,
|
||||
).annotate({ identifier: "Model.VariantSettings" })
|
||||
|
||||
export const Overlays = {
|
||||
settings: Settings.pipe(optional),
|
||||
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
|
||||
@@ -101,6 +107,7 @@ export interface Variant extends Schema.Schema.Type<typeof Variant> {}
|
||||
export const Variant = Schema.Struct({
|
||||
id: VariantID,
|
||||
...Overlays,
|
||||
settings: VariantSettings.pipe(optional),
|
||||
}).annotate({ identifier: "Model.Variant" })
|
||||
|
||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
|
||||
Reference in New Issue
Block a user