mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 02:41:37 +00:00
Fixed a bug that allowed adding a provider without selecting a model
This commit is contained in:
parent
3eb3515634
commit
839068ff34
@ -4636,9 +4636,6 @@ 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"
|
||||
|
||||
|
||||
@ -102,6 +102,7 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
|
||||
GetPreviousInstanceName = () => this.dataEditingPreviousInstanceName,
|
||||
GetUsedInstanceNames = () => this.UsedInstanceNames,
|
||||
GetHost = () => this.DataHost,
|
||||
IsModelProvidedManually = () => this.DataLLMProvider is LLMProviders.SELF_HOSTED && this.DataHost is Host.OLLAMA,
|
||||
};
|
||||
}
|
||||
|
||||
@ -208,7 +209,16 @@ public partial class EmbeddingProviderDialog : 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.providerValidation.ValidatingModel(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;
|
||||
|
||||
@ -115,6 +115,7 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
GetPreviousInstanceName = () => this.dataEditingPreviousInstanceName,
|
||||
GetUsedInstanceNames = () => this.UsedInstanceNames,
|
||||
GetHost = () => this.DataHost,
|
||||
IsModelProvidedManually = () => this.DataLLMProvider.IsLLMModelProvidedManually(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -222,7 +223,16 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
await this.form.Validate();
|
||||
if (!string.IsNullOrWhiteSpace(this.dataAPIKeyStorageIssue))
|
||||
this.dataAPIKeyStorageIssue = string.Empty;
|
||||
|
||||
|
||||
// Manually validate the model selection (needed when no models are loaded
|
||||
// and the MudSelect is not rendered):
|
||||
var modelValidationError = this.providerValidation.ValidatingModel(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;
|
||||
|
||||
@ -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.ValidateSelectedModel">
|
||||
Validation="@this.providerValidation.ValidatingModel">
|
||||
@foreach (var model in this.availableModels)
|
||||
{
|
||||
<MudSelectItem Value="@model">
|
||||
|
||||
@ -102,6 +102,7 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
||||
GetPreviousInstanceName = () => this.dataEditingPreviousInstanceName,
|
||||
GetUsedInstanceNames = () => this.UsedInstanceNames,
|
||||
GetHost = () => this.DataHost,
|
||||
IsModelProvidedManually = () => this.DataLLMProvider.IsTranscriptionModelProvidedManually(this.DataHost),
|
||||
};
|
||||
}
|
||||
|
||||
@ -219,7 +220,7 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
||||
|
||||
// Manually validate the model selection (needed when no models are loaded
|
||||
// and the MudSelect is not rendered):
|
||||
var modelValidationError = this.ValidateSelectedModel(this.DataModel);
|
||||
var modelValidationError = this.providerValidation.ValidatingModel(this.DataModel);
|
||||
if (!string.IsNullOrWhiteSpace(modelValidationError))
|
||||
{
|
||||
this.dataIssues = [..this.dataIssues, modelValidationError];
|
||||
@ -256,27 +257,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
||||
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 async Task OnAPIKeyChanged(string apiKey)
|
||||
|
||||
@ -19,7 +19,9 @@ public sealed class ProviderValidation
|
||||
public Func<IEnumerable<string>> GetUsedInstanceNames { get; init; } = () => [];
|
||||
|
||||
public Func<Host> GetHost { get; init; } = () => Host.NONE;
|
||||
|
||||
|
||||
public Func<bool> IsModelProvidedManually { get; init; } = () => false;
|
||||
|
||||
public string? ValidatingHostname(string hostname)
|
||||
{
|
||||
if(this.GetProvider() != LLMProviders.SELF_HOSTED)
|
||||
@ -70,12 +72,22 @@ public sealed class ProviderValidation
|
||||
|
||||
public string? ValidatingModel(Model model)
|
||||
{
|
||||
if(this.GetProvider() is LLMProviders.SELF_HOSTED && this.GetHost() == Host.LLAMA_CPP)
|
||||
// For NONE providers, no validation is needed:
|
||||
if (this.GetProvider() is LLMProviders.NONE)
|
||||
return null;
|
||||
|
||||
|
||||
// For self-hosted llama.cpp or whisper.cpp, no model selection needed
|
||||
// (model is loaded at startup):
|
||||
if (this.GetProvider() is LLMProviders.SELF_HOSTED && this.GetHost() is Host.LLAMA_CPP or Host.WHISPER_CPP)
|
||||
return null;
|
||||
|
||||
// For manually entered models, this validation doesn't apply:
|
||||
if (this.IsModelProvidedManually())
|
||||
return null;
|
||||
|
||||
if (model == default)
|
||||
return TB("Please select a model.");
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# v26.1.2, build 232 (2026-01-xx xx:xx UTC)
|
||||
- Added the option to hide specific assistants by configuration plugins. This is useful for enterprise environments in organizations.
|
||||
- Fixed a logging bug that prevented log events from being recorded in some cases.
|
||||
- Fixed a logging bug that prevented log events from being recorded in some cases.
|
||||
- Fixed a bug that allowed adding a provider without selecting a model.
|
||||
Loading…
Reference in New Issue
Block a user