-
Notifications
You must be signed in to change notification settings - Fork 4
/
completions_test.go
30 lines (28 loc) · 1 KB
/
completions_test.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
// Copyright (c) 2022 0x9ef. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
package openai
import (
"context"
"encoding/json"
"log"
"os"
"testing"
)
func TestCompletion(t *testing.T) {
e := New(os.Getenv("OPENAI_KEY"))
r, err := e.Completion(context.Background(), &CompletionOptions{
Model: DefaultModel,
Prompt: []string{`Write a thorough blog post outline with at least 8 sections and a unique structure for a blog post titled “The global recession cases & consequences”.
Avoid lists. Do not be repetitive. The tone should be educational. The audience is intermediate in the subject. Other information to know is “Will be a global recession in 2023?
Or has this process already started?”. In your response, do not say anything additional, just provide the outline.`},
})
if err != nil {
log.Fatal(err)
}
if b, err := json.MarshalIndent(r, "", " "); err != nil {
log.Fatal(err)
} else {
log.Println(string(b))
}
}