GHHG10/CodeServer / opencode /packages /core /src /github-copilot /openai-compatible-error.ts
GHHG10's picture
download
raw
893 Bytes
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,
}

Xet Storage Details

Size:
893 Bytes
·
Xet hash:
56abbbea4f23e314c1e25500e2c31759bb02d776ff666e80585e2bfc382325e0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.