update
This commit is contained in:
parent
29b67990d6
commit
751fd8d3b4
File diff suppressed because it is too large
Load Diff
@ -18,10 +18,7 @@ import {
|
||||
import moment from "moment";
|
||||
import pageBg from '../../assets/pageBg.png'
|
||||
|
||||
|
||||
|
||||
|
||||
const userInput = ref();
|
||||
const userInput = ref('新桥服务区python营收');
|
||||
const loading = ref();
|
||||
const error = ref();
|
||||
const response = ref();
|
||||
@ -40,16 +37,13 @@ const controllers = ref<AbortController[]>([]);
|
||||
const showController = ref<boolean>(false);
|
||||
// 当前的滚动条list
|
||||
const scrollList = reactive<any>([]);
|
||||
|
||||
const messageList = reactive<any>([]);
|
||||
const aliyunMessageList = reactive<any>([]);
|
||||
let deepseekMessageList = reactive<any>([]);
|
||||
|
||||
// 是否开启自由定义
|
||||
const startFree = ref<boolean>(false);
|
||||
// 自由定义的文本内容
|
||||
const freeContent = ref<string>("");
|
||||
|
||||
const maxTokens = ref<number>(4096);
|
||||
const Temperature = ref<number>(0.4);
|
||||
const TopP = ref<number>(0.4);
|
||||
@ -64,7 +58,7 @@ const showDeepseek = ref<boolean>(true);
|
||||
// 是否引入地图的数据
|
||||
const useMapData = ref<boolean>(true);
|
||||
// 几个大模型种类的切换
|
||||
const modalTypeSelect = ref<number[]>([2, 4]);
|
||||
const modalTypeSelect = ref<number[]>([5]);
|
||||
// 几个模型的具体数据
|
||||
let modalTypeDataList = reactive<any>([
|
||||
{
|
||||
@ -107,6 +101,16 @@ let modalTypeDataList = reactive<any>([
|
||||
showCopy: false,
|
||||
showReload: false,
|
||||
},
|
||||
{
|
||||
label: "Gemini",
|
||||
value: 5,
|
||||
messageList: [],
|
||||
isShow: true,
|
||||
responseText: "",
|
||||
descResponseText: "",
|
||||
showCopy: false,
|
||||
showReload: false,
|
||||
},
|
||||
]);
|
||||
// 是否显示左侧
|
||||
const hideLeft = ref<boolean>(true);
|
||||
@ -148,12 +152,10 @@ let routerRole = ref<any>({
|
||||
onMounted(async () => {
|
||||
let param1: string = ""
|
||||
if (/Mobi|Android/i.test(navigator.userAgent)) {
|
||||
console.log("是手机");
|
||||
isPhone.value = true;
|
||||
// 只显示一个对话框
|
||||
modalTypeSelect.value = [4];
|
||||
}
|
||||
console.log('modalTypeDataListmodalTypeDataList', modalTypeDataList);
|
||||
|
||||
if (modalTypeDataList && modalTypeDataList.length > 0) {
|
||||
modalTypeDataList.forEach((item: any) => {
|
||||
@ -166,7 +168,6 @@ onMounted(async () => {
|
||||
} else {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
param1 = urlParams.get('comeForm') || "";
|
||||
console.log("comeForm", param1);
|
||||
if (param1 === 'YNMap') {
|
||||
pageType.value = 1
|
||||
hideLeft.value = false
|
||||
@ -223,8 +224,6 @@ onMounted(async () => {
|
||||
// routerRole.value.content = ""
|
||||
// }
|
||||
|
||||
console.log("YSRole", YSRole);
|
||||
console.log("routerRole", routerRole);
|
||||
});
|
||||
|
||||
const showPhoneChange = ref<boolean>(false);
|
||||
@ -277,14 +276,11 @@ const handleGetPrompt = async () => {
|
||||
sortstr: "OPERATE_DATE desc",
|
||||
};
|
||||
const data = await handleGetPROMPTList(req);
|
||||
console.log("data", data);
|
||||
return data.List;
|
||||
};
|
||||
|
||||
// 更新提示词
|
||||
const handleUpdatePrompt = async (id: number) => {
|
||||
console.log("id", id);
|
||||
console.log("YSRole.value", YSRole.value);
|
||||
|
||||
let req: any = {};
|
||||
if (id === 1000) {
|
||||
@ -300,7 +296,6 @@ const handleUpdatePrompt = async (id: number) => {
|
||||
OPERATE_DATE: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
}
|
||||
console.log("req", req);
|
||||
const data = await handleSynchroPROMPT(req);
|
||||
if (data.Result_Code === 100) {
|
||||
ElMessage({
|
||||
@ -402,7 +397,6 @@ const aLiYunGetDeepSeek = async (question: string) => {
|
||||
// messages: [{ role: "user", content: question }],
|
||||
// stream: true,
|
||||
// });
|
||||
// console.log("data", data);
|
||||
|
||||
let oldMessage: any = [];
|
||||
if (aliyunMessageList && aliyunMessageList.length > 0) {
|
||||
@ -508,7 +502,6 @@ const aliyunStreamChunk = async (chunk: any) => {
|
||||
|
||||
// 直接提问deepseek 没有格式 不走语义
|
||||
const handleAskDirectlyDeepseek = async () => {
|
||||
console.log("modalTypeDataList", modalTypeDataList);
|
||||
if (modalTypeDataList && modalTypeDataList.length > 0) {
|
||||
modalTypeDataList.forEach((item: any) => {
|
||||
if (item.isShow) {
|
||||
@ -538,7 +531,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
userInput.value = "";
|
||||
|
||||
|
||||
console.log('modalTypeDataList', modalTypeDataList);
|
||||
// 找到当前选择的模型 添加问题的数据
|
||||
modalTypeDataList.forEach((item: any) => {
|
||||
if (item.isShow) {
|
||||
@ -549,8 +541,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
index: list && list.length > 0 ? list.length : 0,
|
||||
});
|
||||
item.messageList = list;
|
||||
console.log('listlistlistlist', JSON.parse(JSON.stringify(list)))
|
||||
|
||||
handleScrollToBottomID("gjldBox" + item.value);
|
||||
}
|
||||
});
|
||||
@ -560,7 +550,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
await handleAskDirectlyDeepseek();
|
||||
return;
|
||||
}
|
||||
console.log('pageType.valuepageType.value', pageType.value);
|
||||
|
||||
// 判断一下 是不是被内嵌到别人那边的 内嵌的话 就走这儿 不走下面的了
|
||||
if (containsDaping(thisQuestion)) {
|
||||
@ -575,7 +564,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
}
|
||||
if (item.isShow) {
|
||||
let list: any = item.messageList;
|
||||
console.log("list", list);
|
||||
list.push({
|
||||
role: "default",
|
||||
content: "",
|
||||
@ -586,15 +574,8 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('newRuleTextnewRuleTextnewRuleText', newRuleText.value);
|
||||
console.log('routerRolerouterRolerouterRolerouterRole', routerRole.value);
|
||||
console.log('thisQuestionthisQuestionthisQuestionthisQuestion', thisQuestion);
|
||||
|
||||
|
||||
let YNMapData: any = await handleGetYNMapData()
|
||||
|
||||
|
||||
|
||||
// 配置问题内容
|
||||
mapQuestion = `#云南大屏直接进行路由角色说明解析#<Br/>
|
||||
#路由角色解析#<Br/>
|
||||
@ -605,15 +586,9 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
${YNMapData}
|
||||
`;
|
||||
|
||||
console.log('mapQuestionmapQuestionmapQuestion', mapQuestion);
|
||||
|
||||
|
||||
for (let i = 0; i < modalTypeDataList.length; i++) {
|
||||
if (modalTypeDataList[i].isShow) {
|
||||
let list: any = modalTypeDataList[i].messageList;
|
||||
|
||||
console.log('listlistlistlist', JSON.parse(JSON.stringify(list)));
|
||||
|
||||
list[list.length - 1] = {
|
||||
...list[list.length - 1],
|
||||
content: mapQuestion,
|
||||
@ -622,15 +597,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
modalTypeDataList[i].messageList = list;
|
||||
}
|
||||
}
|
||||
console.log('modalTypeDataListmodalTypeDataListmodalTypeDataList', JSON.parse(JSON.stringify(modalTypeDataList)));
|
||||
|
||||
// let nowShowIdList: any = [];
|
||||
// for (let i = 0; i < modalTypeDataList.length; i++) {
|
||||
// if (modalTypeDataList[i].isShow) {
|
||||
// nowShowIdList.push(modalTypeDataList[i].value)
|
||||
// }
|
||||
// }
|
||||
// handleOnceMoreModal(nowShowIdList);
|
||||
return
|
||||
}
|
||||
|
||||
@ -645,7 +611,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
}
|
||||
if (item.isShow) {
|
||||
let list: any = item.messageList;
|
||||
console.log("list", list);
|
||||
list.push({
|
||||
role: "default",
|
||||
content: "",
|
||||
@ -661,27 +626,13 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
// 确保每次问问题都可以拿到最新的规则文本
|
||||
await handleNewRuleList();
|
||||
|
||||
// 拿到这一次问问题的哪个模型 不一样的模型 他们的自己语义对话框的id不同
|
||||
// let nowValueList: any = []
|
||||
// if(bigObj.value){
|
||||
// nowValueList= [bigObj.value]
|
||||
// }else{
|
||||
// modalTypeDataList.forEach((item: any) => {
|
||||
// nowValueList.push(item.value)
|
||||
// })
|
||||
// }
|
||||
|
||||
for (let i = 0; i < modalTypeDataList.length; i++) {
|
||||
console.log("modalTypeDataList[i].isShow", modalTypeDataList[i].isShow);
|
||||
|
||||
if (modalTypeDataList[i].isShow) {
|
||||
// 调用自己的语义
|
||||
const mapData: any = await RobotDialogueBoxRef.value.handleSubmit(
|
||||
thisQuestion,
|
||||
modalTypeDataList[i].value
|
||||
);
|
||||
console.log('atatatat', mapData);
|
||||
|
||||
// 判断自己的语义是否成功
|
||||
let userSemanticsIsSuccess: boolean = true;
|
||||
|
||||
@ -752,6 +703,10 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
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,
|
||||
@ -770,7 +725,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
if (item.VHtml && item.VHtml !== "暂无数据") {
|
||||
allStr += `#id【${item.ruleDetail.ANALYSISRULE_ID}】接口数据如下#:<Br/>${item.VHtml}<Br/>`;
|
||||
} else {
|
||||
console.log("dataStrdataStrdataStr", dataStr);
|
||||
allStr += `#id【${item.ruleDetail.ANALYSISRULE_ID}】接口数据如下#:<Br/>${dataStr}<Br/>`;
|
||||
}
|
||||
let desc: string = `接口意图:${item.ruleDetail.USER_INTENT};接口备注:${item.ruleDetail.ANALYSISRULE_DESC}。`;
|
||||
@ -809,9 +763,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
userSemanticsIsSuccess = false;
|
||||
}
|
||||
|
||||
console.log('mapQuestionmapQuestionmapQuestion', mapQuestion);
|
||||
|
||||
|
||||
if (
|
||||
bigObj.value
|
||||
? modalTypeDataList[i].value === bigObj.value
|
||||
@ -890,8 +841,6 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
});
|
||||
}
|
||||
|
||||
console.log('nowShowIdListnowShowIdListnowShowIdList', nowShowIdList);
|
||||
|
||||
// 判断一下 是不是开启了 省略过程 那就是直接去调用ai深度分析
|
||||
if (omitProcess.value) {
|
||||
handleOnceMoreModal(nowShowIdList);
|
||||
@ -992,11 +941,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
console.log('bigObj3232', bigObj);
|
||||
|
||||
|
||||
|
||||
// 最后显示的文字
|
||||
let mapQuestion: string = "";
|
||||
let thisQuestion: string = "";
|
||||
@ -1017,13 +961,11 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
|
||||
let lastUserObj: any = userList[userList.length - 1];
|
||||
|
||||
console.log("lastUserObj", lastUserObj);
|
||||
let showBtn: string = "";
|
||||
|
||||
// 判断这一次deepseek是否成功分析出来了
|
||||
let userSemanticsIsSuccess: boolean = true;
|
||||
const data = await handleGetInterfaceID(lastUserObj.content, bigObj);
|
||||
console.log("dsadasdasdasdsgas", data);
|
||||
if (bigObj.messageList && bigObj.messageList.length > 0) {
|
||||
bigObj.messageList.forEach((item: any) => {
|
||||
if (item.role === "user") {
|
||||
@ -1044,7 +986,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
data.question,
|
||||
bigObj.value
|
||||
);
|
||||
console.log("newData3232", newData);
|
||||
if (newData && newData.length > 0) {
|
||||
userSemanticsIsSuccess = true;
|
||||
let allStr: string = "";
|
||||
@ -1082,8 +1023,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
tabHeader += `<Br/>`;
|
||||
dataStr += `${tabHeader}`;
|
||||
}
|
||||
console.log("tabHeader", tabHeader);
|
||||
console.log("item.RESPONSE_FIELD", obj);
|
||||
} else if (item.columns && item.columns.length > 0) {
|
||||
item.columns.forEach((subItem: any) => {
|
||||
if (subItem.prop) {
|
||||
@ -1104,7 +1043,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
}
|
||||
dataStr += str;
|
||||
}
|
||||
console.log("showColumnsList", showColumnsList);
|
||||
dataStr += `<Br/>`;
|
||||
}
|
||||
|
||||
@ -1113,8 +1051,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
let str: string = "";
|
||||
let obj: any = JSON.parse(JSON.stringify(subItem));
|
||||
obj = handleChangObjType(obj);
|
||||
console.log("handleChangObjType", obj);
|
||||
|
||||
if (obj) {
|
||||
let text: string = handleTableDataToStr(
|
||||
obj,
|
||||
@ -1133,7 +1069,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
if (item.VHtml && item.VHtml !== "暂无数据") {
|
||||
allStr += `#id【${item.ruleDetail.ANALYSISRULE_ID}】接口数据如下#:<Br/>${item.VHtml}<Br/>`;
|
||||
} else {
|
||||
console.log("dataStrdataStrdataStr", dataStr);
|
||||
allStr += `#id【${item.ruleDetail.ANALYSISRULE_ID}】接口数据如下#:<Br/>${dataStr}<Br/>`;
|
||||
}
|
||||
let desc: string = `接口意图:${item.ruleDetail.USER_INTENT};接口备注:${item.ruleDetail.ANALYSISRULE_DESC}。`;
|
||||
@ -1142,7 +1077,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
});
|
||||
// 驿商语义解析 的替换 如果规则id只有一个 且这个的id配置了大模型输出规范字段 那么就替换
|
||||
let newContent: string = "";
|
||||
console.log("allStr", allStr);
|
||||
if (
|
||||
newData &&
|
||||
newData.length === 1 &&
|
||||
@ -1331,26 +1265,6 @@ const handleUseRoleQuestion = async (bigObj: any, obj: any) => {
|
||||
};
|
||||
bigObj.messageList = list;
|
||||
}
|
||||
|
||||
// modalTypeDataList.forEach((item: any) => {
|
||||
// if (item.isShow) {
|
||||
// let list: any = item.messageList;
|
||||
// list[list.length - 1] = {
|
||||
// ...list[list.length - 1],
|
||||
// content: mapQuestion,
|
||||
// loading: false,
|
||||
// loadingContent: null,
|
||||
// userSemanticsIsSuccess: userSemanticsIsSuccess,
|
||||
// };
|
||||
// item.messageList = list;
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log("mapQuestionmapQuestionmapQuestionmapQuestion", mapQuestion);
|
||||
console.log(
|
||||
"mapQuestionmapQuestionmapQuestionmapQuestion",
|
||||
bigObj.messageList
|
||||
);
|
||||
};
|
||||
|
||||
// 一次性执行多个模型的问问题方法
|
||||
@ -1371,8 +1285,6 @@ const handleOnceMoreModal = async (typeList: number[]) => {
|
||||
const handleGetAnswerID = async (obj: any) => {
|
||||
// 最新的相应文本
|
||||
// let responseText: string = "";
|
||||
console.log("obj2222", obj);
|
||||
|
||||
let oldMessage: any = [];
|
||||
// 当对话列表小于3时 说明是第一次问问题 那么就直接找user就好了
|
||||
if (
|
||||
@ -1402,8 +1314,6 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
});
|
||||
} else if (obj.messageList && obj.messageList.length >= 2) {
|
||||
// 区分之前的问题记录 和 最新的问题记录
|
||||
console.log("obj.messageList", obj.messageList);
|
||||
|
||||
obj.messageList.forEach((item: any, index: number) => {
|
||||
// if (startFree.value ? item.role === "user" : item.role === "default") {
|
||||
if (item.role === "default" || item.role === "user") {
|
||||
@ -1445,8 +1355,6 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
console.log("oldMessage", oldMessage);
|
||||
|
||||
obj.messageList.push({
|
||||
role: "assistant",
|
||||
content: "",
|
||||
@ -1455,7 +1363,6 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
loadingContent: "深度分析中...",
|
||||
});
|
||||
handleScrollToBottomID("gjldBox" + obj.value);
|
||||
console.log("modalTypeDataList", modalTypeDataList);
|
||||
|
||||
// 记录是否有数据流
|
||||
let hasStreamData: boolean = false;
|
||||
@ -1463,7 +1370,6 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
const controller = new AbortController();
|
||||
controllers.value.push(controller); // 存入全局数组
|
||||
showController.value = true;
|
||||
console.log("controller", controller);
|
||||
let timeoutId: any = null; // 记录超时 ID
|
||||
|
||||
try {
|
||||
@ -1510,19 +1416,22 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
: ""
|
||||
: obj.value === 4
|
||||
? "qwen-plus"
|
||||
: "",
|
||||
: obj.value === 5
|
||||
? 'claude-sonnet-4-5'
|
||||
: '',
|
||||
messages: [...oldMessage],
|
||||
stream: true,
|
||||
max_tokens: 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",
|
||||
},
|
||||
// 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",
|
||||
@ -1536,12 +1445,30 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
? "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(
|
||||
@ -1553,13 +1480,67 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
? "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"
|
||||
: "",
|
||||
options
|
||||
obj.value === 5 ? {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-goog-api-key": "AIzaSyAg1lJ8oZL_jMAefrRswIhx5xA8JTOZUTs",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
contents: geminiContent
|
||||
}),
|
||||
} : options
|
||||
);
|
||||
console.log("response", response);
|
||||
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");
|
||||
@ -1602,6 +1583,8 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
|
||||
resolve(true); // 完成流处理后resolve
|
||||
}
|
||||
}
|
||||
|
||||
// messageList.push({
|
||||
// role: "assistant",
|
||||
// content: responseText.value,
|
||||
@ -1619,14 +1602,11 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
} finally {
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log("res", res);
|
||||
hasStreamData = true; // 这里标记数据流出现了
|
||||
clearTimeout(timeoutId); // 取消超时逻辑
|
||||
}),
|
||||
// handleAiDeepThinking(obj, oldMessage, controller).then((res) => {
|
||||
// if (res) {
|
||||
// console.log("标记数据流", res);
|
||||
|
||||
// hasStreamData = true; // 这里标记数据流出现了
|
||||
// clearTimeout(timeoutId); // 取消超时逻辑
|
||||
// }
|
||||
@ -1739,7 +1719,6 @@ const handleAiDeepThinking = async (
|
||||
options
|
||||
);
|
||||
|
||||
console.log("response", response);
|
||||
if (response.status === 200) {
|
||||
isSuccess = true;
|
||||
}
|
||||
@ -1916,7 +1895,6 @@ const handleAnswerText = async (question: string) => {
|
||||
responseText.value = "";
|
||||
descResponseText.value = "";
|
||||
showController.value = false;
|
||||
console.log("messageList", messageList);
|
||||
} catch (error: any) {
|
||||
if (error.name !== "AbortError") {
|
||||
console.error("流式请求失败:", error);
|
||||
@ -1927,7 +1905,6 @@ const handleAnswerText = async (question: string) => {
|
||||
|
||||
// .then((response) => response.json())
|
||||
// .then((response) => {
|
||||
// console.log("response", response);
|
||||
// let textAnswer = response.choices[0].message.content || "";
|
||||
// textData.value = textAnswer;
|
||||
// })
|
||||
@ -1973,6 +1950,53 @@ const handleStreamChunkID = async (chunk: any, obj: any) => {
|
||||
});
|
||||
};
|
||||
|
||||
// gemini移除多余字符的方法
|
||||
const trimFirstChar = (str: string) => {
|
||||
if (typeof str !== 'string' || str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
const firstChar = str[0];
|
||||
|
||||
if (firstChar === '[' || firstChar === ',' || firstChar === ']') {
|
||||
return str.slice(1);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
// gemini 的流式返回
|
||||
const handleStreamChunkIDGemini = async (chunk: any, obj: any) => {
|
||||
if (!(chunk && chunk.length > 0)) {
|
||||
return
|
||||
}
|
||||
|
||||
chunk.forEach((line: any) => {
|
||||
try {
|
||||
// const parsed = JSON.parse(line);
|
||||
const parsed = line;
|
||||
let text = "";
|
||||
let descText = "";
|
||||
if (parsed.candidates[0].content.parts[0].text) {
|
||||
text = parsed.candidates[0].content.parts[0].text || "";
|
||||
obj.responseText += text; // 实时更新响应文本
|
||||
}
|
||||
|
||||
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 = {
|
||||
@ -2078,7 +2102,6 @@ const handleGetDeepseek = async (question: string) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log("oldMessage", oldMessage);
|
||||
|
||||
try {
|
||||
let modal = {
|
||||
@ -2128,7 +2151,6 @@ const handleGetDeepseek = async (question: string) => {
|
||||
// messages: [...oldMessage],
|
||||
// model: "deepseek-reasoner",
|
||||
// });
|
||||
// console.log("completion", completion);
|
||||
while (isStreaming) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
@ -2211,13 +2233,8 @@ const handleDeepseekScrollToBottom = () => {
|
||||
|
||||
// 模型种类切换
|
||||
const handleChangeModalType = (e: any) => {
|
||||
console.log("e1", e);
|
||||
console.log("pageType", pageType.value);
|
||||
console.log("isPhone", isPhone);
|
||||
let newList: number[] = [];
|
||||
if (pageType.value === 1 || isPhone.value) {
|
||||
console.log('1');
|
||||
|
||||
if (e && e.length > 1) {
|
||||
newList = [e[e.length - 1]]
|
||||
}
|
||||
@ -2231,7 +2248,6 @@ const handleChangeModalType = (e: any) => {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('2');
|
||||
if (e && e.length > 2) {
|
||||
e.forEach((item: number, index: number) => {
|
||||
if (index === 0) {
|
||||
@ -2244,7 +2260,6 @@ const handleChangeModalType = (e: any) => {
|
||||
if (!(newList && newList.length > 1)) {
|
||||
newList = e;
|
||||
}
|
||||
console.log('newList', newList);
|
||||
|
||||
modalTypeDataList.forEach((item: any) => {
|
||||
if (newList.indexOf(item.value) !== -1) {
|
||||
@ -2253,7 +2268,6 @@ const handleChangeModalType = (e: any) => {
|
||||
item.isShow = false;
|
||||
}
|
||||
});
|
||||
console.log("modalTypeDataList", modalTypeDataList);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2276,8 +2290,6 @@ const handleStop = () => {
|
||||
item.descResponseText = "";
|
||||
}
|
||||
});
|
||||
console.log("modalTypeDataList", modalTypeDataList);
|
||||
|
||||
showController.value = false;
|
||||
};
|
||||
|
||||
@ -2295,8 +2307,6 @@ const handleChangeVersion = () => {
|
||||
watch(
|
||||
() => controllers,
|
||||
(newVal, oldVal) => {
|
||||
console.log("newVal", newVal);
|
||||
console.log("oldVal", oldVal);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
@ -2340,8 +2350,6 @@ watch(
|
||||
|
||||
// 点击深度分析
|
||||
const handleDepthAnalysis = async (bigObj: any, obj: any) => {
|
||||
console.log("bigObj", bigObj);
|
||||
console.log("obj", obj);
|
||||
handleOnceMoreModal([bigObj.value]);
|
||||
};
|
||||
|
||||
@ -2380,7 +2388,6 @@ const handleGetInterfaceID = async (questionText: string, bigObj: any) => {
|
||||
// for (let i = 0; i < modalTypeDataList.length; i++) {
|
||||
// let item: any = modalTypeDataList[i];
|
||||
// if (item.isShow) {
|
||||
// console.log("handleGetDeepseekAnswer", item);
|
||||
// // 取最新一条的用户提问
|
||||
// let userQuestion: any = [];
|
||||
// if (item.messageList && item.messageList.length > 0) {
|
||||
@ -2393,8 +2400,6 @@ const handleGetInterfaceID = async (questionText: string, bigObj: any) => {
|
||||
|
||||
// // 最新的问题对象
|
||||
// let lastObj: any = userQuestion[userQuestion.length - 1];
|
||||
// console.log("lastObj", lastObj);
|
||||
|
||||
// }
|
||||
// }
|
||||
};
|
||||
@ -2468,14 +2473,11 @@ const handleGetDeepseekAnswer = async (questionText: string, obj: any) => {
|
||||
const data = await axios(config);
|
||||
let id = data.data.choices[0].message.content;
|
||||
id = fixToJson(id);
|
||||
console.log("id", id);
|
||||
|
||||
let idObj: any = handleChangeJSON(id);
|
||||
console.log("idObj", idObj);
|
||||
idObj.idList = idObj.idList.toString();
|
||||
idObj.idList = handleParseToArray(idObj.idList);
|
||||
// const arr = handleParseToArray(id);
|
||||
// console.log("handleGetDeepseekAnswer", arr);
|
||||
|
||||
return idObj;
|
||||
};
|
||||
@ -2519,7 +2521,6 @@ const fixToJson = (input: any): string | null => {
|
||||
const handleChangeJSON = (jsonStr: any) => {
|
||||
try {
|
||||
jsonStr = jsonStr.replace(/\s+/g, "");
|
||||
console.log("jsonStr", jsonStr);
|
||||
|
||||
let openBraces = (jsonStr.match(/{/g) || []).length;
|
||||
let closeBraces = (jsonStr.match(/}/g) || []).length;
|
||||
@ -2567,7 +2568,6 @@ const handleQuestionReload = (obj: any, bigObj: any) => {
|
||||
if (showController.value || isLoading) {
|
||||
return;
|
||||
}
|
||||
console.log("obj", obj);
|
||||
userInput.value = obj.content;
|
||||
handleSendRequest(bigObj);
|
||||
};
|
||||
@ -2609,7 +2609,6 @@ const handleScroll = (e: any) => {
|
||||
// }
|
||||
// }
|
||||
// // el.forEach((item: any) => {
|
||||
// // console.log("item", item);
|
||||
// // });
|
||||
// }
|
||||
|
||||
@ -2667,7 +2666,6 @@ const handleNewRuleList = async () => {
|
||||
pagesize: 999999,
|
||||
PageIndex: 1,
|
||||
});
|
||||
console.log("handleNewRuleList", data);
|
||||
let str: string = "";
|
||||
|
||||
if (data && data.length > 0) {
|
||||
@ -2686,8 +2684,6 @@ const handleNewRuleList = async () => {
|
||||
`;
|
||||
|
||||
newRuleText.value = res;
|
||||
|
||||
console.log("res", res);
|
||||
};
|
||||
|
||||
// 隐藏左侧
|
||||
@ -2742,7 +2738,6 @@ const handleCopyContent = (bigObj: any) => {
|
||||
|
||||
// 改变工作模式的方法
|
||||
const handleChangeProcess = (e: any) => {
|
||||
console.log("e", e);
|
||||
modalTypeDataList.forEach((item: any) => {
|
||||
let nowLength = item.messageList.length;
|
||||
if (item.messageList && item.messageList.length > 0) {
|
||||
@ -3001,6 +2996,9 @@ const handleChangeProcess = (e: any) => {
|
||||
<div class="contentTitle" v-if="item.value === 4 && item.isShow" @click="handleShowPhoneChangeBox">
|
||||
通义千问
|
||||
</div>
|
||||
<div class="contentTitle" v-if="item.value === 5 && item.isShow" @click="handleShowPhoneChangeBox">
|
||||
Gemini
|
||||
</div>
|
||||
<div class="phoneModalSelectBox" v-if="item.isShow && showPhoneChange">
|
||||
<div class="phoneModal" v-for="(item, index) in modalTypeDataList" :key="index"
|
||||
@click="handlePhoneChangeModal(item.value)">
|
||||
@ -3096,7 +3094,8 @@ const handleChangeProcess = (e: any) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toolBox">
|
||||
<div class="toolBox"
|
||||
:style="{ justifyContent: modalTypeSelect && modalTypeSelect.length === 1 ? 'center' : 'flex-end' }">
|
||||
<div class="deleteBox" v-if="item.showReload && !showController" style="margin-right: 16px">
|
||||
<img class="deleteIcon" src="@/assets/ai/reloadSmallIcon.svg" @click="handleBottomReload(item)" />
|
||||
<span class="deleteText" @click="handleBottomReload(item)">刷新</span>
|
||||
|
||||
@ -21,5 +21,11 @@ export default defineConfig({
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/v1': {
|
||||
target: 'http://localhost:8045',
|
||||
changeOrigin: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user