Skip to content

Commit 8a9367d

Browse files
authored
Merge pull request #9 from coohu/ssy
2 parents 26c4337 + 950e7d9 commit 8a9367d

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

clawlet

35.8 MB
Binary file not shown.

cmd/clawlet/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ func applyEnvOverrides(cfg *config.Config) {
101101
}
102102
cfg.Env["GOOGLE_API_KEY"] = v
103103
}
104+
if v := os.Getenv("SHENGSUANYUN_API_KEY"); v != "" {
105+
if cfg.Env == nil {
106+
cfg.Env = map[string]string{}
107+
}
108+
cfg.Env["SHENGSUANYUN_API_KEY"] = v
109+
}
104110
if v := strings.TrimSpace(os.Getenv("CLAWLET_WEB_ALLOWED_DOMAINS")); v != "" {
105111
cfg.Tools.Web.AllowedDomains = splitCSV(v)
106112
}

config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ const (
336336
DefaultOpenRouterBaseURL = "https://openrouter.ai/api/v1"
337337
DefaultAnthropicBaseURL = "https://api.anthropic.com"
338338
DefaultGeminiBaseURL = "https://generativelanguage.googleapis.com/v1beta"
339+
DefaultShengSuanYunBaseURL = "https://router.shengsuanyun.com/api/v1"
339340
DefaultOllamaBaseURL = "http://localhost:11434/v1"
340341
DefaultWebFetchMaxResponseBytes = int64(500_000)
341342
DefaultWebFetchTimeoutSec = 30
@@ -808,6 +809,8 @@ func (cfg *Config) ApplyLLMRouting() (provider string, configuredModel string) {
808809
cfg.LLM.BaseURL = DefaultGeminiBaseURL
809810
case "ollama":
810811
cfg.LLM.BaseURL = DefaultOllamaBaseURL
812+
case "shengsuanyun":
813+
cfg.LLM.BaseURL = DefaultShengSuanYunBaseURL
811814
}
812815
}
813816

@@ -817,6 +820,8 @@ func (cfg *Config) ApplyLLMRouting() (provider string, configuredModel string) {
817820
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["OPENAI_API_KEY"])
818821
case "openrouter":
819822
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["OPENROUTER_API_KEY"])
823+
case "shengsuanyun":
824+
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["SHENGSUANYUN_API_KEY"])
820825
case "anthropic":
821826
cfg.LLM.APIKey = strings.TrimSpace(cfg.Env["ANTHROPIC_API_KEY"])
822827
case "gemini":
@@ -841,6 +846,9 @@ func parseRoutedModel(s string) (provider string, model string) {
841846
if after, ok := strings.CutPrefix(s, "openrouter/"); ok {
842847
return "openrouter", after
843848
}
849+
if after, ok := strings.CutPrefix(s, "shengsuanyun/"); ok {
850+
return "shengsuanyun", after
851+
}
844852
if after, ok := strings.CutPrefix(s, "anthropic/"); ok {
845853
return "anthropic", after
846854
}

llm/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (c *Client) Chat(ctx context.Context, messages []Message, tools []ToolDefin
4242
c.HTTP = &http.Client{Timeout: 120 * time.Second}
4343
}
4444
switch normalizeProvider(c.Provider) {
45-
case "", "openai", "openrouter", "ollama":
45+
case "", "openai", "openrouter", "ollama","shengsuanyun":
4646
return c.chatOpenAICompatible(ctx, messages, tools)
4747
case "anthropic":
4848
return c.chatAnthropic(ctx, messages, tools)

0 commit comments

Comments
 (0)