Browse Source

对deepmate的第一步意图识别添加trycatch

lihuilin/feature-20251024095243-我的
wangyi 4 weeks ago
parent
commit
224b92e05e
  1. 71
      pages/deepMate/deepMate.vue

71
pages/deepMate/deepMate.vue

@ -19,7 +19,8 @@
<image
src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
class="icon"
@click="goToNotice" @tap="goToNotice"
@click="goToNotice"
@tap="goToNotice"
>
</image>
<image
@ -298,11 +299,9 @@ import {
postHistoryDetail,
} from "../../api/deepMate/deepMate";
const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return `<p>${text}</p>`;
renderer.heading = function (text, level) {
return `<p>${text}</p>`;
};
// marked
marked.setOptions({
@ -628,13 +627,20 @@ const simulateBotResponse = async (userMessage) => {
isSending.value = true;
//
const res = await postIntent({
content: userMessage,
language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb",
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
let res;
try {
res = await postIntent({
content: userMessage,
language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb",
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
} catch (error) {
} finally {
isSending.value = false;
}
console.log("res" + res);
@ -701,31 +707,39 @@ const simulateBotResponse = async (userMessage) => {
//
const StockInfo = await postStock({
language: 'cn',
token: 'pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q',
language: "cn",
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
recordId: Number(recordId),
parentId: Number(parentId),
stockId: Number(stockId),
});
console.log('postStock payload', { language: 'cn', token: '790750702588f1ea79f24dc56ccd5d8a', recordId, parentId, stockId });
console.log('StockInfo', StockInfo);
console.log("postStock payload", {
language: "cn",
token: "790750702588f1ea79f24dc56ccd5d8a",
recordId,
parentId,
stockId,
});
console.log("StockInfo", StockInfo);
const cftl = StockInfo?.cftl || {};
const date = StockInfo?.date || '';
const date = StockInfo?.date || "";
if (StockInfo && StockInfo.code !== 200) {
const errMsg = `postStock失败(${StockInfo.code}): ${StockInfo.message || '未知错误'}`
console.warn(errMsg, StockInfo)
messages.value[messages.value.length - 1].isThinking = false
messages.value[messages.value.length - 1].isTyping = false
messages.value[messages.value.length - 1].content = errMsg
isSending.value = false
return
const errMsg = `postStock失败(${StockInfo.code}): ${
StockInfo.message || "未知错误"
}`;
console.warn(errMsg, StockInfo);
messages.value[messages.value.length - 1].isThinking = false;
messages.value[messages.value.length - 1].isTyping = false;
messages.value[messages.value.length - 1].content = errMsg;
isSending.value = false;
return;
}
const markdown = StockInfo?.data?.markdown || '抱歉,未找到该股票';
console.log('StockInfo', StockInfo);
const markdown = StockInfo?.data?.markdown || "抱歉,未找到该股票";
console.log("StockInfo", StockInfo);
//
// const toDataInfo = await getData();
@ -934,9 +948,8 @@ async function itemClick(item) {
isThinking: false,
};
onDrawerBackClick()
onDrawerBackClick();
messages.value.push(botMsg);
}
}
</script>

Loading…
Cancel
Save