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 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) } 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 { diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index 90f2a1f2..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.toFixed(2)} + return {balance.toFixed(5)} } return ${balance.toFixed(2)} }