refactor: unwrap ConfigProvider namespace + self-reexport (#22949)
This commit is contained in:
@@ -1,120 +1,120 @@
|
|||||||
import z from "zod"
|
import z from "zod"
|
||||||
|
|
||||||
export namespace ConfigProvider {
|
export const Model = z
|
||||||
export const Model = z
|
.object({
|
||||||
.object({
|
id: z.string(),
|
||||||
id: z.string(),
|
name: z.string(),
|
||||||
name: z.string(),
|
family: z.string().optional(),
|
||||||
family: z.string().optional(),
|
release_date: z.string(),
|
||||||
release_date: z.string(),
|
attachment: z.boolean(),
|
||||||
attachment: z.boolean(),
|
reasoning: z.boolean(),
|
||||||
reasoning: z.boolean(),
|
temperature: z.boolean(),
|
||||||
temperature: z.boolean(),
|
tool_call: z.boolean(),
|
||||||
tool_call: z.boolean(),
|
interleaved: z
|
||||||
interleaved: z
|
.union([
|
||||||
.union([
|
z.literal(true),
|
||||||
z.literal(true),
|
z
|
||||||
z
|
.object({
|
||||||
.object({
|
field: z.enum(["reasoning_content", "reasoning_details"]),
|
||||||
field: z.enum(["reasoning_content", "reasoning_details"]),
|
})
|
||||||
})
|
.strict(),
|
||||||
.strict(),
|
])
|
||||||
])
|
.optional(),
|
||||||
.optional(),
|
cost: z
|
||||||
cost: z
|
.object({
|
||||||
.object({
|
input: z.number(),
|
||||||
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(),
|
output: z.number(),
|
||||||
}),
|
cache_read: z.number().optional(),
|
||||||
modalities: z
|
cache_write: z.number().optional(),
|
||||||
.object({
|
context_over_200k: z
|
||||||
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
.object({
|
||||||
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
input: z.number(),
|
||||||
})
|
output: z.number(),
|
||||||
.optional(),
|
cache_read: z.number().optional(),
|
||||||
experimental: z.boolean().optional(),
|
cache_write: z.number().optional(),
|
||||||
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
|
})
|
||||||
provider: z.object({ npm: z.string().optional(), api: z.string().optional() }).optional(),
|
.optional(),
|
||||||
options: z.record(z.string(), z.any()),
|
})
|
||||||
headers: z.record(z.string(), z.string()).optional(),
|
.optional(),
|
||||||
variants: z
|
limit: z.object({
|
||||||
.record(
|
context: z.number(),
|
||||||
z.string(),
|
input: z.number().optional(),
|
||||||
z
|
output: z.number(),
|
||||||
.object({
|
}),
|
||||||
disabled: z.boolean().optional().describe("Disable this variant for the model"),
|
modalities: z
|
||||||
})
|
.object({
|
||||||
.catchall(z.any()),
|
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||||
)
|
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||||
.optional()
|
})
|
||||||
.describe("Variant-specific configuration"),
|
.optional(),
|
||||||
})
|
experimental: z.boolean().optional(),
|
||||||
.partial()
|
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(
|
||||||
|
z.string(),
|
||||||
|
z
|
||||||
|
.object({
|
||||||
|
disabled: z.boolean().optional().describe("Disable this variant for the model"),
|
||||||
|
})
|
||||||
|
.catchall(z.any()),
|
||||||
|
)
|
||||||
|
.optional()
|
||||||
|
.describe("Variant-specific configuration"),
|
||||||
|
})
|
||||||
|
.partial()
|
||||||
|
|
||||||
export const Info = z
|
export const Info = z
|
||||||
.object({
|
.object({
|
||||||
api: z.string().optional(),
|
api: z.string().optional(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
env: z.array(z.string()),
|
env: z.array(z.string()),
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
npm: z.string().optional(),
|
npm: z.string().optional(),
|
||||||
whitelist: z.array(z.string()).optional(),
|
whitelist: z.array(z.string()).optional(),
|
||||||
blacklist: 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(),
|
||||||
baseURL: z.string().optional(),
|
baseURL: z.string().optional(),
|
||||||
enterpriseUrl: z.string().optional().describe("GitHub Enterprise URL for copilot authentication"),
|
enterpriseUrl: z.string().optional().describe("GitHub Enterprise URL for copilot authentication"),
|
||||||
setCacheKey: z.boolean().optional().describe("Enable promptCacheKey for this provider (default false)"),
|
setCacheKey: z.boolean().optional().describe("Enable promptCacheKey for this provider (default false)"),
|
||||||
timeout: z
|
timeout: z
|
||||||
.union([
|
.union([
|
||||||
z
|
z
|
||||||
.number()
|
.number()
|
||||||
.int()
|
.int()
|
||||||
.positive()
|
.positive()
|
||||||
.describe(
|
.describe(
|
||||||
"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
|
"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
|
||||||
),
|
),
|
||||||
z.literal(false).describe("Disable timeout for this provider entirely."),
|
z.literal(false).describe("Disable timeout for this provider entirely."),
|
||||||
])
|
])
|
||||||
.optional()
|
.optional()
|
||||||
.describe(
|
.describe(
|
||||||
"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
|
"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout.",
|
||||||
),
|
),
|
||||||
chunkTimeout: z
|
chunkTimeout: z
|
||||||
.number()
|
.number()
|
||||||
.int()
|
.int()
|
||||||
.positive()
|
.positive()
|
||||||
.optional()
|
.optional()
|
||||||
.describe(
|
.describe(
|
||||||
"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
|
"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted.",
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.catchall(z.any())
|
.catchall(z.any())
|
||||||
.optional(),
|
.optional(),
|
||||||
models: z.record(z.string(), Model).optional(),
|
models: z.record(z.string(), Model).optional(),
|
||||||
})
|
})
|
||||||
.partial()
|
.partial()
|
||||||
.strict()
|
.strict()
|
||||||
.meta({
|
.meta({
|
||||||
ref: "ProviderConfig",
|
ref: "ProviderConfig",
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Info = z.infer<typeof Info>
|
export type Info = z.infer<typeof Info>
|
||||||
}
|
|
||||||
|
export * as ConfigProvider from "./provider"
|
||||||
|
|||||||
Reference in New Issue
Block a user