Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions app/MindWork AI Studio/Assistants/I18N/allTexts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5944,6 +5944,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGMETHODDIALOG::T662524223"] = "A lin
-- Cancel
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGMETHODDIALOG::T900713019"] = "Cancel"

-- Hugging Face Inference Provider
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T1085481431"] = "Hugging Face Inference Provider"

-- Failed to store the API key in the operating system. The message was: {0}. Please try again.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T1122745046"] = "Failed to store the API key in the operating system. The message was: {0}. Please try again."

Expand All @@ -5968,6 +5971,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T1847791252"] = "Up
-- Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T1870831108"] = "Failed to load the API key from the operating system. The message was: {0}. You might ignore this message and provide the API key again."

-- Hugging Face offers embeddings through a few of its inference providers only, which is why this list is shorter than the one for chatting.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T194295715"] = "Hugging Face offers embeddings through a few of its inference providers only, which is why this list is shorter than the one for chatting."

-- Model
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::EMBEDDINGPROVIDERDIALOG::T2189814010"] = "Model"

Expand Down Expand Up @@ -6361,6 +6367,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1870831108"] = "Failed to l
-- Speech input
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1874348907"] = "Speech input"

-- Choose which inference provider should answer your requests. When you pick one of the automatic options instead, Hugging Face selects a provider for you and switches to another one when your choice is unavailable.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1889879830"] = "Choose which inference provider should answer your requests. When you pick one of the automatic options instead, Hugging Face selects a provider for you and switches to another one when your choice is unavailable."

-- Please enter a model name.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::PROVIDERDIALOG::T1936099896"] = "Please enter a model name."

Expand Down Expand Up @@ -7987,6 +7996,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SINGLEINPUTDIALOG::T4030229154"] = "Your Inp
-- Cancel
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::SINGLEINPUTDIALOG::T900713019"] = "Cancel"

-- Hugging Face Inference Provider
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T1085481431"] = "Hugging Face Inference Provider"

-- Failed to store the API key in the operating system. The message was: {0}. Please try again.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T1122745046"] = "Failed to store the API key in the operating system. The message was: {0}. Please try again."

Expand Down Expand Up @@ -8029,6 +8041,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T2810182573"] =
-- Instance Name
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T2842060373"] = "Instance Name"

-- Hugging Face transcribes audio through a few of its inference providers only, which is why this list is shorter than the one for chatting.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T3397943774"] = "Hugging Face transcribes audio through a few of its inference providers only, which is why this list is shorter than the one for chatting."

-- Please enter a transcription model name.
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::TRANSCRIPTIONPROVIDERDIALOG::T3703662664"] = "Please enter a transcription model name."

Expand Down Expand Up @@ -9274,6 +9289,21 @@ UI_TEXT_CONTENT["AISTUDIO::PROVIDER::CONFIDENCELEVELEXTENSIONS::T3188327965"] =
-- Very Low
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::CONFIDENCELEVELEXTENSIONS::T786675843"] = "Very Low"

-- Automatic: the cheapest provider
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::HUGGINGFACE::HFINFERENCEPROVIDEREXTENSIONS::T1680748563"] = "Automatic: the cheapest provider"

-- Automatic: your preferred order
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::HUGGINGFACE::HFINFERENCEPROVIDEREXTENSIONS::T2027398472"] = "Automatic: your preferred order"

-- Automatic: the fastest provider
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::HUGGINGFACE::HFINFERENCEPROVIDEREXTENSIONS::T997045984"] = "Automatic: the fastest provider"

-- No Hugging Face inference provider offers the selected model. Please check the model name and whether it is still available on Hugging Face.
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::HUGGINGFACE::PROVIDERHUGGINGFACE::T1055093108"] = "No Hugging Face inference provider offers the selected model. Please check the model name and whether it is still available on Hugging Face."

-- The Hugging Face inference provider '{0}' does not offer the selected model. Please select another inference provider, or let Hugging Face choose one for you.
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::HUGGINGFACE::PROVIDERHUGGINGFACE::T3314840969"] = "The Hugging Face inference provider '{0}' does not offer the selected model. Please select another inference provider, or let Hugging Face choose one for you."

-- Self-hosted
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::LLMPROVIDERSEXTENSIONS::T146444217"] = "Self-hosted"

Expand Down Expand Up @@ -11197,9 +11227,15 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T3550629491"]
-- Please enter an instance name.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T3999823516"] = "Please enter an instance name."

-- This Hugging Face inference provider does not transcribe audio. Please select another one.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T4142849031"] = "This Hugging Face inference provider does not transcribe audio. Please select another one."

-- Please select an Hugging Face inference provider.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T497939286"] = "Please select an Hugging Face inference provider."

