fix: account for additional openai retry case (#24063)
This commit is contained in:
@@ -111,12 +111,13 @@ export type ParsedStreamError =
|
||||
| {
|
||||
type: "api_error"
|
||||
message: string
|
||||
isRetryable: false
|
||||
isRetryable: boolean
|
||||
responseBody: string
|
||||
}
|
||||
|
||||
export function parseStreamError(input: unknown): ParsedStreamError | undefined {
|
||||
const body = json(input)
|
||||
const raw = json(input)
|
||||
const body = typeof raw?.message === "string" ? (json(raw.message) ?? raw) : raw
|
||||
if (!body) return
|
||||
|
||||
const responseBody = JSON.stringify(body)
|
||||
@@ -150,6 +151,13 @@ export function parseStreamError(input: unknown): ParsedStreamError | undefined
|
||||
isRetryable: false,
|
||||
responseBody,
|
||||
}
|
||||
case "server_error":
|
||||
return {
|
||||
type: "api_error",
|
||||
message: typeof body?.error?.message === "string" ? body?.error?.message : "Server error.",
|
||||
isRetryable: true,
|
||||
responseBody,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user