From 8651451e5396e8e65f3caef93c7520787cc2b7e9 Mon Sep 17 00:00:00 2001 From: igophper <34326532+igophper@users.noreply.github.com> Date: Tue, 19 Sep 2023 22:39:54 +0800 Subject: [PATCH 1/3] fix: sum null to 0 (#541) Co-authored-by: igophper --- model/log.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/log.go b/model/log.go index 1c0a2dc6..8e177258 100644 --- a/model/log.go +++ b/model/log.go @@ -135,7 +135,7 @@ func SearchUserLogs(userId int, keyword string) (logs []*Log, err error) { } func SumUsedQuota(logType int, startTimestamp int64, endTimestamp int64, modelName string, username string, tokenName string, channel int) (quota int) { - tx := DB.Table("logs").Select("sum(quota)") + tx := DB.Table("logs").Select("ifnull(sum(quota),0)") if username != "" { tx = tx.Where("username = ?", username) } @@ -159,7 +159,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) } From f5a1cd34634b92ea2013cfa16b599d06a4253386 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 23 Sep 2023 22:37:11 +0800 Subject: [PATCH 2/3] feat: add support for gpt-3.5-turbo-instruct (close #545) --- common/model-ratio.go | 1 + controller/model.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/common/model-ratio.go b/common/model-ratio.go index eeb23e07..0d341b02 100644 --- a/common/model-ratio.go +++ b/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, diff --git a/controller/model.go b/controller/model.go index 637ebe10..dedd0f0a 100644 --- a/controller/model.go +++ b/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", From fd9846361129452fe5ad8b45b9b401311f5872c9 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 23 Sep 2023 22:57:59 +0800 Subject: [PATCH 3/3] chore: update ali's model name --- common/model-ratio.go | 4 ++-- controller/model.go | 8 ++++---- web/src/pages/Channel/EditChannel.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/model-ratio.go b/common/model-ratio.go index 0d341b02..4b3dd763 100644 --- a/common/model-ratio.go +++ b/common/model-ratio.go @@ -51,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 diff --git a/controller/model.go b/controller/model.go index dedd0f0a..ae2061b3 100644 --- a/controller/model.go +++ b/controller/model.go @@ -352,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, }, { diff --git a/web/src/pages/Channel/EditChannel.js b/web/src/pages/Channel/EditChannel.js index 4c8dd0c4..9b128591 100644 --- a/web/src/pages/Channel/EditChannel.js +++ b/web/src/pages/Channel/EditChannel.js @@ -67,7 +67,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'];