fix: fix xunfei version config
This commit is contained in:
parent
4dadf6852e
commit
3d2252df6f
@ -67,26 +67,28 @@ func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, mode
|
|||||||
c.Set(ctxkey.BaseURL, channel.GetBaseURL())
|
c.Set(ctxkey.BaseURL, channel.GetBaseURL())
|
||||||
cfg, _ := channel.LoadConfig()
|
cfg, _ := channel.LoadConfig()
|
||||||
// this is for backward compatibility
|
// this is for backward compatibility
|
||||||
switch channel.Type {
|
if channel.Other != nil {
|
||||||
case channeltype.Azure:
|
switch channel.Type {
|
||||||
if cfg.APIVersion == "" {
|
case channeltype.Azure:
|
||||||
cfg.APIVersion = channel.Other
|
if cfg.APIVersion == "" {
|
||||||
}
|
cfg.APIVersion = *channel.Other
|
||||||
case channeltype.Xunfei:
|
}
|
||||||
if cfg.APIVersion == "" {
|
case channeltype.Xunfei:
|
||||||
cfg.APIVersion = channel.Other
|
if cfg.APIVersion == "" {
|
||||||
}
|
cfg.APIVersion = *channel.Other
|
||||||
case channeltype.Gemini:
|
}
|
||||||
if cfg.APIVersion == "" {
|
case channeltype.Gemini:
|
||||||
cfg.APIVersion = channel.Other
|
if cfg.APIVersion == "" {
|
||||||
}
|
cfg.APIVersion = *channel.Other
|
||||||
case channeltype.AIProxyLibrary:
|
}
|
||||||
if cfg.LibraryID == "" {
|
case channeltype.AIProxyLibrary:
|
||||||
cfg.LibraryID = channel.Other
|
if cfg.LibraryID == "" {
|
||||||
}
|
cfg.LibraryID = *channel.Other
|
||||||
case channeltype.Ali:
|
}
|
||||||
if cfg.Plugin == "" {
|
case channeltype.Ali:
|
||||||
cfg.Plugin = channel.Other
|
if cfg.Plugin == "" {
|
||||||
|
cfg.Plugin = *channel.Other
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Set(ctxkey.Config, cfg)
|
c.Set(ctxkey.Config, cfg)
|
||||||
|
@ -27,7 +27,7 @@ type Channel struct {
|
|||||||
TestTime int64 `json:"test_time" gorm:"bigint"`
|
TestTime int64 `json:"test_time" gorm:"bigint"`
|
||||||
ResponseTime int `json:"response_time"` // in milliseconds
|
ResponseTime int `json:"response_time"` // in milliseconds
|
||||||
BaseURL *string `json:"base_url" gorm:"column:base_url;default:''"`
|
BaseURL *string `json:"base_url" gorm:"column:base_url;default:''"`
|
||||||
Other string `json:"other"` // DEPRECATED: please save config to field Config
|
Other *string `json:"other"` // DEPRECATED: please save config to field Config
|
||||||
Balance float64 `json:"balance"` // in USD
|
Balance float64 `json:"balance"` // in USD
|
||||||
BalanceUpdatedTime int64 `json:"balance_updated_time" gorm:"bigint"`
|
BalanceUpdatedTime int64 `json:"balance_updated_time" gorm:"bigint"`
|
||||||
Models string `json:"models"`
|
Models string `json:"models"`
|
||||||
|
@ -27,14 +27,6 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
|
|||||||
|
|
||||||
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {
|
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {
|
||||||
adaptor.SetupCommonRequestHeader(c, req, meta)
|
adaptor.SetupCommonRequestHeader(c, req, meta)
|
||||||
version := parseAPIVersionByModelName(meta.ActualModelName)
|
|
||||||
if version == "" {
|
|
||||||
version = a.meta.Config.APIVersion
|
|
||||||
}
|
|
||||||
if version == "" {
|
|
||||||
version = "v1.1"
|
|
||||||
}
|
|
||||||
a.meta.Config.APIVersion = version
|
|
||||||
// check DoResponse for auth part
|
// check DoResponse for auth part
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -69,6 +61,14 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Met
|
|||||||
if a.request == nil {
|
if a.request == nil {
|
||||||
return nil, openai.ErrorWrapper(errors.New("request is nil"), "request_is_nil", http.StatusBadRequest)
|
return nil, openai.ErrorWrapper(errors.New("request is nil"), "request_is_nil", http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
|
version := parseAPIVersionByModelName(meta.ActualModelName)
|
||||||
|
if version == "" {
|
||||||
|
version = a.meta.Config.APIVersion
|
||||||
|
}
|
||||||
|
if version == "" {
|
||||||
|
version = "v1.1"
|
||||||
|
}
|
||||||
|
a.meta.Config.APIVersion = version
|
||||||
if meta.IsStream {
|
if meta.IsStream {
|
||||||
err, usage = StreamHandler(c, meta, *a.request, splits[0], splits[1], splits[2])
|
err, usage = StreamHandler(c, meta, *a.request, splits[0], splits[1], splits[2])
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,9 +181,6 @@ const EditChannel = () => {
|
|||||||
if (localInputs.type === 3 && localInputs.other === '') {
|
if (localInputs.type === 3 && localInputs.other === '') {
|
||||||
localInputs.other = '2024-03-01-preview';
|
localInputs.other = '2024-03-01-preview';
|
||||||
}
|
}
|
||||||
if (localInputs.type === 18 && localInputs.other === '') {
|
|
||||||
localInputs.other = 'v2.1';
|
|
||||||
}
|
|
||||||
let res;
|
let res;
|
||||||
localInputs.models = localInputs.models.join(',');
|
localInputs.models = localInputs.models.join(',');
|
||||||
localInputs.group = localInputs.groups.join(',');
|
localInputs.group = localInputs.groups.join(',');
|
||||||
|
Loading…
Reference in New Issue
Block a user