Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

联系人回复消息报错Cannot read properties of undefined (reading 'choices') #170

Closed
Ale6333499 opened this issue Apr 30, 2024 · 18 comments

Comments

@Ale6333499
Copy link

uncaughtException TypeError: Cannot read properties of undefined (reading 'choices')
at WebSocket. (file:///Users/jevon/Downloads/wechat-bot-main/src/xunfei/xunfei.js:93:33)
at callListener (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/event-target.js:209:9)
at WebSocket.emit (node:events:518:28)
at Receiver.receiverOnMessage (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/websocket.js:1209:20)
at Receiver.emit (node:events:518:28)
at Receiver.dataMessage (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/receiver.js:594:14)
at Receiver.getData (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/receiver.js:496:10)
at Receiver.startLoop (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/receiver.js:167:16)
at Receiver._write (/Users/jevon/Downloads/wechat-bot-main/node_modules/ws/lib/receiver.js:94:10)

@qdhonker
Copy link

我也是这个问题,解决了吗

@Ale6333499
Copy link
Author

我也是这个问题,解决了吗

我这个是因为讯飞的API接口出的问题,我的账号没有实名认证所以调用出错了,导致返回结构体不正确继而导致这个属性未找到的错误。你可以试着排查一下。

@qdhonker
Copy link

排查到了,已经提交讯飞的实名认证,你认证完就可以调了吗

@Ale6333499
Copy link
Author

排查到了,已经提交讯飞的实名认证,你认证完就可以调了吗

是的

@qdhonker
Copy link

搞定了,感谢回复

@Ale6333499
Copy link
Author

搞定了,感谢回复
👌

@wangrongding
Copy link
Owner

👍👍

@ChaoQiezi
Copy link

认证之后还是存在报错

@mzal123
Copy link

mzal123 commented Aug 13, 2024

我也是认证之后还是报这个错,怎么解决呢

@Ale6333499
Copy link
Author

每个人的报错原因可能都不一样,建议大家试着排查一下是否api已经认证,以及是不是回复的消息结构变化了导致属性未获取到

@EmericZh
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~
🚀🚀🚀 / prompt 你好!
file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93
total_res += data.payload.choices.text[0].content
^

TypeError: Cannot read properties of undefined (reading 'choices')
at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33)
at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14)
at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9)
at WebSocket.emit (node:events:519:28)
at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20)
at Receiver.emit (node:events:519:28)
at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14)
at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10)
at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16)
at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)

@EmericZh
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~ 🚀🚀🚀 / prompt 你好! file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93 total_res += data.payload.choices.text[0].content ^

TypeError: Cannot read properties of undefined (reading 'choices') at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33) at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14) at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20) at Receiver.emit (node:events:519:28) at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14) at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10) at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16) at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)


在代码里面打印了一下报错,发现提示的是apiAuthError, 最后排查到是 /src/xunfei/xunfei.js 文件内的httpUrl问题,完美解决,撒花🧨🧨🧨

@ZhaoX19990227
Copy link

web端调试没问题,也是报这个错,有其他方式解决的吗?

@djhealthunion-dev
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~ 🚀🚀🚀 / prompt 你好! file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93 total_res += data.payload.choices.text[0].content ^
TypeError: Cannot read properties of undefined (reading 'choices') at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33) at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14) at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20) at Receiver.emit (node:events:519:28) at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14) at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10) at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16) at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)

在代码里面打印了一下报错,发现提示的是apiAuthError, 最后排查到是 /src/xunfei/xunfei.js 文件内的httpUrl问题,完美解决,撒花🧨🧨🧨

那到底是咋解决的呢

@djhealthunion-dev
Copy link

apiAuthError

https://console.xfyun.cn/services/sparkapiCenter 现在这个地址查看对应模型剩余的token,我现在用的是4.0 ultra,在xunfei.js,修改 httpUrl 为https://spark-api.xf-yun.com/v4.0/chat, authenticate 方法中新增一个case
case '/v4.0/chat':
modelDomain = '4.0Ultra'
就可以了

@EmericZh
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~ 🚀🚀🚀 / prompt 你好! file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93 total_res += data.payload.choices.text[0].content ^
TypeError: Cannot read properties of undefined (reading 'choices') at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33) at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14) at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20) at Receiver.emit (node:events:519:28) at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14) at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10) at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16) at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)

在代码里面打印了一下报错,发现提示的是apiAuthError, 最后排查到是 /src/xunfei/xunfei.js 文件内的httpUrl问题,完美解决,撒花🧨🧨🧨

那到底是咋解决的呢

打开你的/src/xunfei/xunfei.js文件找到httpUrl改一下,我记得是版本问题

@djhealthunion-dev
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~ 🚀🚀🚀 / prompt 你好! file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93 total_res += data.payload.choices.text[0].content ^
TypeError: Cannot read properties of undefined (reading 'choices') at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33) at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14) at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20) at Receiver.emit (node:events:519:28) at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14) at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10) at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16) at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)

在代码里面打印了一下报错,发现提示的是apiAuthError, 最后排查到是 /src/xunfei/xunfei.js 文件内的httpUrl问题,完美解决,撒花🧨🧨🧨

那到底是咋解决的呢

打开你的/src/xunfei/xunfei.js文件找到httpUrl改一下,我记得是版本问题

已经解决了,修改一下大模型版本号就可以了

@EmericZh
Copy link

认证了,讯飞线上调适也通,三个key也都确认没错了,还是不行~ 🚀🚀🚀 / prompt 你好! file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93 total_res += data.payload.choices.text[0].content ^
TypeError: Cannot read properties of undefined (reading 'choices') at WebSocket. (file:///Users/share/Documents/HaiTang/SliverFox/wechat-bot/src/xunfei/xunfei.js:93:33) at callListener (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:290:14) at WebSocket.onMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/event-target.js:209:9) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/websocket.js:1220:20) at Receiver.emit (node:events:519:28) at Receiver.dataMessage (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:596:14) at Receiver.getData (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:496:10) at Receiver.startLoop (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:167:16) at Receiver._write (/Users/share/Documents/HaiTang/SliverFox/wechat-bot/node_modules/ws/lib/receiver.js:94:10)

在代码里面打印了一下报错,发现提示的是apiAuthError, 最后排查到是 /src/xunfei/xunfei.js 文件内的httpUrl问题,完美解决,撒花🧨🧨🧨

那到底是咋解决的呢

打开你的/src/xunfei/xunfei.js文件找到httpUrl改一下,我记得是版本问题

已经解决了,修改一下大模型版本号就可以了

恭喜恭喜✿✿ヽ(°▽°)ノ✿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants