Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 15, 2024
2 parents de75c4a + 26c3edd commit c65d096
Show file tree
Hide file tree
Showing 25 changed files with 241 additions and 66 deletions.
14 changes: 13 additions & 1 deletion app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import QualityIcon from "../icons/hd.svg";
import StyleIcon from "../icons/palette.svg";
import PluginIcon from "../icons/plugin.svg";
import ShortcutkeyIcon from "../icons/shortcutkey.svg";
import ReloadIcon from "../icons/reload.svg";

import {
ChatMessage,
Expand Down Expand Up @@ -624,7 +625,7 @@ export function ChatActions(props: {
items={models.map((m) => ({
title: `${m.displayName}${
m?.provider?.providerName
? "(" + m?.provider?.providerName + ")"
? " (" + m?.provider?.providerName + ")"
: ""
}`,
value: `${m.name}@${m?.provider?.providerName}`,
Expand Down Expand Up @@ -1541,6 +1542,17 @@ function _Chat() {
</div>
</div>
<div className="window-actions">
<div className="window-action-button">
<IconButton
icon={<ReloadIcon />}
bordered
title={Locale.Chat.Actions.RefreshTitle}
onClick={() => {
showToast(Locale.Chat.Actions.RefreshToast);
chatStore.summarizeSession(true);
}}
/>
</div>
{!isMobileScreen && (
<div className="window-action-button">
<IconButton
Expand Down
47 changes: 40 additions & 7 deletions app/components/model-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ import Locale from "../locales";
import { InputRange } from "./input-range";
import { ListItem, Select } from "./ui-lib";
import { useAllModels } from "../utils/hooks";
import { groupBy } from "lodash-es";

export function ModelConfigList(props: {
modelConfig: ModelConfig;
updateConfig: (updater: (config: ModelConfig) => void) => void;
}) {
const allModels = useAllModels();
const groupModels = groupBy(
allModels.filter((v) => v.available),
"provider.providerName",
);
const value = `${props.modelConfig.model}@${props.modelConfig?.providerName}`;
const compressModelValue = `${props.modelConfig.compressModel}@${props.modelConfig?.compressProviderName}`;

return (
<>
<ListItem title={Locale.Settings.Model}>
<Select
aria-label={Locale.Settings.Model}
value={value}
align="left"
onChange={(e) => {
const [model, providerName] = e.currentTarget.value.split("@");
props.updateConfig((config) => {
Expand All @@ -27,13 +34,15 @@ export function ModelConfigList(props: {
});
}}
>
{allModels
.filter((v) => v.available)
.map((v, i) => (
<option value={`${v.name}@${v.provider?.providerName}`} key={i}>
{v.displayName}({v.provider?.providerName})
</option>
))}
{Object.keys(groupModels).map((providerName, index) => (
<optgroup label={providerName} key={index}>
{groupModels[providerName].map((v, i) => (
<option value={`${v.name}@${v.provider?.providerName}`} key={i}>
{v.displayName}
</option>
))}
</optgroup>
))}
</Select>
</ListItem>
<ListItem
Expand Down Expand Up @@ -228,6 +237,30 @@ export function ModelConfigList(props: {
}
></input>
</ListItem>
<ListItem
title={Locale.Settings.CompressModel.Title}
subTitle={Locale.Settings.CompressModel.SubTitle}
>
<Select
aria-label={Locale.Settings.CompressModel.Title}
value={compressModelValue}
onChange={(e) => {
const [model, providerName] = e.currentTarget.value.split("@");
props.updateConfig((config) => {
config.compressModel = ModalConfigValidator.model(model);
config.compressProviderName = providerName as ServiceProvider;
});
}}
>
{allModels
.filter((v) => v.available)
.map((v, i) => (
<option value={`${v.name}@${v.provider?.providerName}`} key={i}>
{v.displayName}({v.provider?.providerName})
</option>
))}
</Select>
</ListItem>
</>
);
}
6 changes: 6 additions & 0 deletions app/components/ui-lib.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@
position: relative;
max-width: fit-content;

&.left-align-option {
option {
text-align: left;
}
}

.select-with-icon-select {
height: 100%;
border: var(--border-in-light);
Expand Down
12 changes: 9 additions & 3 deletions app/components/ui-lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,19 @@ export function PasswordInput(

export function Select(
props: React.DetailedHTMLProps<
React.SelectHTMLAttributes<HTMLSelectElement>,
React.SelectHTMLAttributes<HTMLSelectElement> & {
align?: "left" | "center";
},
HTMLSelectElement
>,
) {
const { className, children, ...otherProps } = props;
const { className, children, align, ...otherProps } = props;
return (
<div className={`${styles["select-with-icon"]} ${className}`}>
<div
className={`${styles["select-with-icon"]} ${
align === "left" ? styles["left-align-option"] : ""
} ${className}`}
>
<select className={styles["select-with-icon-select"]} {...otherProps}>
{children}
</select>
Expand Down
6 changes: 6 additions & 0 deletions app/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const ar: PartialLocaleType = {
PinToastAction: "عرض",
Delete: "حذف",
Edit: "تحرير",
RefreshTitle: "تحديث العنوان",
RefreshToast: "تم إرسال طلب تحديث العنوان",
},
Commands: {
new: "دردشة جديدة",
Expand Down Expand Up @@ -404,6 +406,10 @@ const ar: PartialLocaleType = {
},

Model: "النموذج",
CompressModel: {
Title: "نموذج الضغط",
SubTitle: "النموذج المستخدم لضغط السجل التاريخي",
},
Temperature: {
Title: "العشوائية (temperature)",
SubTitle: "كلما زادت القيمة، زادت العشوائية في الردود",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/bn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const bn: PartialLocaleType = {
PinToastAction: "দেখুন",
Delete: "মুছে ফেলুন",
Edit: "সম্পাদনা করুন",
RefreshTitle: "শিরোনাম রিফ্রেশ করুন",
RefreshToast: "শিরোনাম রিফ্রেশ অনুরোধ পাঠানো হয়েছে",
},
Commands: {
new: "নতুন চ্যাট",
Expand Down Expand Up @@ -411,6 +413,10 @@ const bn: PartialLocaleType = {
},

Model: "মডেল (model)",
CompressModel: {
Title: "সংকোচন মডেল",
SubTitle: "ইতিহাস সংকুচিত করার জন্য ব্যবহৃত মডেল",
},
Temperature: {
Title: "যাদুকরিতা (temperature)",
SubTitle: "মান বাড়ালে উত্তর বেশি এলোমেলো হবে",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const cn = {
Delete: "删除",
Edit: "编辑",
FullScreen: "全屏",
RefreshTitle: "刷新标题",
RefreshToast: "已发送刷新标题请求",
},
Commands: {
new: "新建聊天",
Expand Down Expand Up @@ -470,6 +472,10 @@ const cn = {
},

Model: "模型 (model)",
CompressModel: {
Title: "压缩模型",
SubTitle: "用于压缩历史记录的模型",
},
Temperature: {
Title: "随机性 (temperature)",
SubTitle: "值越大,回复越随机",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const cs: PartialLocaleType = {
PinToastAction: "Zobrazit",
Delete: "Smazat",
Edit: "Upravit",
RefreshTitle: "Obnovit název",
RefreshToast: "Požadavek na obnovení názvu byl odeslán",
},
Commands: {
new: "Nová konverzace",
Expand Down Expand Up @@ -410,6 +412,10 @@ const cs: PartialLocaleType = {
},

Model: "Model (model)",
CompressModel: {
Title: "Kompresní model",
SubTitle: "Model používaný pro kompresi historie",
},
Temperature: {
Title: "Náhodnost (temperature)",
SubTitle: "Čím vyšší hodnota, tím náhodnější odpovědi",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const de: PartialLocaleType = {
PinToastAction: "Ansehen",
Delete: "Löschen",
Edit: "Bearbeiten",
RefreshTitle: "Titel aktualisieren",
RefreshToast: "Anfrage zur Titelaktualisierung gesendet",
},
Commands: {
new: "Neues Gespräch",
Expand Down Expand Up @@ -421,6 +423,10 @@ const de: PartialLocaleType = {
},

Model: "Modell",
CompressModel: {
Title: "Kompressionsmodell",
SubTitle: "Modell zur Komprimierung des Verlaufs",
},
Temperature: {
Title: "Zufälligkeit (temperature)",
SubTitle: "Je höher der Wert, desto zufälliger die Antwort",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const en: LocaleType = {
Delete: "Delete",
Edit: "Edit",
FullScreen: "FullScreen",
RefreshTitle: "Refresh Title",
RefreshToast: "Title refresh request sent",
},
Commands: {
new: "Start a new chat",
Expand Down Expand Up @@ -474,6 +476,10 @@ const en: LocaleType = {
},

Model: "Model",
CompressModel: {
Title: "Compression Model",
SubTitle: "Model used to compress history",
},
Temperature: {
Title: "Temperature",
SubTitle: "A larger value makes the more random output",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const es: PartialLocaleType = {
PinToastAction: "Ver",
Delete: "Eliminar",
Edit: "Editar",
RefreshTitle: "Actualizar título",
RefreshToast: "Se ha enviado la solicitud de actualización del título",
},
Commands: {
new: "Nueva conversación",
Expand Down Expand Up @@ -423,6 +425,10 @@ const es: PartialLocaleType = {
},

Model: "Modelo (model)",
CompressModel: {
Title: "Modelo de compresión",
SubTitle: "Modelo utilizado para comprimir el historial",
},
Temperature: {
Title: "Aleatoriedad (temperature)",
SubTitle: "Cuanto mayor sea el valor, más aleatorio será el resultado",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const fr: PartialLocaleType = {
PinToastAction: "Voir",
Delete: "Supprimer",
Edit: "Modifier",
RefreshTitle: "Actualiser le titre",
RefreshToast: "Demande d'actualisation du titre envoyée",
},
Commands: {
new: "Nouvelle discussion",
Expand Down Expand Up @@ -422,6 +424,10 @@ const fr: PartialLocaleType = {
},

Model: "Modèle",
CompressModel: {
Title: "Modèle de compression",
SubTitle: "Modèle utilisé pour compresser l'historique",
},
Temperature: {
Title: "Aléatoire (temperature)",
SubTitle: "Plus la valeur est élevée, plus les réponses sont aléatoires",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const id: PartialLocaleType = {
PinToastAction: "Lihat",
Delete: "Hapus",
Edit: "Edit",
RefreshTitle: "Segarkan Judul",
RefreshToast: "Permintaan penyegaran judul telah dikirim",
},
Commands: {
new: "Obrolan Baru",
Expand Down Expand Up @@ -411,6 +413,10 @@ const id: PartialLocaleType = {
},

Model: "Model",
CompressModel: {
Title: "Model Kompresi",
SubTitle: "Model yang digunakan untuk mengompres riwayat",
},
Temperature: {
Title: "Randomness (temperature)",
SubTitle: "Semakin tinggi nilainya, semakin acak responsnya",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const it: PartialLocaleType = {
PinToastAction: "Visualizza",
Delete: "Elimina",
Edit: "Modifica",
RefreshTitle: "Aggiorna titolo",
RefreshToast: "Richiesta di aggiornamento del titolo inviata",
},
Commands: {
new: "Nuova chat",
Expand Down Expand Up @@ -423,6 +425,10 @@ const it: PartialLocaleType = {
},

Model: "Modello (model)",
CompressModel: {
Title: "Modello di compressione",
SubTitle: "Modello utilizzato per comprimere la cronologia",
},
Temperature: {
Title: "Casualità (temperature)",
SubTitle: "Valore più alto, risposte più casuali",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/jp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const jp: PartialLocaleType = {
PinToastAction: "見る",
Delete: "削除",
Edit: "編集",
RefreshTitle: "タイトルを更新",
RefreshToast: "タイトル更新リクエストが送信されました",
},
Commands: {
new: "新しいチャット",
Expand Down Expand Up @@ -407,6 +409,10 @@ const jp: PartialLocaleType = {
},

Model: "モデル (model)",
CompressModel: {
Title: "圧縮モデル",
SubTitle: "履歴を圧縮するために使用されるモデル",
},
Temperature: {
Title: "ランダム性 (temperature)",
SubTitle: "値が大きいほど応答がランダムになります",
Expand Down
6 changes: 6 additions & 0 deletions app/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const ko: PartialLocaleType = {
PinToastAction: "보기",
Delete: "삭제",
Edit: "편집",
RefreshTitle: "제목 새로고침",
RefreshToast: "제목 새로고침 요청이 전송되었습니다",
},
Commands: {
new: "새 채팅",
Expand Down Expand Up @@ -404,6 +406,10 @@ const ko: PartialLocaleType = {
},

Model: "모델 (model)",
CompressModel: {
Title: "압축 모델",
SubTitle: "기록을 압축하는 데 사용되는 모델",
},
Temperature: {
Title: "무작위성 (temperature)",
SubTitle: "값이 클수록 응답이 더 무작위적",
Expand Down
Loading

0 comments on commit c65d096

Please sign in to comment.