Download packages/core/src/github-copilot/openai-compatible-error.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 893 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/github-copilot/openai-compatible-error.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/core/src/github-copilot/openai-compatible-error.ts
-
curl -L -o openai-compatible-error.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/src/github-copilot/openai-compatible-error.ts
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, | |
| } | |