Browse Source

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

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

55
pages/deepMate/deepMate.vue

@ -19,7 +19,8 @@
<image <image
src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg" src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
class="icon" class="icon"
@click="goToNotice" @tap="goToNotice"
@click="goToNotice"
@tap="goToNotice"
> >
</image> </image>
<image <image
@ -298,8 +299,6 @@ import {
postHistoryDetail, postHistoryDetail,
} from "../../api/deepMate/deepMate"; } from "../../api/deepMate/deepMate";
const renderer = new marked.Renderer(); const renderer = new marked.Renderer();
renderer.heading = function (text, level) { renderer.heading = function (text, level) {
return `<p>${text}</p>`; return `<p>${text}</p>`;
@ -628,13 +627,20 @@ const simulateBotResponse = async (userMessage) => {
isSending.value = true; isSending.value = true;
// //
const res = await postIntent({
let res;
try {
res = await postIntent({
content: userMessage, content: userMessage,
language: "cn", language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb", marketList: "hk,cn,usa,my,sg,vi,in,gb",
token: token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
}); });
} catch (error) {
} finally {
isSending.value = false;
}
console.log("res" + res); console.log("res" + res);
@ -701,31 +707,39 @@ const simulateBotResponse = async (userMessage) => {
// //
const StockInfo = await postStock({ const StockInfo = await postStock({
language: 'cn',
token: 'pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q',
language: "cn",
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
recordId: Number(recordId), recordId: Number(recordId),
parentId: Number(parentId), parentId: Number(parentId),
stockId: Number(stockId), 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 cftl = StockInfo?.cftl || {};
const date = StockInfo?.date || '';
const date = StockInfo?.date || "";
if (StockInfo && StockInfo.code !== 200) { 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(); // const toDataInfo = await getData();
@ -934,9 +948,8 @@ async function itemClick(item) {
isThinking: false, isThinking: false,
}; };
onDrawerBackClick()
onDrawerBackClick();
messages.value.push(botMsg); messages.value.push(botMsg);
} }
} }
</script> </script>

Loading…
Cancel
Save