go-chatgpt
所属分类:GPT/ChatGPT
开发工具:GO
文件大小:5KB
下载次数:0
上传日期:2022-12-10 20:07:59
上 传 者:
sh-1993
说明: 果朗的一个非官方的ChatGPT客户端。
(An unofficial ChatGPT client in Golang.
,)
文件列表:
auth.go (246, 2022-12-11)
chatgpt.go (839, 2022-12-11)
chatgpt_test.go (479, 2022-12-11)
client.go (3378, 2022-12-11)
go.mod (196, 2022-12-11)
go.sum (1177, 2022-12-11)
request.go (696, 2022-12-11)
response.go (907, 2022-12-11)
# ChatGPT client (unofficial)
Unofficial golang client for ChatGPT. Reverse Engineered from [chat.openai.com](https://chat.openai.com)
## Usage
1. Install the package.
```bash
go get github.com/abhayptp/go-chatgpt
```
2. Get bearer token from the browser.
To avoid needing to refresh bearer token every hour, you can also copy "__Secure-next-auth.session-token" key from cookie and pass it in Credentials in Step 3.
3. Pass the bearer token while initializing client.
```go
package main
import (
"fmt"
"github.com/abhayptp/go-chatgpt"
)
func main() {
// Initialize. Copy bearer-token and session-token from browser developer tools.
c := chatgpt.NewChatGpt(chatgpt.NewClient(&chatgpt.Credentials{
BearerToken: "Bearer
",
SessionToken: "",
}))
// Send message
res, err := c.SendMessage("hello")
if err != nil {
// Handle err
}
// Handle response
fmt.Println(res)
}
```
近期下载者:
相关文件:
收藏者: