refactor: improve channel base URL handling and enhance RelayInfo logging

This commit is contained in:
CaIon
2025-08-14 22:15:18 +08:00
parent 89caccd4e0
commit 7f1f368065
5 changed files with 92 additions and 10 deletions

View File

@@ -144,7 +144,9 @@ func testChannel(channel *model.Channel, testModel string) testResult {
}
}
err = helper.ModelMappedHelper(c, info, nil)
info.InitChannelMeta(c)
err = helper.ModelMappedHelper(c, info, request)
if err != nil {
return testResult{
context: c,
@@ -166,10 +168,10 @@ func testChannel(channel *model.Channel, testModel string) testResult {
}
}
// 创建一个用于日志的 info 副本,移除 ApiKey
logInfo := *info
logInfo.ApiKey = ""
common.SysLog(fmt.Sprintf("testing channel %d with model %s , info %+v ", channel.Id, testModel, logInfo))
//// 创建一个用于日志的 info 副本,移除 ApiKey
//logInfo := info
//logInfo.ApiKey = ""
common.SysLog(fmt.Sprintf("testing channel %d with model %s , info %+v ", channel.Id, testModel, info.ToString()))
priceData, err := helper.ModelPriceHelper(c, info, 0, request.GetTokenCountMeta())
if err != nil {

View File

@@ -133,13 +133,13 @@ func Relay(c *gin.Context, relayFormat types.RelayFormat) {
return
}
preConsumedQuota, newApiErr := service.PreConsumeQuota(c, priceData.ShouldPreConsumedQuota, relayInfo)
if newApiErr != nil {
preConsumedQuota, newAPIError := service.PreConsumeQuota(c, priceData.ShouldPreConsumedQuota, relayInfo)
if newAPIError != nil {
return
}
defer func() {
if newApiErr != nil {
if newAPIError != nil {
service.ReturnPreConsumedQuota(c, relayInfo, preConsumedQuota)
}
}()