在之前的帖子里: t/909257
我写了个 Go SDK ,包名:github.com/chatgp/gpt3, 对接了 ChatGPT 官方 API 。
今日官方 API 支持了新的对话模型 gpt-3.5-turbo ,我的 SDK 无需做任何改动,只增加了一个测试用例,可以直接使用,推荐给大家~
package main import ( "fmt" "log" "time" "github.com/chatgp/gpt3" ) func main() { apiKey := "sk-xxx" // new gpt-3 client cli, _ := gpt3.NewClient(&gpt3.Options{ ApiKey: apiKey, Timeout: 30 * time.Second, Debug: true, }) // request api uri := "/v1/chat/completions" params := map[string]interface{}{ "model": "gpt-3.5-turbo", "messages": []map[string]interface{}{ {"role": "user", "content": "hello 10 times"}, }, } res, err := cli.Post(uri, params) if err != nil { log.Fatalf("request api failed: %v", err) } fmt.Printf("message is: %s", res.Get("choices.0.message.content").String()) // Output: xxx }
ChatGPT 新模型 API 文档: https://platform.openai.com/docs/guides/chat
![]() | 1 justin2018 2023-03-02 12:51:58 +08:00 楼主 IDE 用的是啥主题 |
![]() | 2 ALLROBOT 2023-03-02 13:35:09 +08:00 via Android https://github.com/Chanzhaoyu/chatgpt-web 这个能访问网页版的 chatgpt ,服务部署好,手机电脑均可访问 chatgpt |
6 Hansah 2023-03-02 14:35:10 +08:00 |
![]() | 7 idoubi OP GPTalk:基于 chatgpt plus 账号实现的智能聊天应用 http://s.n88k1.today/gptalk TryChatGPT:基于 chatgpt 标准 API 实现的智能聊天应用 http://z.n88k1.today/trygpt chatgpt-go:模拟登录 chatgpt 官网实现的 Go SDK https://github.com/chatgp/chatgpt-go gpt3:对接 openai 标准 API 实现的 Go SDK https://github.com/chatgp/gpt3 欢迎试用,感谢支持~ |
![]() | 9 jimmy3780 2023-03-03 02:54:48 +08:00 via iPhone @justin2018 目测像是 GitHub 的亮色主题 |
12 Dreamacro 2023-03-03 13:19:26 +08:00 ![]() 说实话我没见过哪个 SDK 是需要自己构建一个 map[string]any 参数的,连 uri 也要自己输。没觉得你这个库相比于 https://github.com/go-resty/resty 来说有啥区别,只是一个 http client |
![]() | 13 voidmnwzp 2023-03-15 16:04:09 +08:00 你这个 sdk 没办法用代理吧? |