mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-11 02:43:44 +08:00
Merge remote-tracking branch 'origin/upstream/main'
This commit is contained in:
@@ -8,8 +8,8 @@ import (
|
||||
)
|
||||
|
||||
func GetSubscription(c *gin.Context) {
|
||||
var remainQuota int
|
||||
var usedQuota int
|
||||
var remainQuota int64
|
||||
var usedQuota int64
|
||||
var err error
|
||||
var token *model.Token
|
||||
var expiredTime int64
|
||||
@@ -60,7 +60,7 @@ func GetSubscription(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetUsage(c *gin.Context) {
|
||||
var quota int
|
||||
var quota int64
|
||||
var err error
|
||||
var token *model.Token
|
||||
if config.DisplayTokenStatEnabled {
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
|
||||
func buildTestRequest() *relaymodel.GeneralOpenAIRequest {
|
||||
testRequest := &relaymodel.GeneralOpenAIRequest{
|
||||
MaxTokens: 1,
|
||||
MaxTokens: 2,
|
||||
Stream: false,
|
||||
Model: "gpt-3.5-turbo",
|
||||
}
|
||||
|
||||
@@ -234,18 +234,18 @@ func UpdateToken(c *gin.Context) {
|
||||
tokenInDB.ExpiredTime = *tokenPatch.ExpiredTime
|
||||
}
|
||||
if tokenPatch.RemainQuota != nil {
|
||||
tokenInDB.RemainQuota = *tokenPatch.RemainQuota
|
||||
tokenInDB.RemainQuota = int64(*tokenPatch.RemainQuota)
|
||||
}
|
||||
if tokenPatch.UnlimitedQuota != nil {
|
||||
tokenInDB.UnlimitedQuota = *tokenPatch.UnlimitedQuota
|
||||
}
|
||||
}
|
||||
|
||||
tokenInDB.RemainQuota -= tokenPatch.AddUsedQuota
|
||||
tokenInDB.UsedQuota += tokenPatch.AddUsedQuota
|
||||
tokenInDB.RemainQuota -= int64(tokenPatch.AddUsedQuota)
|
||||
tokenInDB.UsedQuota += int64(tokenPatch.AddUsedQuota)
|
||||
|
||||
if tokenPatch.AddUsedQuota != 0 {
|
||||
model.RecordLog(userId, model.LogTypeConsume, fmt.Sprintf("外部(%s)消耗 %s", tokenPatch.AddReason, common.LogQuota(tokenPatch.AddUsedQuota)))
|
||||
model.RecordLog(userId, model.LogTypeConsume, fmt.Sprintf("外部(%s)消耗 %s", tokenPatch.AddReason, common.LogQuota(int64(tokenPatch.AddUsedQuota))))
|
||||
}
|
||||
|
||||
if err = tokenInDB.Update(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user