parent
2e3aa940fb
commit
7345639af3
@ -0,0 +1,59 @@
|
|||||||
|
import EmojiPicker, {
|
||||||
|
Emoji,
|
||||||
|
EmojiStyle,
|
||||||
|
Theme as EmojiTheme,
|
||||||
|
} from "emoji-picker-react";
|
||||||
|
|
||||||
|
import { ModelType } from "../store";
|
||||||
|
|
||||||
|
import BotIcon from "../icons/bot.svg";
|
||||||
|
import BlackBotIcon from "../icons/black-bot.svg";
|
||||||
|
|
||||||
|
export function getEmojiUrl(unified: string, style: EmojiStyle) {
|
||||||
|
return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AvatarPicker(props: {
|
||||||
|
onEmojiClick: (emojiId: string) => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<EmojiPicker
|
||||||
|
lazyLoadEmojis
|
||||||
|
theme={EmojiTheme.AUTO}
|
||||||
|
getEmojiUrl={getEmojiUrl}
|
||||||
|
onEmojiClick={(e) => {
|
||||||
|
props.onEmojiClick(e.unified);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Avatar(props: { model?: ModelType; avatar?: string }) {
|
||||||
|
if (props.model) {
|
||||||
|
return (
|
||||||
|
<div className="no-dark">
|
||||||
|
{props.model?.startsWith("gpt-4") ? (
|
||||||
|
<BlackBotIcon className="user-avtar" />
|
||||||
|
) : (
|
||||||
|
<BotIcon className="user-avtar" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="user-avtar">
|
||||||
|
{props.avatar && <EmojiAvatar avatar={props.avatar} />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EmojiAvatar(props: { avatar: string; size?: number }) {
|
||||||
|
return (
|
||||||
|
<Emoji
|
||||||
|
unified={props.avatar}
|
||||||
|
size={props.size ?? 18}
|
||||||
|
getEmojiUrl={getEmojiUrl}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,141 @@
|
|||||||
|
import styles from "./settings.module.scss";
|
||||||
|
import { ALL_MODELS, ModalConfigValidator, ModelConfig } from "../store";
|
||||||
|
|
||||||
|
import Locale from "../locales";
|
||||||
|
import { InputRange } from "./input-range";
|
||||||
|
import { List, ListItem } from "./ui-lib";
|
||||||
|
|
||||||
|
export function ModelConfigList(props: {
|
||||||
|
modelConfig: ModelConfig;
|
||||||
|
updateConfig: (updater: (config: ModelConfig) => void) => void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<List>
|
||||||
|
<ListItem title={Locale.Settings.Model}>
|
||||||
|
<select
|
||||||
|
value={props.modelConfig.model}
|
||||||
|
onChange={(e) => {
|
||||||
|
props.updateConfig(
|
||||||
|
(config) =>
|
||||||
|
(config.model = ModalConfigValidator.model(
|
||||||
|
e.currentTarget.value,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{ALL_MODELS.map((v) => (
|
||||||
|
<option value={v.name} key={v.name} disabled={!v.available}>
|
||||||
|
{v.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem
|
||||||
|
title={Locale.Settings.Temperature.Title}
|
||||||
|
subTitle={Locale.Settings.Temperature.SubTitle}
|
||||||
|
>
|
||||||
|
<InputRange
|
||||||
|
value={props.modelConfig.temperature?.toFixed(1)}
|
||||||
|
min="0"
|
||||||
|
max="2"
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e) => {
|
||||||
|
props.updateConfig(
|
||||||
|
(config) =>
|
||||||
|
(config.temperature = ModalConfigValidator.temperature(
|
||||||
|
e.currentTarget.valueAsNumber,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
></InputRange>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem
|
||||||
|
title={Locale.Settings.MaxTokens.Title}
|
||||||
|
subTitle={Locale.Settings.MaxTokens.SubTitle}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min={100}
|
||||||
|
max={32000}
|
||||||
|
value={props.modelConfig.max_tokens}
|
||||||
|
onChange={(e) =>
|
||||||
|
props.updateConfig(
|
||||||
|
(config) =>
|
||||||
|
(config.max_tokens = ModalConfigValidator.max_tokens(
|
||||||
|
e.currentTarget.valueAsNumber,
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
></input>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem
|
||||||
|
title={Locale.Settings.PresencePenlty.Title}
|
||||||
|
subTitle={Locale.Settings.PresencePenlty.SubTitle}
|
||||||
|
>
|
||||||
|
<InputRange
|
||||||
|
value={props.modelConfig.presence_penalty?.toFixed(1)}
|
||||||
|
min="-2"
|
||||||
|
max="2"
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e) => {
|
||||||
|
props.updateConfig(
|
||||||
|
(config) =>
|
||||||
|
(config.presence_penalty =
|
||||||
|
ModalConfigValidator.presence_penalty(
|
||||||
|
e.currentTarget.valueAsNumber,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
></InputRange>
|
||||||
|
</ListItem>
|
||||||
|
|
||||||
|
<ListItem
|
||||||
|
title={Locale.Settings.HistoryCount.Title}
|
||||||
|
subTitle={Locale.Settings.HistoryCount.SubTitle}
|
||||||
|
>
|
||||||
|
<InputRange
|
||||||
|
title={props.modelConfig.historyMessageCount.toString()}
|
||||||
|
value={props.modelConfig.historyMessageCount}
|
||||||
|
min="0"
|
||||||
|
max="25"
|
||||||
|
step="1"
|
||||||
|
onChange={(e) =>
|
||||||
|
props.updateConfig(
|
||||||
|
(config) => (config.historyMessageCount = e.target.valueAsNumber),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
></InputRange>
|
||||||
|
</ListItem>
|
||||||
|
|
||||||
|
<ListItem
|
||||||
|
title={Locale.Settings.CompressThreshold.Title}
|
||||||
|
subTitle={Locale.Settings.CompressThreshold.SubTitle}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min={500}
|
||||||
|
max={4000}
|
||||||
|
value={props.modelConfig.compressMessageLengthThreshold}
|
||||||
|
onChange={(e) =>
|
||||||
|
props.updateConfig(
|
||||||
|
(config) =>
|
||||||
|
(config.compressMessageLengthThreshold =
|
||||||
|
e.currentTarget.valueAsNumber),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
></input>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem title={Locale.Memory.Title} subTitle={Locale.Memory.Send}>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={props.modelConfig.sendMemory}
|
||||||
|
onChange={(e) =>
|
||||||
|
props.updateConfig(
|
||||||
|
(config) => (config.sendMemory = e.currentTarget.checked),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
></input>
|
||||||
|
</ListItem>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
export * from "./app";
|
export * from "./chat";
|
||||||
export * from "./update";
|
export * from "./update";
|
||||||
export * from "./access";
|
export * from "./access";
|
||||||
export * from "./config";
|
export * from "./config";
|
||||||
|
Loading…
Reference in new issue