Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added clawlet
Binary file not shown.
6 changes: 6 additions & 0 deletions cmd/clawlet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ func applyEnvOverrides(cfg *config.Config) {
}
cfg.Env["GOOGLE_API_KEY"] = v
}
if v := os.Getenv("SHENGSUANYUN_API_KEY"); v != "" {
if cfg.Env == nil {
cfg.Env = map[string]string{}
}
cfg.Env["SHENGSUANYUN_API_KEY"] = v
}
if v := strings.TrimSpace(os.Getenv("CLAWLET_WEB_ALLOWED_DOMAINS")); v != "" {
cfg.Tools.Web.AllowedDomains = splitCSV(v)
}
Expand Down
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ const (
DefaultOpenRouterBaseURL = "https://openrouter.ai/api/v1"
DefaultAnthropicBaseURL = "https://api.anthropic.com"
DefaultGeminiBaseURL = "https://generativelanguage.googleapis.com/v1beta"
DefaultShengSuanYunBaseURL = "https://router.shengsuanyun.com/api/v1"
DefaultOllamaBaseURL = "http://localhost:11434/v1"
DefaultWebFetchMaxResponseBytes = int64(500_000)
DefaultWebFetchTimeoutSec = 30
Expand Down Expand Up @@ -808,6 +809,8 @@ func (cfg *Config) ApplyLLMRouting() (provider string, configuredModel string) {
cfg.LLM.BaseURL = DefaultGeminiBaseURL
case "ollama":
cfg.LLM.BaseURL = DefaultOllamaBaseURL
case "shengsuanyun":
cfg.LLM.BaseURL = DefaultShengSuanYunBaseURL
}
}

Expand All @@ -817,6 +820,8 @@ func (cfg *Config) ApplyLLMRouting() (provider string, configuredModel string) {
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["OPENAI_API_KEY"])
case "openrouter":
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["OPENROUTER_API_KEY"])
case "shengsuanyun":
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["SHENGSUANYUN_API_KEY"])
case "anthropic":
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["ANTHROPIC_API_KEY"])
case "gemini":
Expand All @@ -841,6 +846,9 @@ func parseRoutedModel(s string) (provider string, model string) {
if after, ok := strings.CutPrefix(s, "openrouter/"); ok {
return "openrouter", after
}
if after, ok := strings.CutPrefix(s, "shengsuanyun/"); ok {
return "shengsuanyun", after
}
if after, ok := strings.CutPrefix(s, "anthropic/"); ok {
return "anthropic", after
}
Expand Down
2 changes: 1 addition & 1 deletion llm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c *Client) Chat(ctx context.Context, messages []Message, tools []ToolDefin
c.HTTP = &http.Client{Timeout: 120 * time.Second}
}
switch normalizeProvider(c.Provider) {
case "", "openai", "openrouter", "ollama":
case "", "openai", "openrouter", "ollama","shengsuanyun":
return c.chatOpenAICompatible(ctx, messages, tools)
case "anthropic":
return c.chatAnthropic(ctx, messages, tools)
Expand Down