mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-17 17:16:38 +08:00
Merge branch 'upstream/main'
This commit is contained in:
commit
4fb8501833
@ -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
|
* [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.
|
* [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.
|
* [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
|
## 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.
|
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.
|
||||||
|
@ -287,8 +287,8 @@ graph LR
|
|||||||
+ インターフェイスアドレスと API Key が正しいか再確認してください。
|
+ インターフェイスアドレスと 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)および**適用される法令**を遵守してご利用ください。違法な目的での利用はご遠慮ください。
|
本プロジェクトはオープンソースプロジェクトです。OpenAI の[利用規約](https://openai.com/policies/terms-of-use)および**適用される法令**を遵守してご利用ください。違法な目的での利用はご遠慮ください。
|
||||||
|
|
||||||
|
@ -93,6 +93,9 @@ func Error(ctx context.Context, msg string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Debugf(ctx context.Context, format string, a ...any) {
|
func Debugf(ctx context.Context, format string, a ...any) {
|
||||||
|
if !config.DebugEnabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
logHelper(ctx, loggerDEBUG, fmt.Sprintf(format, a...))
|
logHelper(ctx, loggerDEBUG, fmt.Sprintf(format, a...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@ package ratio
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/songquanpeng/one-api/common/logger"
|
"github.com/songquanpeng/one-api/common/logger"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var groupRatioLock sync.RWMutex
|
||||||
var GroupRatio = map[string]float64{
|
var GroupRatio = map[string]float64{
|
||||||
"default": 1,
|
"default": 1,
|
||||||
"vip": 1,
|
"vip": 1,
|
||||||
@ -20,11 +22,15 @@ func GroupRatio2JSONString() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateGroupRatioByJSONString(jsonStr string) error {
|
func UpdateGroupRatioByJSONString(jsonStr string) error {
|
||||||
|
groupRatioLock.Lock()
|
||||||
|
defer groupRatioLock.Unlock()
|
||||||
GroupRatio = make(map[string]float64)
|
GroupRatio = make(map[string]float64)
|
||||||
return json.Unmarshal([]byte(jsonStr), &GroupRatio)
|
return json.Unmarshal([]byte(jsonStr), &GroupRatio)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupRatio(name string) float64 {
|
func GetGroupRatio(name string) float64 {
|
||||||
|
groupRatioLock.RLock()
|
||||||
|
defer groupRatioLock.RUnlock()
|
||||||
ratio, ok := GroupRatio[name]
|
ratio, ok := GroupRatio[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.SysError("group ratio not found: " + name)
|
logger.SysError("group ratio not found: " + name)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/songquanpeng/one-api/common/logger"
|
"github.com/songquanpeng/one-api/common/logger"
|
||||||
)
|
)
|
||||||
@ -15,6 +16,8 @@ const (
|
|||||||
RMB = USD / USD2RMB
|
RMB = USD / USD2RMB
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var modelRatioLock sync.RWMutex
|
||||||
|
|
||||||
// ModelRatio
|
// ModelRatio
|
||||||
// https://platform.openai.com/docs/models/model-endpoint-compatibility
|
// https://platform.openai.com/docs/models/model-endpoint-compatibility
|
||||||
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Blfmc9dlf
|
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Blfmc9dlf
|
||||||
@ -508,11 +511,15 @@ func ModelRatio2JSONString() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpdateModelRatioByJSONString(jsonStr string) error {
|
func UpdateModelRatioByJSONString(jsonStr string) error {
|
||||||
|
modelRatioLock.Lock()
|
||||||
|
defer modelRatioLock.Unlock()
|
||||||
ModelRatio = make(map[string]float64)
|
ModelRatio = make(map[string]float64)
|
||||||
return json.Unmarshal([]byte(jsonStr), &ModelRatio)
|
return json.Unmarshal([]byte(jsonStr), &ModelRatio)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetModelRatio(name string, channelType int) float64 {
|
func GetModelRatio(name string, channelType int) float64 {
|
||||||
|
modelRatioLock.RLock()
|
||||||
|
defer modelRatioLock.RUnlock()
|
||||||
if strings.HasPrefix(name, "qwen-") && strings.HasSuffix(name, "-internet") {
|
if strings.HasPrefix(name, "qwen-") && strings.HasSuffix(name, "-internet") {
|
||||||
name = strings.TrimSuffix(name, "-internet")
|
name = strings.TrimSuffix(name, "-internet")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user