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);

View File

@@ -105,6 +105,7 @@ Latex block: $$e=mc^2$$
`;
export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
export const GOOGLE_SUMMARIZE_MODEL = "gemini-pro";
export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",

View File

@@ -8,6 +8,7 @@ import {
DEFAULT_INPUT_TEMPLATE,
DEFAULT_MODELS,
DEFAULT_SYSTEM_TEMPLATE,
GOOGLE_SUMMARIZE_MODEL,
KnowledgeCutOffDate,
ModelProvider,
StoreKey,
@@ -96,6 +97,7 @@ function getSummarizeModel(currentModel: string) {
const model = DEFAULT_MODELS.find((m) => m.name === currentModel);
console.log("model", model);
if (!model) return currentModel;
if (model.provider.providerType === "google") return GOOGLE_SUMMARIZE_MODEL;
// if it is using gpt-* models, force to use 3.5 to summarize
return currentModel.startsWith("gpt") ? SUMMARIZE_MODEL : currentModel;
}