Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/9ssi7/gpt
ChatGPT API client for golang
https://github.com/9ssi7/gpt
chatgpt chatgpt-api golang gpt
Last synced: about 1 month ago
JSON representation
ChatGPT API client for golang
- Host: GitHub
- URL: https://github.com/9ssi7/gpt
- Owner: 9ssi7
- License: apache-2.0
- Created: 2023-08-26T19:25:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-26T20:12:00.000Z (over 1 year ago)
- Last Synced: 2024-12-13T23:49:33.261Z (about 1 month ago)
- Topics: chatgpt, chatgpt-api, golang, gpt
- Language: Go
- Homepage: https://pkg.go.dev/github.com/ssibrahimbas/gpt
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gpt Go Package
The `gpt` package is a Go library designed to facilitate easy communication with the GPT-3 API. This library enables you to perform text completion operations using OpenAI's GPT-3 model.
## Installation
To include this package as a Go module in your project:
```bash
go get github.com/ssibrahimbas/gpt
```## Usage
Below is a basic usage example:
```go
package mainimport (
"fmt"
"github.com/ssibrahimbas/gpt"
)func main() {
client := gpt.New(gpt.Config{
ApiKey: "YOUR_API_KEY",
})
res, err := client.Complete(gpt.CompletionRequest{
Messages: []gpt.Message{
{
Role: gpt.RoleUser,
Content: "Hello, how are you?",
},
},
Model: gpt.ModelGpt3Turbo,
Temperature: 0.7,
MaxTokens: 64,
TopP: 1,
FrequencyPenalty: 0,
PresencePenalty: 0,
})
if err != nil {
panic(err)
}
fmt.Println(res.Choices[0].Message.Content)
}
```In this example, we're sending a completion request to the GPT-3 API and printing the generated text response from the model.
## Configuration
The `gpt.New` function takes a `Config` object containing your API key. You can obtain this key from OpenAI's official website.
## Documentation
For detailed documentation and further usage examples, please refer to the Go documentation comments within the package. You can also view the documentation online at [pkg.go.dev](https://pkg.go.dev/github.com/ssibrahimbas/gpt).
## License
This project is licensed under the Apache 2.0 license. Please refer to the [LICENSE](LICENSE) file for more details.