feat: 算力引擎 Go 后端核心(new-api)
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package tencent
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/QuantumNous/new-api/constant"
|
||||
"github.com/QuantumNous/new-api/relay/channel"
|
||||
"github.com/QuantumNous/new-api/relay/channel/openai"
|
||||
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
||||
)
|
||||
|
||||
const tokenHubBaseURL = "https://tokenhub.tencentmaas.com"
|
||||
|
||||
// DispatchAdaptor 按密钥格式分流:三段式 ak/sk 走原生 TC3,单段 TokenHub key 走 OpenAI 兼容。
|
||||
type DispatchAdaptor struct {
|
||||
channel.Adaptor
|
||||
}
|
||||
|
||||
func (a *DispatchAdaptor) Init(info *relaycommon.RelayInfo) {
|
||||
if strings.Contains(info.ApiKey, "|") {
|
||||
a.Adaptor = &Adaptor{}
|
||||
} else {
|
||||
a.Adaptor = &openai.Adaptor{}
|
||||
if info.ChannelBaseUrl == "" || info.ChannelBaseUrl == constant.ChannelBaseURLs[constant.ChannelTypeTencent] {
|
||||
info.ChannelBaseUrl = tokenHubBaseURL
|
||||
}
|
||||
}
|
||||
a.Adaptor.Init(info)
|
||||
}
|
||||
|
||||
func (a *DispatchAdaptor) GetModelList() []string {
|
||||
return ModelList
|
||||
}
|
||||
|
||||
func (a *DispatchAdaptor) GetChannelName() string {
|
||||
return ChannelName
|
||||
}
|
||||
Reference in New Issue
Block a user