@@ -47,8 +47,7 @@ var _ = Describe("API test", func() {
47
47
It ("returns the models list" , func () {
48
48
models , err := client .ListModels (context .TODO ())
49
49
Expect (err ).ToNot (HaveOccurred ())
50
- Expect (len (models .Models )).To (Equal (5 ))
51
- Expect (models .Models [0 ].ID ).To (Equal ("testmodel" ))
50
+ Expect (len (models .Models )).To (Equal (7 ))
52
51
})
53
52
It ("can generate completions" , func () {
54
53
resp , err := client .CreateCompletion (context .TODO (), openai.CompletionRequest {Model : "testmodel" , Prompt : "abcdedfghikl" })
@@ -97,6 +96,33 @@ var _ = Describe("API test", func() {
97
96
Expect (err ).ToNot (HaveOccurred ())
98
97
Expect (resp .Text ).To (ContainSubstring ("This is the Micro Machine Man presenting" ))
99
98
})
99
+
100
+ It ("calculate embeddings" , func () {
101
+ if runtime .GOOS != "linux" {
102
+ Skip ("test supported only on linux" )
103
+ }
104
+ resp , err := client .CreateEmbeddings (
105
+ context .Background (),
106
+ openai.EmbeddingRequest {
107
+ Model : openai .AdaEmbeddingV2 ,
108
+ Input : []string {"sun" , "cat" },
109
+ },
110
+ )
111
+ Expect (err ).ToNot (HaveOccurred ())
112
+ Expect (len (resp .Data [0 ].Embedding )).To (BeNumerically ("==" , 384 ))
113
+ Expect (len (resp .Data [1 ].Embedding )).To (BeNumerically ("==" , 384 ))
114
+
115
+ sunEmbedding := resp .Data [0 ].Embedding
116
+ resp2 , err := client .CreateEmbeddings (
117
+ context .Background (),
118
+ openai.EmbeddingRequest {
119
+ Model : openai .AdaEmbeddingV2 ,
120
+ Input : []string {"sun" },
121
+ },
122
+ )
123
+ Expect (err ).ToNot (HaveOccurred ())
124
+ Expect (resp2 .Data [0 ].Embedding ).To (Equal (sunEmbedding ))
125
+ })
100
126
})
101
127
102
128
Context ("Config file" , func () {
@@ -123,8 +149,7 @@ var _ = Describe("API test", func() {
123
149
124
150
models , err := client .ListModels (context .TODO ())
125
151
Expect (err ).ToNot (HaveOccurred ())
126
- Expect (len (models .Models )).To (Equal (7 ))
127
- Expect (models .Models [0 ].ID ).To (Equal ("testmodel" ))
152
+ Expect (len (models .Models )).To (Equal (9 ))
128
153
})
129
154
It ("can generate chat completions from config file" , func () {
130
155
resp , err := client .CreateChatCompletion (context .TODO (), openai.ChatCompletionRequest {Model : "list1" , Messages : []openai.ChatCompletionMessage {openai.ChatCompletionMessage {Role : "user" , Content : "abcdedfghikl" }}})
0 commit comments