Browse Source

deepmate对接接口

lihuilin/feature-20251024095243-我的
Ethereal 4 weeks ago
parent
commit
8f267cc82b
  1. 2
      api/deepMate/deepMate.js
  2. 72
      pages/deepMate/deepMate.vue
  3. 3
      pages/home/deepExploration.vue
  4. 2
      utils/http.js

2
api/deepMate/deepMate.js

@ -34,7 +34,7 @@ export const postIntent = (data) => {
export const postStock = (data) => {
return http({
method: 'POST',
url: '/api/coze/decodingSecond',
url: '/api/deepMate/dmSecond',
data
})
}

72
pages/deepMate/deepMate.vue

@ -287,7 +287,7 @@
:key="sIdx"
class="history-section"
>
<text class="section-title">{{ section.title }}</text>
<text class="section-title">{{ section.stockName }}</text>
<view
v-for="(item, idx) in section.items"
:key="idx"
@ -455,8 +455,8 @@ const goBlank = () => {
};
//
const openHistoryDrawer = () => {
const res = postHistory({
const openHistoryDrawer = async() => {
const res = await postHistory({
model: 5,
});
@ -604,18 +604,67 @@ const simulateBotResponse = async (userMessage) => {
//
const res = await postIntent({
content: userMessage,
language: 'cn',
marketList: 'hk,cn,usa,my,sg,vi,in,gb',
token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
language: "cn",
marketList: "hk,cn,usa,my,sg,vi,in,gb",
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
console.log("res" + res);
//
if (res.code !== 200) {
console.log("未通过意图识别");
//
const errorMessage = res.message || "请求失败,请稍后重试";
let responseText = `我已经收到您的消息: "${userMessage}"。错误信息: "${errorMessage}"`;
//
let index = 0;
const botIndex = messages.value.length - 1;
const typeWriter = () => {
if (index < responseText.length) {
const ch = responseText.charAt(index);
const current = messages.value[botIndex];
//
messages.value.splice(botIndex, 1, {
...current,
content: current.content + ch,
isTyping: true,
});
index++;
scrollToBottom();
//
const baseDelay = 5; //
const slowPunct = /[。!?!?;;]/; //
const midPunct = /[,、,::]/; //
const delay = slowPunct.test(ch)
? 220
: midPunct.test(ch)
? 120
: baseDelay;
setTimeout(typeWriter, delay);
} else {
//
const current = messages.value[botIndex];
messages.value.splice(botIndex, 1, { ...current, isTyping: false });
isSending.value = false;
nextTick(() => {
scrollToBottom();
});
}
};
//
setTimeout(typeWriter, 300);
return;
}
console.log("通过意图识别");
//
const recordId = res.data.recordId;
const parentId = res.data.parentId;
@ -623,10 +672,11 @@ const simulateBotResponse = async (userMessage) => {
//
const StockInfo = await postStock({
recordId: "42",
parentId: "0",
stockId:"42",
token: memberStore.userInfo?.token || '',
recordId: recordId,
parentId: parentId,
stockId: stockId,
token:
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
language: "cn",
});
console.log("StockInfo", StockInfo);
@ -635,7 +685,7 @@ const simulateBotResponse = async (userMessage) => {
// return ;
// }
const markdown = StockInfo.markdown;
const markdown = StockInfo.data.markdown;
console.log("StockInfo", StockInfo);
//

3
pages/home/deepExploration.vue

@ -20,6 +20,9 @@ function showLoginPrompt() {
userStore.clearUserInfo();
}
console.log(userStore.userInfo);
function toDeepMate() {
uni.navigateTo({
url: "/pages/deepMate/deepMate",

2
utils/http.js

@ -39,7 +39,7 @@ const httpInterceptor = {
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
const memberStore = useUserStore()
// const token = memberStore.userInfo?.token || options.data?.token
const token = '790750702588f1ea79f24dc56ccd5d8a'
const token = 'dccec0b65a94f498b8183a17589ab16e'
if (token) {
options.header.token = token
}

Loading…
Cancel
Save