-- This Hugging Face inference provider does not create embeddings. Please select another one.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T649507886"] = "This Hugging Face inference provider does not create embeddings. Please select another one."

-- Please select a model.
UI_TEXT_CONTENT["AISTUDIO::TOOLS::VALIDATION::PROVIDERVALIDATION::T818893091"] = "Please select a model."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private async Task EditEmbeddingProvider(EmbeddingProvider embeddingProvider)
{ x => x.IsSelfHosted, embeddingProvider.IsSelfHosted },
{ x => x.IsEditing, true },
{ x => x.DataHost, embeddingProvider.Host },
{ x => x.HFInferenceProviderId, embeddingProvider.HFInferenceProvider },
{ x => x.IsEnterpriseConfiguration, embeddingProvider.IsEnterpriseConfiguration },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private async Task EditTranscriptionProvider(TranscriptionProvider transcription
{ x => x.IsSelfHosted, transcriptionProvider.IsSelfHosted },
{ x => x.IsEditing, true },
{ x => x.DataHost, transcriptionProvider.Host },
{ x => x.HFInferenceProviderId, transcriptionProvider.HFInferenceProvider },
{ x => x.IsEnterpriseConfiguration, transcriptionProvider.IsEnterpriseConfiguration },
};

Expand Down
19 changes: 19 additions & 0 deletions app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using AIStudio.Provider
@using AIStudio.Provider.HuggingFace
@using AIStudio.Provider.SelfHosted
@inherits MSGComponentBase

Expand Down Expand Up @@ -64,6 +65,24 @@
</MudSelect>
}

@if (this.DataLLMProvider.IsHFInstanceProviderNeeded())
{
<MudSelect T="HFInferenceProvider" Value="@this.HFInferenceProviderId" ValueChanged="@this.OnHFInferenceProviderChanged" Label="@T("Hugging Face Inference Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.Dns" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHFInstanceProviderForEmbeddings">
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
{
@if (inferenceProvider.SupportsEmbeddings())
{
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
}
</MudSelect>
<MudJustifiedText Class="mb-3">
@T("Hugging Face offers embeddings through a few of its inference providers only, which is why this list is shorter than the one for chatting.")
</MudJustifiedText>
}

<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">
@if (this.DataLLMProvider.IsEmbeddingModelProvidedManually(this.DataHost))
Expand Down
24 changes: 24 additions & 0 deletions app/MindWork AI Studio/Dialogs/EmbeddingProviderDialog.razor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AIStudio.Components;
using AIStudio.Provider;
using AIStudio.Provider.HuggingFace;
using AIStudio.Settings;
using AIStudio.Tools.Services;
using AIStudio.Tools.Validation;
Expand Down Expand Up @@ -68,6 +69,12 @@ public partial class EmbeddingProviderDialog : MSGComponentBase, ISecretId
/// </summary>
[Parameter]
public Model DataModel { get; set; }

/// <summary>
/// The Hugging Face inference provider to use.
/// </summary>
[Parameter]
public HFInferenceProvider HFInferenceProviderId { get; set; } = HFInferenceProvider.NONE;

/// <summary>
/// Should the dialog be in editing mode?
Expand Down Expand Up @@ -151,6 +158,7 @@ private EmbeddingProvider CreateEmbeddingProviderSettings()
IsEnterpriseConfiguration = this.IsEnterpriseConfiguration,
EnterpriseConfigurationPluginId = Guid.Empty,
CustomIconDataUrl = this.DataCustomIconDataUrl,
HFInferenceProvider = this.HFInferenceProviderId,
};
}

Expand Down Expand Up @@ -316,6 +324,22 @@ private void OnHostChanged(Host selectedHost)
this.dataLoadingModelsIssue = string.Empty;
}

/// <summary>
/// Resets the model selection when the user picks another Hugging Face inference provider.
/// </summary>
/// <remarks>
/// Each inference provider offers embedding models of its own, so the models loaded for the
/// previous one say nothing about the new one.
/// </remarks>
/// <param name="selectedInferenceProvider">The inference provider the user chose.</param>
private void OnHFInferenceProviderChanged(HFInferenceProvider selectedInferenceProvider)
{
this.HFInferenceProviderId = selectedInferenceProvider;
this.DataModel = default;
this.availableModels.Clear();
this.dataLoadingModelsIssue = string.Empty;
}

