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