Commit 26570415 by chenjinjing

no message

parent 46eb12ab
...@@ -10,7 +10,7 @@ import { AIANSWERTYPE } from "../../config/enum"; ...@@ -10,7 +10,7 @@ import { AIANSWERTYPE } from "../../config/enum";
export async function getAIAnswerInterface(question, sceneUuids, threadId) { export async function getAIAnswerInterface(question, sceneUuids, threadId) {
const interfaceName = "获取问数结果信息"; const interfaceName = "获取问数结果信息";
let body = {question, sceneUuids, threadId}; let body = {question, sceneUuids, threadId};
// let data = await getInterfaceByInterfaceName( dataCenterInterfaceConfig.answerText, body ); let data = await getInterfaceByInterfaceName( dataCenterInterfaceConfig.answerText, body );
/**----------------test */ /**----------------test */
// let sample = {header:[], data:[]}; // let sample = {header:[], data:[]};
...@@ -50,21 +50,21 @@ export async function getAIAnswerInterface(question, sceneUuids, threadId) { ...@@ -50,21 +50,21 @@ export async function getAIAnswerInterface(question, sceneUuids, threadId) {
// ]; // ];
// } // }
let data = { // let data = {
questionId:"", // questionId:"",
content:"", // content:"",
params:[], // params:[],
sample:null // sample:null
} // }
if (question == "今年营销项目带来多少收入") { // if (question == "今年营销项目带来多少收入") {
data.content = "为您查询:项目启动时间${filterValue1}的收入${filterValue3}为636181.6320754716552286"; // data.content = "为您查询:项目启动时间${filterValue1}的收入${filterValue3}为636181.6320754716552286";
data.params = [ // data.params = [
{name:"filterValue1", display:"大于等于2025-01-01"}, // {name:"filterValue1", display:"大于等于2025-01-01"},
{name:"filterValue2", display:"123"}, // {name:"filterValue2", display:"123"},
{name:"filterValue3", display:"营销项目金额"}, // {name:"filterValue3", display:"营销项目金额"},
]; // ];
} // }
/**----------------test */ /**----------------test */
...@@ -75,18 +75,22 @@ export async function getAIAnswerInterface(question, sceneUuids, threadId) { ...@@ -75,18 +75,22 @@ export async function getAIAnswerInterface(question, sceneUuids, threadId) {
if (!sample) { if (!sample) {
let aiAnswerStr = replacePlaceholders(content, params); let aiAnswerStr = replacePlaceholders(content, params);
// // 1. 找到最后一个 "为" 的位置 // 1. 找到最后一个 "为" 的位置
// let lastWeiIndex = aiAnswerStr.lastIndexOf("为"); let lastWeiIndex = aiAnswerStr.lastIndexOf("为");
// let beforeWei = ""; let beforeWei = "";
// let afterWei = ""; let afterWei = "";
// if (lastWeiIndex !== -1) { let afterWeiNum;
// // 2. 截取 "为" 前面的部分(不包含"为") if (lastWeiIndex !== -1) {
// beforeWei = aiAnswerStr.slice(0, lastWeiIndex); // 2. 截取 "为" 前面的部分(不包含"为")
// // 3. 截取 "为" 后面的部分(不包含"为") beforeWei = aiAnswerStr.slice(0, lastWeiIndex);
// afterWei = aiAnswerStr.slice(lastWeiIndex + 1); // +1 跳过 "为" 字 // 3. 截取 "为" 后面的部分(不包含"为")
// } afterWei = aiAnswerStr.slice(lastWeiIndex + 1); // +1 跳过 "为" 字
let afterWeiFloat = parseFloat(afterWei);
if (isNaN(afterWeiFloat)) afterWeiNum = afterWei;
afterWeiNum = afterWeiFloat.toFixed(2);
}
aiAnswerType = AIANSWERTYPE.文本; aiAnswerType = AIANSWERTYPE.文本;
aiAnswerData = aiAnswerStr; aiAnswerData = `${beforeWei}${afterWeiNum}`;
} else if (!Object.keys(sample).length) { } else if (!Object.keys(sample).length) {
throw new SysError(SYSTEMERRORENUM.未按接口协议返回, interfaceName, "sample 为空", sample); throw new SysError(SYSTEMERRORENUM.未按接口协议返回, interfaceName, "sample 为空", sample);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment