Skip to content

Commit 84c6a9a

Browse files
committed
fix: update uri to omit deployment ids for assistant and thread paths
1 parent 7666e30 commit 84c6a9a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/openai/http.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,21 @@ def conn(multipart: false)
8686

8787
def uri(path:)
8888
if azure?
89-
base = File.join(@uri_base, path)
90-
"#{base}?api-version=#{@api_version}"
89+
azure_uri(path)
9190
else
9291
File.join(@uri_base, @api_version, path)
9392
end
9493
end
9594

95+
def azure_uri(path:)
96+
base = File.join(@uri_base, path)
97+
98+
# Remove the deployment to support assistants for azure
99+
base = base.gsub(/\/deployments\/.+\//, '/') if (path.include?('/assistants') || path.include?('/threads'))
100+
101+
"#{base}?api-version=#{@api_version}"
102+
end
103+
96104
def multipart_parameters(parameters)
97105
parameters&.transform_values do |value|
98106
next value unless value.respond_to?(:close) # File or IO object.

spec/openai/client/http_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@
239239
let(:uri_base) { "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo" }
240240
it { expect(uri).to eq("https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo/chat?api-version=v1") }
241241
end
242+
243+
context "with assistants" do
244+
let(:path) { "/assistants" }
245+
let(:uri_base) { "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo" }
246+
it { expect(uri).to eq("https://custom-domain.openai.azure.com/openai/assistants?api-version=v1") }
247+
end
242248
end
243249
end
244250

0 commit comments

Comments
 (0)