tweak: separate ModelsDev.Model and Config model schemas (#21561)

This commit is contained in:
Aiden Cline
2026-04-08 15:55:14 -05:00
committed by GitHub
parent 00cb8839ae
commit 4961d72c0f
5 changed files with 169 additions and 116 deletions
+75 -19
View File
@@ -786,28 +786,81 @@ export namespace Config {
}) })
export type Layout = z.infer<typeof Layout> export type Layout = z.infer<typeof Layout>
export const Provider = ModelsDev.Provider.partial() export const Model = z
.extend({ .object({
whitelist: z.array(z.string()).optional(), id: z.string(),
blacklist: z.array(z.string()).optional(), name: z.string(),
models: z family: z.string().optional(),
release_date: z.string(),
attachment: z.boolean(),
reasoning: z.boolean(),
temperature: z.boolean(),
tool_call: z.boolean(),
interleaved: z
.union([
z.literal(true),
z
.object({
field: z.enum(["reasoning_content", "reasoning_details"]),
})
.strict(),
])
.optional(),
cost: z
.object({
input: z.number(),
output: z.number(),
cache_read: z.number().optional(),
cache_write: z.number().optional(),
context_over_200k: z
.object({
input: z.number(),
output: z.number(),
cache_read: z.number().optional(),
cache_write: z.number().optional(),
})
.optional(),
})
.optional(),
limit: z.object({
context: z.number(),
input: z.number().optional(),
output: z.number(),
}),
modalities: z
.object({
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
})
.optional(),
experimental: z.boolean().optional(),
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
options: z.record(z.string(), z.any()),
headers: z.record(z.string(), z.string()).optional(),
variants: z
.record( .record(
z.string(), z.string(),
ModelsDev.Model.partial().extend({ z
variants: z .object({
.record( disabled: z.boolean().optional().describe("Disable this variant for the model"),
z.string(), })
z .catchall(z.any()),
.object({
disabled: z.boolean().optional().describe("Disable this variant for the model"),
})
.catchall(z.any()),
)
.optional()
.describe("Variant-specific configuration"),
}),
) )
.optional(), .optional()
.describe("Variant-specific configuration"),
})
.partial()
export const Provider = z
.object({
api: z.string().optional(),
name: z.string(),
env: z.array(z.string()),
id: z.string(),
npm: z.string().optional(),
whitelist: z.array(z.string()).optional(),
blacklist: z.array(z.string()).optional(),
options: z options: z
.object({ .object({
apiKey: z.string().optional(), apiKey: z.string().optional(),
@@ -840,11 +893,14 @@ export namespace Config {
}) })
.catchall(z.any()) .catchall(z.any())
.optional(), .optional(),
models: z.record(z.string(), Model).optional(),
}) })
.partial()
.strict() .strict()
.meta({ .meta({
ref: "ProviderConfig", ref: "ProviderConfig",
}) })
export type Provider = z.infer<typeof Provider> export type Provider = z.infer<typeof Provider>
export const Info = z export const Info = z
-3
View File
@@ -70,10 +70,7 @@ export namespace ModelsDev {
.optional(), .optional(),
experimental: z.boolean().optional(), experimental: z.boolean().optional(),
status: z.enum(["alpha", "beta", "deprecated"]).optional(), status: z.enum(["alpha", "beta", "deprecated"]).optional(),
options: z.record(z.string(), z.any()),
headers: z.record(z.string(), z.string()).optional(),
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(), provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
variants: z.record(z.string(), z.record(z.string(), z.any())).optional(),
}) })
export type Model = z.infer<typeof Model> export type Model = z.infer<typeof Model>
+2 -2
View File
@@ -937,8 +937,8 @@ export namespace Provider {
npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible", npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible",
}, },
status: model.status ?? "active", status: model.status ?? "active",
headers: model.headers ?? {}, headers: {},
options: model.options ?? {}, options: {},
cost: { cost: {
input: model.cost?.input ?? 0, input: model.cost?.input ?? 0,
output: model.cost?.output ?? 0, output: model.cost?.output ?? 0,
+27 -27
View File
@@ -1250,6 +1250,29 @@ export type ProviderConfig = {
env?: Array<string> env?: Array<string>
id?: string id?: string
npm?: string npm?: string
whitelist?: Array<string>
blacklist?: Array<string>
options?: {
apiKey?: string
baseURL?: string
/**
* GitHub Enterprise URL for copilot authentication
*/
enterpriseUrl?: string
/**
* Enable promptCacheKey for this provider (default false)
*/
setCacheKey?: boolean
/**
* Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
*/
timeout?: number | false
/**
* Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.
*/
chunkTimeout?: number
[key: string]: unknown | string | boolean | number | false | number | undefined
}
models?: { models?: {
[key: string]: { [key: string]: {
id?: string id?: string
@@ -1288,16 +1311,16 @@ export type ProviderConfig = {
} }
experimental?: boolean experimental?: boolean
status?: "alpha" | "beta" | "deprecated" status?: "alpha" | "beta" | "deprecated"
provider?: {
npm?: string
api?: string
}
options?: { options?: {
[key: string]: unknown [key: string]: unknown
} }
headers?: { headers?: {
[key: string]: string [key: string]: string
} }
provider?: {
npm?: string
api?: string
}
/** /**
* Variant-specific configuration * Variant-specific configuration
*/ */
@@ -1312,29 +1335,6 @@ export type ProviderConfig = {
} }
} }
} }
whitelist?: Array<string>
blacklist?: Array<string>
options?: {
apiKey?: string
baseURL?: string
/**
* GitHub Enterprise URL for copilot authentication
*/
enterpriseUrl?: string
/**
* Enable promptCacheKey for this provider (default false)
*/
setCacheKey?: boolean
/**
* Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.
*/
timeout?: number | false
/**
* Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.
*/
chunkTimeout?: number
[key: string]: unknown | string | boolean | number | false | number | undefined
}
} }
export type McpLocalConfig = { export type McpLocalConfig = {
+65 -65
View File
@@ -10596,6 +10596,60 @@
"npm": { "npm": {
"type": "string" "type": "string"
}, },
"whitelist": {
"type": "array",
"items": {
"type": "string"
}
},
"blacklist": {
"type": "array",
"items": {
"type": "string"
}
},
"options": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
},
"baseURL": {
"type": "string"
},
"enterpriseUrl": {
"description": "GitHub Enterprise URL for copilot authentication",
"type": "string"
},
"setCacheKey": {
"description": "Enable promptCacheKey for this provider (default false)",
"type": "boolean"
},
"timeout": {
"description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
"anyOf": [
{
"description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
{
"description": "Disable timeout for this provider entirely.",
"type": "boolean",
"const": false
}
]
},
"chunkTimeout": {
"description": "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"additionalProperties": {}
},
"models": { "models": {
"type": "object", "type": "object",
"propertyNames": { "propertyNames": {
@@ -10725,6 +10779,17 @@
"type": "string", "type": "string",
"enum": ["alpha", "beta", "deprecated"] "enum": ["alpha", "beta", "deprecated"]
}, },
"provider": {
"type": "object",
"properties": {
"npm": {
"type": "string"
},
"api": {
"type": "string"
}
}
},
"options": { "options": {
"type": "object", "type": "object",
"propertyNames": { "propertyNames": {
@@ -10741,17 +10806,6 @@
"type": "string" "type": "string"
} }
}, },
"provider": {
"type": "object",
"properties": {
"npm": {
"type": "string"
},
"api": {
"type": "string"
}
}
},
"variants": { "variants": {
"description": "Variant-specific configuration", "description": "Variant-specific configuration",
"type": "object", "type": "object",
@@ -10771,60 +10825,6 @@
} }
} }
} }
},
"whitelist": {
"type": "array",
"items": {
"type": "string"
}
},
"blacklist": {
"type": "array",
"items": {
"type": "string"
}
},
"options": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
},
"baseURL": {
"type": "string"
},
"enterpriseUrl": {
"description": "GitHub Enterprise URL for copilot authentication",
"type": "string"
},
"setCacheKey": {
"description": "Enable promptCacheKey for this provider (default false)",
"type": "boolean"
},
"timeout": {
"description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
"anyOf": [
{
"description": "Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
},
{
"description": "Disable timeout for this provider entirely.",
"type": "boolean",
"const": false
}
]
},
"chunkTimeout": {
"description": "Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 9007199254740991
}
},
"additionalProperties": {}
} }
}, },
"additionalProperties": false "additionalProperties": false