diff --git a/controller/relay.go b/controller/relay.go index 90285222..8e1ad985 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -95,7 +95,8 @@ func relayHelper(c *gin.Context) error { // https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api query := c.Request.URL.Query() if query.Get("api-version") == "" { - requestURL = fmt.Sprintf("%s?api-version=2023-03-15-preview", requestURL) + apiVersion := c.GetString("api_version") + requestURL = fmt.Sprintf("%s?api-version=%s", requestURL, apiVersion) } baseURL = c.GetString("base_url") task := strings.TrimPrefix(requestURL, "/v1/") diff --git a/middleware/distributor.go b/middleware/distributor.go index 04e9f84d..65fcbd3d 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -65,6 +65,9 @@ func Distribute() func(c *gin.Context) { c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key)) if channel.Type == common.ChannelTypeCustom || channel.Type == common.ChannelTypeAzure { c.Set("base_url", channel.BaseURL) + if channel.Type == common.ChannelTypeAzure { + c.Set("api_version", channel.Other) + } } c.Next() } diff --git a/model/channel.go b/model/channel.go index ef76bf54..f653f068 100644 --- a/model/channel.go +++ b/model/channel.go @@ -15,6 +15,7 @@ type Channel struct { CreatedTime int64 `json:"created_time" gorm:"bigint"` AccessedTime int64 `json:"accessed_time" gorm:"bigint"` BaseURL string `json:"base_url" gorm:"column:base_url"` + Other string `json:"other"` } func GetAllChannels(startIdx int, num int) ([]*Channel, error) { diff --git a/web/src/pages/Channel/EditChannel.js b/web/src/pages/Channel/EditChannel.js index db77ed56..1d87ee25 100644 --- a/web/src/pages/Channel/EditChannel.js +++ b/web/src/pages/Channel/EditChannel.js @@ -13,7 +13,8 @@ const EditChannel = () => { name: '', type: 1, key: '', - base_url: '' + base_url: '', + other: '' }; const [inputs, setInputs] = useState(originInputs); const handleInputChange = (e, { name, value }) => { @@ -92,6 +93,16 @@ const EditChannel = () => { autoComplete='new-password' /> +