-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (27 loc) · 810 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"fmt"
otiai10 "github.com/otiai10/openaigo"
sashabaranov "github.com/sashabaranov/go-openai"
"github.com/emikhalev/chatgpt-golang-examples/utils"
)
func main() {
ctx := context.Background()
apiKey := utils.APIKey()
{ // otiai10
client := otiai10.NewClient(apiKey)
models, err := client.ListModels(ctx)
fmt.Printf("otiai10 ListModels: %v \n (err: %+v)\n\n",
utils.SPrintStruct(models), err)
model, err := client.RetrieveModel(ctx, models.Data[0].ID)
fmt.Printf("otiai10 RetrieveModel: %v \n (err: %+v)\n\n",
utils.SPrintStruct(model), err)
}
{ // sashabaranov
client := sashabaranov.NewClient(apiKey)
models, err := client.ListModels(ctx)
fmt.Printf("sashabaranov ListModels: %v \n (err: %+v)\n\n",
utils.SPrintStruct(models), err)
}
}