浏览代码

修复问题

李富豪 1 年之前
父节点
当前提交
079f9b02c6
共有 4 个文件被更改,包括 25 次插入24 次删除
  1. 18 18
      app/client/platforms/bigmodel.ts
  2. 1 1
      app/store/prompt.ts
  3. 5 3
      public/prompts.json
  4. 1 2
      public/prompts_bk.json

+ 18 - 18
app/client/platforms/bigmodel.ts

@@ -111,27 +111,11 @@ export class BigModelApi implements LLMApi {
         // start animaion
         animateResponseText();
 
-        const finish = async () => {
+        const finish = () => {
           if (!finished) {
             finished = true;
             options.onFinish(responseText + remainText);
           }
-          const session = useChatStore.getState().sessions[0];
-          const data = {
-            id: session.id,
-            messages: session.messages.map(item => {
-              return {
-                id: item.id,
-                date: item.date,
-                role: item.role,
-                content: item.content,
-              }
-            })
-          }
-          await fetch('/api/bigModel', {
-            method: 'POST',
-            body: JSON.stringify(data)
-          });
         };
 
         controller.signal.onabort = finish;
@@ -193,8 +177,24 @@ export class BigModelApi implements LLMApi {
               console.error("[Request] parse error", text, msg);
             }
           },
-          onclose() {
+          async onclose() {
             finish();
+            const session = useChatStore.getState().sessions[0];
+            const data = {
+              id: session.id,
+              messages: session.messages.map(item => {
+                return {
+                  id: item.id,
+                  date: item.date,
+                  role: item.role,
+                  content: item.content,
+                }
+              })
+            }
+            await fetch('/api/bigModel', {
+              method: 'POST',
+              body: JSON.stringify(data)
+            });
           },
           onerror(e) {
             options.onError?.(e);

+ 1 - 1
app/store/prompt.ts

@@ -158,7 +158,7 @@ export const usePromptStore = createPersistStore(
           if (getLang() === "cn") {
             fetchPrompts = fetchPrompts.reverse();
           }
-          const builtinPrompts = fetchPrompts.map((promptList: PromptList) => {
+          const builtinPrompts = fetchPrompts.filter(item => item).map((promptList: PromptList) => {
             return promptList.map(
               ([title, content]) =>
                 ({

+ 5 - 3
public/prompts.json

@@ -1,8 +1,10 @@
 {
-  "bigmodel": [
+  "cn": [
     [
       "文档",
       "从文档\n\"\"\"\n{{ knowledge}}\n\"\"\"\n中找问题\n\"\"\"\n{{question}}\n\"\"\"\n的答案,找到答案就仅使用文档语句回答问题,找不到答案就判断用户的问题是否与招聘、应聘有关。如果无关,就礼貌地提示用户问与招聘、应聘相关的问题;如果有关,就先用自身知识进行回答,然后告诉用户:“抱歉,针对这个问题,我的知识库里没有相关的信息。其他相关资讯,可前往企业校招子站、空中宣讲会页面,或关注我司微信公众号,并感谢大家对我们的关注和支持!”\n不要回答和招聘、应聘不相关的问题。\n不要复述问题,直接开始回答。\n如果问了多个问题,请注意回答的格式和条理要清晰。"
-    ],
-  ]
+    ]
+  ],
+  "tw": [],
+  "en": []
 }

+ 1 - 2
public/prompts_bk.json

@@ -1634,5 +1634,4 @@
     ],
     []
   ]
-}
-
+}