diff options
| author | Grail Finder <wohilas@gmail.com> | 2025-11-24 12:00:46 +0300 |
|---|---|---|
| committer | Grail Finder <wohilas@gmail.com> | 2025-11-24 12:00:46 +0300 |
| commit | 8a62e987894dc6b0b083d23acfcfad9547fa1106 (patch) | |
| tree | 91f2b3b866874815c162a5333e77e0b6f73f82a4 /config | |
| parent | 504af1a2132ca51f50ab24cd95f2690a4d45323e (diff) | |
Fix: apilinks rotation
Diffstat (limited to 'config')
| -rw-r--r-- | config/config.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/config/config.go b/config/config.go index fab9259..681757d 100644 --- a/config/config.go +++ b/config/config.go @@ -84,10 +84,33 @@ func LoadConfig(fn string) (*Config, error) { config.OpenRouterCompletionAPI: config.OpenRouterChatAPI, config.OpenRouterChatAPI: config.ChatAPI, } - for _, el := range []string{config.ChatAPI, config.CompletionAPI, config.DeepSeekChatAPI, config.DeepSeekCompletionAPI} { - if el != "" { - config.ApiLinks = append(config.ApiLinks, el) + // Build ApiLinks slice with only non-empty API links + // Only include DeepSeek APIs if DeepSeekToken is provided + if config.DeepSeekToken != "" { + if config.DeepSeekChatAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.DeepSeekChatAPI) } + if config.DeepSeekCompletionAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.DeepSeekCompletionAPI) + } + } + + // Only include OpenRouter APIs if OpenRouterToken is provided + if config.OpenRouterToken != "" { + if config.OpenRouterChatAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.OpenRouterChatAPI) + } + if config.OpenRouterCompletionAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.OpenRouterCompletionAPI) + } + } + + // Always include basic APIs + if config.ChatAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.ChatAPI) + } + if config.CompletionAPI != "" { + config.ApiLinks = append(config.ApiLinks, config.CompletionAPI) } // if any value is empty fill with default return config, nil |
