Comments (5)
其实里面有注释,用了 //
其他感觉顾名思义的,就没写,因为有些所谓注释就是把英文翻译成中文,好像没必要(没别的意思)
流程就是根据 AJAX
请求的不同状态,然后再根据 HTTP
状态码来判断正常处理还是报错,应该挺清晰的
你可以本地跑打个断点,或者输出下 ChatGPT
返回的数据,就一目了然了
或者看重说说哪里不清楚的
from go-chatgpt-api.
其实里面有注释,用了 //
其他感觉顾名思义的,就没写,因为有些所谓注释就是把英文翻译成中文,好像没必要(没别的意思)
流程就是根据
AJAX
请求的不同状态,然后再根据HTTP
状态码来判断正常处理还是报错,应该挺清晰的你可以本地跑打个断点,或者输出下
ChatGPT
返回的数据,就一目了然了或者看重说说哪里不清楚的
我想重构下代码的,因为里面出现了很多魔鬼数字,以及api经过了转换并不一定与openai的相兼容,但POST request部分,那些处理非200的response分支我没有遇到过,着实下不去手。
from go-chatgpt-api.
我不明白,那些魔鬼数字指的是 422、429 那些?
from go-chatgpt-api.
是的。还有dataArray.pop().substring(6)
的6,这
conversationResponseDataString[0:1] == strconv.Itoa(4) || conversationResponseDataString[0:1] == strconv.Itoa(5) {
statusCode, _ := strconv.Atoi(conversationResponseDataString[0:3])
等多处。
from go-chatgpt-api.
4xx 5xx 其实是 HTTP 状态码,有报错就额外处理
substring(6) 就是把 "data: {ChatGPT 实际数据的}" 的"data: " 去掉,因为 API 返回 SSE 有额外的处理返回 "data: "
然后你引用那段就是取出 HTTP 状态码如果有错误(不是 200 就是错)就返回异常
这些是基础设施的代码,如果你重构这里提 PR 我是不合并的
from go-chatgpt-api.
Related Issues (20)
- go-chatgpt-api 不向 ARKOSE_TOKEN_URL 发送请求就返回 Failed to get arkose token. HOT 1
- 可以在docker-compose里使用账号密码组来让他自动获取token吗? HOT 2
- chatgpt-proxy-server-warp 这个源代码为啥隐藏? HOT 6
- 和潘多拉联动的话,key还需要吗? HOT 2
- failed to start HOT 10
- refreshPuidErrorMessage HOT 2
- Post "https://chat.openai.com/backend-api/conversation": unexpected EOF HOT 1
- platform/login err HOT 7
- 更新了最新的镜像版本,还是报错nil和403 HOT 6
- 登录获取access token似乎还是有问题 HOT 2
- Latest Image does not locate .har file HOT 1
- 不支持vercel吗 HOT 1
- 大神回复真快 HOT 10
- 这个怎么使用,我点了render按钮。部署成功后返回service go-chatgpt-api is ready信息。 HOT 1
- 最新版镜像报错422,"none is not an allowed value" HOT 1
- 提问后拿不到结果 HOT 4
- chatgpt login err HOT 10
- tcr9i.chat.openai.com connect: connection timed out HOT 8
- AccessToken 和 模拟 apiKey 下的报错问题 HOT 3
- 如何模拟 https://api.openai.com/v1/models接口呢 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-chatgpt-api.