Enforced model validation

This commit is contained in:
Thorsten Sommer 2026-01-13 20:03:31 +01:00
parent 165f833954
commit 3eb3515634
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 36 additions and 3 deletions

View File

@ -4636,6 +4636,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T3703662664"] =
-- Model selection -- Model selection
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T416738168"] = "Model selection" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T416738168"] = "Model selection"
-- Please select a transcription model.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T794751523"] = "Please select a transcription model."
-- Host -- Host
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T808120719"] = "Host" UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T808120719"] = "Host"

View File

@ -90,7 +90,7 @@
<MudSelect Disabled="@this.IsNoneProvider" @bind-Value="@this.DataModel" Label="@T("Model")" <MudSelect Disabled="@this.IsNoneProvider" @bind-Value="@this.DataModel" Label="@T("Model")"
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural" OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural"
AdornmentColor="Color.Info" Adornment="Adornment.Start" AdornmentColor="Color.Info" Adornment="Adornment.Start"
Validation="@this.providerValidation.ValidatingModel"> Validation="@this.ValidateSelectedModel">
@foreach (var model in this.availableModels) @foreach (var model in this.availableModels)
{ {
<MudSelectItem Value="@model"> <MudSelectItem Value="@model">

View File

@ -217,6 +217,15 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
await this.form.Validate(); await this.form.Validate();
this.dataAPIKeyStorageIssue = string.Empty; this.dataAPIKeyStorageIssue = string.Empty;
// Manually validate the model selection (needed when no models are loaded
// and the MudSelect is not rendered):
var modelValidationError = this.ValidateSelectedModel(this.DataModel);
if (!string.IsNullOrWhiteSpace(modelValidationError))
{
this.dataIssues = [..this.dataIssues, modelValidationError];
this.dataIsValid = false;
}
// When the data is not valid, we don't store it: // When the data is not valid, we don't store it:
if (!this.dataIsValid) if (!this.dataIsValid)
return; return;
@ -247,6 +256,27 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
return null; return null;
} }
private string? ValidateSelectedModel(Model model)
{
// Exception for self-hosted whisper.cpp - no model selection needed:
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED && this.DataHost is Host.WHISPER_CPP)
return null;
// For manually entered models, this validation doesn't apply:
if (this.DataLLMProvider.IsTranscriptionModelProvidedManually(this.DataHost))
return null;
// For NONE providers, no validation is needed yet:
if (this.DataLLMProvider is LLMProviders.NONE)
return null;
// Check if a model is selected:
if (model == default)
return T("Please select a transcription model.");
return null;
}
private void Cancel() => this.MudDialog.Cancel(); private void Cancel() => this.MudDialog.Cancel();
private async Task OnAPIKeyChanged(string apiKey) private async Task OnAPIKeyChanged(string apiKey)