2023-11-08 19:01:29 +00:00
|
|
|
import { ModalConfigValidator, ModelConfig } from "../store";
|
2023-04-22 17:27:15 +00:00
|
|
|
|
|
|
|
import Locale from "../locales";
|
|
|
|
import { InputRange } from "./input-range";
|
2023-06-23 16:07:46 +00:00
|
|
|
import { ListItem, Select } from "./ui-lib";
|
2023-11-08 19:01:29 +00:00
|
|
|
import { useAllModels } from "../utils/hooks";
|
2023-04-22 17:27:15 +00:00
|
|
|
|
|
|
|
export function ModelConfigList(props: {
|
|
|
|
modelConfig: ModelConfig;
|
|
|
|
updateConfig: (updater: (config: ModelConfig) => void) => void;
|
|
|
|
}) {
|
2023-11-08 19:01:29 +00:00
|
|
|
const allModels = useAllModels();
|
2023-07-04 15:16:24 +00:00
|
|
|
|
2023-04-22 17:27:15 +00:00
|
|
|
return (
|
2023-04-22 17:37:47 +00:00
|
|
|
<>
|
2023-04-22 17:27:15 +00:00
|
|
|
<ListItem title={Locale.Settings.Model}>
|
2023-05-10 07:14:49 +00:00
|
|
|
<Select
|
2023-04-22 17:27:15 +00:00
|
|
|
value={props.modelConfig.model}
|
|
|
|
onChange={(e) => {
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
|
|
|
(config.model = ModalConfigValidator.model(
|
|
|
|
e.currentTarget.value,
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
>
|
2023-11-08 19:01:29 +00:00
|
|
|
{allModels.map((v, i) => (
|
2023-07-09 10:15:52 +00:00
|
|
|
<option value={v.name} key={i} disabled={!v.available}>
|
2023-04-22 17:27:15 +00:00
|
|
|
{v.name}
|
|
|
|
</option>
|
|
|
|
))}
|
2023-05-10 07:14:49 +00:00
|
|
|
</Select>
|
2023-04-22 17:27:15 +00:00
|
|
|
</ListItem>
|
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.Temperature.Title}
|
|
|
|
subTitle={Locale.Settings.Temperature.SubTitle}
|
|
|
|
>
|
|
|
|
<InputRange
|
|
|
|
value={props.modelConfig.temperature?.toFixed(1)}
|
|
|
|
min="0"
|
2023-04-23 13:54:18 +00:00
|
|
|
max="1" // lets limit it to 0-1
|
2023-04-22 17:27:15 +00:00
|
|
|
step="0.1"
|
|
|
|
onChange={(e) => {
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
|
|
|
(config.temperature = ModalConfigValidator.temperature(
|
|
|
|
e.currentTarget.valueAsNumber,
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
></InputRange>
|
|
|
|
</ListItem>
|
2023-07-03 16:39:54 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.TopP.Title}
|
|
|
|
subTitle={Locale.Settings.TopP.SubTitle}
|
|
|
|
>
|
|
|
|
<InputRange
|
|
|
|
value={(props.modelConfig.top_p ?? 1).toFixed(1)}
|
|
|
|
min="0"
|
|
|
|
max="1"
|
|
|
|
step="0.1"
|
|
|
|
onChange={(e) => {
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
2023-07-03 17:49:05 +00:00
|
|
|
(config.top_p = ModalConfigValidator.top_p(
|
2023-07-03 16:39:54 +00:00
|
|
|
e.currentTarget.valueAsNumber,
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
></InputRange>
|
|
|
|
</ListItem>
|
2023-04-22 17:27:15 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.MaxTokens.Title}
|
|
|
|
subTitle={Locale.Settings.MaxTokens.SubTitle}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="number"
|
2023-11-08 19:19:13 +00:00
|
|
|
min={1024}
|
|
|
|
max={512000}
|
2023-04-22 17:27:15 +00:00
|
|
|
value={props.modelConfig.max_tokens}
|
|
|
|
onChange={(e) =>
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
|
|
|
(config.max_tokens = ModalConfigValidator.max_tokens(
|
|
|
|
e.currentTarget.valueAsNumber,
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
></input>
|
|
|
|
</ListItem>
|
|
|
|
<ListItem
|
2023-05-16 07:40:43 +00:00
|
|
|
title={Locale.Settings.PresencePenalty.Title}
|
|
|
|
subTitle={Locale.Settings.PresencePenalty.SubTitle}
|
2023-04-22 17:27:15 +00:00
|
|
|
>
|
|
|
|
<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>
|
|
|
|
|
2023-06-04 08:05:35 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.FrequencyPenalty.Title}
|
|
|
|
subTitle={Locale.Settings.FrequencyPenalty.SubTitle}
|
|
|
|
>
|
|
|
|
<InputRange
|
|
|
|
value={props.modelConfig.frequency_penalty?.toFixed(1)}
|
|
|
|
min="-2"
|
|
|
|
max="2"
|
|
|
|
step="0.1"
|
|
|
|
onChange={(e) => {
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
|
|
|
(config.frequency_penalty =
|
|
|
|
ModalConfigValidator.frequency_penalty(
|
|
|
|
e.currentTarget.valueAsNumber,
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
></InputRange>
|
|
|
|
</ListItem>
|
|
|
|
|
2023-07-10 10:56:22 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.InjectSystemPrompts.Title}
|
|
|
|
subTitle={Locale.Settings.InjectSystemPrompts.SubTitle}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
checked={props.modelConfig.enableInjectSystemPrompts}
|
|
|
|
onChange={(e) =>
|
|
|
|
props.updateConfig(
|
|
|
|
(config) =>
|
|
|
|
(config.enableInjectSystemPrompts = e.currentTarget.checked),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
></input>
|
|
|
|
</ListItem>
|
|
|
|
|
2023-06-23 16:07:46 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.InputTemplate.Title}
|
|
|
|
subTitle={Locale.Settings.InputTemplate.SubTitle}
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
value={props.modelConfig.template}
|
|
|
|
onChange={(e) =>
|
|
|
|
props.updateConfig(
|
|
|
|
(config) => (config.template = e.currentTarget.value),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
></input>
|
|
|
|
</ListItem>
|
|
|
|
|
2023-04-22 17:27:15 +00:00
|
|
|
<ListItem
|
|
|
|
title={Locale.Settings.HistoryCount.Title}
|
|
|
|
subTitle={Locale.Settings.HistoryCount.SubTitle}
|
|
|
|
>
|
|
|
|
<InputRange
|
|
|
|
title={props.modelConfig.historyMessageCount.toString()}
|
|
|
|
value={props.modelConfig.historyMessageCount}
|
|
|
|
min="0"
|
2023-08-02 15:35:51 +00:00
|
|
|
max="64"
|
2023-04-22 17:27:15 +00:00
|
|
|
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>
|
2023-04-22 17:37:47 +00:00
|
|
|
</>
|
2023-04-22 17:27:15 +00:00
|
|
|
);
|
|
|
|
}
|