-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
knowledge_test.go
50 lines (40 loc) · 1.16 KB
/
knowledge_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
package zhipu
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestKnowledgeCapacity(t *testing.T) {
client, err := NewClient()
require.NoError(t, err)
s := client.KnowledgeCapacity()
res, err := s.Do(context.Background())
require.NoError(t, err)
require.NotEmpty(t, res.Total.Length)
require.NotEmpty(t, res.Total.WordNum)
}
func TestKnowledgeServiceAll(t *testing.T) {
client, err := NewClient()
require.NoError(t, err)
s := client.KnowledgeCreate()
s.SetName("test")
s.SetDescription("test description")
s.SetEmbeddingID(KnowledgeEmbeddingIDEmbedding2)
res, err := s.Do(context.Background())
require.NoError(t, err)
require.NotEmpty(t, res.ID)
s2 := client.KnowledgeList()
res2, err := s2.Do(context.Background())
require.NoError(t, err)
require.NotEmpty(t, res2.List)
require.Equal(t, res.ID, res2.List[0].ID)
s3 := client.KnowledgeEdit(res.ID)
s3.SetDescription("test description 2")
s3.SetName("test 2")
s3.SetEmbeddingID(KnowledgeEmbeddingIDEmbedding2)
err = s3.Do(context.Background())
require.NoError(t, err)
s4 := client.KnowledgeDelete(res.ID)
err = s4.Do(context.Background())
require.NoError(t, err)
}