|
@@ -1,6 +1,6 @@
|
|
|
"use client";
|
|
"use client";
|
|
|
import { REQUEST_TIMEOUT_MS } from "@/app/constant";
|
|
import { REQUEST_TIMEOUT_MS } from "@/app/constant";
|
|
|
-import { useAppConfig, useChatStore } from "@/app/store";
|
|
|
|
|
|
|
+import { useChatStore } from "@/app/store";
|
|
|
import {
|
|
import {
|
|
|
ChatOptions,
|
|
ChatOptions,
|
|
|
LLMApi,
|
|
LLMApi,
|
|
@@ -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 } from "../config";
|
|
|
|
|
|
|
+import { bigModelApiKey, knowledgeId } from "../config";
|
|
|
|
|
|
|
|
export class BigModelApi implements LLMApi {
|
|
export class BigModelApi implements LLMApi {
|
|
|
path(): string {
|
|
path(): string {
|
|
@@ -33,23 +33,23 @@ export class BigModelApi implements LLMApi {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const modelConfig = {
|
|
|
|
|
- ...useAppConfig.getState().modelConfig,
|
|
|
|
|
- ...useChatStore.getState().currentSession().mask.modelConfig,
|
|
|
|
|
- ...{
|
|
|
|
|
- model: options.config.model,
|
|
|
|
|
- },
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const shouldStream = !!options.config.stream;
|
|
|
|
|
|
|
+ const shouldStream = true;
|
|
|
|
|
|
|
|
// 通用大模型参数
|
|
// 通用大模型参数
|
|
|
const requestPayload: any = {
|
|
const requestPayload: any = {
|
|
|
messages,
|
|
messages,
|
|
|
- stream: shouldStream,
|
|
|
|
|
- model: 'glm-4-flash',
|
|
|
|
|
- temperature: modelConfig.temperature,
|
|
|
|
|
- top_p: modelConfig.top_p,
|
|
|
|
|
|
|
+ stream: shouldStream,// 流式回复
|
|
|
|
|
+ model: 'glm-4-flash',// 模型
|
|
|
|
|
+ temperature: 0.95,// 采样温度
|
|
|
|
|
+ top_p: 0.7,// 核取样
|
|
|
|
|
+ tools: [
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'retrieval', // 工具类型为检索
|
|
|
|
|
+ retrieval: {
|
|
|
|
|
+ knowledge_id: knowledgeId,// 知识库ID
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const controller = new AbortController();
|
|
const controller = new AbortController();
|