@@ -29,6 +29,7 @@ import (
2929 "time"
3030
3131 "github.com/linuxsuren/atest-ext-ai/pkg/ai/discovery"
32+ "github.com/linuxsuren/atest-ext-ai/pkg/ai/models"
3233 "github.com/linuxsuren/atest-ext-ai/pkg/ai/providers/universal"
3334 "github.com/linuxsuren/atest-ext-ai/pkg/config"
3435 "github.com/linuxsuren/atest-ext-ai/pkg/interfaces"
@@ -543,12 +544,9 @@ func createOpenAICompatibleClient(provider string, cfg config.AIService) (interf
543544 }
544545
545546 if uniCfg .Endpoint == "" {
546- switch normalized {
547- case "openai" :
548- uniCfg .Endpoint = "https://api.openai.com"
549- case "deepseek" :
550- uniCfg .Endpoint = "https://api.deepseek.com"
551- case "custom" :
547+ if endpoint := models .EndpointForProvider (normalized ); endpoint != "" {
548+ uniCfg .Endpoint = endpoint
549+ } else if normalized == "custom" {
552550 return nil , fmt .Errorf ("endpoint is required for custom provider" )
553551 }
554552 }
@@ -585,41 +583,42 @@ func normalizeProviderName(provider string) string {
585583
586584// getOnlineProviders returns predefined online providers
587585func (m * Manager ) getOnlineProviders () []* ProviderInfo {
588- return []* ProviderInfo {
589- {
590- Name : "deepseek" ,
591- Type : "online" ,
592- Available : true ,
593- Endpoint : "https://api.deepseek.com" ,
594- Models : []interfaces.ModelInfo {
595- {ID : "deepseek-chat" , Name : "DeepSeek Chat" , Description : "DeepSeek's flagship conversational AI model" , MaxTokens : 32768 },
596- {ID : "deepseek-reasoner" , Name : "DeepSeek Reasoner" , Description : "DeepSeek's reasoning model with thinking capabilities" , MaxTokens : 32768 },
597- },
598- LastChecked : time .Now (),
599- Config : map [string ]interface {}{
600- "requires_api_key" : true ,
601- "provider_type" : "online" ,
602- },
603- },
604- {
605- Name : "openai" ,
606- Type : "online" ,
607- Available : true ,
608- Endpoint : "https://api.openai.com" ,
609- Models : []interfaces.ModelInfo {
610- {ID : "gpt-5" , Name : "GPT-5" , Description : "OpenAI's flagship GPT-5 model" , MaxTokens : 200000 },
611- {ID : "gpt-5-mini" , Name : "GPT-5 Mini" , Description : "Optimized GPT-5 model for lower latency workloads" , MaxTokens : 80000 },
612- {ID : "gpt-5-nano" , Name : "GPT-5 Nano" , Description : "Cost-efficient GPT-5 variant for lightweight tasks" , MaxTokens : 40000 },
613- {ID : "gpt-5-pro" , Name : "GPT-5 Pro" , Description : "High performance GPT-5 model with extended reasoning" , MaxTokens : 240000 },
614- {ID : "gpt-4.1" , Name : "GPT-4.1" , Description : "Balanced GPT-4 series model with strong multimodal support" , MaxTokens : 128000 },
615- },
586+ catalog , err := models .GetCatalog ()
587+ if err != nil {
588+ logging .Logger .Warn ("Failed to load model catalog" , "error" , err )
589+ return nil
590+ }
591+
592+ var providers []* ProviderInfo
593+ for _ , name := range catalog .ProviderNames () {
594+ entry , ok := catalog .Provider (name )
595+ if ! ok {
596+ continue
597+ }
598+
599+ providerType := entry .Category
600+ if providerType == "" {
601+ providerType = "cloud"
602+ }
603+ if providerType != "cloud" && providerType != "online" {
604+ continue
605+ }
606+
607+ providers = append (providers , & ProviderInfo {
608+ Name : entry .Name ,
609+ Type : providerType ,
610+ Available : true ,
611+ Endpoint : entry .Endpoint ,
612+ Models : entry .Models ,
616613 LastChecked : time .Now (),
617614 Config : map [string ]interface {}{
618- "requires_api_key" : true ,
619- "provider_type" : "online" ,
615+ "requires_api_key" : entry . RequiresAPIKey ,
616+ "provider_type" : providerType ,
620617 },
621- },
618+ })
622619 }
620+
621+ return providers
623622}
624623
625624// ===== Retry Logic =====
0 commit comments