update
This commit is contained in:
parent
751fd8d3b4
commit
c0c4402902
@ -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;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
}
|
||||
|
||||
.leftFilterTabBox {
|
||||
height: calc(100vh - 540px);
|
||||
height: calc(100vh - 580px);
|
||||
|
||||
.el-tabs__header {
|
||||
.el-tabs__nav-wrap {
|
||||
|
||||
@ -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,16 +741,15 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
dataStr += `<Br/>`;
|
||||
}
|
||||
|
||||
// 拿一下语义规则的内容
|
||||
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,
|
||||
@ -722,6 +765,8 @@ const handleSendRequest = async (bigObj?: any) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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,6 +1376,204 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
});
|
||||
handleScrollToBottomID("gjldBox" + obj.value);
|
||||
|
||||
console.log('pythonSemanticspythonSemantics', pythonSemantics);
|
||||
// 判断一下 如果开了专家模式 就直接去问 封装成接口的gemini 不然就按原本的路子走
|
||||
if (pythonSemantics.value) {
|
||||
// 拿到最新的问题
|
||||
console.log('objobjobjobj', JSON.parse(JSON.stringify(oldMessage)));
|
||||
|
||||
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 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",
|
||||
},
|
||||
body: JSON.stringify(req),
|
||||
})
|
||||
if (response.status === 100) {
|
||||
isSuccess = true;
|
||||
}
|
||||
// 非流式返回
|
||||
// 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) : ""
|
||||
handleStreamChunkIDGeminiNew(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)
|
||||
}
|
||||
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
// 若以后不要流式返回 就把下面这段注释取消掉 就可以一口气返回了
|
||||
// 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 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;
|
||||
// 终止器
|
||||
@ -1636,6 +1846,7 @@ const handleGetAnswerID = async (obj: any) => {
|
||||
};
|
||||
obj.messageList = list;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 最后的ai深度思考 超时终止 这个方法是他的请求内容
|
||||
@ -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>
|
||||
|
||||
@ -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
|
||||
}
|
||||
80
src/request/requestPython.ts
Normal file
80
src/request/requestPython.ts
Normal 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;
|
||||
Loading…
x
Reference in New Issue
Block a user