This library provides unofficial Go client for YandexGPT API.
go get github.com/sheeiavellie/go-yandexgpt@latest
Currently, go-yandexgpt requires Go version 1.22 or greater.
package main
import (
"context"
"fmt"
"github.com/sheeiavellie/go-yandexgpt"
)
func main() {
client := yandexgpt.NewYandexGPTClientWithAPIKey("apiKey")
request := yandexgpt.YandexGPTRequest{
ModelURI: yandexgpt.MakeModelURI("catalogID", yandexgpt.YandexGPTModelLite),
CompletionOptions: yandexgpt.YandexGPTCompletionOptions{
Stream: false,
Temperature: 0.7,
MaxTokens: 2000,
},
Messages: []yandexgpt.YandexGPTMessage{
{
Role: yandexgpt.YandexGPTMessageRoleSystem,
Text: "Every time you get ONE you answer just TWO",
},
{
Role: yandexgpt.YandexGPTMessageRoleUser,
Text: "ONE",
},
},
}
response, err := client.CreateRequest(context.Background(), request)
if err != nil {
fmt.Println("Request error")
return
}
fmt.Println(response.Result.Alternatives[0].Message.Text)
}
You can get all the necessary information from the official documentation.
You can contribute by:
- Reporting issues
- Suggesting new features and enhancements
- Improving documentation
For minor changes you can just send a PR without opening linked issue.
For major changes open an issue.
I highly encourage using conventional commits style in commit messages.
For PR titles it is required to use conventional commits style titles.
You can use any of these prefixes:
- fix
- feat
- chore
- refactor
- test
- ci
- Alexander V. Trotsky (Author)
- Contributors
This project was highly inspired by go-openai by sashabaranov
Made with 💖 and some wizardry 🧙🔮