feat: support moonshot (#63)

This commit is contained in:
Buer
2024-02-07 23:30:36 +08:00
committed by GitHub
parent 6f3b8ed997
commit 3789c30154
5 changed files with 55 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
package moonshot
import (
"one-api/common/requester"
"one-api/model"
"one-api/providers/base"
"one-api/providers/openai"
)
type MoonshotProviderFactory struct{}
// 创建 MoonshotProvider
func (f MoonshotProviderFactory) Create(channel *model.Channel) base.ProviderInterface {
config := getMoonshotConfig()
return &MoonshotProvider{
OpenAIProvider: openai.OpenAIProvider{
BaseProvider: base.BaseProvider{
Config: config,
Channel: channel,
Requester: requester.NewHTTPRequester(*channel.Proxy, openai.RequestErrorHandle),
},
BalanceAction: false,
},
}
}
func getMoonshotConfig() base.ProviderConfig {
return base.ProviderConfig{
BaseURL: "https://api.moonshot.cn",
ChatCompletions: "/v1/chat/completions",
}
}
type MoonshotProvider struct {
openai.OpenAIProvider
}