mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
Merge PR #365: Add Qwen provider
This commit is contained in:
@@ -59,6 +59,13 @@ func NewTelegramChannel(cfg *config.Config, bus *bus.MessageBus) (*TelegramChann
|
||||
Proxy: http.ProxyURL(proxyURL),
|
||||
},
|
||||
}))
|
||||
} else if os.Getenv("HTTP_PROXY") != "" || os.Getenv("HTTPS_PROXY") != "" {
|
||||
// Use environment proxy if configured
|
||||
opts = append(opts, telego.WithHTTPClient(&http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
bot, err := telego.NewBot(telegramCfg.Token, opts...)
|
||||
|
||||
@@ -180,6 +180,7 @@ type ProvidersConfig struct {
|
||||
ShengSuanYun ProviderConfig `json:"shengsuanyun"`
|
||||
DeepSeek ProviderConfig `json:"deepseek"`
|
||||
GitHubCopilot ProviderConfig `json:"github_copilot"`
|
||||
Qwen ProviderConfig `json:"qwen"`
|
||||
}
|
||||
|
||||
type ProviderConfig struct {
|
||||
|
||||
@@ -19,6 +19,8 @@ var supportedProviders = map[string]bool{
|
||||
"zhipu": true,
|
||||
"vllm": true,
|
||||
"gemini": true,
|
||||
"qwen": true,
|
||||
"deepseek": true,
|
||||
}
|
||||
|
||||
var supportedChannels = map[string]bool{
|
||||
@@ -253,6 +255,15 @@ func MergeConfig(existing, incoming *config.Config) *config.Config {
|
||||
if existing.Providers.Gemini.APIKey == "" {
|
||||
existing.Providers.Gemini = incoming.Providers.Gemini
|
||||
}
|
||||
if existing.Providers.DeepSeek.APIKey == "" {
|
||||
existing.Providers.DeepSeek = incoming.Providers.DeepSeek
|
||||
}
|
||||
if existing.Providers.GitHubCopilot.APIBase == "" {
|
||||
existing.Providers.GitHubCopilot = incoming.Providers.GitHubCopilot
|
||||
}
|
||||
if existing.Providers.Qwen.APIKey == "" {
|
||||
existing.Providers.Qwen = incoming.Providers.Qwen
|
||||
}
|
||||
|
||||
if !existing.Channels.Telegram.Enabled && incoming.Channels.Telegram.Enabled {
|
||||
existing.Channels.Telegram = incoming.Channels.Telegram
|
||||
|
||||
@@ -56,7 +56,7 @@ func (p *HTTPProvider) Chat(ctx context.Context, messages []Message, tools []Too
|
||||
// Strip provider prefix from model name (e.g., moonshot/kimi-k2.5 -> kimi-k2.5, groq/openai/gpt-oss-120b -> openai/gpt-oss-120b, ollama/qwen2.5:14b -> qwen2.5:14b)
|
||||
if idx := strings.Index(model, "/"); idx != -1 {
|
||||
prefix := model[:idx]
|
||||
if prefix == "moonshot" || prefix == "nvidia" || prefix == "groq" || prefix == "ollama" {
|
||||
if prefix == "moonshot" || prefix == "nvidia" || prefix == "groq" || prefix == "ollama" || prefix == "qwen" {
|
||||
model = model[idx+1:]
|
||||
}
|
||||
}
|
||||
@@ -324,6 +324,14 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
|
||||
model = "deepseek-chat"
|
||||
}
|
||||
}
|
||||
case "qwen":
|
||||
if cfg.Providers.Qwen.APIKey != "" {
|
||||
apiKey = cfg.Providers.Qwen.APIKey
|
||||
apiBase = cfg.Providers.Qwen.APIBase
|
||||
if apiBase == "" {
|
||||
apiBase = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
}
|
||||
}
|
||||
case "github_copilot", "copilot":
|
||||
if cfg.Providers.GitHubCopilot.APIBase != "" {
|
||||
apiBase = cfg.Providers.GitHubCopilot.APIBase
|
||||
@@ -402,6 +410,14 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
|
||||
apiBase = "https://api.groq.com/openai/v1"
|
||||
}
|
||||
|
||||
case (strings.Contains(lowerModel, "qwen") || strings.HasPrefix(model, "qwen/")) && cfg.Providers.Qwen.APIKey != "":
|
||||
apiKey = cfg.Providers.Qwen.APIKey
|
||||
apiBase = cfg.Providers.Qwen.APIBase
|
||||
proxy = cfg.Providers.Qwen.Proxy
|
||||
if apiBase == "" {
|
||||
apiBase = "https://dashscope.aliyuncs.com/compatible-mode/v1"
|
||||
}
|
||||
|
||||
case (strings.Contains(lowerModel, "nvidia") || strings.HasPrefix(model, "nvidia/")) && cfg.Providers.Nvidia.APIKey != "":
|
||||
apiKey = cfg.Providers.Nvidia.APIKey
|
||||
apiBase = cfg.Providers.Nvidia.APIBase
|
||||
|
||||
Reference in New Issue
Block a user