Просмотр исходного кода

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	model/log.go
CaIon 2 лет назад
Родитель
Сommit
3d55548c92
4 измененных файлов с 18 добавлено и 10 удалено
  1. 3 2
      common/model-ratio.go
  2. 13 4
      controller/model.go
  3. 1 3
      model/log.go
  4. 1 1
      web/src/pages/Channel/EditChannel.js

+ 3 - 2
common/model-ratio.go

@@ -24,6 +24,7 @@ var ModelRatio = map[string]float64{
 	"gpt-3.5-turbo-0613":        0.75,
 	"gpt-3.5-turbo-16k":         1.5, // $0.003 / 1K tokens
 	"gpt-3.5-turbo-16k-0613":    1.5,
+	"gpt-3.5-turbo-instruct":    0.75, // $0.0015 / 1K tokens
 	"text-ada-001":              0.2,
 	"text-babbage-001":          0.25,
 	"text-curie-001":            1,
@@ -50,8 +51,8 @@ var ModelRatio = map[string]float64{
 	"chatglm_pro":               0.7143, // ¥0.01 / 1k tokens
 	"chatglm_std":               0.3572, // ¥0.005 / 1k tokens
 	"chatglm_lite":              0.1429, // ¥0.002 / 1k tokens
-	"qwen-v1":                   0.8572, // ¥0.012 / 1k tokens
-	"qwen-plus-v1":              1,      // ¥0.014 / 1k tokens
+	"qwen-turbo":                0.8572, // ¥0.012 / 1k tokens
+	"qwen-plus":                 10,     // ¥0.14 / 1k tokens
 	"text-embedding-v1":         0.05,   // ¥0.0007 / 1k tokens
 	"SparkDesk":                 1.2858, // ¥0.018 / 1k tokens
 	"360GPT_S2_V9":              0.8572, // ¥0.012 / 1k tokens

+ 13 - 4
controller/model.go

@@ -117,6 +117,15 @@ func init() {
 			Root:       "gpt-3.5-turbo-16k-0613",
 			Parent:     nil,
 		},
+		{
+			Id:         "gpt-3.5-turbo-instruct",
+			Object:     "model",
+			Created:    1677649963,
+			OwnedBy:    "openai",
+			Permission: permission,
+			Root:       "gpt-3.5-turbo-instruct",
+			Parent:     nil,
+		},
 		{
 			Id:         "gpt-4",
 			Object:     "model",
@@ -343,21 +352,21 @@ func init() {
 			Parent:     nil,
 		},
 		{
-			Id:         "qwen-v1",
+			Id:         "qwen-turbo",
 			Object:     "model",
 			Created:    1677649963,
 			OwnedBy:    "ali",
 			Permission: permission,
-			Root:       "qwen-v1",
+			Root:       "qwen-turbo",
 			Parent:     nil,
 		},
 		{
-			Id:         "qwen-plus-v1",
+			Id:         "qwen-plus",
 			Object:     "model",
 			Created:    1677649963,
 			OwnedBy:    "ali",
 			Permission: permission,
-			Root:       "qwen-plus-v1",
+			Root:       "qwen-plus",
 			Parent:     nil,
 		},
 		{

+ 1 - 3
model/log.go

@@ -71,7 +71,6 @@ func RecordConsumeLog(ctx context.Context, userId int, channelId int, promptToke
 		ModelName:        modelName,
 		Quota:            quota,
 		Channel:          channelId,
-		TokenId:          tokenId,
 	}
 	err := DB.Create(log).Error
 	if err != nil {
@@ -164,7 +163,6 @@ func SumUsedQuota(logType int, startTimestamp int64, endTimestamp int64, modelNa
 	if modelName != "" {
 		tx = tx.Where("model_name = ?", modelName)
 	}
-
 	if channel != 0 {
 		tx = tx.Where("channel = ?", channel)
 	}
@@ -173,7 +171,7 @@ func SumUsedQuota(logType int, startTimestamp int64, endTimestamp int64, modelNa
 }
 
 func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelName string, username string, tokenName string) (token int) {
-	tx := DB.Table("logs").Select("sum(prompt_tokens) + sum(completion_tokens)")
+	tx := DB.Table("logs").Select("ifnull(sum(prompt_tokens),0) + ifnull(sum(completion_tokens),0)")
 	if username != "" {
 		tx = tx.Where("username = ?", username)
 	}

+ 1 - 1
web/src/pages/Channel/EditChannel.js

@@ -68,7 +68,7 @@ const EditChannel = () => {
           localModels = ['ERNIE-Bot', 'ERNIE-Bot-turbo', 'Embedding-V1'];
           break;
         case 17:
-          localModels = ['qwen-v1', 'qwen-plus-v1', 'text-embedding-v1'];
+          localModels = ['qwen-turbo', 'qwen-plus', 'text-embedding-v1'];
           break;
         case 16:
           localModels = ['chatglm_pro', 'chatglm_std', 'chatglm_lite'];