mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 16:36:37 +08:00
fix: 修复模型映射功能失效 (close #105)
This commit is contained in:
parent
97dd80541b
commit
d4df1960b2
@ -38,7 +38,7 @@ func Relay(c *gin.Context) {
|
|||||||
retryTimes = common.RetryTimes
|
retryTimes = common.RetryTimes
|
||||||
}
|
}
|
||||||
if retryTimes > 0 {
|
if retryTimes > 0 {
|
||||||
c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s?retry=%d&error=%s", c.Request.URL.Path, retryTimes-1, err.Error.Message))
|
c.Redirect(http.StatusTemporaryRedirect, fmt.Sprintf("%s?retry=%d", c.Request.URL.Path, retryTimes-1))
|
||||||
} else {
|
} else {
|
||||||
if err.StatusCode == http.StatusTooManyRequests {
|
if err.StatusCode == http.StatusTooManyRequests {
|
||||||
//err.Error.Message = "当前分组上游负载已饱和,请稍后再试"
|
//err.Error.Message = "当前分组上游负载已饱和,请稍后再试"
|
||||||
|
@ -8,16 +8,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Redemption struct {
|
type Redemption struct {
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
UserId int `json:"user_id"`
|
UserId int `json:"user_id"`
|
||||||
Key string `json:"key" gorm:"type:char(32);uniqueIndex"`
|
Key string `json:"key" gorm:"type:char(32);uniqueIndex"`
|
||||||
Status int `json:"status" gorm:"default:1"`
|
Status int `json:"status" gorm:"default:1"`
|
||||||
Name string `json:"name" gorm:"index"`
|
Name string `json:"name" gorm:"index"`
|
||||||
Quota int `json:"quota" gorm:"default:100"`
|
Quota int `json:"quota" gorm:"default:100"`
|
||||||
CreatedTime int64 `json:"created_time" gorm:"bigint"`
|
CreatedTime int64 `json:"created_time" gorm:"bigint"`
|
||||||
RedeemedTime int64 `json:"redeemed_time" gorm:"bigint"`
|
RedeemedTime int64 `json:"redeemed_time" gorm:"bigint"`
|
||||||
Count int `json:"count" gorm:"-:all"` // only for api request
|
Count int `json:"count" gorm:"-:all"` // only for api request
|
||||||
UsedUserId int `json:"used_user_id"`
|
UsedUserId int `json:"used_user_id"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllRedemptions(startIdx int, num int) ([]*Redemption, error) {
|
func GetAllRedemptions(startIdx int, num int) ([]*Redemption, error) {
|
||||||
|
@ -60,7 +60,6 @@ func getAndValidateTextRequest(c *gin.Context, relayInfo *relaycommon.RelayInfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
relayInfo.IsStream = textRequest.Stream
|
relayInfo.IsStream = textRequest.Stream
|
||||||
relayInfo.UpstreamModelName = textRequest.Model
|
|
||||||
return textRequest, nil
|
return textRequest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +85,11 @@ func TextHelper(c *gin.Context) *dto.OpenAIErrorWithStatusCode {
|
|||||||
}
|
}
|
||||||
if modelMap[textRequest.Model] != "" {
|
if modelMap[textRequest.Model] != "" {
|
||||||
textRequest.Model = modelMap[textRequest.Model]
|
textRequest.Model = modelMap[textRequest.Model]
|
||||||
|
// set upstream model name
|
||||||
isModelMapped = true
|
isModelMapped = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
relayInfo.UpstreamModelName = textRequest.Model
|
||||||
modelPrice := common.GetModelPrice(textRequest.Model, false)
|
modelPrice := common.GetModelPrice(textRequest.Model, false)
|
||||||
groupRatio := common.GetGroupRatio(relayInfo.Group)
|
groupRatio := common.GetGroupRatio(relayInfo.Group)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user