2WeirDo / weirdo_terminal

一个 web 终端项目
https://weirdo-terminal.com
MIT License
11 stars 0 forks source link

调用chatgpt 的服务失败 #2

Open KZ137onethe opened 6 months ago

KZ137onethe commented 6 months ago

前提:执行 ./testgpt/index.js的代码,且配置了openai的apikey。 报错信息: node:internal/deps/undici/undici:11576 Error.captureStackTrace(err, this); ^

TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11576:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.then.promptTokens (file:///C:/D/FrontEndDevelopment/OpenSource/weirdo_terminal/testgpt/node_modules/.pnpm/chatgpt@5.2.5/node_modules/chatgpt/build/index.js:298:25) { cause: Error: getaddrinfo ENOTFOUND openapi.ssiic.com at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:108:26) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'openapi.ssiic.com' } }

Node.js v18.17.0 报错图片: 调用chatgpt失败

疑惑:在报错之后呢,看了下代码,发现apiBaseUrl是个啥东西,官方文档里面也没说,百度了下好像是说一个代理地址。然后看了下报错信息,fetch失败?node版本没问题,怎么会失败呢?蒙圈.... 问下怎么解决?

2WeirDo commented 6 months ago

你的 api key 应该是没额度吧, 需要一个有额度的key, 具体可通过某宝解决, 推荐 AI 智能科技馆 ~ 如果网络方面有问题, apiBaseUrl 一般是用来做中转的, 没问题的话就不用 不过推荐还是使用文心一言, 国内访问快一些