Skip to content

Commit 3584c0c

Browse files
authored
Merge pull request #766 from penzhan8451/main
fix: openrouter in providers and modellist length is greater than 0
2 parents 8a1fb03 + a161bf9 commit 3584c0c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pkg/providers/legacy_provider.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,21 @@ import (
1818
func CreateProvider(cfg *config.Config) (LLMProvider, string, error) {
1919
model := cfg.Agents.Defaults.GetModelName()
2020

21-
// Ensure model_list is populated (should be done by LoadConfig, but handle edge cases)
22-
if len(cfg.ModelList) == 0 && cfg.HasProvidersConfig() {
23-
cfg.ModelList = config.ConvertProvidersToModelList(cfg)
21+
// Ensure model_list is populated from providers config if needed
22+
// This handles two cases:
23+
// 1. ModelList is empty - convert all providers
24+
// 2. ModelList has some entries but not all providers - merge missing ones
25+
if cfg.HasProvidersConfig() {
26+
providerModels := config.ConvertProvidersToModelList(cfg)
27+
existingModelNames := make(map[string]bool)
28+
for _, m := range cfg.ModelList {
29+
existingModelNames[m.ModelName] = true
30+
}
31+
for _, pm := range providerModels {
32+
if !existingModelNames[pm.ModelName] {
33+
cfg.ModelList = append(cfg.ModelList, pm)
34+
}
35+
}
2436
}
2537

2638
// Must have model_list at this point

0 commit comments

Comments
 (0)