mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-14 23:00:27 +00:00
feat: support Mistral's models now (close #1051)
This commit is contained in:
10
relay/channel/mistral/constants.go
Normal file
10
relay/channel/mistral/constants.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package mistral
|
||||
|
||||
var ModelList = []string{
|
||||
"open-mistral-7b",
|
||||
"open-mixtral-8x7b",
|
||||
"mistral-small-latest",
|
||||
"mistral-medium-latest",
|
||||
"mistral-large-latest",
|
||||
"mistral-embed",
|
||||
}
|
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/songquanpeng/one-api/relay/channel/ai360"
|
||||
"github.com/songquanpeng/one-api/relay/channel/baichuan"
|
||||
"github.com/songquanpeng/one-api/relay/channel/minimax"
|
||||
"github.com/songquanpeng/one-api/relay/channel/mistral"
|
||||
"github.com/songquanpeng/one-api/relay/channel/moonshot"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"github.com/songquanpeng/one-api/relay/util"
|
||||
@@ -94,6 +95,8 @@ func (a *Adaptor) GetModelList() []string {
|
||||
return baichuan.ModelList
|
||||
case common.ChannelTypeMinimax:
|
||||
return minimax.ModelList
|
||||
case common.ChannelTypeMistral:
|
||||
return mistral.ModelList
|
||||
default:
|
||||
return ModelList
|
||||
}
|
||||
@@ -111,6 +114,8 @@ func (a *Adaptor) GetChannelName() string {
|
||||
return "baichuan"
|
||||
case common.ChannelTypeMinimax:
|
||||
return "minimax"
|
||||
case common.ChannelTypeMistral:
|
||||
return "mistralai"
|
||||
default:
|
||||
return "openai"
|
||||
}
|
||||
|
@@ -172,10 +172,8 @@ func postConsumeQuota(ctx context.Context, usage *relaymodel.Usage, meta *util.R
|
||||
if err != nil {
|
||||
logger.Error(ctx, "error update user quota cache: "+err.Error())
|
||||
}
|
||||
if quota != 0 {
|
||||
logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f,补全倍率 %.2f", modelRatio, groupRatio, completionRatio)
|
||||
model.RecordConsumeLog(ctx, meta.UserId, meta.ChannelId, promptTokens, completionTokens, textRequest.Model, meta.TokenName, quota, logContent)
|
||||
model.UpdateUserUsedQuotaAndRequestCount(meta.UserId, quota)
|
||||
model.UpdateChannelUsedQuota(meta.ChannelId, quota)
|
||||
}
|
||||
logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f,补全倍率 %.2f", modelRatio, groupRatio, completionRatio)
|
||||
model.RecordConsumeLog(ctx, meta.UserId, meta.ChannelId, promptTokens, completionTokens, textRequest.Model, meta.TokenName, quota, logContent)
|
||||
model.UpdateUserUsedQuotaAndRequestCount(meta.UserId, quota)
|
||||
model.UpdateChannelUsedQuota(meta.ChannelId, quota)
|
||||
}
|
||||
|
Reference in New Issue
Block a user