|
17 | 17 | let!(:c0) { OpenAI::Client.new }
|
18 | 18 | let!(:c1) do
|
19 | 19 | OpenAI::Client.new(
|
| 20 | + api_type: "azure", |
20 | 21 | access_token: "access_token1",
|
21 | 22 | organization_id: "organization_id1",
|
22 | 23 | request_timeout: 60,
|
23 |
| - uri_base: "https://oai.hconeai.com/" |
| 24 | + uri_base: "https://oai.hconeai.com/", |
| 25 | + extra_headers: { "test" => "X-Test" } |
24 | 26 | )
|
25 | 27 | end
|
26 | 28 | let!(:c2) do
|
|
33 | 35 | end
|
34 | 36 |
|
35 | 37 | it "does not confuse the clients" do
|
| 38 | + expect(c0.azure?).to eq(false) |
36 | 39 | expect(c0.access_token).to eq(ENV.fetch("OPENAI_ACCESS_TOKEN", "dummy-token"))
|
37 | 40 | expect(c0.organization_id).to eq("organization_id0")
|
38 | 41 | expect(c0.request_timeout).to eq(OpenAI::Configuration::DEFAULT_REQUEST_TIMEOUT)
|
|
41 | 44 | expect(c0.send(:headers).values).to include(c0.organization_id)
|
42 | 45 | expect(c0.send(:conn).options.timeout).to eq(OpenAI::Configuration::DEFAULT_REQUEST_TIMEOUT)
|
43 | 46 | expect(c0.send(:uri, path: "")).to include(OpenAI::Configuration::DEFAULT_URI_BASE)
|
| 47 | + expect(c0.send(:headers).values).not_to include("X-Test") |
44 | 48 |
|
| 49 | + expect(c1.azure?).to eq(true) |
45 | 50 | expect(c1.access_token).to eq("access_token1")
|
46 | 51 | expect(c1.organization_id).to eq("organization_id1")
|
47 | 52 | expect(c1.request_timeout).to eq(60)
|
48 | 53 | expect(c1.uri_base).to eq("https://oai.hconeai.com/")
|
49 |
| - expect(c1.send(:headers).values).to include("Bearer #{c1.access_token}") |
50 |
| - expect(c1.send(:headers).values).to include(c1.organization_id) |
| 54 | + expect(c1.send(:headers).values).to include(c1.access_token) |
51 | 55 | expect(c1.send(:conn).options.timeout).to eq(60)
|
52 | 56 | expect(c1.send(:uri, path: "")).to include("https://oai.hconeai.com/")
|
| 57 | + expect(c1.send(:headers).values).to include("X-Test") |
53 | 58 |
|
| 59 | + expect(c2.azure?).to eq(false) |
54 | 60 | expect(c2.access_token).to eq("access_token2")
|
55 | 61 | expect(c2.organization_id).to eq("organization_id0") # Fall back to default.
|
56 | 62 | expect(c2.request_timeout).to eq(1)
|
|
59 | 65 | expect(c2.send(:headers).values).to include(c2.organization_id)
|
60 | 66 | expect(c2.send(:conn).options.timeout).to eq(1)
|
61 | 67 | expect(c2.send(:uri, path: "")).to include("https://example.com/")
|
| 68 | + expect(c2.send(:headers).values).not_to include("X-Test") |
62 | 69 | end
|
63 | 70 |
|
64 | 71 | context "hitting other classes" do
|
|
0 commit comments