This commit is contained in:
ylj20011123 2026-01-06 19:26:01 +08:00
parent 751fd8d3b4
commit c0c4402902
5 changed files with 670 additions and 288 deletions

View File

@ -399,8 +399,10 @@ const handleConfigRequest = async (
return handleGetListSumObj(resultNest, config.totalField);
}
return resultNest;
} else if (config.responseFormat === 'original') {
return data.Result_Data;
}
} else {
} else if (detail.RULE_SOURCE === 2000) {
//
if (config.responseFormat === "nestingList") {
data = handleSetRowKeyTable(wrapTreeNode(data.Result_Data.List));
@ -551,6 +553,10 @@ const handleConfigRequest = async (
}
return finalRes;
} else if (detail.RULE_SOURCE === 3000) {
if (config.responseFormat === 'original') {
return data.Result_Data.content;
}
}
};
@ -802,7 +808,7 @@ const handleAnalyzeConfig = async (configDetail: any, answer: any) => {
//
let req: any = handleGetReq(configDetail, answer);
console.log("req2", req);
console.log("req2", JSON.parse(JSON.stringify(req)));
// post
if (OUTPUT_FORMAT) {
if (OUTPUT_FORMAT.paramsFormat === "searchModel") {
@ -824,7 +830,7 @@ const handleAnalyzeConfig = async (configDetail: any, answer: any) => {
haveALLNull = false;
}
}
console.log("reqreqreqreq", JSON.parse(JSON.stringify(req)));
if (!req.ServerpartId && !req.SERVERPART_ID) {
req.ServerpartId = allID.value;
}

View File

@ -59,7 +59,7 @@
}
.leftFilterTabBox {
height: calc(100vh - 540px);
height: calc(100vh - 580px);
.el-tabs__header {
.el-tabs__nav-wrap {

View File

@ -17,8 +17,9 @@ import {
} from "./service";
import moment from "moment";
import pageBg from '../../assets/pageBg.png'
import { handleGetGeminiResult } from "../service";
const userInput = ref('新桥服务区python营收');
const userInput = ref('');
const loading = ref();
const error = ref();
const response = ref();
@ -116,6 +117,45 @@ let modalTypeDataList = reactive<any>([
const hideLeft = ref<boolean>(true);
//
const omitProcess = ref<boolean>(false);
// id
const thisSessionId = ref<string>("");
// 使
const pythonSemantics = ref<boolean>(true);
//
const selectModal = ref<number>(1);
//
const selectModalList = [
{ label: "[日常使用] Gemini 2.5 Flash ", value: 1 },
{ label: "[专家模式] Gemini 3.0 Flash", value: 2 },
// { label: "[ 3.3] Gemini 2.5 Flash", value: 3 },
// { label: "gemini-3-flash-preview()", value: 1 },
// { label: "gemini-2.5-flash()", value: 2 },
// { label: "gemini-3-flash-preview", value: 3 },
]
const selectModalCacheIDList: any = {
1: "cachedContents/oo1x7gs8rnvcd5gd0vkyqopgzs06z4snmx5m8qgp",
2: "cachedContents/jipudug6kwzw83niu4ufka93cpqwepumnfx4evsy",
// 3: "cachedContents/oo1x7gs8rnvcd5gd0vkyqopgzs06z4snmx5m8qgp",
// 4: "cachedContents/8x6no7sqolqrakwjra9md56r4pixe32obxc9jarp",
// 5: "cachedContents/oo1x7gs8rnvcd5gd0vkyqopgzs06z4snmx5m8qgp"
}
const selectModalListObj: any = {
1: "gemini-2.5-flash",
2: "gemini-3-flash-preview",
// 3: "gemini-2.5-flash",
// 4: "gemini-3-flash-preview",
// 5: "gemini-2.5-flash",
// 3: "gemini-3-flash-preview"
}
const selectModalCacheID = ref<string>("cachedContents/95ttblr2a58llzeoiaqmkd0kavw3kf4o6bkicx51")
// const selectModalCacheID = {
// 1: "cachedContents/ajvtu6x0pjpgqrox2zzumdj8fxt5pti9pk73u633",
// 2: "cachedContents/spsbxuz8yqfjqklyyogf0wffzech2eh5xwosfw3g",
// 3: "cachedContents/95ttblr2a58llzeoiaqmkd0kavw3kf4o6bkicx51",
// }
// tab
const leftTabShow = ref<string>("first");
// 0 1
@ -545,6 +585,11 @@ const handleSendRequest = async (bigObj?: any) => {
}
});
if (pythonSemantics.value) {
await handleAskDirectlyDeepseek();
return
}
//
if (startFree.value || thisQuestion.length > 50) {
await handleAskDirectlyDeepseek();
@ -600,8 +645,6 @@ const handleSendRequest = async (bigObj?: any) => {
return
}
if (useMapData) {
modalTypeDataList.forEach((item: any) => {
if (bigObj.value) {
@ -627,6 +670,7 @@ const handleSendRequest = async (bigObj?: any) => {
await handleNewRuleList();
for (let i = 0; i < modalTypeDataList.length; i++) {
console.log("thisQuestion21", thisQuestion);
if (modalTypeDataList[i].isShow) {
//
const mapData: any = await RobotDialogueBoxRef.value.handleSubmit(
@ -697,31 +741,32 @@ const handleSendRequest = async (bigObj?: any) => {
dataStr += `<Br/>`;
}
if (item.tableData && item.tableData.length > 0) {
item.tableData.forEach((subItem: any) => {
let str: string = "";
let obj: any = JSON.parse(JSON.stringify(subItem));
obj = handleChangObjType(obj);
//
let OUTPUT_FORMATRUNLE: any = JSON.parse(item.ruleDetail.OUTPUT_FORMAT)
if (OUTPUT_FORMATRUNLE.responseFormat !== 'original') {
if (item.tableData && item.tableData.length > 0) {
item.tableData.forEach((subItem: any) => {
let str: string = "";
let obj: any = JSON.parse(JSON.stringify(subItem));
obj = handleChangObjType(obj);
console.log("obj", obj);
console.log("showColumnsListshowColumnsList", showColumnsList);
console.log("itemitem", item);
if (obj) {
let text: string = handleTableDataToStr(
obj,
showColumnsList,
item.ruleDetail.CHILD_NODENAME,
1
);
str = `${text}`;
}
if (str) {
dataStr += `
if (obj) {
let text: string = handleTableDataToStr(
obj,
showColumnsList,
item.ruleDetail.CHILD_NODENAME,
1
);
str = `${text}`;
}
if (str) {
dataStr += `
${str}`;
}
});
}
});
}
}
if (item.VHtml && item.VHtml !== "暂无数据") {
allStr += `#id【${item.ruleDetail.ANALYSISRULE_ID}】接口数据如下#<Br/>${item.VHtml}<Br/>`;
} else {
@ -1287,23 +1332,12 @@ const handleGetAnswerID = async (obj: any) => {
// let responseText: string = "";
let oldMessage: any = [];
// 3 user
if (
obj.messageList &&
obj.messageList.length < 2 &&
obj.messageList.length > 0
) {
if (obj.messageList && obj.messageList.length < 2 && obj.messageList.length > 0) {
obj.messageList.forEach((item: any, index: number) => {
// if (startFree.value ? item.role === "user" : item.role === "default") {
if (item.role === "default") {
oldMessage.push({
role: "user",
content: item.content,
// (RoleDescription.value ? suffixText.value : "") +
// (useMapData
// ? item.mapContent === ""
// ? ""
// : item.mapContent
// : item.content),
});
} else if (item.role === "user") {
oldMessage.push({
@ -1320,12 +1354,6 @@ const handleGetAnswerID = async (obj: any) => {
oldMessage.push({
role: "user",
content: item.content,
// (RoleDescription.value ? suffixText.value : "") +
// (useMapData
// ? item.mapContent === ""
// ? ""
// : item.mapContent
// : item.content),
});
} else if (item.role === "assistant") {
//
@ -1337,24 +1365,8 @@ const handleGetAnswerID = async (obj: any) => {
});
}
// if (obj.messageList && obj.messageList.length > 0) {
// obj.messageList.forEach((item: any, index: number) => {
// if (item.role !== "default") {
// if (index + 1 === obj.messageList.length) {
// oldMessage.push({
// role: item.role,
// content:
// (RoleDescription.value ? suffixText.value : "") + item.content,
// });
// } else {
// oldMessage.push({
// role: item.role,
// content: useMapData ? item.mapContent : item.content,
// });
// }
// }
// });
// }
obj.messageList.push({
role: "assistant",
content: "",
@ -1364,140 +1376,72 @@ const handleGetAnswerID = async (obj: any) => {
});
handleScrollToBottomID("gjldBox" + obj.value);
//
let hasStreamData: boolean = false;
//
const controller = new AbortController();
controllers.value.push(controller); //
showController.value = true;
let timeoutId: any = null; // ID
console.log('pythonSemanticspythonSemantics', pythonSemantics);
// gemini
if (pythonSemantics.value) {
//
console.log('objobjobjobj', JSON.parse(JSON.stringify(oldMessage)));
try {
const timeoutPromise = new Promise((resolve) => {
timeoutId = setTimeout(() => {
if (!hasStreamData) {
//
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
resolve({});
}
}, 60000);
});
let resText: any = await Promise.race([
new Promise(async (resolve) => {
try {
//
let isStreaming: boolean = true;
let modal = {
model:
obj.value === 1
? selectDeepseekVersion.value === 1
? "deepseek-chat"
: selectDeepseekVersion.value === 2
? "deepseek-reasoner"
: ""
: obj.value === 2
? selectDeepseekVersion.value === 1
? "deepseek-ai/DeepSeek-V3"
: selectDeepseekVersion.value === 2
? "deepseek-ai/DeepSeek-R1-Distill-Llama-70B"
: ""
: obj.value === 3
? selectDeepseekVersion.value === 1
? "deepseek-v3"
: selectDeepseekVersion.value === 2
? "deepseek-r1"
: ""
: obj.value === 4
? "qwen-plus"
: obj.value === 5
? 'claude-sonnet-4-5'
: '',
messages: [...oldMessage],
stream: true,
// max_tokens: 200000,
// max_tokens: obj.value === 5 ? 200000 : maxTokens.value,
// stop: ["null"],
// temperature: Temperature.value,
// top_p: TopP.value,
// top_k: TopK.value,
// frequency_penalty: FrequencyPenalty.value,
// n: 1,
// response_format: {
// type: "text",
// },
};
const options = {
method: "POST",
headers: {
Authorization:
obj.value === 1
? "Bearer sk-d47e0bdc7fd249f29d2f0dba807d46f0"
: obj.value === 2
? "Bearer sk-nynbgbtnmsffijgkttoimqkptetivviwuqrdhbuclgbmvnsq"
: obj.value === 3
? "Bearer sk-1aa2c1c672034c6d826ce62d3aebcb47"
: obj.value === 4
? "Bearer sk-1aa2c1c672034c6d826ce62d3aebcb47"
: obj.value === 5
? "Bearer sk-f67d5aae13e14efc8a01e8cd0e665d15"
: "",
"Content-Type": "application/json",
},
body: JSON.stringify(modal),
signal: controller.signal, //
};
let geminiContent: any = []
if (modal.messages && modal.messages.length > 0) {
modal.messages.forEach((item: any, index: number) => {
if (item.role === "user") {
if (index + 1 === modal.messages.length) {
geminiContent.push({
parts: [
{
text: item.content,
}
]
})
}
}
})
let geminiContent: any = []
if (oldMessage && oldMessage.length > 0) {
oldMessage.forEach((item: any, index: number) => {
if (item.role === "user") {
if (index + 1 === oldMessage.length) {
geminiContent.push(item.content)
}
//
let isSuccess: boolean = false;
const response: any = await fetch(
obj.value === 1
? "https://api.deepseek.com/v1/chat/completions"
: obj.value === 2
? "https://api.siliconflow.cn/v1/chat/completions"
: obj.value === 3
? "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
: obj.value === 4
? "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
: obj.value === 5
? "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent"
: "",
obj.value === 5 ? {
}
})
}
//
let hasStreamData: boolean = false;
//
const controller = new AbortController();
controllers.value.push(controller); //
showController.value = true;
let timeoutId: any = null; // ID
try {
const timeoutPromise = new Promise((resolve) => {
timeoutId = setTimeout(() => {
if (!hasStreamData) {
//
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
resolve({});
}
}, 60000);
});
let resText: any = await Promise.race([
new Promise(async (resolve) => {
try {
//
let isStreaming: boolean = true;
const req: any = {
question: geminiContent[0],
config_type: "deep_analysis",
cache_id: selectModal.value ? selectModalCacheIDList[selectModal.value] : "cachedContents/95ttblr2a58llzeoiaqmkd0kavw3kf4o6bkicx51",
model_name: selectModal.value ? selectModalListObj[selectModal.value] : "gemini-2.5-flash",
stream: true,
max_output_tokens: 8192,
thisSessionId: thisSessionId.value || ""
}
let isSuccess: boolean = false;
const response: any = await fetch('http://192.168.1.207:8002/api/gemini/query/', {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": "AIzaSyAg1lJ8oZL_jMAefrRswIhx5xA8JTOZUTs",
},
body: JSON.stringify({
contents: geminiContent
}),
} : options
);
if (response.status === 200) {
isSuccess = true;
}
if (obj.value === 5) {
body: JSON.stringify(req),
})
if (response.status === 100) {
isSuccess = true;
}
//
// const data = await response.json();
const reader = response.body.getReader();
@ -1508,7 +1452,7 @@ const handleGetAnswerID = async (obj: any) => {
const chunk = decoder.decode(value);
let JSONChunk = trimFirstChar(chunk)
JSONChunk = JSONChunk ? JSON.parse(JSONChunk) : ""
handleStreamChunkIDGemini(JSONChunk ? [JSONChunk] : [], obj)
handleStreamChunkIDGeminiNew(JSONChunk ? [JSONChunk] : [], obj)
//
let nowShowList: any = [];
if (modalTypeDataList && modalTypeDataList.length > 0) {
@ -1540,101 +1484,368 @@ const handleGetAnswerID = async (obj: any) => {
}
resolve(true)
}
} else {
//
const reader = response.body.getReader();
const decoder = new TextDecoder("utf-8");
while (isStreaming) {
const { done, value } = await reader.read();
if (done) break;
//
const chunk = decoder.decode(value);
handleStreamChunkID(chunk, obj);
//
let nowShowList: any = [];
if (modalTypeDataList && modalTypeDataList.length > 0) {
modalTypeDataList.forEach((item: any) => {
if (item.isShow) {
nowShowList.push(item);
}
});
}
let index: number = 99999;
let isBottom: any = "default";
if (nowShowList && nowShowList.length > 0) {
nowShowList.forEach((item: any, itemIndex: number) => {
if (item.value === obj.value) {
index = itemIndex;
if (scrollList.value && scrollList.value.length > 0) {
isBottom = scrollList.value[itemIndex].isBottom;
}
}
});
}
if (
index === 99999 ||
isBottom === "default" ||
isBottom === true
) {
handleScrollToBottomID("gjldBox" + obj.value);
}
resolve(true); // resolve
} catch (error: any) {
if (error.name !== "AbortError") {
console.error("流式请求失败:", error);
}
} finally {
}
}).then((res) => {
hasStreamData = true; //
clearTimeout(timeoutId); //
}),
timeoutPromise
]);
showController.value = false;
return resText;
} catch (error) {
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
}
// messageList.push({
// role: "assistant",
// content: responseText.value,
// descResponseText: descResponseText.value,
// });
obj.responseText = "";
obj.descResponseText = "";
showController.value = false;
// handleStop();
return isSuccess;
} catch (error: any) {
if (error.name !== "AbortError") {
console.error("流式请求失败:", error);
}
} finally {
}
}).then((res) => {
hasStreamData = true; //
clearTimeout(timeoutId); //
}),
// handleAiDeepThinking(obj, oldMessage, controller).then((res) => {
// if (res) {
// hasStreamData = true; //
// clearTimeout(timeoutId); //
// }
// }),
timeoutPromise,
]);
return resText;
} catch (error) {
// modalTypeDataList.forEach((item: any) => {
// if (item.isShow) {
// let list: any = item.messageList;
// list[list.length - 1] = {
// ...list[list.length - 1],
// content: "",
// loading: false,
// loadingContent: null,
// };
// item.messageList = list;
//
// const data = await handleGetGeminiResult(req)
// console.log('gemini', data);
// if (data.Result_Code === 100) {
// obj.responseText = data.Result_Data;
// obj.descResponseText = "";
// obj.messageList[obj.messageList.length - 1] = {
// ...obj.messageList[obj.messageList.length - 1],
// content: marked(data.Result_Data),
// realContent: data.Result_Data,
// descResponseText: "",
// loading: false,
// loadingContent: null,
// index:
// obj.messageList && obj.messageList.length > 0
// ? obj.messageList.length
// : 0,
// };
// showController.value = false;
// //
// let nowShowList: any = [];
// if (modalTypeDataList && modalTypeDataList.length > 0) {
// modalTypeDataList.forEach((item: any) => {
// if (item.isShow) {
// nowShowList.push(item);
// }
// });
// }
// });
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
// let index: number = 99999;
// let isBottom: any = "default";
// if (nowShowList && nowShowList.length > 0) {
// nowShowList.forEach((item: any, itemIndex: number) => {
// if (item.value === obj.value) {
// index = itemIndex;
// if (scrollList.value && scrollList.value.length > 0) {
// isBottom = scrollList.value[itemIndex].isBottom;
// }
// }
// });
// }
// if (
// index === 99999 ||
// isBottom === "default" ||
// isBottom === true
// ) {
// handleScrollToBottomID("gjldBox" + obj.value);
// }
// return data.Result_Data
// } else {
// let list: any = obj.messageList;
// list[list.length - 1] = {
// ...list[list.length - 1],
// content: "",
// loading: false,
// loadingContent: null,
// };
// obj.messageList = list;
// }
} else {
//
let hasStreamData: boolean = false;
//
const controller = new AbortController();
controllers.value.push(controller); //
showController.value = true;
let timeoutId: any = null; // ID
try {
const timeoutPromise = new Promise((resolve) => {
timeoutId = setTimeout(() => {
if (!hasStreamData) {
//
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
resolve({});
}
}, 60000);
});
let resText: any = await Promise.race([
new Promise(async (resolve) => {
try {
//
let isStreaming: boolean = true;
let modal = {
model:
obj.value === 1
? selectDeepseekVersion.value === 1
? "deepseek-chat"
: selectDeepseekVersion.value === 2
? "deepseek-reasoner"
: ""
: obj.value === 2
? selectDeepseekVersion.value === 1
? "deepseek-ai/DeepSeek-V3"
: selectDeepseekVersion.value === 2
? "deepseek-ai/DeepSeek-R1-Distill-Llama-70B"
: ""
: obj.value === 3
? selectDeepseekVersion.value === 1
? "deepseek-v3"
: selectDeepseekVersion.value === 2
? "deepseek-r1"
: ""
: obj.value === 4
? "qwen-plus"
: obj.value === 5
? 'claude-sonnet-4-5'
: '',
messages: [...oldMessage],
stream: true,
// max_tokens: 200000,
// max_tokens: obj.value === 5 ? 200000 : maxTokens.value,
// stop: ["null"],
// temperature: Temperature.value,
// top_p: TopP.value,
// top_k: TopK.value,
// frequency_penalty: FrequencyPenalty.value,
// n: 1,
// response_format: {
// type: "text",
// },
};
const options = {
method: "POST",
headers: {
Authorization:
obj.value === 1
? "Bearer sk-d47e0bdc7fd249f29d2f0dba807d46f0"
: obj.value === 2
? "Bearer sk-nynbgbtnmsffijgkttoimqkptetivviwuqrdhbuclgbmvnsq"
: obj.value === 3
? "Bearer sk-1aa2c1c672034c6d826ce62d3aebcb47"
: obj.value === 4
? "Bearer sk-1aa2c1c672034c6d826ce62d3aebcb47"
: obj.value === 5
? "Bearer sk-f67d5aae13e14efc8a01e8cd0e665d15"
: "",
"Content-Type": "application/json",
},
body: JSON.stringify(modal),
signal: controller.signal, //
};
let geminiContent: any = []
if (modal.messages && modal.messages.length > 0) {
modal.messages.forEach((item: any, index: number) => {
if (item.role === "user") {
if (index + 1 === modal.messages.length) {
geminiContent.push({
parts: [
{
text: item.content,
}
]
})
}
}
})
}
//
let isSuccess: boolean = false;
const response: any = await fetch(
obj.value === 1
? "https://api.deepseek.com/v1/chat/completions"
: obj.value === 2
? "https://api.siliconflow.cn/v1/chat/completions"
: obj.value === 3
? "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
: obj.value === 4
? "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"
: obj.value === 5
? "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent"
: "",
obj.value === 5 ? {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": "AIzaSyAg1lJ8oZL_jMAefrRswIhx5xA8JTOZUTs",
},
body: JSON.stringify({
contents: geminiContent
}),
} : options
);
if (response.status === 200) {
isSuccess = true;
}
if (obj.value === 5) {
//
// const data = await response.json();
const reader = response.body.getReader();
const decoder = new TextDecoder("utf-8");
while (isStreaming) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
let JSONChunk = trimFirstChar(chunk)
JSONChunk = JSONChunk ? JSON.parse(JSONChunk) : ""
handleStreamChunkIDGemini(JSONChunk ? [JSONChunk] : [], obj)
//
let nowShowList: any = [];
if (modalTypeDataList && modalTypeDataList.length > 0) {
modalTypeDataList.forEach((item: any) => {
if (item.isShow) {
nowShowList.push(item);
}
});
}
let index: number = 99999;
let isBottom: any = "default";
if (nowShowList && nowShowList.length > 0) {
nowShowList.forEach((item: any, itemIndex: number) => {
if (item.value === obj.value) {
index = itemIndex;
if (scrollList.value && scrollList.value.length > 0) {
isBottom = scrollList.value[itemIndex].isBottom;
}
}
});
}
if (
index === 99999 ||
isBottom === "default" ||
isBottom === true
) {
handleScrollToBottomID("gjldBox" + obj.value);
}
resolve(true)
}
} else {
//
const reader = response.body.getReader();
const decoder = new TextDecoder("utf-8");
while (isStreaming) {
const { done, value } = await reader.read();
if (done) break;
//
const chunk = decoder.decode(value);
handleStreamChunkID(chunk, obj);
//
let nowShowList: any = [];
if (modalTypeDataList && modalTypeDataList.length > 0) {
modalTypeDataList.forEach((item: any) => {
if (item.isShow) {
nowShowList.push(item);
}
});
}
let index: number = 99999;
let isBottom: any = "default";
if (nowShowList && nowShowList.length > 0) {
nowShowList.forEach((item: any, itemIndex: number) => {
if (item.value === obj.value) {
index = itemIndex;
if (scrollList.value && scrollList.value.length > 0) {
isBottom = scrollList.value[itemIndex].isBottom;
}
}
});
}
if (
index === 99999 ||
isBottom === "default" ||
isBottom === true
) {
handleScrollToBottomID("gjldBox" + obj.value);
}
resolve(true); // resolve
}
}
// messageList.push({
// role: "assistant",
// content: responseText.value,
// descResponseText: descResponseText.value,
// });
obj.responseText = "";
obj.descResponseText = "";
showController.value = false;
// handleStop();
return isSuccess;
} catch (error: any) {
if (error.name !== "AbortError") {
console.error("流式请求失败:", error);
}
} finally {
}
}).then((res) => {
hasStreamData = true; //
clearTimeout(timeoutId); //
}),
// handleAiDeepThinking(obj, oldMessage, controller).then((res) => {
// if (res) {
// hasStreamData = true; //
// clearTimeout(timeoutId); //
// }
// }),
timeoutPromise,
]);
return resText;
} catch (error) {
// modalTypeDataList.forEach((item: any) => {
// if (item.isShow) {
// let list: any = item.messageList;
// list[list.length - 1] = {
// ...list[list.length - 1],
// content: "",
// loading: false,
// loadingContent: null,
// };
// item.messageList = list;
// }
// });
let list: any = obj.messageList;
list[list.length - 1] = {
...list[list.length - 1],
content: "请求超时,请稍后重试!",
loading: false,
loadingContent: null,
};
obj.messageList = list;
}
}
};
@ -1997,6 +2208,38 @@ const handleStreamChunkIDGemini = async (chunk: any, obj: any) => {
});
};
// gemini
const handleStreamChunkIDGeminiNew = async (chunk: any, obj: any) => {
if (!(chunk && chunk.length > 0)) {
return
}
chunk.forEach((line: any) => {
try {
// const parsed = JSON.parse(line);
const parsed = line;
if (parsed.text) {
obj.responseText += parsed.text
}
if (parsed.session_id) {
thisSessionId.value = parsed.session_id
}
obj.messageList[obj.messageList.length - 1] = {
...obj.messageList[obj.messageList.length - 1],
content: marked(obj.responseText),
realContent: obj.responseText,
loading: false,
loadingContent: null,
index:
obj.messageList && obj.messageList.length > 0
? obj.messageList.length
: 0,
};
} catch (err) {
}
});
};
//
const handleGetYNMapData = async () => {
let obj: any = {
@ -2350,6 +2593,7 @@ watch(
//
const handleDepthAnalysis = async (bigObj: any, obj: any) => {
console.log('bigObjbigObjbigObj', bigObj);
handleOnceMoreModal([bigObj.value]);
};
@ -2660,6 +2904,7 @@ const handleNewRuleList = async () => {
const data = await handleGetANALYSISRULEList({
searchParameter: {
ANALYSISRULE_IDS: "",
RULE_SOURCE: pythonSemantics.value ? 3000 : '',
current: 1,
pageSize: 10,
},
@ -2736,6 +2981,10 @@ const handleCopyContent = (bigObj: any) => {
}
};
const handleChangePython = (e: any) => {
pythonSemantics.value = !pythonSemantics.value;
}
//
const handleChangeProcess = (e: any) => {
modalTypeDataList.forEach((item: any) => {
@ -2852,6 +3101,35 @@ const handleChangeProcess = (e: any) => {
</el-tab-pane>
</el-tabs>
<div class="filterItem" style="height: 40px">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">专家模式</span>
</div>
<el-switch v-model="pythonSemantics" size="default" @change="handleChangePython" />
</div>
</div>
<div class="filterItem" style="height: 40px">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">模型选择</span>
</div>
<el-select style="width: 70%;" v-model="selectModal" placeholder="请选择">
<el-option v-for="item in selectModalList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</div>
</div>
<div class="filterItem" style="height: 40px">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">知识库编码</span>
</div>
<el-input style="width: 70%;" v-model="selectModalCacheID" placeholder="请输入" />
</div>
</div>
<div class="filterItem" style="height: 40px">
<div class="topItem">
<div class="titleBox">
@ -2863,7 +3141,7 @@ const handleChangeProcess = (e: any) => {
</div>
</div>
<div class="filterItem">
<div class="filterItem" v-if="false">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">Max Tokens</span>
@ -2879,7 +3157,7 @@ const handleChangeProcess = (e: any) => {
</div>
</div>
<div class="filterItem">
<div class="filterItem" v-if="false">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">Temperature</span>
@ -2894,7 +3172,7 @@ const handleChangeProcess = (e: any) => {
</div>
</div>
<div class="filterItem">
<div class="filterItem" v-if="false">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">Top-P</span>
@ -2909,7 +3187,7 @@ const handleChangeProcess = (e: any) => {
</div>
</div>
<div class="filterItem">
<div class="filterItem" v-if="false">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">Top-K</span>
@ -2924,7 +3202,7 @@ const handleChangeProcess = (e: any) => {
</div>
</div>
<div class="filterItem">
<div class="filterItem" v-if="false">
<div class="topItem">
<div class="titleBox">
<span class="itemTitle">Frequency Penalty</span>

View File

@ -1,4 +1,5 @@
import request from "../request/request";
import requestPython from '../request/requestPython'
export async function GetProjectSplitSummary(params: any) {
const data: any = await request.get('/BusinessProject/GetMonthSummaryList', params)
@ -15,3 +16,20 @@ export async function GetProjectSplitSummary(params: any) {
return data.Result_Data;
}
// 测试AI回复
export async function handleGetGeminiResult(params: any) {
const data: any = await requestPython.post('gemini/query/', params)
if (data.Result_Code !== 100) {
return {
data: [],
current: 1,
pageSize: 20,
total: 0,
success: true,
};
}
return data
}

View File

@ -0,0 +1,80 @@
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
// import { notification } from 'antd';
// import Cookies from 'js-cookie';
import moment from 'moment';
// 定义 HTTP 状态码及其描述
const codeMessage: Record<number, string> = {
200: '服务器成功返回请求的数据。',
201: '新建或修改数据成功。',
202: '一个请求已经进入后台排队(异步任务)。',
204: '删除数据成功。',
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
401: '用户没有权限(令牌、用户名、密码错误)。',
403: '用户得到授权,但是访问是被禁止的。',
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
406: '请求的格式不可得。',
410: '请求的资源被永久删除,且不会再得到的。',
422: '当创建一个对象时,发生一个验证错误。',
500: '服务器发生错误,请检查服务器。',
502: '网关错误。',
503: '服务不可用,服务器暂时过载或维护。',
504: '网关超时。',
};
// 错误处理
const errorHandler = (error: any): any => {
const { response } = error;
if (response && response.status) {
const errorText = codeMessage[response.status] || response.statusText;
const { status, url } = response;
// notification.error({
// message: `请求错误 ${status}: ${url}`,
// description: errorText,
// });
} else {
// notification.error({
// description: '您的网络异常,无法连接到服务器。',
// message: '网络异常',
// });
}
return Promise.reject(error);
};
// 创建 axios 实例
const instance = axios.create({
baseURL: 'http://192.168.1.207:8002/api/', // 默认请求前缀
timeout: 60000, // 请求超时时间
headers: {
"provincecode": "340000",
'Content-Type': 'application/json',
},
});
// 请求拦截器
instance.interceptors.request.use(
(config: any) => {
return config;
},
errorHandler
);
// 响应拦截器
instance.interceptors.response.use(
(response: AxiosResponse) => {
// 每次响应,设置一个 tmp 的 Cookie
// Cookies.set('tmp', moment().format());
return response.data; // 统一返回 data
},
errorHandler
);
// 封装的请求方法
const request = {
get: (url: string, params?: any) => instance.get(url, { params }),
post: (url: string, data?: any) => instance.post(url, data),
put: (url: string, data?: any) => instance.put(url, data),
delete: (url: string, params?: any) => instance.delete(url, { params }),
};
export default request;