Преглед на файлове

默认展示聊天框 更改我猜你可能问的展示方式

sunsheng преди 2 месеца
родител
ревизия
69082bede5
променени са 3 файла, в които са добавени 77 реда и са изтрити 68 реда
  1. 5 1
      README.md
  2. 71 66
      app/components/chat.tsx
  3. 1 1
      app/store/chat.ts

+ 5 - 1
README.md

@@ -148,4 +148,8 @@ http://localhost:4000/#/knowledgeChat?showMenu=false&chatMode=LOCAL&appId=292481
     const loginUrl = 'http://esc.sribs.com.cn:8080/esc-sso/oauth2.0/authorize?client_id=e97f94cf93761f4d69e8&response_type=code';
     const externalLoginUrl = loginUrl + `&redirect_uri=${encodeURIComponent(originUrl)}&state=${encodeURIComponent(fullUrl)}`;
     location.replace(externalLoginUrl);
-  }
+  }
+# 招聘的只需要改动这里就行了
+4、app/components/Chat.tsx // 上线的时候默认的appID要改成生产的
+const appId = '2959949063168331776'; // 生产ID
+const appId = '2924812721300312064'; // 测试ID

+ 71 - 66
app/components/chat.tsx

@@ -214,8 +214,9 @@ export function SessionConfigModel(props: { onClose: () => void }) {
 const CallWord = (props: {
   setUserInput: (value: string) => void,
   doSubmit: (userInput: string) => void,
+  questionList: string[]
 }) => {
-  const { setUserInput, doSubmit } = props
+  const { setUserInput, doSubmit,questionList } = props
   const list = [
     {
       title: '信息公布',
@@ -257,7 +258,7 @@ const CallWord = (props: {
   return (
     <>
       {
-        list.map((item, index) => {
+        questionList.map((item, index) => {
           return <span
             key={index}
             style={{
@@ -271,16 +272,16 @@ const CallWord = (props: {
             }}
             onClick={() => {
               const plan: string = '2';
-              if (plan === '1') {
+              // if (plan === '1') {
                 // 方案1.点击后出现在输入框内,用户自己点击发送
-                setUserInput(item.text);
-              } else {
+                setUserInput(item);
+              // } else {
                 // 方案2.点击后直接发送
-                doSubmit(item.text)
-              }
+                doSubmit(item)
+              // }
             }}
           >
-            {item.title}
+            {item}
           </span>
         })
       }
@@ -554,6 +555,7 @@ export function ChatActions(props: {
   showPromptHints: () => void;
   hitBottom: boolean;
   uploading: boolean;
+  questionList: string[];
 }) {
   const config = useAppConfig();
   const navigate = useNavigate();
@@ -788,7 +790,7 @@ export function ChatActions(props: {
           icon={<StopIcon />}
         />
       )} */}
-
+      {/* 最下面按钮 回到最下面 */}
       {!props.hitBottom && (
         <ChatAction
           onClick={props.scrollToBottom}
@@ -828,11 +830,12 @@ export function ChatActions(props: {
           </>
         }
       /> */}
-
-      {/* <CallWord */}
-      {/*   setUserInput={props.setUserInput} */}
-      {/*   doSubmit={props.doSubmit} */}
-      {/* /> */}
+      {/* 提示词展示 */}
+      {!props.sendStatus&&<CallWord
+        questionList={props.questionList}
+        setUserInput={props.setUserInput}
+        doSubmit={props.doSubmit}
+      />}
 
       {/* <ChatAction
         onClick={props.showPromptHints}
@@ -1098,6 +1101,8 @@ function _Chat() {
 
   const [selectedFruit, setSelectedFruit] = React.useState(chatStore.chatMode);
 
+
+
   // 获取应用列表
   const fetchApplicationList = async (chatMode?: string) => {
     let mode = chatMode || selectedFruit;
@@ -1138,7 +1143,7 @@ function _Chat() {
     try {
       let url = null;
       if (selectedFruit === 'LOCAL') {
-        url = '/deepseek/api/free//presets';
+        url = '/deepseek/api/free/presets';
       }
       // else {
       //   url = '/bigmodel/api/presets';
@@ -1332,7 +1337,7 @@ function _Chat() {
       e.preventDefault();
     }
   };
-
+  // 历史对话消息
   const onRightClick = (e: any, message: ChatMessage) => {
     // copy to clipboard
     if (selectOrCopy(e.currentTarget, getMessageTextContent(message))) {
@@ -1423,12 +1428,11 @@ function _Chat() {
       },
     });
   };
-
+  // 默认添加一条数据- start
   const context: RenderMessage[] = useMemo(() => {
     return session.mask.hideContext ? [] : session.mask.context.slice();
   }, [session.mask.context, session.mask.hideContext]);
   const accessStore = useAccessStore();
-
   if (
     context.length === 0 &&
     session.messages.at(0)?.content !== BOT_HELLO.content
@@ -1439,6 +1443,7 @@ function _Chat() {
     }
     context.push(copiedHello);
   }
+  // 默认添加一条数据- end
 
   // preview messages
   const renderMessages = useMemo(() => {
@@ -1979,7 +1984,7 @@ function _Chat() {
       >
         {/* 这里是具体的聊天框 */}
         {
-          messages.length > 1 ?
+          // messages.length > 1 ?
             <>
               {messages.map((message, i) => {
                 const isUser = message.role === "user";
@@ -2217,53 +2222,52 @@ function _Chat() {
                 );
               })}
             </>
-            :
-            <>
-              <div style={{ padding: '0 20px' }}>
-                <div style={{ display: 'flex', justifyContent: 'center' }}>
-                  <img style={{ width: 80, height: 80 }} src={avatarSrc.src} />
-                </div>
-                <h1 style={{ textAlign: 'center' }}>
-                  {getAppName()}
-                </h1>
-                <p style={{ textAlign: 'center' }}>
-                  {getDesc()}
-                </p>
-                <div style={{ background: '#fff', padding: 10, borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,.1)' }}>
-                  <p>我猜您可能想问:</p>
-                  {
-                    questionList.map((item, index) => {
-                      return (
-                        <div
-                          style={{
-                            padding: '10px',
-                            marginBottom: '10px',
-                            border: '1px solid #e6e8f1',
-                            borderRadius: '10px',
-                            fontSize: '16px',
-                            display: 'flex',
-                            justifyContent: 'space-between',
-                            alignItems: 'center',
-                            cursor: 'pointer'
-                          }}
-                          onClick={() => {
-                            setUserInput(item)
-                            doSubmit(item)
-                          }}
-                          key={index}
-                        >
-                          <div>
-                            {item}
-                          </div>
-                          <RightOutlined />
-                        </div>
-                      )
-                    })
-                  }
-                </div>
-
-              </div>
-            </>
+            // :
+            // <>
+            //   <div style={{ padding: '0 20px' }}>
+            //     <div style={{ display: 'flex', justifyContent: 'center' }}>
+            //       <img style={{ width: 80, height: 80 }} src={avatarSrc.src} />
+            //     </div>
+            //     <h1 style={{ textAlign: 'center' }}>
+            //       {getAppName()}
+            //     </h1>
+            //     <p style={{ textAlign: 'center' }}>
+            //       {getDesc()}
+            //     </p>
+            //     <div style={{ background: '#fff', padding: 10, borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,.1)' }}>
+            //       <p>我猜您可能想问:</p>
+            //       {
+            //         questionList.map((item, index) => {
+            //           return (
+            //             <div
+            //               style={{
+            //                 padding: '10px',
+            //                 marginBottom: '10px',
+            //                 border: '1px solid #e6e8f1',
+            //                 borderRadius: '10px',
+            //                 fontSize: '16px',
+            //                 display: 'flex',
+            //                 justifyContent: 'space-between',
+            //                 alignItems: 'center',
+            //                 cursor: 'pointer'
+            //               }}
+            //               onClick={() => {
+            //                 setUserInput(item)
+            //                 doSubmit(item)
+            //               }}
+            //               key={index}
+            //             >
+            //               <div>
+            //                 {item}
+            //               </div>
+            //               <RightOutlined />
+            //             </div>
+            //           )
+            //         })
+            //       }
+            //     </div>
+            //   </div>
+            // </>
         }
       </div>
       <div className={styles["chat-input-panel"]}>
@@ -2281,6 +2285,7 @@ function _Chat() {
           scrollToBottom={scrollToBottom}
           hitBottom={hitBottom}
           uploading={uploading}
+          questionList={questionList}
           showPromptHints={() => {
             // Click again to close
             if (promptHints.length > 0) {

+ 1 - 1
app/store/chat.ts

@@ -83,7 +83,7 @@ export interface ChatSession {
 export const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
 export const BOT_HELLO: ChatMessage = createMessage({
   role: "assistant",
-  content: '您好,欢迎使用建科·小智,与本项目相关的问题都可以问我。',
+  content: '感谢关注上海建科工程咨询有限公司的校园招聘,欢迎提问,小智竭诚为您答疑解惑。',
 });
 
 function createEmptySession(): ChatSession {