|
|
@@ -22,10 +22,12 @@ import avatar from "../icons/aiIcon.png";
|
|
|
import sdsk from "../icons/sdsk.png";
|
|
|
import sdsk_selected from "../icons/sdsk_selected.png";
|
|
|
import hlw from "../icons/hlw.png";
|
|
|
+import hlw_selected from "../icons/hlw_selected.png";
|
|
|
import { Avatar } from "./emoji";
|
|
|
import { MaskAvatar } from "./mask";
|
|
|
|
|
|
import {
|
|
|
+ ChatMessage,
|
|
|
SubmitKey,
|
|
|
useChatStore,
|
|
|
useAccessStore,
|
|
|
@@ -86,14 +88,15 @@ import { ExportMessageModal } from "./exporter";
|
|
|
import { getClientConfig } from "../config/client";
|
|
|
import { useAllModels } from "../utils/hooks";
|
|
|
import { nanoid } from "nanoid";
|
|
|
-import { message, Upload, UploadProps, Tooltip } from "antd";
|
|
|
+import { message, Upload, UploadProps, Tooltip, Drawer, Button } from "antd";
|
|
|
import {
|
|
|
PaperClipOutlined,
|
|
|
SendOutlined,
|
|
|
FileOutlined,
|
|
|
FilePdfOutlined,
|
|
|
FileTextOutlined,
|
|
|
- FileWordOutlined
|
|
|
+ FileWordOutlined,
|
|
|
+ RightOutlined
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
export function createMessage(override: Partial<ChatMessage>): ChatMessage {
|
|
|
@@ -106,14 +109,6 @@ export function createMessage(override: Partial<ChatMessage>): ChatMessage {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-export type ChatMessage = RequestMessage & {
|
|
|
- date: string;
|
|
|
- streaming?: boolean;
|
|
|
- isError?: boolean;
|
|
|
- id: string;
|
|
|
- model?: ModelType;
|
|
|
-};
|
|
|
-
|
|
|
export const BOT_HELLO: ChatMessage = createMessage({
|
|
|
role: "assistant",
|
|
|
content: '您好,我是小智',
|
|
|
@@ -1373,6 +1368,68 @@ function _Chat() {
|
|
|
|
|
|
const [webSearch, setWebSearch] = useState<boolean>(chatStore.web_search);
|
|
|
|
|
|
+ const [drawerOpen, setDrawerOpen] = useState(false);
|
|
|
+ type DrawerList = {
|
|
|
+ title: string,
|
|
|
+ content: string,
|
|
|
+ web_url: string,
|
|
|
+ }[]
|
|
|
+ const [drawerList, setDrawerList] = useState<DrawerList>([]);
|
|
|
+
|
|
|
+ interface NetworkDrawerProps {
|
|
|
+ list: DrawerList,
|
|
|
+ }
|
|
|
+
|
|
|
+ const NetworkDrawer: React.FC<NetworkDrawerProps> = (props) => {
|
|
|
+ return (
|
|
|
+ <Drawer
|
|
|
+ title='网页搜索'
|
|
|
+ open={drawerOpen}
|
|
|
+ onClose={() => {
|
|
|
+ setDrawerOpen(false);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {props.list.map((item, index) => {
|
|
|
+ return <div
|
|
|
+ style={{
|
|
|
+ padding: 10,
|
|
|
+ background: '#fafafa',
|
|
|
+ borderRadius: 4,
|
|
|
+ marginBottom: 10,
|
|
|
+ cursor: 'pointer',
|
|
|
+ }}
|
|
|
+ key={index}
|
|
|
+ onClick={() => {
|
|
|
+ window.open(item.web_url);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div style={{
|
|
|
+ margin: '5px 0',
|
|
|
+ fontSize: 16,
|
|
|
+ display: '-webkit-box',
|
|
|
+ WebkitBoxOrient: 'vertical',
|
|
|
+ WebkitLineClamp: 2,// 限制显示两行
|
|
|
+ overflow: 'hidden',
|
|
|
+ }}>
|
|
|
+ {item.title}
|
|
|
+ </div>
|
|
|
+ <div style={{
|
|
|
+ color: '#afafaf',
|
|
|
+ display: '-webkit-box',
|
|
|
+ WebkitBoxOrient: 'vertical',
|
|
|
+ WebkitLineClamp: 4,// 限制显示两行
|
|
|
+ overflow: 'hidden',
|
|
|
+ textOverflow: 'ellipsis',
|
|
|
+ }}>
|
|
|
+ {item.content}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </Drawer >
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.chat} key={session.id}>
|
|
|
{
|
|
|
@@ -1477,6 +1534,27 @@ function _Chat() {
|
|
|
正在输入…
|
|
|
</div>
|
|
|
)} */}
|
|
|
+ {
|
|
|
+ message.networkInfo && message.networkInfo.list.length > 0 &&
|
|
|
+ <div style={{ marginTop: 10 }}>
|
|
|
+ <Button
|
|
|
+ icon={<RightOutlined />}
|
|
|
+ iconPosition='end'
|
|
|
+ onClick={() => {
|
|
|
+ setDrawerList(message.networkInfo!.list);
|
|
|
+ setDrawerOpen(true);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 查询到{message.networkInfo.list.length}篇相关资料
|
|
|
+ </Button>
|
|
|
+ {
|
|
|
+ drawerOpen &&
|
|
|
+ <NetworkDrawer
|
|
|
+ list={message.networkInfo.list}
|
|
|
+ />
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ }
|
|
|
<div className={styles["chat-message-item"]}>
|
|
|
<Markdown
|
|
|
key={message.streaming ? "loading" : "done"}
|
|
|
@@ -1689,7 +1767,7 @@ function _Chat() {
|
|
|
}}
|
|
|
>
|
|
|
<img
|
|
|
- src={hlw.src}
|
|
|
+ src={webSearch ? hlw_selected.src : hlw.src}
|
|
|
style={{
|
|
|
width: 18,
|
|
|
height: 18,
|
|
|
@@ -1836,6 +1914,7 @@ export function Chat() {
|
|
|
|
|
|
useEffect(() => {
|
|
|
chatStore.setModel('DeepSeek');
|
|
|
+ chatStore.setWebSearch(false);
|
|
|
}, []);
|
|
|
|
|
|
return <_Chat key={sessionIndex}></_Chat>;
|