update
This commit is contained in:
1 parent
604250ecb1
commit
2f7567d23e
2 files changed
+17
-7
No files matched your search
@@ -16,6 +16,7 @@ package azureopenai
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -41,6 +42,7 @@ type ModelsList struct {
|
||||
}
|
||||
|
||||
func Models(endpoint, apikey string) (*ModelsList, error) {
|
||||
endpoint = removeTrailingSlash(endpoint)
|
||||
var modelsl ModelsList
|
||||
req, _ := http.NewRequest(http.MethodGet, endpoint+"/openai/deployments?api-version=2022-12-01", nil)
|
||||
req.Header.Set("api-key", apikey)
|
||||
@@ -56,3 +58,11 @@ func Models(endpoint, apikey string) (*ModelsList, error) {
|
||||
return &modelsl, nil
|
||||
|
||||
}
|
||||
|
||||
func removeTrailingSlash(s string) string {
|
||||
const prefix = "openai.azure.com/"
|
||||
if strings.HasPrefix(s, prefix) && strings.HasSuffix(s, "/") {
|
||||
return s[:len(s)-1]
|
||||
}
|
||||
return s
|
||||
}
|
||||
Reference in new issue
Block a user