// 在页面中创建 XMLHttpRequest 对象
let xhr = null
// #ifdef H5
xhr = new XMLHttpRequest()
// #endif
// #ifdef APP-PLUS
xhr = new plus.net.XMLHttpRequest()
// #endif
//const msgNum = messageList.value.length;
xhr.onreadystatechange = function() {
console.log("onreadystatechange: " + xhr.readyState);
if (xhr.readyState == 3) {
> **// 这里安卓端只执行一次,ios端正常**
// 处理 HTTP 数据块
//let result=JSON.parse(xhr.responseText)
that.parseContent(xhr.responseText)
//console.log(xhr)
}
if (xhr.readyState == 4) {
console.log("问答完毕")
that.loadding = false
that.messageList.push({
content: that.messages[that.messages.length - 1].content,
role: "assistant"
})
uni.setStorageSync("chatgpt_messages", that.messages)
uni.setStorageSync("chatgpt_messageList", that.messageList)
}
}
xhr.onload = function() {
console.log("onreadystatechange: " + xhr.readyState);
}
xhr.open("POST", "https://111.com/completions", true)
xhr.setRequestHeader("Content-type", "application/json");
//xhr.responseType = "document"
//xhr.timeout = 0
xhr.send(JSON.stringify({
model: "gpt-3.5-turbo",
stream: true,
messages: messageList,
}))
Aideners
你好,问题解决了吗?我这边也遇到了同样的问题
2023-10-10 09:27
howryanl (作者)
目前没有解决。o(╥﹏╥)o
2023-10-23 15:34