forked from XiaoMo/ChatGPT-Next-Web
commit
4e1e1d4fef
@ -28,7 +28,6 @@ export const ChatControllerPool = {
|
|||||||
|
|
||||||
remove(sessionIndex: number, messageId: number) {
|
remove(sessionIndex: number, messageId: number) {
|
||||||
const key = this.key(sessionIndex, messageId);
|
const key = this.key(sessionIndex, messageId);
|
||||||
this.controllers[key]?.abort();
|
|
||||||
delete this.controllers[key];
|
delete this.controllers[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
transform: scale(2);
|
height: 50%;
|
||||||
|
transform: scale(1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-title {
|
.main-title {
|
||||||
@ -184,6 +185,10 @@
|
|||||||
max-width: calc(100% - 104px);
|
max-width: calc(100% - 104px);
|
||||||
box-shadow: var(--card-shadow);
|
box-shadow: var(--card-shadow);
|
||||||
border: var(--border-in-light);
|
border: var(--border-in-light);
|
||||||
|
|
||||||
|
* {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-assistant {
|
&-assistant {
|
||||||
|
@ -7,17 +7,19 @@ import { copyToClipboard, downloadAs, useMobileScreen } from "../utils";
|
|||||||
|
|
||||||
import CopyIcon from "../icons/copy.svg";
|
import CopyIcon from "../icons/copy.svg";
|
||||||
import LoadingIcon from "../icons/three-dots.svg";
|
import LoadingIcon from "../icons/three-dots.svg";
|
||||||
import ChatGptIcon from "../icons/chatgpt.svg";
|
import ChatGptIcon from "../icons/chatgpt.png";
|
||||||
import ShareIcon from "../icons/share.svg";
|
import ShareIcon from "../icons/share.svg";
|
||||||
|
import BotIcon from "../icons/bot.png";
|
||||||
|
|
||||||
import DownloadIcon from "../icons/download.svg";
|
import DownloadIcon from "../icons/download.svg";
|
||||||
import { useMemo, useRef, useState } from "react";
|
import { useMemo, useRef, useState } from "react";
|
||||||
import { MessageSelector, useMessageSelector } from "./message-selector";
|
import { MessageSelector, useMessageSelector } from "./message-selector";
|
||||||
import { Avatar } from "./emoji";
|
import { Avatar } from "./emoji";
|
||||||
import { MaskAvatar } from "./mask";
|
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import NextImage from "next/image";
|
||||||
|
|
||||||
import { toBlob, toPng } from "html-to-image";
|
import { toBlob, toPng } from "html-to-image";
|
||||||
|
import { DEFAULT_MASK_AVATAR } from "../store/mask";
|
||||||
|
|
||||||
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
||||||
loading: () => <LoadingIcon />,
|
loading: () => <LoadingIcon />,
|
||||||
@ -253,6 +255,22 @@ export function PreviewActions(props: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ExportAvatar(props: { avatar: string }) {
|
||||||
|
if (props.avatar === DEFAULT_MASK_AVATAR) {
|
||||||
|
return (
|
||||||
|
<NextImage
|
||||||
|
src={BotIcon.src}
|
||||||
|
width={30}
|
||||||
|
height={30}
|
||||||
|
alt="bot"
|
||||||
|
className="user-avatar"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Avatar avatar={props.avatar}></Avatar>;
|
||||||
|
}
|
||||||
|
|
||||||
export function ImagePreviewer(props: {
|
export function ImagePreviewer(props: {
|
||||||
messages: ChatMessage[];
|
messages: ChatMessage[];
|
||||||
topic: string;
|
topic: string;
|
||||||
@ -319,7 +337,12 @@ export function ImagePreviewer(props: {
|
|||||||
>
|
>
|
||||||
<div className={styles["chat-info"]}>
|
<div className={styles["chat-info"]}>
|
||||||
<div className={styles["logo"] + " no-dark"}>
|
<div className={styles["logo"] + " no-dark"}>
|
||||||
<ChatGptIcon />
|
<NextImage
|
||||||
|
src={ChatGptIcon.src}
|
||||||
|
alt="logo"
|
||||||
|
width={50}
|
||||||
|
height={50}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@ -328,9 +351,9 @@ export function ImagePreviewer(props: {
|
|||||||
github.com/Yidadaa/ChatGPT-Next-Web
|
github.com/Yidadaa/ChatGPT-Next-Web
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["icons"]}>
|
<div className={styles["icons"]}>
|
||||||
<Avatar avatar={config.avatar}></Avatar>
|
<ExportAvatar avatar={config.avatar} />
|
||||||
<span className={styles["icon-space"]}>&</span>
|
<span className={styles["icon-space"]}>&</span>
|
||||||
<MaskAvatar mask={session.mask} />
|
<ExportAvatar avatar={mask.avatar} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -358,14 +381,12 @@ export function ImagePreviewer(props: {
|
|||||||
key={i}
|
key={i}
|
||||||
>
|
>
|
||||||
<div className={styles["avatar"]}>
|
<div className={styles["avatar"]}>
|
||||||
{m.role === "user" ? (
|
<ExportAvatar
|
||||||
<Avatar avatar={config.avatar}></Avatar>
|
avatar={m.role === "user" ? config.avatar : mask.avatar}
|
||||||
) : (
|
/>
|
||||||
<MaskAvatar mask={session.mask} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`${styles["body"]} `}>
|
<div className={styles["body"]}>
|
||||||
<Markdown
|
<Markdown
|
||||||
content={m.content}
|
content={m.content}
|
||||||
fontSize={config.fontSize}
|
fontSize={config.fontSize}
|
||||||
|
BIN
app/icons/bot.png
Normal file
BIN
app/icons/bot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
app/icons/chatgpt.png
Normal file
BIN
app/icons/chatgpt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@ -257,7 +257,12 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// get recent messages
|
// get recent messages
|
||||||
const systemMessages = [systemInfo];
|
const systemMessages = [];
|
||||||
|
// if user define a mask with context prompts, wont send system info
|
||||||
|
if (session.mask.context.length === 0) {
|
||||||
|
systemMessages.push(systemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
const recentMessages = get().getMessagesWithMemory();
|
const recentMessages = get().getMessagesWithMemory();
|
||||||
const sendMessages = systemMessages.concat(
|
const sendMessages = systemMessages.concat(
|
||||||
recentMessages.concat(userMessage),
|
recentMessages.concat(userMessage),
|
||||||
@ -345,7 +350,7 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
|
|
||||||
// wont send cleared context messages
|
// wont send cleared context messages
|
||||||
const clearedContextMessages = session.messages.slice(
|
const clearedContextMessages = session.messages.slice(
|
||||||
(session.clearContextIndex ?? 0),
|
session.clearContextIndex ?? 0,
|
||||||
);
|
);
|
||||||
const messages = clearedContextMessages.filter((msg) => !msg.isError);
|
const messages = clearedContextMessages.filter((msg) => !msg.isError);
|
||||||
const n = messages.length;
|
const n = messages.length;
|
||||||
|
Loading…
Reference in New Issue
Block a user