update
This commit is contained in:
@@ -16,6 +16,7 @@ package azureopenai
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -41,6 +42,7 @@ type ModelsList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Models(endpoint, apikey string) (*ModelsList, error) {
|
func Models(endpoint, apikey string) (*ModelsList, error) {
|
||||||
|
endpoint = removeTrailingSlash(endpoint)
|
||||||
var modelsl ModelsList
|
var modelsl ModelsList
|
||||||
req, _ := http.NewRequest(http.MethodGet, endpoint+"/openai/deployments?api-version=2022-12-01", nil)
|
req, _ := http.NewRequest(http.MethodGet, endpoint+"/openai/deployments?api-version=2022-12-01", nil)
|
||||||
req.Header.Set("api-key", apikey)
|
req.Header.Set("api-key", apikey)
|
||||||
@@ -56,3 +58,11 @@ func Models(endpoint, apikey string) (*ModelsList, error) {
|
|||||||
return &modelsl, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package store
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Key struct {
|
type Key struct {
|
||||||
ID uint `gorm:"primarykey" json:"id,omitempty"`
|
ID uint `gorm:"primarykey" json:"id,omitempty"`
|
||||||
Key string `gorm:"unique;not null" json:"key,omitempty"`
|
Key string `gorm:"unique;not null" json:"key,omitempty"`
|
||||||
Name string `gorm:"unique;not null" json:"name,omitempty"`
|
Name string `gorm:"unique;not null" json:"name,omitempty"`
|
||||||
UserId string `json:"-,omitempty"`
|
UserId string `json:"-,omitempty"`
|
||||||
KeyType string
|
ApiType string `gorm:"column:api_type"`
|
||||||
EndPoint string
|
EndPoint string `gorm:"column:endpoint"`
|
||||||
DeploymentName string
|
DeploymentName string `gorm:"column:deployment_name"`
|
||||||
CreatedAt time.Time `json:"createdAt,omitempty"`
|
CreatedAt time.Time `json:"createdAt,omitempty"`
|
||||||
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user