Fix model state after switching the host

This commit is contained in:
Thorsten Sommer 2026-01-18 17:12:49 +01:00
parent 8605bf12ab
commit eb34b9bd34
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
6 changed files with 35 additions and 5 deletions

View File

@ -44,7 +44,7 @@
@if (this.DataLLMProvider.IsHostNeeded()) @if (this.DataLLMProvider.IsHostNeeded())
{ {
<MudSelect @bind-Value="@this.DataHost" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost"> <MudSelect T="Host" Value="@this.DataHost" ValueChanged="@this.OnHostChanged" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost">
@foreach (Host host in Enum.GetValues(typeof(Host))) @foreach (Host host in Enum.GetValues(typeof(Host)))
{ {
if (host.IsEmbeddingSupported()) if (host.IsEmbeddingSupported())

View File

@ -264,7 +264,17 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
} }
} }
private void OnHostChanged(Host selectedHost)
{
// When the host changes, reset the model selection state:
this.DataHost = selectedHost;
this.DataModel = default;
this.dataManuallyModel = string.Empty;
this.availableModels.Clear();
this.dataLoadingModelsIssue = string.Empty;
}
private async Task ReloadModels() private async Task ReloadModels()
{ {
this.dataLoadingModelsIssue = string.Empty; this.dataLoadingModelsIssue = string.Empty;

View File

@ -41,7 +41,7 @@
@if (this.DataLLMProvider.IsHostNeeded()) @if (this.DataLLMProvider.IsHostNeeded())
{ {
<MudSelect @bind-Value="@this.DataHost" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost"> <MudSelect T="Host" Value="@this.DataHost" ValueChanged="@this.OnHostChanged" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost">
@foreach (Host host in Enum.GetValues(typeof(Host))) @foreach (Host host in Enum.GetValues(typeof(Host)))
{ {
@if (host.IsChatSupported()) @if (host.IsChatSupported())

View File

@ -288,6 +288,16 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
} }
} }
private void OnHostChanged(Host selectedHost)
{
// When the host changes, reset the model selection state:
this.DataHost = selectedHost;
this.DataModel = default;
this.dataManuallyModel = string.Empty;
this.availableModels.Clear();
this.dataLoadingModelsIssue = string.Empty;
}
private async Task ReloadModels() private async Task ReloadModels()
{ {

View File

@ -44,7 +44,7 @@
@if (this.DataLLMProvider.IsHostNeeded()) @if (this.DataLLMProvider.IsHostNeeded())
{ {
<MudSelect @bind-Value="@this.DataHost" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost"> <MudSelect T="Host" Value="@this.DataHost" ValueChanged="@this.OnHostChanged" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost">
@foreach (Host host in Enum.GetValues(typeof(Host))) @foreach (Host host in Enum.GetValues(typeof(Host)))
{ {
if (host.IsTranscriptionSupported()) if (host.IsTranscriptionSupported())

View File

@ -279,7 +279,17 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
} }
} }
private void OnHostChanged(Host selectedHost)
{
// When the host changes, reset the model selection state:
this.DataHost = selectedHost;
this.DataModel = default;
this.dataManuallyModel = string.Empty;
this.availableModels.Clear();
this.dataLoadingModelsIssue = string.Empty;
}
private async Task ReloadModels() private async Task ReloadModels()
{ {
this.dataLoadingModelsIssue = string.Empty; this.dataLoadingModelsIssue = string.Empty;