Fix code
This commit is contained in:
parent
88b346ae85
commit
ceca424248
@ -9,6 +9,7 @@ function inputPop() {
|
||||
return systemInfo.platform == "ios" || systemInfo.platform == "android"
|
||||
}
|
||||
|
||||
// 各平台对话分离
|
||||
var sid_prefix = systemInfo.platform == "ios" || systemInfo.platform == "android" ? "" : systemInfo.platform
|
||||
|
||||
const initHeight = inputPop() ? 20 : 5
|
||||
@ -195,10 +196,15 @@ Page({
|
||||
} else {
|
||||
that.pushStorageMessage(cht, "搜索中🔍...", "rob", [], true)
|
||||
}
|
||||
if (systemInfo.platform == "ios" || systemInfo.platform == "android" || systemInfo.platform == "devtools") {
|
||||
that.sendWSRequest(content)
|
||||
// 经测试,mac 平台下打开debug才能触发websocket的onOpen回调。。。
|
||||
if (systemInfo.platform == "mac") {
|
||||
if (systemInfo.enableDebug) {
|
||||
that.sendWSRequest(content)
|
||||
} else {
|
||||
that.sendHttpRequest(content)
|
||||
}
|
||||
} else {
|
||||
that.sendHttpRequest(content)
|
||||
that.sendWSRequest(content)
|
||||
}
|
||||
},
|
||||
pushStorageMessage: function (cht, content, role, suggests, blink, pop, num_in_conversation = -1, final = true) {
|
||||
@ -268,17 +274,20 @@ Page({
|
||||
}
|
||||
})
|
||||
socket.onOpen(() => {
|
||||
that.setData({
|
||||
socket: {
|
||||
socket: socket,
|
||||
isOpen: true
|
||||
}
|
||||
})
|
||||
setTimeout(() => {
|
||||
if (callback) {
|
||||
callback()
|
||||
}
|
||||
}, 50)
|
||||
console.log("Socket onOpen", socket)
|
||||
if (socket.readyState == 1) {
|
||||
that.setData({
|
||||
socket: {
|
||||
socket: socket,
|
||||
isOpen: true
|
||||
}
|
||||
})
|
||||
setTimeout(() => {
|
||||
if (callback) {
|
||||
callback()
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
})
|
||||
socket.onClose((code, reason) => {
|
||||
console.log('Socket onClose', code, reason)
|
||||
@ -299,6 +308,9 @@ Page({
|
||||
},
|
||||
searching: false
|
||||
})
|
||||
wx.showToast({
|
||||
title: '网络异常',
|
||||
})
|
||||
})
|
||||
socket.onMessage(data => {
|
||||
const cht = app.globalData.cht;
|
||||
@ -348,4 +360,4 @@ Page({
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -100,13 +100,17 @@ async def process_data(res, q, sid, auto_reset=None):
|
||||
if status == 'Success':
|
||||
item = res['item']['messages']
|
||||
if len(item) >= 2:
|
||||
if 'text' not in item[1]:
|
||||
text = '响应异常'
|
||||
logger.error('响应异常:%s', res)
|
||||
else:
|
||||
text = item[1]['text']
|
||||
if re.search(r'\[\^\d+\^\]', text):
|
||||
text = item[1]['adaptiveCards'][0]['body'][0]['text']
|
||||
if 'adaptiveCards' in item[1]:
|
||||
try:
|
||||
text = item[1]['adaptiveCards'][0]['body'][0]['text']
|
||||
except KeyError:
|
||||
pass
|
||||
if not text:
|
||||
if 'text' not in item[1]:
|
||||
text = '响应异常'
|
||||
logger.error('响应异常:%s', res)
|
||||
else:
|
||||
text = item[1]['text']
|
||||
text = re.sub(r'\[\^\d+\^\]', '', text)
|
||||
suggests = [x['text'] for x in item[1]['suggestedResponses']] if 'suggestedResponses' in item[1] else []
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user