File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 184
184
it { expect ( parsed ) . to eq ( [ { "prompt" => ":)" } , { "prompt" => ":(" } ] ) }
185
185
end
186
186
end
187
+
188
+ describe ".uri" do
189
+ let ( :path ) { "/chat" }
190
+ let ( :uri ) { OpenAI ::Client . send ( :uri , path : path ) }
191
+
192
+ it { expect ( uri ) . to eq ( "https://api.openai.com/v1/chat" ) }
193
+
194
+ describe "with Azure" do
195
+ before do
196
+ OpenAI . configuration . uri_base = "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo"
197
+ OpenAI . configuration . api_type = :azure
198
+ end
199
+
200
+ after do
201
+ OpenAI . configuration . uri_base = "https://api.openai.com/"
202
+ OpenAI . configuration . api_type = nil
203
+ end
204
+
205
+ let ( :path ) { "/chat" }
206
+ let ( :uri ) { OpenAI ::Client . send ( :uri , path : path ) }
207
+
208
+ it { expect ( uri ) . to eq ( "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo/chat?api-version=v1" ) }
209
+ end
210
+ end
211
+
212
+ describe ".headers" do
213
+ before do
214
+ OpenAI . configuration . api_type = :nil
215
+ end
216
+
217
+ let ( :headers ) { OpenAI ::Client . send ( :headers ) }
218
+
219
+ it {
220
+ expect ( headers ) . to eq ( { "Authorization" => "Bearer #{ OpenAI . configuration . access_token } " ,
221
+ "Content-Type" => "application/json" , "OpenAI-Organization" => nil } )
222
+ }
223
+
224
+ describe "with Azure" do
225
+ before do
226
+ OpenAI . configuration . api_type = :azure
227
+ end
228
+
229
+ after do
230
+ OpenAI . configuration . api_type = nil
231
+ end
232
+
233
+ let ( :headers ) { OpenAI ::Client . send ( :headers ) }
234
+
235
+ it {
236
+ expect ( headers ) . to eq ( { "Content-Type" => "application/json" ,
237
+ "api-key" => OpenAI . configuration . access_token } )
238
+ }
239
+ end
240
+ end
187
241
end
You can’t perform that action at this time.
0 commit comments