mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-22 03:16:38 +08:00
fix: Improve error handling and logging in channel update abilities
- Improve error handling in `UpdateAbilities()` method - Log model name change request to the mapped model
This commit is contained in:
parent
4625a0b97d
commit
3da0f62055
@ -3,6 +3,8 @@ package model
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/songquanpeng/one-api/common"
|
"github.com/songquanpeng/one-api/common"
|
||||||
"github.com/songquanpeng/one-api/common/config"
|
"github.com/songquanpeng/one-api/common/config"
|
||||||
"github.com/songquanpeng/one-api/common/helper"
|
"github.com/songquanpeng/one-api/common/helper"
|
||||||
@ -122,8 +124,12 @@ func (channel *Channel) Update() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
DB.Model(channel).First(channel, "id = ?", channel.Id)
|
DB.Model(channel).First(channel, "id = ?", channel.Id)
|
||||||
err = channel.UpdateAbilities()
|
if err = channel.UpdateAbilities(); err != nil {
|
||||||
return err
|
logger.SysError("failed to update abilities: " + err.Error())
|
||||||
|
return errors.Wrap(err, "failed to update abilities")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) UpdateResponseTime(responseTime int64) {
|
func (channel *Channel) UpdateResponseTime(responseTime int64) {
|
||||||
|
@ -29,9 +29,16 @@ func RelayTextHelper(c *gin.Context) *model.ErrorWithStatusCode {
|
|||||||
meta.IsStream = textRequest.Stream
|
meta.IsStream = textRequest.Stream
|
||||||
|
|
||||||
// map model name
|
// map model name
|
||||||
var isModelMapped bool
|
var (
|
||||||
|
originRequestModel = textRequest.Model
|
||||||
|
isModelMapped bool
|
||||||
|
)
|
||||||
meta.OriginModelName = textRequest.Model
|
meta.OriginModelName = textRequest.Model
|
||||||
textRequest.Model, isModelMapped = util.GetMappedModelName(textRequest.Model, meta.ModelMapping)
|
textRequest.Model, isModelMapped = util.GetMappedModelName(textRequest.Model, meta.ModelMapping)
|
||||||
|
if isModelMapped {
|
||||||
|
logger.Info(c.Request.Context(), fmt.Sprintf("rewrite model name from %s to %s", originRequestModel, textRequest.Model))
|
||||||
|
}
|
||||||
|
|
||||||
meta.ActualModelName = textRequest.Model
|
meta.ActualModelName = textRequest.Model
|
||||||
// get model ratio & group ratio
|
// get model ratio & group ratio
|
||||||
modelRatio := common.GetModelRatio(textRequest.Model)
|
modelRatio := common.GetModelRatio(textRequest.Model)
|
||||||
|
Loading…
Reference in New Issue
Block a user