From 955d5f8707f4d0886fe4e26904464e4d6c13e588 Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 12 Jun 2023 09:11:48 +0800 Subject: [PATCH 1/5] fix: fix group list not correct (close #147) --- common/group-ratio.go | 1 + common/model-ratio.go | 1 + 2 files changed, 2 insertions(+) diff --git a/common/group-ratio.go b/common/group-ratio.go index 0a9cf4ba..b9efbdad 100644 --- a/common/group-ratio.go +++ b/common/group-ratio.go @@ -17,6 +17,7 @@ func GroupRatio2JSONString() string { } func UpdateGroupRatioByJSONString(jsonStr string) error { + GroupRatio = make(map[string]float64) return json.Unmarshal([]byte(jsonStr), &GroupRatio) } diff --git a/common/model-ratio.go b/common/model-ratio.go index bc7e7be3..fc982491 100644 --- a/common/model-ratio.go +++ b/common/model-ratio.go @@ -39,6 +39,7 @@ func ModelRatio2JSONString() string { } func UpdateModelRatioByJSONString(jsonStr string) error { + ModelRatio = make(map[string]float64) return json.Unmarshal([]byte(jsonStr), &ModelRatio) } From 8b2ef666efe51f4e455044a1977a74f034a531c0 Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 12 Jun 2023 09:40:49 +0800 Subject: [PATCH 2/5] fix: fix OpenAI-SB balance not correct --- web/src/components/ChannelsTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index 999027fc..48fd521d 100644 --- a/web/src/components/ChannelsTable.js +++ b/web/src/components/ChannelsTable.js @@ -29,7 +29,7 @@ function renderType(type) { function renderBalance(type, balance) { if (type === 5) { - return {balance.toFixed(2)} + return ¥{(balance / 10000).toFixed(2)} } return ${balance.toFixed(2)} } From f2c238dd54e98a010cf540499b4e201feee49e51 Mon Sep 17 00:00:00 2001 From: quzard <1191890118@qq.com> Date: Mon, 12 Jun 2023 15:22:22 +0800 Subject: [PATCH 3/5] change openaiSB balance --- web/src/components/ChannelsTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index 6cc394f8..466e789c 100644 --- a/web/src/components/ChannelsTable.js +++ b/web/src/components/ChannelsTable.js @@ -29,7 +29,7 @@ function renderType(type) { function renderBalance(type, balance) { if (type === 5) { - return ¥{(balance / 10000).toFixed(2)} + return {balance.toFixed(5)} } return ${balance.toFixed(2)} } From 7c7eb6b7ece0865a94fb563de7376fe7d3e11940 Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 12 Jun 2023 16:11:57 +0800 Subject: [PATCH 4/5] fix: now the input field can be array type now (close #149) --- controller/relay-utils.go | 14 ++++++++++++++ controller/relay.go | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/controller/relay-utils.go b/controller/relay-utils.go index bb25fa3b..a2dc2685 100644 --- a/controller/relay-utils.go +++ b/controller/relay-utils.go @@ -58,6 +58,20 @@ func countTokenMessages(messages []Message, model string) int { return tokenNum } +func countTokenInput(input any, model string) int { + switch input.(type) { + case string: + return countTokenText(input.(string), model) + case []string: + text := "" + for _, s := range input.([]string) { + text += s + } + return countTokenText(text, model) + } + return 0 +} + func countTokenText(text string, model string) int { tokenEncoder := getTokenEncoder(model) token := tokenEncoder.Encode(text, nil, nil) diff --git a/controller/relay.go b/controller/relay.go index 7882a09d..35897909 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -38,7 +38,7 @@ type GeneralOpenAIRequest struct { Temperature float64 `json:"temperature"` TopP float64 `json:"top_p"` N int `json:"n"` - Input string `json:"input"` + Input any `json:"input"` } type ChatRequest struct { @@ -189,7 +189,7 @@ func relayHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode { case RelayModeCompletions: promptTokens = countTokenText(textRequest.Prompt, textRequest.Model) case RelayModeModeration: - promptTokens = countTokenText(textRequest.Input, textRequest.Model) + promptTokens = countTokenInput(textRequest.Input, textRequest.Model) } preConsumedTokens := common.PreConsumedQuota if textRequest.MaxTokens != 0 { From 0c34ed4c61e1729cd481cae6c545737ec8ce7614 Mon Sep 17 00:00:00 2001 From: JustSong Date: Tue, 13 Jun 2023 17:45:01 +0800 Subject: [PATCH 5/5] docs: update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 189bc03a..aecb8e47 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,8 @@ sudo certbot --nginx sudo service nginx restart ``` +初始账号用户名为 `root`,密码为 `123456`。 + ### 手动部署 1. 从 [GitHub Releases](https://github.com/songquanpeng/one-api/releases/latest) 下载可执行文件或者从源码编译: ```shell