Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added summary model for Claude LLMs. #5280

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Latex block: $$e=mc^2$$

export const SUMMARIZE_MODEL = "gpt-4o-mini";
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
export const CLAUDE_SUMMARIZE_MODEL = "claude-3-haiku-20240307"

export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",
Expand Down
27 changes: 19 additions & 8 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
StoreKey,
SUMMARIZE_MODEL,
GEMINI_SUMMARIZE_MODEL,
CLAUDE_SUMMARIZE_MODEL,
} from "../constant";
import { getClientApi } from "../client/api";
import type {
Expand Down Expand Up @@ -91,22 +92,32 @@ function createEmptySession(): ChatSession {
}

function getSummarizeModel(currentModel: string) {
const configStore = useAppConfig.getState();
const accessStore = useAccessStore.getState();
const allModel = collectModelsWithDefaultModel(
configStore.models,
[configStore.customModels, accessStore.customModels].join(","),
accessStore.defaultModel,
);
// if it is using gpt-* models, force to use 4o-mini to summarize
if (currentModel.startsWith("gpt")) {
const configStore = useAppConfig.getState();
const accessStore = useAccessStore.getState();
const allModel = collectModelsWithDefaultModel(
configStore.models,
[configStore.customModels, accessStore.customModels].join(","),
accessStore.defaultModel,
);
const summarizeModel = allModel.find(
(m) => m.name === SUMMARIZE_MODEL && m.available,
);
return summarizeModel?.name ?? currentModel;
}
if (currentModel.startsWith("gemini")) {
return GEMINI_SUMMARIZE_MODEL;
const summarizeModel = allModel.find(
(m) => m.name === GEMINI_SUMMARIZE_MODEL && m.available,
);
return summarizeModel?.name ?? currentModel;
}
// if it is using claude-* models, use claude-3-haiku-20240307 to summarize
if (currentModel.startsWith("claude")) {
const summarizeModel = allModel.find(
(m) => m.name === CLAUDE_SUMMARIZE_MODEL && m.available,
);
return summarizeModel?.name ?? currentModel;
}
return currentModel;
}
Expand Down
Loading