mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 11:58:00 +00:00
Store the model a self-hosted transcription provider was given
This commit is contained in:
3 files changed
+21
-81
No files matched your search
@@ -87,47 +87,28 @@
|
|||||||
{
|
{
|
||||||
<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
|
<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
|
||||||
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">
|
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">
|
||||||
@if (this.DataLLMProvider.IsTranscriptionModelProvidedManually(this.DataHost))
|
<MudButton Disabled="@(this.IsEnterpriseConfiguration || !this.DataLLMProvider.CanLoadModels(this.DataHost, this.dataAPIKey))" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Refresh" OnClick="@this.ReloadModels">
|
||||||
|
@T("Load")
|
||||||
|
</MudButton>
|
||||||
|
@if(this.availableModels.Count is 0)
|
||||||
{
|
{
|
||||||
<MudTextField
|
<MudText Typo="Typo.body1">
|
||||||
T="string"
|
@T("No models loaded or available.")
|
||||||
@bind-Text="@this.dataManuallyModel"
|
</MudText>
|
||||||
Label="@T("Model")"
|
|
||||||
Class="mb-3"
|
|
||||||
Adornment="Adornment.Start"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.Dns"
|
|
||||||
AdornmentColor="Color.Info"
|
|
||||||
Disabled="@this.IsEnterpriseConfiguration"
|
|
||||||
Validation="@this.ValidateManuallyModel"
|
|
||||||
UserAttributes="@SPELLCHECK_ATTRIBUTES"
|
|
||||||
HelperText="@T("Currently, we cannot query the transcription models for the selected provider and/or host. Therefore, please enter the model name manually.")"
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudButton Disabled="@(this.IsEnterpriseConfiguration || !this.DataLLMProvider.CanLoadModels(this.DataHost, this.dataAPIKey))" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Refresh" OnClick="@this.ReloadModels">
|
<MudSelect Disabled="@(this.IsEnterpriseConfiguration || this.IsNoneProvider)" @bind-Value="@this.DataModel" Label="@T("Model")"
|
||||||
@T("Load")
|
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural"
|
||||||
</MudButton>
|
AdornmentColor="Color.Info" Adornment="Adornment.Start"
|
||||||
@if(this.availableModels.Count is 0)
|
Validation="@this.providerValidation.ValidatingModel">
|
||||||
{
|
@foreach (var model in this.availableModels)
|
||||||
<MudText Typo="Typo.body1">
|
{
|
||||||
@T("No models loaded or available.")
|
<MudSelectItem Value="@model">
|
||||||
</MudText>
|
@model
|
||||||
}
|
</MudSelectItem>
|
||||||
else
|
}
|
||||||
{
|
</MudSelect>
|
||||||
<MudSelect Disabled="@(this.IsEnterpriseConfiguration || this.IsNoneProvider)" @bind-Value="@this.DataModel" Label="@T("Model")"
|
|
||||||
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural"
|
|
||||||
AdornmentColor="Color.Info" Adornment="Adornment.Start"
|
|
||||||
Validation="@this.providerValidation.ValidatingModel">
|
|
||||||
@foreach (var model in this.availableModels)
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="@model">
|
|
||||||
@model
|
|
||||||
</MudSelectItem>
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</MudStack>
|
</MudStack>
|
||||||
@if (!string.IsNullOrWhiteSpace(this.dataLoadingModelsIssue))
|
@if (!string.IsNullOrWhiteSpace(this.dataLoadingModelsIssue))
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
private string[] dataIssues = [];
|
private string[] dataIssues = [];
|
||||||
private string dataAPIKey = string.Empty;
|
private string dataAPIKey = string.Empty;
|
||||||
private bool dataHadStoredAPIKeyOnLoad;
|
private bool dataHadStoredAPIKeyOnLoad;
|
||||||
private string dataManuallyModel = string.Empty;
|
|
||||||
private string dataAPIKeyStorageIssue = string.Empty;
|
private string dataAPIKeyStorageIssue = string.Empty;
|
||||||
private string dataEditingPreviousInstanceName = string.Empty;
|
private string dataEditingPreviousInstanceName = string.Empty;
|
||||||
private string dataLoadingModelsIssue = string.Empty;
|
private string dataLoadingModelsIssue = string.Empty;
|
||||||
@@ -127,7 +126,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
GetPreviousInstanceName = () => this.dataEditingPreviousInstanceName,
|
GetPreviousInstanceName = () => this.dataEditingPreviousInstanceName,
|
||||||
GetUsedInstanceNames = () => this.UsedInstanceNames,
|
GetUsedInstanceNames = () => this.UsedInstanceNames,
|
||||||
GetHost = () => this.DataHost,
|
GetHost = () => this.DataHost,
|
||||||
IsModelProvidedManually = () => this.DataLLMProvider.IsTranscriptionModelProvidedManually(this.DataHost),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,30 +133,9 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
{
|
{
|
||||||
var cleanedHostname = this.DataHostname.Trim();
|
var cleanedHostname = this.DataHostname.Trim();
|
||||||
|
|
||||||
// Determine the model based on the provider and host configuration:
|
// whisper.cpp serves whatever it was started with and names no models, so the placeholder
|
||||||
Model model;
|
// stands in for the one model there is. Everywhere else the user picked one from the list:
|
||||||
if (this.DataLLMProvider.IsTranscriptionModelSelectionHidden(this.DataHost))
|
var model = this.DataLLMProvider.IsTranscriptionModelSelectionHidden(this.DataHost) ? Model.SYSTEM_MODEL : this.DataModel;
|
||||||
{
|
|
||||||
// Use system model placeholder for hosts that don't support model selection (e.g., whisper.cpp):
|
|
||||||
model = Model.SYSTEM_MODEL;
|
|
||||||
}
|
|
||||||
else if (this.DataLLMProvider is LLMProviders.SELF_HOSTED)
|
|
||||||
{
|
|
||||||
switch (this.DataHost)
|
|
||||||
{
|
|
||||||
case Host.OLLAMA:
|
|
||||||
model = new Model(this.dataManuallyModel, null);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Host.VLLM:
|
|
||||||
case Host.LM_STUDIO:
|
|
||||||
default:
|
|
||||||
model = this.DataModel;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
model = this.DataModel;
|
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
@@ -195,10 +172,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
{
|
{
|
||||||
this.dataEditingPreviousInstanceName = this.DataName.ToLowerInvariant();
|
this.dataEditingPreviousInstanceName = this.DataName.ToLowerInvariant();
|
||||||
|
|
||||||
// When using self-hosted models, we must copy the model name:
|
|
||||||
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED)
|
|
||||||
this.dataManuallyModel = this.DataModel.Id;
|
|
||||||
|
|
||||||
// Load the API key. A self-hosted server may well need one: LM Studio can ask for a
|
// Load the API key. A self-hosted server may well need one: LM Studio can ask for a
|
||||||
// token of its own, and any of these servers can sit behind an authenticating proxy.
|
// token of its own, and any of these servers can sit behind an authenticating proxy.
|
||||||
// So we try for every host and treat a missing key as the normal case (isTrying).
|
// So we try for every host and treat a missing key as the normal case (isTrying).
|
||||||
@@ -302,14 +275,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
this.MudDialog.Close(DialogResult.Ok(addedProviderSettings));
|
this.MudDialog.Close(DialogResult.Ok(addedProviderSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string? ValidateManuallyModel(string manuallyModel)
|
|
||||||
{
|
|
||||||
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED && string.IsNullOrWhiteSpace(manuallyModel))
|
|
||||||
return T("Please enter a transcription model name.");
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -327,7 +292,6 @@ public partial class TranscriptionProviderDialog : MSGComponentBase, ISecretId
|
|||||||
// When the host changes, reset the model selection state:
|
// When the host changes, reset the model selection state:
|
||||||
this.DataHost = selectedHost;
|
this.DataHost = selectedHost;
|
||||||
this.DataModel = default;
|
this.DataModel = default;
|
||||||
this.dataManuallyModel = string.Empty;
|
|
||||||
this.availableModels.Clear();
|
this.availableModels.Clear();
|
||||||
this.dataLoadingModelsIssue = string.Empty;
|
this.dataLoadingModelsIssue = string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -421,11 +421,6 @@ public static class LLMProvidersExtensions
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool IsTranscriptionModelProvidedManually(this LLMProviders provider, Host host) => provider switch
|
|
||||||
{
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the model selection should be completely hidden for LLM providers.
|
/// Determines if the model selection should be completely hidden for LLM providers.
|
||||||
/// This is the case when the host does not support model selection.
|
/// This is the case when the host does not support model selection.
|
||||||
|
|||||||
Reference in new issue
Block a user