ChatGPT 今日发布 gpt-3.5-turbo 模型 API,同步奉上 Go SDK 和应用

2023-03-02 10:58:12 +08:00
 idoubi

在之前的帖子里: https://www.v2ex.com/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

3914 次点击
所在节点    分享创造
13 条回复
justin2018
2023-03-02 12:51:58 +08:00
楼主 IDE 用的是啥主题 😁
ALLROBOT
2023-03-02 13:35:09 +08:00
https://github.com/Chanzhaoyu/chatgpt-web
这个能访问网页版的 chatgpt ,服务部署好,手机电脑均可访问 chatgpt
siknet
2023-03-02 13:46:27 +08:00
E:\MOBAN
@ALLROBOT #2 这个就算是 docker 也要挂梯子的吧
ALLROBOT
2023-03-02 13:57:45 +08:00
@siknet 我这儿使用全程直连的,使用没什么问题
siknet
2023-03-02 14:29:50 +08:00
@ALLROBOT #4 搭好了,好像和官方 web 版差不多,这个是 3.0 还是 3.5 的模型?
siknet
2023-03-02 14:35:10 +08:00
@ALLROBOT #4 搭好了,好像和官方 web 版差不多,应该是 3.5 的模型
#####
更新 chatgpt 使 ChatGPTAPI 支持 gpt-3.5-turbo-0301 (默认)
idoubi
2023-03-02 17:54:04 +08:00
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

欢迎试用,感谢支持~
echoless
2023-03-02 20:26:15 +08:00
@ALLROBOT #2 牛皮
jimmy3780
2023-03-03 02:54:48 +08:00
@justin2018 目测像是 GitHub 的亮色主题
yrj
2023-03-03 03:23:36 +08:00
@idoubi 那个标准 api 的回答好像智障,确认切换到 3.5 了吗?
idoubi
2023-03-03 08:24:20 +08:00
@yrj 昨天被 qiang 了 你再试试
Dreamacro
2023-03-03 13:19:26 +08:00
说实话我没见过哪个 SDK 是需要自己构建一个 map[string]any 参数的,连 uri 也要自己输。没觉得你这个库相比于 https://github.com/go-resty/resty 来说有啥区别,只是一个 http client
voidmnwzp
2023-03-15 16:04:09 +08:00
你这个 sdk 没办法用代理吧?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/920414

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX