@@ -66,6 +66,62 @@ func TestCreateBatchWithUploadFile(t *testing.T) {
66
66
checks .NoError (t , err , "CreateBatchWithUploadFile error" )
67
67
}
68
68
69
+ func TestCreateBatchWithChatCompletions (t * testing.T ) {
70
+ client , server , teardown := setupOpenAITestServer ()
71
+ defer teardown ()
72
+ server .RegisterHandler ("/v1/files" , handleCreateFile )
73
+ server .RegisterHandler ("/v1/batches" , handleBatchEndpoint )
74
+
75
+ var chatCompletions = make ([]openai.BatchChatCompletion , 5 )
76
+ for i := 0 ; i < 5 ; i ++ {
77
+ chatCompletions [i ] = openai.BatchChatCompletion {
78
+ CustomID : fmt .Sprintf ("req-%d" , i ),
79
+ ChatCompletion : openai.ChatCompletionRequest {
80
+ Model : openai .GPT4oMini ,
81
+ Messages : []openai.ChatCompletionMessage {
82
+ {
83
+ Role : openai .ChatMessageRoleUser ,
84
+ Content : fmt .Sprintf ("What is the square of %d?" , i + 1 ),
85
+ },
86
+ },
87
+ },
88
+ }
89
+ }
90
+ _ , err := client .CreateBatchWithChatCompletions (
91
+ context .Background (),
92
+ openai.CreateBatchWithChatCompletionsRequest {
93
+ ChatCompletions : chatCompletions ,
94
+ },
95
+ )
96
+ checks .NoError (t , err , "CreateBatchWithChatCompletions error" )
97
+ }
98
+
99
+ func TestCreateBatchWithEmbeddings (t * testing.T ) {
100
+ client , server , teardown := setupOpenAITestServer ()
101
+ defer teardown ()
102
+ server .RegisterHandler ("/v1/files" , handleCreateFile )
103
+ server .RegisterHandler ("/v1/batches" , handleBatchEndpoint )
104
+
105
+ var embeddings = make ([]openai.BatchEmbedding , 3 )
106
+ for i := 0 ; i < 3 ; i ++ {
107
+ embeddings [i ] = openai.BatchEmbedding {
108
+ CustomID : fmt .Sprintf ("req-%d" , i ),
109
+ Embedding : openai.EmbeddingRequest {
110
+ Input : "The food was delicious and the waiter..." ,
111
+ Model : openai .AdaEmbeddingV2 ,
112
+ EncodingFormat : openai .EmbeddingEncodingFormatFloat ,
113
+ },
114
+ }
115
+ }
116
+ _ , err := client .CreateBatchWithEmbeddings (
117
+ context .Background (),
118
+ openai.CreateBatchWithEmbeddingsRequest {
119
+ Embeddings : embeddings ,
120
+ },
121
+ )
122
+ checks .NoError (t , err , "CreateBatchWithEmbeddings error" )
123
+ }
124
+
69
125
func TestRetrieveBatch (t * testing.T ) {
70
126
client , server , teardown := setupOpenAITestServer ()
71
127
defer teardown ()
0 commit comments