This commit is contained in:
Hk-Gosuto
2024-02-20 17:16:20 +08:00
parent 4e5bd62477
commit 3974f0d477
4 changed files with 11 additions and 1 deletions

View File

@@ -172,7 +172,10 @@ export class GeminiProApi implements LLMApi {
// start animaion
animateResponseText();
fetch(streamChatPath, chatPayload)
.then((response) => {
.then(async (response) => {
if (!response.ok) {
throw new Error(await response?.text());
}
const reader = response?.body?.getReader();
const decoder = new TextDecoder();
let partialData = "";
@@ -220,6 +223,7 @@ export class GeminiProApi implements LLMApi {
})
.catch((error) => {
console.error("Error:", error);
options.onError?.(error as Error);
});
} else {
const res = await fetch(chatPath, chatPayload);