2023-03-09 17:01:40 +00:00
|
|
|
|
"use client";
|
|
|
|
|
|
2023-03-11 12:54:24 +00:00
|
|
|
|
import { useState, useRef, useEffect } from "react";
|
2023-03-10 18:25:33 +00:00
|
|
|
|
import ReactMarkdown from "react-markdown";
|
2023-03-11 12:54:24 +00:00
|
|
|
|
import "katex/dist/katex.min.css";
|
|
|
|
|
import RemarkMath from "remark-math";
|
|
|
|
|
import RehypeKatex from "rehype-katex";
|
2023-03-10 18:25:33 +00:00
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
import EmojiPicker, { Emoji, Theme as EmojiTheme } from "emoji-picker-react";
|
2023-03-11 17:14:07 +00:00
|
|
|
|
|
2023-03-09 17:01:40 +00:00
|
|
|
|
import { IconButton } from "./button";
|
2023-03-12 19:06:21 +00:00
|
|
|
|
import styles from "./home.module.scss";
|
2023-03-09 17:01:40 +00:00
|
|
|
|
|
|
|
|
|
import SettingsIcon from "../icons/settings.svg";
|
|
|
|
|
import GithubIcon from "../icons/github.svg";
|
|
|
|
|
import ChatGptIcon from "../icons/chatgpt.svg";
|
|
|
|
|
import SendWhiteIcon from "../icons/send-white.svg";
|
|
|
|
|
import BrainIcon from "../icons/brain.svg";
|
|
|
|
|
import ExportIcon from "../icons/export.svg";
|
|
|
|
|
import BotIcon from "../icons/bot.svg";
|
|
|
|
|
import AddIcon from "../icons/add.svg";
|
2023-03-10 18:25:33 +00:00
|
|
|
|
import DeleteIcon from "../icons/delete.svg";
|
|
|
|
|
import LoadingIcon from "../icons/three-dots.svg";
|
2023-03-12 19:06:21 +00:00
|
|
|
|
import ResetIcon from "../icons/reload.svg";
|
2023-03-10 18:25:33 +00:00
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
import { Message, SubmitKey, useChatStore, Theme } from "../store";
|
2023-03-11 17:14:07 +00:00
|
|
|
|
import { Card, List, ListItem, Popover } from "./ui-lib";
|
2023-03-10 18:25:33 +00:00
|
|
|
|
|
2023-03-11 12:54:24 +00:00
|
|
|
|
export function Markdown(props: { content: string }) {
|
|
|
|
|
return (
|
|
|
|
|
<ReactMarkdown remarkPlugins={[RemarkMath]} rehypePlugins={[RehypeKatex]}>
|
|
|
|
|
{props.content}
|
|
|
|
|
</ReactMarkdown>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-10 18:25:33 +00:00
|
|
|
|
export function Avatar(props: { role: Message["role"] }) {
|
2023-03-11 17:14:07 +00:00
|
|
|
|
const config = useChatStore((state) => state.config);
|
|
|
|
|
|
2023-03-10 18:25:33 +00:00
|
|
|
|
if (props.role === "assistant") {
|
|
|
|
|
return <BotIcon className={styles["user-avtar"]} />;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 17:14:07 +00:00
|
|
|
|
return (
|
|
|
|
|
<div className={styles["user-avtar"]}>
|
|
|
|
|
<Emoji unified={config.avatar} size={18} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2023-03-10 18:25:33 +00:00
|
|
|
|
}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
|
|
|
|
|
export function ChatItem(props: {
|
|
|
|
|
onClick?: () => void;
|
2023-03-10 18:25:33 +00:00
|
|
|
|
onDelete?: () => void;
|
2023-03-09 17:01:40 +00:00
|
|
|
|
title: string;
|
|
|
|
|
count: number;
|
|
|
|
|
time: string;
|
|
|
|
|
selected: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={`${styles["chat-item"]} ${
|
|
|
|
|
props.selected && styles["chat-item-selected"]
|
|
|
|
|
}`}
|
2023-03-10 18:25:33 +00:00
|
|
|
|
onClick={props.onClick}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
>
|
|
|
|
|
<div className={styles["chat-item-title"]}>{props.title}</div>
|
|
|
|
|
<div className={styles["chat-item-info"]}>
|
|
|
|
|
<div className={styles["chat-item-count"]}>{props.count} 条对话</div>
|
|
|
|
|
<div className={styles["chat-item-date"]}>{props.time}</div>
|
|
|
|
|
</div>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<div className={styles["chat-item-delete"]} onClick={props.onDelete}>
|
|
|
|
|
<DeleteIcon />
|
|
|
|
|
</div>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ChatList() {
|
2023-03-10 18:25:33 +00:00
|
|
|
|
const [sessions, selectedIndex, selectSession, removeSession] = useChatStore(
|
|
|
|
|
(state) => [
|
|
|
|
|
state.sessions,
|
|
|
|
|
state.currentSessionIndex,
|
|
|
|
|
state.selectSession,
|
|
|
|
|
state.removeSession,
|
|
|
|
|
]
|
|
|
|
|
);
|
2023-03-09 17:01:40 +00:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={styles["chat-list"]}>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
{sessions.map((item, i) => (
|
|
|
|
|
<ChatItem
|
|
|
|
|
title={item.topic}
|
|
|
|
|
time={item.lastUpdate}
|
|
|
|
|
count={item.messages.length}
|
|
|
|
|
key={i}
|
|
|
|
|
selected={i === selectedIndex}
|
|
|
|
|
onClick={() => selectSession(i)}
|
|
|
|
|
onDelete={() => removeSession(i)}
|
|
|
|
|
/>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
function useSubmitHandler() {
|
|
|
|
|
const config = useChatStore((state) => state.config);
|
|
|
|
|
const submitKey = config.submitKey;
|
|
|
|
|
|
|
|
|
|
const shouldSubmit = (e: KeyboardEvent) => {
|
|
|
|
|
if (e.key !== "Enter") return false;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
(config.submitKey === SubmitKey.AltEnter && e.altKey) ||
|
|
|
|
|
(config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) ||
|
|
|
|
|
(config.submitKey === SubmitKey.ShiftEnter && e.shiftKey) ||
|
|
|
|
|
config.submitKey === SubmitKey.Enter
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
submitKey,
|
|
|
|
|
shouldSubmit,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 17:01:40 +00:00
|
|
|
|
export function Chat() {
|
2023-03-10 18:25:33 +00:00
|
|
|
|
type RenderMessage = Message & { preview?: boolean };
|
|
|
|
|
|
|
|
|
|
const session = useChatStore((state) => state.currentSession());
|
|
|
|
|
const [userInput, setUserInput] = useState("");
|
|
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
2023-03-12 19:06:21 +00:00
|
|
|
|
const { submitKey, shouldSubmit } = useSubmitHandler();
|
2023-03-10 18:25:33 +00:00
|
|
|
|
|
|
|
|
|
const onUserInput = useChatStore((state) => state.onUserInput);
|
|
|
|
|
const onUserSubmit = () => {
|
|
|
|
|
if (userInput.length <= 0) return;
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
onUserInput(userInput).then(() => setIsLoading(false));
|
|
|
|
|
setUserInput("");
|
|
|
|
|
};
|
|
|
|
|
const onInputKeyDown = (e: KeyboardEvent) => {
|
2023-03-12 19:06:21 +00:00
|
|
|
|
if (shouldSubmit(e)) {
|
2023-03-10 18:25:33 +00:00
|
|
|
|
onUserSubmit();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const latestMessageRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
const messages = (session.messages as RenderMessage[])
|
|
|
|
|
.concat(
|
|
|
|
|
isLoading
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
role: "assistant",
|
|
|
|
|
content: "……",
|
|
|
|
|
date: new Date().toLocaleString(),
|
|
|
|
|
preview: true,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: []
|
|
|
|
|
)
|
|
|
|
|
.concat(
|
|
|
|
|
userInput.length > 0
|
|
|
|
|
? [
|
|
|
|
|
{
|
|
|
|
|
role: "user",
|
|
|
|
|
content: userInput,
|
|
|
|
|
date: new Date().toLocaleString(),
|
|
|
|
|
preview: true,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: []
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-03-11 08:24:17 +00:00
|
|
|
|
latestMessageRef.current?.scrollIntoView({
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
block: "end",
|
|
|
|
|
});
|
2023-03-10 18:25:33 +00:00
|
|
|
|
});
|
2023-03-09 17:01:40 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2023-03-11 17:14:07 +00:00
|
|
|
|
<div className={styles.chat} key={session.id}>
|
|
|
|
|
<div className={styles["window-header"]}>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
<div>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
<div className={styles["window-header-title"]}>{session.topic}</div>
|
|
|
|
|
<div className={styles["window-header-sub-title"]}>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
与 ChatGPT 的 {session.messages.length} 条对话
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div className={styles["window-actions"]}>
|
|
|
|
|
<div className={styles["window-action-button"]}>
|
|
|
|
|
<IconButton
|
|
|
|
|
icon={<BrainIcon />}
|
|
|
|
|
bordered
|
|
|
|
|
title="查看压缩后的历史 Prompt(开发中)"
|
|
|
|
|
/>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div className={styles["window-action-button"]}>
|
|
|
|
|
<IconButton
|
|
|
|
|
icon={<ExportIcon />}
|
|
|
|
|
bordered
|
|
|
|
|
title="导出聊天记录为 Markdown(开发中)"
|
|
|
|
|
/>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className={styles["chat-body"]}>
|
|
|
|
|
{messages.map((message, i) => {
|
|
|
|
|
const isUser = message.role === "user";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={i}
|
|
|
|
|
className={
|
2023-03-09 17:16:20 +00:00
|
|
|
|
isUser ? styles["chat-message-user"] : styles["chat-message"]
|
2023-03-09 17:01:40 +00:00
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<div className={styles["chat-message-container"]}>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<div className={styles["chat-message-avatar"]}>
|
|
|
|
|
<Avatar role={message.role} />
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
{(message.preview || message.streaming) && (
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<div className={styles["chat-message-status"]}>正在输入…</div>
|
|
|
|
|
)}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
<div className={styles["chat-message-item"]}>
|
2023-03-11 12:54:24 +00:00
|
|
|
|
{(message.preview || message.content.length === 0) &&
|
|
|
|
|
!isUser ? (
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<LoadingIcon />
|
|
|
|
|
) : (
|
|
|
|
|
<div className="markdown-body">
|
2023-03-11 12:54:24 +00:00
|
|
|
|
<Markdown content={message.content} />
|
2023-03-10 18:25:33 +00:00
|
|
|
|
</div>
|
|
|
|
|
)}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
{!isUser && !message.preview && (
|
2023-03-09 17:01:40 +00:00
|
|
|
|
<div className={styles["chat-message-actions"]}>
|
|
|
|
|
<div className={styles["chat-message-action-date"]}>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
{message.date.toLocaleString()}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<span ref={latestMessageRef} style={{ opacity: 0 }}>
|
|
|
|
|
-
|
|
|
|
|
</span>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className={styles["chat-input-panel"]}>
|
|
|
|
|
<div className={styles["chat-input-panel-inner"]}>
|
|
|
|
|
<textarea
|
|
|
|
|
className={styles["chat-input"]}
|
2023-03-12 19:06:21 +00:00
|
|
|
|
placeholder={`输入消息,${submitKey} 发送`}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
rows={3}
|
2023-03-10 18:25:33 +00:00
|
|
|
|
onInput={(e) => setUserInput(e.currentTarget.value)}
|
|
|
|
|
value={userInput}
|
|
|
|
|
onKeyDown={(e) => onInputKeyDown(e as any)}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
/>
|
|
|
|
|
<IconButton
|
|
|
|
|
icon={<SendWhiteIcon />}
|
|
|
|
|
text={"发送"}
|
2023-03-12 19:06:21 +00:00
|
|
|
|
className={styles["chat-input-send"] + " no-dark"}
|
2023-03-10 18:25:33 +00:00
|
|
|
|
onClick={onUserSubmit}
|
2023-03-09 17:01:40 +00:00
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
function useSwitchTheme() {
|
|
|
|
|
const config = useChatStore((state) => state.config);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
document.body.classList.remove("light");
|
|
|
|
|
document.body.classList.remove("dark");
|
|
|
|
|
if (config.theme === "dark") {
|
|
|
|
|
document.body.classList.add("dark");
|
|
|
|
|
} else if (config.theme === "light") {
|
|
|
|
|
document.body.classList.add("light");
|
|
|
|
|
}
|
|
|
|
|
}, [config.theme]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-09 17:01:40 +00:00
|
|
|
|
export function Home() {
|
2023-03-10 18:25:33 +00:00
|
|
|
|
const [createNewSession] = useChatStore((state) => [state.newSession]);
|
|
|
|
|
|
2023-03-11 17:14:07 +00:00
|
|
|
|
// settings
|
|
|
|
|
const [openSettings, setOpenSettings] = useState(false);
|
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
useSwitchTheme();
|
|
|
|
|
|
2023-03-09 17:01:40 +00:00
|
|
|
|
return (
|
|
|
|
|
<div className={styles.container}>
|
|
|
|
|
<div className={styles.sidebar}>
|
|
|
|
|
<div className={styles["sidebar-header"]}>
|
|
|
|
|
<div className={styles["sidebar-title"]}>ChatGPT Next</div>
|
|
|
|
|
<div className={styles["sidebar-sub-title"]}>
|
|
|
|
|
Build your own AI assistant.
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles["sidebar-logo"]}>
|
|
|
|
|
<ChatGptIcon />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div
|
|
|
|
|
className={styles["sidebar-body"]}
|
|
|
|
|
onClick={() => setOpenSettings(false)}
|
|
|
|
|
>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
<ChatList />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className={styles["sidebar-tail"]}>
|
|
|
|
|
<div className={styles["sidebar-actions"]}>
|
|
|
|
|
<div className={styles["sidebar-action"]}>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
<IconButton
|
|
|
|
|
icon={<SettingsIcon />}
|
|
|
|
|
onClick={() => setOpenSettings(!openSettings)}
|
|
|
|
|
/>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div className={styles["sidebar-action"]}>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<a href="https://github.com/Yidadaa" target="_blank">
|
|
|
|
|
<IconButton icon={<GithubIcon />} />
|
|
|
|
|
</a>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2023-03-10 18:25:33 +00:00
|
|
|
|
<IconButton
|
|
|
|
|
icon={<AddIcon />}
|
|
|
|
|
text={"新的聊天"}
|
|
|
|
|
onClick={createNewSession}
|
|
|
|
|
/>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-03-11 17:14:07 +00:00
|
|
|
|
<div className={styles["window-content"]}>
|
|
|
|
|
{openSettings ? <Settings /> : <Chat key="chat" />}
|
|
|
|
|
</div>
|
2023-03-09 17:01:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-03-11 17:14:07 +00:00
|
|
|
|
|
|
|
|
|
export function Settings() {
|
|
|
|
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
|
|
|
const [config, updateConfig] = useChatStore((state) => [
|
|
|
|
|
state.config,
|
|
|
|
|
state.updateConfig,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className={styles["window-header"]}>
|
|
|
|
|
<div>
|
|
|
|
|
<div className={styles["window-header-title"]}>设置</div>
|
|
|
|
|
<div className={styles["window-header-sub-title"]}>设置选项</div>
|
|
|
|
|
</div>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div className={styles["window-actions"]}>
|
|
|
|
|
<div className={styles["window-action-button"]}>
|
|
|
|
|
<IconButton icon={<ResetIcon />} bordered title="重置所有选项" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
</div>
|
|
|
|
|
<div className={styles["settings"]}>
|
|
|
|
|
<List>
|
|
|
|
|
<ListItem>
|
|
|
|
|
<div className={styles["settings-title"]}>头像</div>
|
|
|
|
|
<Popover
|
|
|
|
|
onClose={() => setShowEmojiPicker(false)}
|
|
|
|
|
content={
|
|
|
|
|
<EmojiPicker
|
|
|
|
|
lazyLoadEmojis
|
2023-03-12 19:06:21 +00:00
|
|
|
|
theme={EmojiTheme.AUTO}
|
2023-03-11 17:14:07 +00:00
|
|
|
|
onEmojiClick={(e) => {
|
|
|
|
|
updateConfig((config) => (config.avatar = e.unified));
|
|
|
|
|
setShowEmojiPicker(false);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
open={showEmojiPicker}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className={styles.avatar}
|
|
|
|
|
onClick={() => setShowEmojiPicker(true)}
|
|
|
|
|
>
|
|
|
|
|
<Avatar role="user" />
|
|
|
|
|
</div>
|
|
|
|
|
</Popover>
|
|
|
|
|
</ListItem>
|
|
|
|
|
|
|
|
|
|
<ListItem>
|
|
|
|
|
<div className={styles["settings-title"]}>发送键</div>
|
|
|
|
|
<div className="">
|
|
|
|
|
<select
|
|
|
|
|
value={config.submitKey}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
updateConfig(
|
|
|
|
|
(config) =>
|
|
|
|
|
(config.submitKey = e.target.value as any as SubmitKey)
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
{Object.values(SubmitKey).map((v) => (
|
|
|
|
|
<option value={v} key={v}>
|
|
|
|
|
{v}
|
|
|
|
|
</option>
|
|
|
|
|
))}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</ListItem>
|
|
|
|
|
|
|
|
|
|
<ListItem>
|
|
|
|
|
<div className={styles["settings-title"]}>主题</div>
|
|
|
|
|
<div className="">
|
|
|
|
|
<select
|
|
|
|
|
value={config.theme}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
updateConfig(
|
|
|
|
|
(config) => (config.theme = e.target.value as any as Theme)
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{Object.values(Theme).map((v) => (
|
|
|
|
|
<option value={v} key={v}>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
{v}
|
|
|
|
|
</option>
|
|
|
|
|
))}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</ListItem>
|
|
|
|
|
</List>
|
|
|
|
|
<List>
|
|
|
|
|
<ListItem>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div className={styles["settings-title"]}>最大上下文消息数</div>
|
|
|
|
|
<input
|
|
|
|
|
type="range"
|
|
|
|
|
title={config.historyMessageCount.toString()}
|
|
|
|
|
value={config.historyMessageCount}
|
|
|
|
|
min="5"
|
|
|
|
|
max="20"
|
|
|
|
|
step="5"
|
|
|
|
|
onChange={(e) =>
|
|
|
|
|
updateConfig(
|
|
|
|
|
(config) =>
|
|
|
|
|
(config.historyMessageCount = e.target.valueAsNumber)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
></input>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
</ListItem>
|
|
|
|
|
|
|
|
|
|
<ListItem>
|
2023-03-12 19:06:21 +00:00
|
|
|
|
<div className={styles["settings-title"]}>
|
|
|
|
|
上下文中包含机器人消息
|
|
|
|
|
</div>
|
|
|
|
|
<input
|
|
|
|
|
type="checkbox"
|
|
|
|
|
checked={config.sendBotMessages}
|
|
|
|
|
onChange={(e) =>
|
|
|
|
|
updateConfig(
|
|
|
|
|
(config) => (config.sendBotMessages = e.currentTarget.checked)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
></input>
|
2023-03-11 17:14:07 +00:00
|
|
|
|
</ListItem>
|
|
|
|
|
</List>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|