-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 1.03 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"bytes"
"context"
_ "embed"
"fmt"
otiai10 "github.com/otiai10/openaigo"
sashabaranov "github.com/sashabaranov/go-openai"
"github.com/emikhalev/chatgpt-golang-examples/utils"
)
//go:embed assets/completion.jsonl
var completionFileV1 []byte
const filePath = "assets/completion.jsonl"
func main() {
ctx := context.Background()
apiKey := utils.APIKey()
{ // otiai10
client := otiai10.NewClient(apiKey)
completionFile := bytes.NewBuffer(completionFileV1)
uploadFile, err := client.UploadFile(ctx, otiai10.FileUploadRequestBody{
Purpose: "fine-tune",
File: completionFile,
})
fmt.Printf("otiai10 UploadFile: %v \n (err: %+v)\n\n",
utils.SPrintStruct(uploadFile), err)
}
{ // sashabaranov
client := sashabaranov.NewClient(apiKey)
uploadFile, err := client.CreateFile(ctx, sashabaranov.FileRequest{
Purpose: "fine-tune",
FileName: "completion2.jsonl",
FilePath: filePath,
})
fmt.Printf("sashabaranov UploadFile: %v \n (err: %+v)\n\n",
utils.SPrintStruct(uploadFile), err)
}
}