private async Task ReloadModels()
{
this.dataLoadingModelsIssue = string.Empty;
Expand Down
25 changes: 16 additions & 9 deletions app/MindWork AI Studio/Dialogs/ProviderDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@

@if (this.DataLLMProvider.IsHFInstanceProviderNeeded())
{
<MudSelect @bind-Value="@this.HFInferenceProviderId" Label="@T("Hugging Face Inference Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.Dns" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHFInstanceProvider">
<MudSelect T="HFInferenceProvider" Value="@this.HFInferenceProviderId" ValueChanged="@this.OnHFInferenceProviderChanged" Label="@T("Hugging Face Inference Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.Dns" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHFInstanceProvider">
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
{
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
@if (inferenceProvider.SupportsChat())
{
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
}
</MudSelect>
@* ReSharper disable Asp.Entity *@
<MudJustifiedText Class="mb-3">
Please double-check if your model name matches the curl specifications provided by the inference provider. If it doesn't, you might get a <b>Not Found</b> error when trying to use the model. Here's a <MudLink Href="https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct?inference_api=true&inference_provider=novita&language=sh" Target="_blank">curl example</MudLink>.
@T("Choose which inference provider should answer your requests. When you pick one of the automatic options instead, Hugging Face selects a provider for you and switches to another one when your choice is unavailable.")
</MudJustifiedText>
@* ReSharper restore Asp.Entity *@
}

@if (!this.IsLLMModelSelectionHidden)
Expand All @@ -90,7 +91,7 @@
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">
@if (this.DataLLMProvider.IsLLMModelProvidedManually())
{
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.DataLLMProvider.GetModelsOverviewURL(this.HFInferenceProviderId)" Target="_blank">
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.ModelsOverviewURL" Target="_blank">
@T("Show available models")
</MudButton>
<MudTextField
Expand All @@ -108,6 +109,12 @@
}
else
{
@if (!string.IsNullOrWhiteSpace(this.ModelsOverviewURL))
{
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.ModelsOverviewURL" Target="_blank">
@T("Show available models")
</MudButton>
}
<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 models")
</MudButton>
Expand Down
25 changes: 24 additions & 1 deletion app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ protected override async Task OnInitializedAsync()
{
this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();

// When using Fireworks or Hugging Face, we must copy the model name:
// When using Fireworks, we must copy the model name:
if (this.DataLLMProvider.IsLLMModelProvidedManually())
this.dataManuallyModel = this.DataModel.Id;

Expand Down Expand Up @@ -372,6 +372,24 @@ private void OnProviderChanged(LLMProviders selectedProvider)
this.usesLegacySystemModelFallback = false;
}

/// <summary>
/// Resets the model selection when the user picks another Hugging Face inference provider.
/// </summary>
/// <remarks>
/// Which models are on offer depends on the inference provider, so the models loaded for the
/// previous one say nothing about the new one. Keeping them would let the user pick a model
/// their provider does not serve, which the router answers with an error.
/// </remarks>
/// <param name="selectedInferenceProvider">The inference provider the user chose.</param>
private void OnHFInferenceProviderChanged(HFInferenceProvider selectedInferenceProvider)
{
this.HFInferenceProviderId = selectedInferenceProvider;
this.DataModel = default;
this.capabilityOverrides = new();
this.availableModels.Clear();
this.dataLoadingModelsIssue = string.Empty;
}

private void OnHostChanged(Host selectedHost)
{
// When the host changes, reset the model selection state:
Expand Down Expand Up @@ -430,6 +448,11 @@ this.DataLLMProvider is LLMProviders.SELF_HOSTED &&
this.DataHost is Host.LLAMA_CPP &&
this.usesLegacySystemModelFallback;

/// <summary>
/// The catalog of the provider, where the user can read up on the models before choosing one.
/// </summary>
private string ModelsOverviewURL => this.DataLLMProvider.GetModelsOverviewURL(this.HFInferenceProviderId);

private void UpdateModelSelectionAfterLoading()
{
if (this.DataLLMProvider is not LLMProviders.SELF_HOSTED || this.DataHost is not Host.LLAMA_CPP)
Expand Down
19 changes: 19 additions & 0 deletions app/MindWork AI Studio/Dialogs/TranscriptionProviderDialog.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using AIStudio.Provider
@using AIStudio.Provider.HuggingFace
@using AIStudio.Provider.SelfHosted
@inherits MSGComponentBase

Expand Down Expand Up @@ -64,6 +65,24 @@
</MudSelect>
}

@if (this.DataLLMProvider.IsHFInstanceProviderNeeded())
{
<MudSelect T="HFInferenceProvider" Value="@this.HFInferenceProviderId" ValueChanged="@this.OnHFInferenceProviderChanged" Label="@T("Hugging Face Inference Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.Dns" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHFInstanceProviderForTranscription">
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
{
@if (inferenceProvider.SupportsTranscription())
{
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
}
</MudSelect>
<MudJustifiedText Class="mb-3">
@T("Hugging Face transcribes audio through a few of its inference providers only, which is why this list is shorter than the one for chatting.")
</MudJustifiedText>
}

@if (!this.DataLLMProvider.IsTranscriptionModelSelectionHidden(this.DataHost))
{
<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
Expand Down
Loading