File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,26 @@ def conn(multipart: false)
86
86
87
87
def uri ( path :)
88
88
if azure?
89
- base = File . join ( @uri_base , path )
90
- "#{ base } ?api-version=#{ @api_version } "
89
+ azure_uri ( path )
91
90
elsif @uri_base . include? ( @api_version )
92
91
File . join ( @uri_base , path )
93
92
else
94
93
File . join ( @uri_base , @api_version , path )
95
94
end
96
95
end
97
96
97
+ def azure_uri ( path )
98
+ base = File . join ( @uri_base , path )
99
+
100
+ # Remove the deployment to support assistants for azure
101
+ if path . include? ( "/assistants" ) || path . include? ( "/threads" )
102
+ base = base . gsub ( %r{/deployments/[^/]+/} ,
103
+ "/" )
104
+ end
105
+
106
+ "#{ base } ?api-version=#{ @api_version } "
107
+ end
108
+
98
109
def multipart_parameters ( parameters )
99
110
parameters &.transform_values do |value |
100
111
next value unless value . respond_to? ( :close ) # File or IO object.
Original file line number Diff line number Diff line change 301
301
let ( :uri_base ) { "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo" }
302
302
it { expect ( uri ) . to eq ( "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo/chat?api-version=v1" ) }
303
303
end
304
+
305
+ context "with assistants" do
306
+ let ( :path ) { "/assistants/test_assistant_id" }
307
+ let ( :uri_base ) { "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo" }
308
+ it { expect ( uri ) . to eq ( "https://custom-domain.openai.azure.com/openai/assistants/test_assistant_id?api-version=v1" ) }
309
+ end
304
310
end
305
311
end
306
312
You can’t perform that action at this time.
0 commit comments