-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
55 lines (51 loc) · 1.03 KB
/
client_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
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
package aimagician_test
import (
"encoding/json"
"fmt"
"net/http"
"testing"
"github.com/wztzt/aimagician"
)
func TestClient(t *testing.T) {
var Cookies []http.Cookie
json.Unmarshal([]byte(
`[
{
"name": "__Secure-session-token",
"value": "",
"path": "/",
"domain": "ai-prompt.guokr.net",
"expires": "2023-04-22T05:32:49.158Z",
"httpOnly": true,
"secure": true,
"sameSite": "Lax"
},
{
"name": "__Secure-uid",
"value": "",
"path": "/",
"domain": "ai-prompt.guokr.net",
"expires": "2023-04-22T05:32:49.158Z",
"httpOnly": false,
"secure": true,
"sameSite": "Lax"
}
]
`), &Cookies)
asks := []string{"讲个故事", "讲个笑话", "五粮液", "茅台"}
client := aimagician.NewClient(Cookies)
stream := client.ChatStream(asks[0])
defer stream.Close()
for {
response, err := stream.Recv()
if err != nil {
fmt.Println(err)
break
}
fmt.Println(*response)
}
/*for i := 0; i < 100; i++ {
reply := client.Chat(asks[i%4])
fmt.Println(reply)
}*/
}