Write the underlying exception details to streamed response

Currently, when stream is enabled the `fetchSSE` isn't returning the api response details.
pull/387/head
Ali Gençay 2023-02-23 04:14:08 -08:00 zatwierdzone przez GitHub
rodzic 1fdf218b37
commit a3e05c2b70
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -12,7 +12,8 @@ export async function fetchSSE(
const { onMessage, ...fetchOptions } = options
const res = await fetch(url, fetchOptions)
if (!res.ok) {
const msg = `ChatGPT error ${res.status || res.statusText}`
const reason = await res.text()
const msg = `ChatGPT error ${res.status || res.statusText}: ${reason}`
const error = new types.ChatGPTError(msg, { cause: res })
error.statusCode = res.status
error.statusText = res.statusText