This commit is contained in:
仙 境 ᰔᩚ 2023-03-29 17:20:38 +08:00
parent 8a05f84838
commit 9ad0e9a013
3 changed files with 19233 additions and 7683 deletions

View File

@ -7,7 +7,6 @@ import { IconButton } from "./button";
import styles from "./home.module.scss";
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";
@ -102,7 +101,7 @@ export function ChatList() {
state.currentSessionIndex,
state.selectSession,
state.removeSession,
]
],
);
return (
@ -170,7 +169,10 @@ export function PromptHints(props: {
);
}
export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean }) {
export function Chat(props: {
showSideBar?: () => void;
sideBarShowing?: boolean;
}) {
type RenderMessage = Message & { preview?: boolean };
const chatStore = useChatStore();
@ -194,7 +196,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
setPromptHints(promptStore.search(text));
},
100,
{ leading: true, trailing: true }
{ leading: true, trailing: true },
);
const onPromptSelect = (prompt: Prompt) => {
@ -280,7 +282,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
preview: true,
},
]
: []
: [],
)
.concat(
userInput.length > 0
@ -292,7 +294,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
preview: true,
},
]
: []
: [],
);
// auto scroll
@ -375,7 +377,8 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
</div>
)}
<div className={styles["chat-message-item"]}>
{(!isUser && !(message.preview || message.content.length === 0)) && (
{!isUser &&
!(message.preview || message.content.length === 0) && (
<div className={styles["chat-message-top-actions"]}>
{message.streaming ? (
<div
@ -555,7 +558,7 @@ export function Home() {
state.newSession,
state.currentSessionIndex,
state.removeSession,
]
],
);
const loading = !useHasHydrated();
const [showSideBar, setShowSideBar] = useState(true);
@ -620,11 +623,6 @@ export function Home() {
}}
/>
</div>
<div className={styles["sidebar-action"]}>
<a href={REPO_URL} target="_blank">
<IconButton icon={<GithubIcon />} />
</a>
</div>
</div>
<div>
<IconButton
@ -648,7 +646,11 @@ export function Home() {
}}
/>
) : (
<Chat key="chat" showSideBar={() => setShowSideBar(true)} sideBarShowing={showSideBar} />
<Chat
key="chat"
showSideBar={() => setShowSideBar(true)}
sideBarShowing={showSideBar}
/>
)}
</div>
</div>

14063
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

12777
yarn.lock

File diff suppressed because it is too large Load Diff