mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 07:41:36 +00:00
Enforced model validation
This commit is contained in:
parent
165f833954
commit
3eb3515634
@ -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"
|
||||||
|
|
||||||
|
|||||||
@ -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">
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user