) {
- const [visible, setVisible] = useState(false);
-
- function changeVisibility() {
- setVisible(!visible);
- }
-
+export function ModelConfigList(props: {
+ modelConfig: ModelConfig;
+ updateConfig: (updater: (config: ModelConfig) => void) => void;
+}) {
return (
-
- : }
- onClick={changeVisibility}
- className={styles["password-eye"]}
- />
-
-
+ <>
+
+
+
+
+ {
+ props.updateConfig(
+ (config) =>
+ (config.temperature = ModalConfigValidator.temperature(
+ e.currentTarget.valueAsNumber,
+ )),
+ );
+ }}
+ >
+
+
+
+ props.updateConfig(
+ (config) =>
+ (config.max_tokens = ModalConfigValidator.max_tokens(
+ e.currentTarget.valueAsNumber,
+ )),
+ )
+ }
+ >
+
+
+ {
+ props.updateConfig(
+ (config) =>
+ (config.presence_penalty =
+ ModalConfigValidator.presence_penalty(
+ e.currentTarget.valueAsNumber,
+ )),
+ );
+ }}
+ >
+
+
+
+
+ props.updateConfig(
+ (config) => (config.historyMessageCount = e.target.valueAsNumber),
+ )
+ }
+ >
+
+
+
+
+ props.updateConfig(
+ (config) =>
+ (config.compressMessageLengthThreshold =
+ e.currentTarget.valueAsNumber),
+ )
+ }
+ >
+
+ >
);
}
@@ -505,44 +605,6 @@ export function Settings() {
/>
)}
-
-
-
- updateConfig(
- (config) =>
- (config.historyMessageCount = e.target.valueAsNumber),
- )
- }
- >
-
-
-
-
- updateConfig(
- (config) =>
- (config.compressMessageLengthThreshold =
- e.currentTarget.valueAsNumber),
- )
- }
- >
-
@@ -578,85 +640,14 @@ export function Settings() {
-
-
-
-
- {
- updateConfig(
- (config) =>
- (config.modelConfig.temperature =
- ModalConfigValidator.temperature(
- e.currentTarget.valueAsNumber,
- )),
- );
- }}
- >
-
-
-
- updateConfig(
- (config) =>
- (config.modelConfig.max_tokens =
- ModalConfigValidator.max_tokens(
- e.currentTarget.valueAsNumber,
- )),
- )
- }
- >
-
-
- {
- updateConfig(
- (config) =>
- (config.modelConfig.presence_penalty =
- ModalConfigValidator.presence_penalty(
- e.currentTarget.valueAsNumber,
- )),
- );
- }}
- >
-
+ {
+ const modelConfig = { ...config.modelConfig };
+ upater(modelConfig);
+ config.update((config) => (config.modelConfig = modelConfig));
+ }}
+ />
{shouldShowPromptModal && (
diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx
index ffc05cf..8e04db3 100644
--- a/app/components/ui-lib.tsx
+++ b/app/components/ui-lib.tsx
@@ -1,8 +1,12 @@
import styles from "./ui-lib.module.scss";
import LoadingIcon from "../icons/three-dots.svg";
import CloseIcon from "../icons/close.svg";
+import EyeIcon from "../icons/eye.svg";
+import EyeOffIcon from "../icons/eye-off.svg";
+
import { createRoot } from "react-dom/client";
-import React, { useEffect } from "react";
+import React, { HTMLProps, useEffect, useState } from "react";
+import { IconButton } from "./button";
export function Popover(props: {
children: JSX.Element;
@@ -190,3 +194,26 @@ export function Input(props: InputProps) {
>
);
}
+
+export function PasswordInput(props: HTMLProps) {
+ const [visible, setVisible] = useState(false);
+
+ function changeVisibility() {
+ setVisible(!visible);
+ }
+
+ return (
+
+ : }
+ onClick={changeVisibility}
+ className={"password-eye"}
+ />
+
+
+ );
+}
diff --git a/app/store/app.ts b/app/store/app.ts
index 2294130..652e26f 100644
--- a/app/store/app.ts
+++ b/app/store/app.ts
@@ -334,14 +334,14 @@ export const useChatStore = create()(
// get short term and unmemoried long term memory
const shortTermMemoryMessageIndex = Math.max(
0,
- n - config.historyMessageCount,
+ n - config.modelConfig.historyMessageCount,
);
const longTermMemoryMessageIndex = session.lastSummarizeIndex;
const oldestIndex = Math.max(
shortTermMemoryMessageIndex,
longTermMemoryMessageIndex,
);
- const threshold = config.compressMessageLengthThreshold;
+ const threshold = config.modelConfig.compressMessageLengthThreshold;
// get recent messages as many as possible
const reversedRecentMessages = [];
@@ -410,7 +410,7 @@ export const useChatStore = create()(
if (historyMsgLength > config?.modelConfig?.max_tokens ?? 4000) {
const n = toBeSummarizedMsgs.length;
toBeSummarizedMsgs = toBeSummarizedMsgs.slice(
- Math.max(0, n - config.historyMessageCount),
+ Math.max(0, n - config.modelConfig.historyMessageCount),
);
}
@@ -423,11 +423,12 @@ export const useChatStore = create()(
"[Chat History] ",
toBeSummarizedMsgs,
historyMsgLength,
- config.compressMessageLengthThreshold,
+ config.modelConfig.compressMessageLengthThreshold,
);
if (
- historyMsgLength > config.compressMessageLengthThreshold &&
+ historyMsgLength >
+ config.modelConfig.compressMessageLengthThreshold &&
session.sendMemory
) {
requestChatStream(
diff --git a/app/store/config.ts b/app/store/config.ts
index 346f38d..9373340 100644
--- a/app/store/config.ts
+++ b/app/store/config.ts
@@ -16,8 +16,6 @@ export enum Theme {
}
const DEFAULT_CONFIG = {
- historyMessageCount: 4,
- compressMessageLengthThreshold: 1000,
sendBotMessages: true as boolean,
submitKey: SubmitKey.CtrlEnter as SubmitKey,
avatar: "1f603",
@@ -34,6 +32,8 @@ const DEFAULT_CONFIG = {
temperature: 1,
max_tokens: 2000,
presence_penalty: 0,
+ historyMessageCount: 4,
+ compressMessageLengthThreshold: 1000,
},
};
diff --git a/app/styles/globals.scss b/app/styles/globals.scss
index 37c6622..5815d74 100644
--- a/app/styles/globals.scss
+++ b/app/styles/globals.scss
@@ -311,3 +311,17 @@ pre {
overflow: auto;
}
}
+
+.password-input-container {
+ max-width: 50%;
+ display: flex;
+ justify-content: flex-end;
+
+ .password-eye {
+ margin-right: 4px;
+ }
+
+ .password-input {
+ min-width: 80%;
+ }
+}