diff --git a/README.en.md b/README.en.md index 2741062e..61864241 100644 --- a/README.en.md +++ b/README.en.md @@ -315,6 +315,7 @@ If the channel ID is not provided, load balancing will be used to distribute the * [FastGPT](https://github.com/labring/FastGPT): Knowledge question answering system based on the LLM * [VChart](https://github.com/VisActor/VChart): More than just a cross-platform charting library, but also an expressive data storyteller. * [VMind](https://github.com/VisActor/VMind): Not just automatic, but also fantastic. Open-source solution for intelligent visualization. +* * [CherryStudio](https://github.com/CherryHQ/cherry-studio): A cross-platform AI client that integrates multiple service providers and supports local knowledge base management. ## Note This project is an open-source project. Please use it in compliance with OpenAI's [Terms of Use](https://openai.com/policies/terms-of-use) and **applicable laws and regulations**. It must not be used for illegal purposes. diff --git a/README.ja.md b/README.ja.md index 4642df7d..38080468 100644 --- a/README.ja.md +++ b/README.ja.md @@ -287,8 +287,8 @@ graph LR + インターフェイスアドレスと API Key が正しいか再確認してください。 ## 関連プロジェクト -[FastGPT](https://github.com/labring/FastGPT): LLM に基づく知識質問応答システム - +* [FastGPT](https://github.com/labring/FastGPT): LLM に基づく知識質問応答システム +* [CherryStudio](https://github.com/CherryHQ/cherry-studio): マルチプラットフォーム対応のAIクライアント。複数のサービスプロバイダーを統合管理し、ローカル知識ベースをサポートします。 ## 注 本プロジェクトはオープンソースプロジェクトです。OpenAI の[利用規約](https://openai.com/policies/terms-of-use)および**適用される法令**を遵守してご利用ください。違法な目的での利用はご遠慮ください。 diff --git a/common/logger/logger.go b/common/logger/logger.go index b5348033..724bc029 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -93,6 +93,9 @@ func Error(ctx context.Context, msg string) { } func Debugf(ctx context.Context, format string, a ...any) { + if !config.DebugEnabled { + return + } logHelper(ctx, loggerDEBUG, fmt.Sprintf(format, a...)) } diff --git a/relay/billing/ratio/group.go b/relay/billing/ratio/group.go index 8e9c5b73..b7f62e6e 100644 --- a/relay/billing/ratio/group.go +++ b/relay/billing/ratio/group.go @@ -3,8 +3,10 @@ package ratio import ( "encoding/json" "github.com/songquanpeng/one-api/common/logger" + "sync" ) +var groupRatioLock sync.RWMutex var GroupRatio = map[string]float64{ "default": 1, "vip": 1, @@ -20,11 +22,15 @@ func GroupRatio2JSONString() string { } func UpdateGroupRatioByJSONString(jsonStr string) error { + groupRatioLock.Lock() + defer groupRatioLock.Unlock() GroupRatio = make(map[string]float64) return json.Unmarshal([]byte(jsonStr), &GroupRatio) } func GetGroupRatio(name string) float64 { + groupRatioLock.RLock() + defer groupRatioLock.RUnlock() ratio, ok := GroupRatio[name] if !ok { logger.SysError("group ratio not found: " + name) diff --git a/relay/billing/ratio/model.go b/relay/billing/ratio/model.go index 4e111871..bebab9ec 100644 --- a/relay/billing/ratio/model.go +++ b/relay/billing/ratio/model.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "strings" + "sync" "github.com/songquanpeng/one-api/common/logger" ) @@ -15,6 +16,8 @@ const ( RMB = USD / USD2RMB ) +var modelRatioLock sync.RWMutex + // ModelRatio // https://platform.openai.com/docs/models/model-endpoint-compatibility // https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Blfmc9dlf @@ -508,11 +511,15 @@ func ModelRatio2JSONString() string { } func UpdateModelRatioByJSONString(jsonStr string) error { + modelRatioLock.Lock() + defer modelRatioLock.Unlock() ModelRatio = make(map[string]float64) return json.Unmarshal([]byte(jsonStr), &ModelRatio) } func GetModelRatio(name string, channelType int) float64 { + modelRatioLock.RLock() + defer modelRatioLock.RUnlock() if strings.HasPrefix(name, "qwen-") && strings.HasSuffix(name, "-internet") { name = strings.TrimSuffix(name, "-internet") }