소스 검색

修复预设词

李富豪 11 달 전
부모
커밋
d50d32b182
7개의 변경된 파일87개의 추가작업 그리고 58개의 파일을 삭제
  1. 3 0
      app/components/DeepSeekChat.tsx
  2. 3 0
      app/components/DeepSeekHomeChat.tsx
  3. 1 1
      app/components/chat.module.scss
  4. 67 35
      app/components/chat.tsx
  5. 13 22
      app/components/sidebar.tsx
  6. BIN
      app/icons/aiIcon.png
  7. BIN
      app/icons/deepSeek.png

+ 3 - 0
app/components/DeepSeekChat.tsx

@@ -1518,6 +1518,9 @@ function _Chat() {
             <SendWhiteIcon />
           </div>
         </div>
+        <div style={{ marginTop: 10, textAlign: 'center', color: '#888888', fontSize: 12 }}>
+          内容由AI生成,仅供参考
+        </div>
       </div>
       {showExport && (
         <ExportMessageModal onClose={() => setShowExport(false)} />

+ 3 - 0
app/components/DeepSeekHomeChat.tsx

@@ -1496,6 +1496,9 @@ function _Chat() {
             <SendWhiteIcon />
           </div>
         </div>
+        <div style={{ marginTop: 10, textAlign: 'center', color: '#888888', fontSize: 12 }}>
+          内容由AI生成,仅供参考
+        </div>
       </div>
       {showExport && (
         <ExportMessageModal onClose={() => setShowExport(false)} />

+ 1 - 1
app/components/chat.module.scss

@@ -514,7 +514,7 @@
   padding-top: 10px;
   box-sizing: border-box;
   flex-direction: column;
-  box-shadow: var(--card-shadow);
+  // box-shadow: var(--card-shadow);
 
   // 背景
   // background: rgba(155, 155, 255, 0.2);

+ 67 - 35
app/components/chat.tsx

@@ -109,8 +109,8 @@ import { prettyObject } from "../utils/format";
 import { ExportMessageModal } from "./exporter";
 import { getClientConfig } from "../config/client";
 import { useAllModels } from "../utils/hooks";
-import { Button, message, Popover, Select } from 'antd';
-import { RightOutlined } from '@ant-design/icons';
+import { Button, message, Popover, Select, Skeleton, Space } from 'antd';
+import { RightOutlined, CheckCircleOutlined } from '@ant-design/icons';
 import api from "@/app/api/api";
 
 const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
@@ -512,6 +512,7 @@ function useScrollToBottom(
 }
 
 export function ChatActions(props: {
+  sendStatus: boolean,
   setUserInput: (value: string) => void;
   doSubmit: (userInput: string) => void;
   uploadImage: () => void;
@@ -576,7 +577,6 @@ export function ChatActions(props: {
 
   type GuessList = string[]
   const [guessList, setGuessList] = useState<GuessList>([]);
-
   const [showSizeSelector, setShowSizeSelector] = useState(false);
   const dalle3Sizes: DalleSize[] = ["1024x1024", "1792x1024", "1024x1792"];
   const currentSize =
@@ -636,37 +636,47 @@ export function ChatActions(props: {
 
   return (
     <div className={styles["chat-input-actions"]}>
-      {guessList.length > 0 && (
+      {
+        props.sendStatus &&
         <div style={{ color: '#8096ca', fontSize: 13 }}>
           <div>
             你还可以尝试提问:
           </div>
-          <div style={{ display: 'flex', marginTop: 10, flexWrap: 'wrap' }}>
-            {
-              guessList.map((item, index) => {
-                return (
-                  <div
-                    style={{
-                      padding: '5px 10px',
-                      background: '#f2f4f8',
-                      borderRadius: 5,
-                      margin: '0 10px 10px 0',
-                      cursor: 'pointer',
-                    }}
-                    onClick={() => {
-                      props.setUserInput(item);
-                      props.doSubmit(item)
-                    }}
-                    key={index}
-                  >
-                    {item}
-                  </div>
-                )
-              })
-            }
-          </div>
+          {
+            guessList.length === 0 ?
+              <Space style={{ margin: '10px 0' }}>
+                <Skeleton.Button size="small" active={true} />
+                <Skeleton.Button size="small" active={true} />
+                <Skeleton.Button size="small" active={true} />
+              </Space>
+              :
+              <div style={{ display: 'flex', marginTop: 10, flexWrap: 'wrap' }}>
+                {
+                  guessList.map((item, index) => {
+                    return (
+                      <div
+                        style={{
+                          padding: '5px 10px',
+                          background: '#f2f4f8',
+                          borderRadius: 5,
+                          margin: '0 10px 10px 0',
+                          cursor: 'pointer',
+                        }}
+                        onClick={() => {
+                          props.setUserInput(item);
+                          props.doSubmit(item)
+                        }}
+                        key={index}
+                      >
+                        {item}
+                      </div>
+                    )
+                  })
+                }
+              </div>
+          }
         </div>
-      )}
+      }
       {/* {couldStop && (
         <ChatAction
           onClick={stopAll}
@@ -931,6 +941,7 @@ function _Chat() {
   const inputRef = useRef<HTMLTextAreaElement>(null);
   const [userInput, setUserInput] = useState("");
   const [isLoading, setIsLoading] = useState(false);
+  const [sendStatus, setSendStatus] = useState(false);
   const { submitKey, shouldSubmit } = useSubmitHandler();
   const scrollRef = useRef<HTMLDivElement>(null);
   const isScrolledToBottom = scrollRef?.current
@@ -1109,6 +1120,7 @@ function _Chat() {
     setPromptHints([]);
     if (!isMobileScreen) inputRef.current?.focus();
     setAutoScroll(true);
+    setSendStatus(true);
   };
 
   const onPromptSelect = (prompt: RenderPrompt) => {
@@ -1570,6 +1582,13 @@ function _Chat() {
                     chatStore.updateCurrentSession((values) => {
                       values.appId = value;
                     });
+                    useChatStore.setState({
+                      message: {
+                        content: '',
+                        role: 'assistant',
+                      }
+                    });
+                    setSendStatus(false);
                   }}
                 />
                 :
@@ -1782,11 +1801,21 @@ function _Chat() {
                       </div>
                     )} */}
                         </div>
-                        {showTyping && (
-                          <div className={styles["chat-message-status"]}>
-                            {Locale.Chat.Typing}
-                          </div>
-                        )}
+                        {
+                          showTyping ?
+                            <div className={styles["chat-message-status"]}>
+                              {isUser ? '正在输入…' : '正在查询文档…'}
+                            </div>
+                            :
+                            <div className={styles["chat-message-status"]}>
+                              {
+                                message.role === 'assistant' && messages.length - 1 === i &&
+                                <div>
+                                  <CheckCircleOutlined /> 文档搜索成功
+                                </div>
+                              }
+                            </div>
+                        }
                         <div className={styles["chat-message-item"]}>
                           <Markdown
                             key={message.streaming ? "loading" : "done"}
@@ -1902,6 +1931,7 @@ function _Chat() {
       <div className={styles["chat-input-panel"]}>
         {/* <PromptHints prompts={promptHints} onPromptSelect={onPromptSelect} /> */}
         <ChatActions
+          sendStatus={sendStatus}
           setUserInput={setUserInput}
           doSubmit={doSubmit}
           uploadImage={uploadImage}
@@ -1980,7 +2010,9 @@ function _Chat() {
           />
         </label>
       </div>
-
+      <div style={{ paddingBottom: 20, textAlign: 'center', color: '#888888', fontSize: 12 }}>
+        内容由AI生成,仅供参考
+      </div>
       {showExport && (
         <ExportMessageModal onClose={() => setShowExport(false)} />
       )}

+ 13 - 22
app/components/sidebar.tsx

@@ -268,11 +268,13 @@ export const SideBar = (props: { className?: string }) => {
                     try {
                       await api.delete(`/bigmodel/api/dialog/del/${child.key}`);
                       await fetchChatList()
-                      // 删除不需要清理消息
-                      // chatStore.clearSessions();
-                      // chatStore.updateCurrentSession((value) => {
-                      //   value.appId = globalStore.selectedAppId;
-                      // });
+                      chatStore.clearSessions();
+                      useChatStore.setState({
+                        message: {
+                          content: '',
+                          role: 'assistant',
+                        }
+                      });
                     } catch (error) {
                       console.error(error);
                     }
@@ -310,6 +312,12 @@ export const SideBar = (props: { className?: string }) => {
 
   useEffect(() => {
     chatStore.clearSessions();
+    useChatStore.setState({
+      message: {
+        content: '',
+        role: 'assistant',
+      }
+    });
   }, []);
 
   return (
@@ -345,12 +353,6 @@ export const SideBar = (props: { className?: string }) => {
               chatStore.updateCurrentSession((value) => {
                 value.appId = globalStore.selectedAppId;
               });
-              useChatStore.setState({
-                message: {
-                  content: '',
-                  role: 'assistant',
-                }
-              });
               if (getType() === 'bigModel') {
                 navigate({ pathname: '/newChat' });
               } else {
@@ -389,17 +391,6 @@ export const SideBar = (props: { className?: string }) => {
             value.id = session.id;
             value.messages = list;
           });
-          const messages = session.messages.slice();
-          const backList = messages.reverse();
-          const record = backList.find((item: any) => item.content && item.role === 'assistant');
-          if (record) {
-            useChatStore.setState({
-              message: {
-                content: record.content as string,
-                role: record.role,
-              }
-            });
-          }
           if (getType() === 'bigModel') {
             navigate({ pathname: '/newChat' });
           } else {

BIN
app/icons/aiIcon.png


BIN
app/icons/deepSeek.png