mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-17 05:33:42 +08:00
🔖 chore: Remove invalid code
This commit is contained in:
@@ -90,7 +90,7 @@ func fetchChannel(c *gin.Context, modelName string) (channel *model.Channel, fai
|
||||
}
|
||||
|
||||
func fetchChannelById(channelId int) (*model.Channel, error) {
|
||||
channel, err := model.GetChannelById(channelId, true)
|
||||
channel, err := model.GetChannelById(channelId)
|
||||
if err != nil {
|
||||
return nil, errors.New("无效的渠道 Id")
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"one-api/common"
|
||||
"one-api/common/config"
|
||||
"one-api/common/utils"
|
||||
"one-api/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ChatCacheProps struct {
|
||||
@@ -31,24 +29,6 @@ type CacheDriver interface {
|
||||
Set(hash string, props *ChatCacheProps, expire int64) error
|
||||
}
|
||||
|
||||
func GetDebugList(userId int) ([]*ChatCacheProps, error) {
|
||||
caches, err := model.GetChatCacheListByUserId(userId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var props []*ChatCacheProps
|
||||
for _, cache := range caches {
|
||||
prop, err := utils.UnmarshalString[ChatCacheProps](cache.Data)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
props = append(props, &prop)
|
||||
}
|
||||
|
||||
return props, nil
|
||||
}
|
||||
|
||||
func NewChatCacheProps(c *gin.Context, allow bool) *ChatCacheProps {
|
||||
props := &ChatCacheProps{
|
||||
Cache: false,
|
||||
|
||||
@@ -99,7 +99,7 @@ func (q *Quota) completedQuotaConsumption(usage *types.Usage, tokenName string,
|
||||
quota = int(1000 * q.inputRatio)
|
||||
} else {
|
||||
completionRatio := q.price.GetOutput() * q.groupRatio
|
||||
quota = int(math.Ceil(((float64(promptTokens) * q.inputRatio) + (float64(completionTokens) * completionRatio))))
|
||||
quota = int(math.Ceil((float64(promptTokens) * q.inputRatio) + (float64(completionTokens) * completionRatio)))
|
||||
}
|
||||
|
||||
if q.inputRatio != 0 && quota <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user