Skip to content

Commit

Permalink
fix ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Oct 9, 2024
1 parent a925b42 commit 93ca303
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
StoreKey,
SUMMARIZE_MODEL,
GEMINI_SUMMARIZE_MODEL,
ServiceProvider,
} from "../constant";
import Locale, { getLang } from "../locales";
import { isDalle3, safeLocalStorage } from "../utils";
Expand Down Expand Up @@ -107,7 +108,10 @@ function createEmptySession(): ChatSession {
};
}

function getSummarizeModel(currentModel: string, providerName: string) {
function getSummarizeModel(
currentModel: string,
providerName: string,
): string[] {
// if it is using gpt-* models, force to use 4o-mini to summarize
if (currentModel.startsWith("gpt") || currentModel.startsWith("chatgpt")) {
const configStore = useAppConfig.getState();
Expand All @@ -121,7 +125,10 @@ function getSummarizeModel(currentModel: string, providerName: string) {
(m) => m.name === SUMMARIZE_MODEL && m.available,
);
if (summarizeModel) {
return [summarizeModel.name, summarizeModel.providerName];
return [
summarizeModel.name,
summarizeModel.provider?.providerName as string,
];
}
}
if (currentModel.startsWith("gemini")) {
Expand Down Expand Up @@ -613,7 +620,7 @@ export const useChatStore = createPersistStore(
session.mask.modelConfig.model,
session.mask.modelConfig.providerName,
);
const api: ClientApi = getClientApi(providerName);
const api: ClientApi = getClientApi(providerName as ServiceProvider);

// remove error messages if any
const messages = session.messages;
Expand Down Expand Up @@ -822,8 +829,8 @@ export const useChatStore = createPersistStore(
if (version < 3.3) {
newState.sessions.forEach((s) => {
const config = useAppConfig.getState();
s.mask.modelConfig.compressModel = undefined;
s.mask.modelConfig.compressProviderName = undefined;
s.mask.modelConfig.compressModel = "";
s.mask.modelConfig.compressProviderName = "";
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const DEFAULT_CONFIG = {
sendMemory: true,
historyMessageCount: 4,
compressMessageLengthThreshold: 1000,
compressModel: undefined,
compressProviderName: undefined,
compressModel: "",
compressProviderName: "",
enableInjectSystemPrompts: true,
template: config?.template ?? DEFAULT_INPUT_TEMPLATE,
size: "1024x1024" as DalleSize,
Expand Down

0 comments on commit 93ca303

Please sign in to comment.