李富豪 il y a 1 an
Parent
commit
54c8e1b128
2 fichiers modifiés avec 21 ajouts et 8 suppressions
  1. 7 1
      app/client/config.ts
  2. 14 7
      app/client/platforms/bigmodel.ts

+ 7 - 1
app/client/config.ts

@@ -2,4 +2,10 @@
 export const bigModelApiKey = '20480a1ad76c4d9e0a168206a25f9614.bUjEVNXHpgY0H0GH';
 
 // 知识库ID
-export const knowledgeId = '1822866230839840768';
+export const knowledgeId = '1822866230839840768';
+
+// 模型面具
+export const mask = {
+    enabled: true,// 是否开启
+    content: ' ',// 内容
+}

+ 14 - 7
app/client/platforms/bigmodel.ts

@@ -13,7 +13,7 @@ import {
 } from "@fortaine/fetch-event-source";
 import { prettyObject } from "@/app/utils/format";
 import { getMessageTextContent } from "@/app/utils";
-import { bigModelApiKey, knowledgeId } from "../config";
+import { bigModelApiKey, knowledgeId, mask } from "../config";
 
 export class BigModelApi implements LLMApi {
   path(): string {
@@ -26,18 +26,25 @@ export class BigModelApi implements LLMApi {
       content: getMessageTextContent(v),
     }));
 
-    if (messages.length % 2 === 0) {
+    // if (messages.length % 2 === 0) {
+    //   messages.unshift({
+    //     role: "user",
+    //     content: " ",
+    //   });
+    // }
+
+    const shouldStream = true;
+
+    if (mask.enabled) {
       messages.unshift({
         role: "user",
-        content: " ",
-      });
+        content: mask.content,
+      })
     }
 
-    const shouldStream = true;
-
     // 通用大模型参数
     const requestPayload: any = {
-      messages,
+      messages: messages,
       stream: shouldStream,// 流式回复
       model: 'glm-4-flash',// 模型
       temperature: 0.95,// 采样温度