fix:Openrouter in providers and modellist
This commit is contained in:
parent
ec6da7a530
commit
81c8c07b79
1 changed files with 15 additions and 3 deletions
|
|
@ -18,9 +18,21 @@ import (
|
||||||
func CreateProvider(cfg *config.Config) (LLMProvider, string, error) {
|
func CreateProvider(cfg *config.Config) (LLMProvider, string, error) {
|
||||||
model := cfg.Agents.Defaults.GetModelName()
|
model := cfg.Agents.Defaults.GetModelName()
|
||||||
|
|
||||||
// Ensure model_list is populated (should be done by LoadConfig, but handle edge cases)
|
// Ensure model_list is populated from providers config if needed
|
||||||
if len(cfg.ModelList) == 0 && cfg.HasProvidersConfig() {
|
// This handles two cases:
|
||||||
cfg.ModelList = config.ConvertProvidersToModelList(cfg)
|
// 1. ModelList is empty - convert all providers
|
||||||
|
// 2. ModelList has some entries but not all providers - merge missing ones
|
||||||
|
if cfg.HasProvidersConfig() {
|
||||||
|
providerModels := config.ConvertProvidersToModelList(cfg)
|
||||||
|
existingModelNames := make(map[string]bool)
|
||||||
|
for _, m := range cfg.ModelList {
|
||||||
|
existingModelNames[m.ModelName] = true
|
||||||
|
}
|
||||||
|
for _, pm := range providerModels {
|
||||||
|
if !existingModelNames[pm.ModelName] {
|
||||||
|
cfg.ModelList = append(cfg.ModelList, pm)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must have model_list at this point
|
// Must have model_list at this point
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue