-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompletion_test.go
More file actions
54 lines (45 loc) · 1.14 KB
/
completion_test.go
File metadata and controls
54 lines (45 loc) · 1.14 KB
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
46
47
48
49
50
51
52
53
54
package openaiclient
import (
"os"
"testing"
"github.com/go-zoox/core-utils/fmt"
_ "github.com/go-zoox/dotenv"
)
func TestCreateCompletion(t *testing.T) {
client, _ := New(&Config{
APIKey: os.Getenv("OPENAI_API_KEY"),
})
completion, err := client.CreateCompletion(&CreateCompletionRequest{
Model: "text-davinci-003",
Prompt: "你好用英语怎么说?",
MaxTokens: 4000, // 4097
Temperature: 1,
})
if err != nil {
t.Fatal(err)
}
fmt.PrintJSON(completion)
}
func TestCreateCompletionAzure(t *testing.T) {
client, err := New(&Config{
APIKey: os.Getenv("OPENAI_API_KEY"),
APIType: APITypeAzure,
APIServer: os.Getenv("AZURE_API_SERVER"),
AzureResource: os.Getenv("AZURE_RESOURCE"),
AzureDeployment: os.Getenv("AZURE_DEPLOYMENT"),
AzureAPIVersion: os.Getenv("AZURE_API_VERSION"),
})
if err != nil {
t.Fatal(err)
}
completion, err := client.CreateCompletion(&CreateCompletionRequest{
Model: "text-davinci-003",
Prompt: "你好用英语怎么说?",
MaxTokens: 4000, // 4097
Temperature: 1,
})
if err != nil {
t.Fatal(err)
}
fmt.PrintJSON(completion)
}