mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 02:41:37 +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
|
||||
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
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T808120719"] = "Host"
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
<MudSelect Disabled="@this.IsNoneProvider" @bind-Value="@this.DataModel" Label="@T("Model")"
|
||||
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural"
|
||||
AdornmentColor="Color.Info" Adornment="Adornment.Start"
|
||||
Validation="@this.providerValidation.ValidatingModel">
|
||||
Validation="@this.ValidateSelectedModel">
|
||||
@foreach (var model in this.availableModels)
|
||||
{
|
||||
<MudSelectItem Value="@model">
|
||||
|
||||
@ -216,7 +216,16 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
||||
{
|
||||
await this.form.Validate();
|
||||
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:
|
||||
if (!this.dataIsValid)
|
||||
return;
|
||||
@ -243,7 +252,28 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
||||
{
|
||||
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED && string.IsNullOrWhiteSpace(manuallyModel))
|
||||
return T("Please enter a transcription model name.");
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user