mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-26 14:24:46 +00:00
core: expose v2 model listing API (#25821)
This commit is contained in:
27
packages/core/src/github-copilot/openai-compatible-error.ts
Normal file
27
packages/core/src/github-copilot/openai-compatible-error.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { z, type ZodType } from "zod/v4"
|
||||
|
||||
export const openaiCompatibleErrorDataSchema = z.object({
|
||||
error: z.object({
|
||||
message: z.string(),
|
||||
|
||||
// The additional information below is handled loosely to support
|
||||
// OpenAI-compatible providers that have slightly different error
|
||||
// responses:
|
||||
type: z.string().nullish(),
|
||||
param: z.any().nullish(),
|
||||
code: z.union([z.string(), z.number()]).nullish(),
|
||||
}),
|
||||
})
|
||||
|
||||
export type OpenAICompatibleErrorData = z.infer<typeof openaiCompatibleErrorDataSchema>
|
||||
|
||||
export type ProviderErrorStructure<T> = {
|
||||
errorSchema: ZodType<T>
|
||||
errorToMessage: (error: T) => string
|
||||
isRetryable?: (response: Response, error?: T) => boolean
|
||||
}
|
||||
|
||||
export const defaultOpenAICompatibleErrorStructure: ProviderErrorStructure<OpenAICompatibleErrorData> = {
|
||||
errorSchema: openaiCompatibleErrorDataSchema,
|
||||
errorToMessage: (data) => data.error.message,
|
||||
}
|
||||
Reference in New Issue
Block a user