File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 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)
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 elsif @uri_base . include? ( @api_version )
9291 File . join ( @uri_base , path )
9392 else
9493 File . join ( @uri_base , @api_version , path )
9594 end
9695 end
9796
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+
98109 def multipart_parameters ( parameters )
99110 parameters &.transform_values do |value |
100111 next value unless value . respond_to? ( :close ) # File or IO object.
Original file line number Diff line number Diff line change 301301 let ( :uri_base ) { "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo" }
302302 it { expect ( uri ) . to eq ( "https://custom-domain.openai.azure.com/openai/deployments/gpt-35-turbo/chat?api-version=v1" ) }
303303 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
304310 end
305311 end
306312
You can’t perform that action at this time.
0 commit comments