diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index 8eb924bb..286c4fa6 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -540,12 +540,18 @@ public sealed class SettingsManager /// since they honor the confidence levels. /// /// - /// The returned list is the live provider list. It is read-only for callers: adding, editing, - /// or removing providers stays inside the settings UI. + /// The returned list is a sorted copy of the provider list, ordered by the used LLM provider and + /// then by the instance name. This way, all providers of the same LLM provider stay together, and + /// newly added providers appear at their alphabetical position instead of at the end. Callers must + /// not mutate the returned list: adding, editing, or removing providers stays inside the settings UI. /// /// /// All configured providers, unfiltered. - public IReadOnlyList GetAllProviders() => this.ConfigurationData.Providers; + public IReadOnlyList GetAllProviders() => this.ConfigurationData.Providers + .OrderBy(x => x.UsedLLMProvider.ToName(), StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.InstanceName, StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.Num) + .ToList(); /// /// Returns the provider with the given id, without applying any confidence filtering. @@ -605,15 +611,45 @@ public sealed class SettingsManager /// /// The component for which the providers get filtered. /// An explicit minimum level, which is applied when it is higher than the component's minimum. - /// All providers the component may use. + /// All providers the component may use, in the same order as GetAllProviders. public IEnumerable GetConfidentProviders(Tools.Components component, ConfidenceLevel explicitMinimum = ConfidenceLevel.UNKNOWN) { var minimumLevel = this.GetEffectiveMinimumConfidenceLevel(component, explicitMinimum); - foreach (var provider in this.ConfigurationData.Providers) + foreach (var provider in this.GetAllProviders()) if (provider.UsedLLMProvider is not LLMProviders.NONE && provider.UsedLLMProvider.GetConfidence(this).Level >= minimumLevel) yield return provider; } + /// + /// Returns all configured embedding providers. + /// + /// + /// The returned list is a sorted copy of the embedding provider list, ordered by the used LLM + /// provider and then by the name. Callers must not mutate the returned list: adding, editing, or + /// removing embedding providers stays inside the settings UI. + /// + /// All configured embedding providers. + public IReadOnlyList GetAllEmbeddingProviders() => this.ConfigurationData.EmbeddingProviders + .OrderBy(x => x.UsedLLMProvider.ToName(), StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.Name, StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.Num) + .ToList(); + + /// + /// Returns all configured transcription providers. + /// + /// + /// The returned list is a sorted copy of the transcription provider list, ordered by the used LLM + /// provider and then by the name. Callers must not mutate the returned list: adding, editing, or + /// removing transcription providers stays inside the settings UI. + /// + /// All configured transcription providers. + public IReadOnlyList GetAllTranscriptionProviders() => this.ConfigurationData.TranscriptionProviders + .OrderBy(x => x.UsedLLMProvider.ToName(), StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.Name, StringComparer.OrdinalIgnoreCase) + .ThenBy(x => x.Num) + .ToList(); + public Profile GetPreselectedProfile(Tools.Components component) { var preselection = component.GetProfilePreselection(this);