7
7
"fmt"
8
8
"io"
9
9
"net/http"
10
+ "net/url"
10
11
"strings"
11
12
12
13
utils "github.com/sashabaranov/go-openai/internal"
@@ -228,10 +229,13 @@ func (c *Client) fullURL(suffix string, args ...any) string {
228
229
if c .config .APIType == APITypeAzure || c .config .APIType == APITypeAzureAD {
229
230
baseURL := c .config .BaseURL
230
231
baseURL = strings .TrimRight (baseURL , "/" )
232
+ parseURL , _ := url .Parse (baseURL )
233
+ query := parseURL .Query ()
234
+ query .Add ("api-version" , c .config .APIVersion )
231
235
// if suffix is /models change to {endpoint}/openai/models?api-version=2022-12-01
232
236
// https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/models/list?tabs=HTTP
233
237
if containsSubstr ([]string {"/models" , "/assistants" , "/threads" , "/files" }, suffix ) {
234
- return fmt .Sprintf ("%s/%s%s?api-version= %s" , baseURL , azureAPIPrefix , suffix , c . config . APIVersion )
238
+ return fmt .Sprintf ("%s/%s%s?%s" , baseURL , azureAPIPrefix , suffix , query . Encode () )
235
239
}
236
240
azureDeploymentName := "UNKNOWN"
237
241
if len (args ) > 0 {
@@ -240,9 +244,9 @@ func (c *Client) fullURL(suffix string, args ...any) string {
240
244
azureDeploymentName = c .config .GetAzureDeploymentByModel (model )
241
245
}
242
246
}
243
- return fmt .Sprintf ("%s/%s/%s/%s%s?api-version= %s" ,
247
+ return fmt .Sprintf ("%s/%s/%s/%s%s?%s" ,
244
248
baseURL , azureAPIPrefix , azureDeploymentsPrefix ,
245
- azureDeploymentName , suffix , c . config . APIVersion ,
249
+ azureDeploymentName , suffix , query . Encode () ,
246
250
)
247
251
}
248
252
0 commit comments