revert: Rework text model logic and update dependencies

- Rewrite model name for relay text
- Simplify logic and move logging statements
- Remove a check that filtered out models by model-mapping
- Remove abilities for the model mapping
- Lower numeric tolerance for test files
This commit is contained in:
Laisky.Cai
2024-03-01 02:14:32 +00:00
parent c849292621
commit ba827b95e3
6 changed files with 13 additions and 155 deletions

View File

@@ -3,9 +3,6 @@ package model
import (
"encoding/json"
"fmt"
"strings"
"github.com/pkg/errors"
"github.com/songquanpeng/one-api/common"
"github.com/songquanpeng/one-api/common/config"
"github.com/songquanpeng/one-api/common/helper"
@@ -118,34 +115,15 @@ func (channel *Channel) Insert() error {
return err
}
func (channel *Channel) Update() (err error) {
// https://github.com/songquanpeng/one-api/issues/1054
// for compatability, filter models by model-mapping.
mapping := channel.GetModelMapping()
if len(mapping) != 0 {
models := strings.Split(channel.Models, ",")
var filteredModels []string
for _, model := range models {
if _, ok := mapping[model]; !ok {
filteredModels = append(filteredModels, model)
}
}
channel.Models = strings.Join(filteredModels, ",")
}
// update
func (channel *Channel) Update() error {
var err error
err = DB.Model(channel).Updates(channel).Error
if err != nil {
return err
}
DB.Model(channel).First(channel, "id = ?", channel.Id)
if err = channel.UpdateAbilities(); err != nil {
logger.SysError("failed to update abilities: " + err.Error())
return errors.Wrap(err, "failed to update abilities")
}
return nil
err = channel.UpdateAbilities()
return err
}
func (channel *Channel) UpdateResponseTime(responseTime int64) {