-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconversation_test.go
More file actions
64 lines (53 loc) · 1.55 KB
/
conversation_test.go
File metadata and controls
64 lines (53 loc) · 1.55 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
55
56
57
58
59
60
61
62
63
64
package chatgptclient
// func TestConversation(t *testing.T) {
// cfg := &Config{
// APIKey: os.Getenv("CHATGPT_API_KEY"),
// }
// core, err := openai.New(&openai.Config{
// APIKey: cfg.APIKey,
// })
// if err != nil {
// t.Fatal(err)
// }
// client := &client{
// core: core,
// cfg: cfg,
// }
// if cfg.MaxRequestResponseTokens == 0 {
// cfg.MaxRequestResponseTokens = DefaultMaxRequestResponseTokens
// }
// if cfg.MaxResponseTokens == 0 {
// cfg.MaxResponseTokens = DefaultMaxResponseTokens
// }
// // fmt.Println("MaxResponseTokens:", client.cfg.MaxRequestResponseTokens)
// conversation, _ := NewConversation(client, &ConversationConfig{})
// var question []byte
// var answer []byte
// question = []byte("OpenAI 是什么?")
// fmt.Printf("question: %s\n", question)
// answer, err = conversation.Ask(question, &ConversationAskConfig{
// ID: "1",
// })
// if err != nil {
// t.Fatal(err)
// }
// fmt.Printf("answer: %s\n\n", answer)
// question = []byte("可以展开讲讲吗?")
// fmt.Printf("question: %s\n", question)
// answer, err = conversation.Ask(question, &ConversationAskConfig{
// ID: "1",
// })
// if err != nil {
// t.Fatal(err)
// }
// fmt.Printf("answer: %s\n\n", answer)
// question = []byte("我们现在讨论的内容是什么?")
// fmt.Printf("question: %s\n", question)
// answer, err = conversation.Ask(question)
// if err != nil {
// t.Fatal(err)
// }
// fmt.Printf("answer: %s\n\n", answer)
// prompt, _ := conversation.BuildPrompt()
// fmt.Printf("prompt:\n\n%s\n", prompt)
// }