Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zzzzer91/chatgpt-go
An unofficial Go SDK for ChatGPT.
https://github.com/zzzzer91/chatgpt-go
Last synced: 4 days ago
JSON representation
An unofficial Go SDK for ChatGPT.
- Host: GitHub
- URL: https://github.com/zzzzer91/chatgpt-go
- Owner: zzzzer91
- License: gpl-3.0
- Created: 2023-03-02T05:18:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-09T11:12:42.000Z (over 1 year ago)
- Last Synced: 2024-06-20T11:50:16.493Z (5 months ago)
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT go client
Usage:
```go
func main() {
secretKey := ""
cli := chatgpt.NewService(secretKey, chatgpt.WithHost("api.openai.com"), chatgpt.WithTimeout(15*time.Second))
msgs := []*Message{
{Role: RoleTypeUser, Content: "who are you"},
}ctx := context.Background()
resp, err := cli.Chat(ctx, msgs)
if err != nil {
panic(err)
}
fmt.Println(resp.Choices[0].Message.Content)err = s.ChatStream(ctx, msgs, func(resp *ChatResponse) error {
fmt.Print(resp.Choices[0].Delta.Content)
return nil
})
if err != nil {
panic(err)
}
}
```