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

feat: add summarize model setting #5369

Closed
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
28 changes: 28 additions & 0 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ import { nanoid } from "nanoid";
import { useMaskStore } from "../store/mask";
import { ProviderType } from "../utils/cloud";

import { useAllModels } from "../utils/hooks";

function EditPromptModal(props: { id: string; onClose: () => void }) {
const promptStore = usePromptStore();
const prompt = promptStore.get(props.id);
@@ -578,6 +580,8 @@ export function Settings() {
const config = useAppConfig();
const updateConfig = config.update;

const allModels = useAllModels();

const updateStore = useUpdateStore();
const [checkingUpdate, setCheckingUpdate] = useState(false);
const currentVersion = updateStore.formatVersion(updateStore.version);
@@ -1448,6 +1452,30 @@ export function Settings() {
></input>
</ListItem>

{config.enableAutoGenerateTitle && (
<ListItem title={Locale.Settings.SummarizeModel}>
<Select
aria-label={Locale.Settings.SummarizeModel}
value={config.summarizeModel}
onChange={(e) => {
const [model, _providerName] =
e.currentTarget.value.split("@");
updateConfig((config) => {
config.summarizeModel = model;
});
}}
>
{allModels
.filter((v) => v.available)
.map((v, i) => (
<option value={v.name} key={i}>
{v.displayName}({v.provider?.providerName})
</option>
))}
</Select>
</ListItem>
)}

<ListItem
title={Locale.Settings.SendPreviewBubble.Title}
subTitle={Locale.Settings.SendPreviewBubble.SubTitle}
1 change: 1 addition & 0 deletions app/locales/ar.ts
Original file line number Diff line number Diff line change
@@ -187,6 +187,7 @@ const ar: PartialLocaleType = {
Title: "توليد العنوان تلقائيًا",
SubTitle: "توليد عنوان مناسب بناءً على محتوى الدردشة",
},
SummarizeModel: "النموذج لتوليد العنوان تلقائيًا",
Sync: {
CloudState: "بيانات السحابة",
NotSyncYet: "لم يتم التزامن بعد",
1 change: 1 addition & 0 deletions app/locales/bn.ts
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ const bn: PartialLocaleType = {
Title: "স্বয়ংক্রিয় শিরোনাম জেনারেশন",
SubTitle: "চ্যাট কনটেন্টের ভিত্তিতে উপযুক্ত শিরোনাম তৈরি করুন",
},
SummarizeModel: "শিরোনাম স্বয়ংক্রিয় জেনারেশনের জন্য নির্দেশনা",
Sync: {
CloudState: "ক্লাউড ডেটা",
NotSyncYet: "এখনো সিঙ্ক করা হয়নি",
1 change: 1 addition & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
@@ -191,6 +191,7 @@ const cn = {
Title: "自动生成标题",
SubTitle: "根据对话内容生成合适的标题",
},
SummarizeModel: "自动生成标题使用模型",
Sync: {
CloudState: "云端数据",
NotSyncYet: "还没有进行过同步",
1 change: 1 addition & 0 deletions app/locales/cs.ts
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ const cs: PartialLocaleType = {
Title: "Automatické generování názvu",
SubTitle: "Generovat vhodný název na základě obsahu konverzace",
},
SummarizeModel: "Model pro automatické generování názvu",
Sync: {
CloudState: "Data na cloudu",
NotSyncYet: "Ještě nebylo synchronizováno",
1 change: 1 addition & 0 deletions app/locales/de.ts
Original file line number Diff line number Diff line change
@@ -192,6 +192,7 @@ const de: PartialLocaleType = {
SubTitle:
"Basierend auf dem Chat-Inhalt einen passenden Titel generieren",
},
SummarizeModel: "Model für automatische Titelgenerierung",
Sync: {
CloudState: "Cloud-Daten",
NotSyncYet: "Noch nicht synchronisiert",
1 change: 1 addition & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
@@ -194,6 +194,7 @@ const en: LocaleType = {
Title: "Auto Generate Title",
SubTitle: "Generate a suitable title based on the conversation content",
},
SummarizeModel: "Model For Auto Generate Title",
Sync: {
CloudState: "Last Update",
NotSyncYet: "Not sync yet",
1 change: 1 addition & 0 deletions app/locales/es.ts
Original file line number Diff line number Diff line change
@@ -195,6 +195,7 @@ const es: PartialLocaleType = {
Title: "Generar título automáticamente",
SubTitle: "Generar un título adecuado basado en el contenido del chat",
},
SummarizeModel: "Modelo para generar título automáticamente",
Sync: {
CloudState: "Datos en la nube",
NotSyncYet: "Aún no se ha sincronizado",
1 change: 1 addition & 0 deletions app/locales/fr.ts
Original file line number Diff line number Diff line change
@@ -194,6 +194,7 @@ const fr: PartialLocaleType = {
SubTitle:
"Générer un titre approprié en fonction du contenu de la discussion",
},
SummarizeModel: "Modèle pour générer automatiquement le titre",
Sync: {
CloudState: "Données cloud",
NotSyncYet: "Pas encore synchronisé",
1 change: 1 addition & 0 deletions app/locales/id.ts
Original file line number Diff line number Diff line change
@@ -189,6 +189,7 @@ const id: PartialLocaleType = {
Title: "Otomatis Membuat Judul",
SubTitle: "Membuat judul yang sesuai berdasarkan konten obrolan",
},
SummarizeModel: "Model untuk otomatis membuat judul",
Sync: {
CloudState: "Data Cloud",
NotSyncYet: "Belum disinkronkan",
1 change: 1 addition & 0 deletions app/locales/it.ts
Original file line number Diff line number Diff line change
@@ -196,6 +196,7 @@ const it: PartialLocaleType = {
SubTitle:
"Genera un titolo appropriato in base al contenuto della conversazione",
},
SummarizeModel: "Modello per generare automaticamente il titolo",
Sync: {
CloudState: "Dati cloud",
NotSyncYet: "Non è ancora avvenuta alcuna sincronizzazione",
1 change: 1 addition & 0 deletions app/locales/jp.ts
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ const jp: PartialLocaleType = {
Title: "自動タイトル生成",
SubTitle: "チャット内容に基づいて適切なタイトルを生成",
},
SummarizeModel: "自動タイトル生成モデル",
Sync: {
CloudState: "クラウドデータ",
NotSyncYet: "まだ同期されていません",
1 change: 1 addition & 0 deletions app/locales/ko.ts
Original file line number Diff line number Diff line change
@@ -187,6 +187,7 @@ const ko: PartialLocaleType = {
Title: "제목 자동 생성",
SubTitle: "대화 내용에 따라 적절한 제목 생성",
},
SummarizeModel: "제목 자동 생성 모델",
Sync: {
CloudState: "클라우드 데이터",
NotSyncYet: "아직 동기화되지 않았습니다.",
1 change: 1 addition & 0 deletions app/locales/no.ts
Original file line number Diff line number Diff line change
@@ -193,6 +193,7 @@ const no: PartialLocaleType = {
Title: "Automatisk generere tittel",
SubTitle: "Generer en passende tittel basert på samtaleinnholdet",
},
SummarizeModel: "Modell for automatisk generering av tittel",
Sync: {
CloudState: "Skydatasynkronisering",
NotSyncYet: "Har ikke blitt synkronisert ennå",
1 change: 1 addition & 0 deletions app/locales/pt.ts
Original file line number Diff line number Diff line change
@@ -187,6 +187,7 @@ const pt: PartialLocaleType = {
Title: "Gerar Título Automaticamente",
SubTitle: "Gerar um título adequado baseado no conteúdo da conversa",
},
SummarizeModel: "Modelo para gerar automaticamente o título",
Sync: {
CloudState: "Última Atualização",
NotSyncYet: "Ainda não sincronizado",
1 change: 1 addition & 0 deletions app/locales/sk.ts
Original file line number Diff line number Diff line change
@@ -189,6 +189,7 @@ const sk: PartialLocaleType = {
Title: "Automaticky generovať názov",
SubTitle: "Generovať vhodný názov na základe obsahu konverzácie",
},
SummarizeModel: "Model na automatické generovanie názvu",
Sync: {
CloudState: "Posledná aktualizácia",
NotSyncYet: "Zatiaľ nesynchronizované",
1 change: 1 addition & 0 deletions app/locales/tr.ts
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ const tr: PartialLocaleType = {
Title: "Başlığı Otomatik Oluştur",
SubTitle: "Sohbet içeriğine göre uygun başlık oluştur",
},
SummarizeModel: "Başlık Otomatik Oluşturma Modeli",
Sync: {
CloudState: "Bulut Verisi",
NotSyncYet: "Henüz senkronize edilmedi",
1 change: 1 addition & 0 deletions app/locales/tw.ts
Original file line number Diff line number Diff line change
@@ -186,6 +186,7 @@ const tw = {
Title: "自動產生標題",
SubTitle: "根據對話內容產生合適的標題",
},
SummarizeModel: "自動產生標題模型",
Sync: {
CloudState: "雲端資料",
NotSyncYet: "還沒有進行過同步",
1 change: 1 addition & 0 deletions app/locales/vi.ts
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ const vi: PartialLocaleType = {
Title: "Tự động tạo tiêu đề",
SubTitle: "Tạo tiêu đề phù hợp dựa trên nội dung cuộc trò chuyện",
},
SummarizeModel: "Mô hình tự động tạo tiêu đề",
Sync: {
CloudState: "Dữ liệu đám mây",
NotSyncYet: "Chưa thực hiện đồng bộ",
5 changes: 5 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
@@ -92,6 +92,11 @@ function createEmptySession(): ChatSession {
}

function getSummarizeModel(currentModel: string) {
const config = useAppConfig.getState();
if (config.summarizeModel) {
return config.summarizeModel;
}
Comment on lines +95 to +98
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a suggestion for enhancement.

The addition of a configuration check for summarizeModel enhances the flexibility of model selection based on user settings. Consider adding a fallback or default model handling if summarizeModel is not set in the configuration to ensure robustness.


// if it is using gpt-* models, force to use 4o-mini to summarize
if (currentModel.startsWith("gpt")) {
const configStore = useAppConfig.getState();
1 change: 1 addition & 0 deletions app/store/config.ts
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ export const DEFAULT_CONFIG = {
tightBorder: !!config?.isApp,
sendPreviewBubble: true,
enableAutoGenerateTitle: true,
summarizeModel: "gpt-3.5-turbo" as ModelType,
sidebarWidth: DEFAULT_SIDEBAR_WIDTH,

disablePromptHint: false,