2024-04-19 19:25:44 +00:00
@using AIStudio.Provider
2025-04-11 12:31:10 +00:00
@using AIStudio.Provider.HuggingFace
2024-07-16 08:28:13 +00:00
@using AIStudio.Provider.SelfHosted
2025-04-27 10:27:10 +00:00
@inherits MSGComponentBase
2024-04-19 19:25:44 +00:00
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
2024-07-03 18:31:04 +00:00
<MudStack Row="@true" AlignItems="AlignItems.Center">
@* ReSharper disable once CSharpWarnings::CS8974 *@
2025-04-27 10:27:10 +00:00
<MudSelect @bind-Value="@this.DataLLMProvider" Label="@T("Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.AccountBalance" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingProvider">
2024-09-13 19:50:00 +00:00
@foreach (LLMProviders provider in Enum.GetValues(typeof(LLMProviders)))
2024-07-03 18:31:04 +00:00
{
2025-04-20 10:42:42 +00:00
<MudSelectItem Value="@provider">
@provider.ToName()
</MudSelectItem>
2024-07-03 18:31:04 +00:00
}
</MudSelect>
2025-04-27 10:27:10 +00:00
<MudButton Disabled="@(!this.DataLLMProvider.ShowRegisterButton())" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.DataLLMProvider.GetCreationURL()" Target="_blank">
@T("Create account")
</MudButton>
2024-07-03 18:31:04 +00:00
</MudStack>
2025-04-20 10:42:42 +00:00
@if (this.DataLLMProvider.IsAPIKeyNeeded(this.DataHost))
{
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.dataAPIKey"
Label="@this.APIKeyText"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.VpnKey"
AdornmentColor="Color.Info"
InputType="InputType.Password"
2025-04-24 09:43:16 +00:00
Immediate="true"
2025-04-20 10:42:42 +00:00
Validation="@this.providerValidation.ValidatingAPIKey"/>
}
2024-05-19 14:12:07 +00:00
2025-04-11 12:31:10 +00:00
@if (this.DataLLMProvider.IsHostnameNeeded())
{
<MudTextField
T="string"
@bind-Text="@this.DataHostname"
2025-04-27 10:27:10 +00:00
Label="@T("Hostname")"
2025-04-11 12:31:10 +00:00
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Dns"
AdornmentColor="Color.Info"
Validation="@this.providerValidation.ValidatingHostname"
UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
}
@if (this.DataLLMProvider.IsHostNeeded())
{
2025-04-27 10:27:10 +00:00
<MudSelect @bind-Value="@this.DataHost" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingHost">
2025-04-11 12:31:10 +00:00
@foreach (Host host in Enum.GetValues(typeof(Host)))
{
2025-04-20 10:42:42 +00:00
<MudSelectItem Value="@host">
@host.Name()
</MudSelectItem>
2025-04-11 12:31:10 +00:00
}
</MudSelect>
}
@if (this.DataLLMProvider.IsHFInstanceProviderNeeded())
{
2025-04-27 10:27:10 +00:00
<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" Validation="@this.providerValidation.ValidatingHFInstanceProvider">
2025-04-20 13:24:43 +00:00
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
2025-04-11 12:31:10 +00:00
{
2025-04-20 13:24:43 +00:00
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
2025-04-26 16:55:23 +00:00
}
2025-04-11 12:31:10 +00:00
</MudSelect>
2025-04-26 16:55:23 +00:00
@* ReSharper disable Asp.Entity *@
2025-04-27 10:27:10 +00:00
<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>.
</MudJustifiedText>
2025-04-26 16:55:23 +00:00
@* ReSharper restore Asp.Entity *@
}
2024-07-16 08:28:13 +00:00
2025-04-24 09:43:16 +00:00
<MudField FullWidth="true" Label="Model selection" Variant="Variant.Outlined" Class="mb-3">
<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">
2025-04-27 10:27:10 +00:00
@T("Show available models")
2025-04-24 09:43:16 +00:00
</MudButton>
<MudTextField
T="string"
@bind-Text="@this.dataManuallyModel"
2025-04-27 10:27:10 +00:00
Label="@T("Model")"
2025-04-24 09:43:16 +00:00
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.FaceRetouchingNatural"
AdornmentColor="Color.Info"
Validation="@this.ValidateManuallyModel"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
/>
}
else
{
<MudButton Disabled="@(!this.DataLLMProvider.CanLoadModels(this.DataHost, this.dataAPIKey))" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Refresh" OnClick="this.ReloadModels">
2025-04-27 10:27:10 +00:00
@T("Load models")
2025-04-24 09:43:16 +00:00
</MudButton>
@if(this.availableModels.Count is 0)
2024-07-25 13:29:44 +00:00
{
2025-04-24 09:43:16 +00:00
<MudText Typo="Typo.body1">
2025-04-27 10:27:10 +00:00
@T("No models loaded or available.")
2025-04-24 09:43:16 +00:00
</MudText>
2024-07-25 13:29:44 +00:00
}
2025-04-24 09:43:16 +00:00
else
{
<MudSelect @bind-Value="@this.DataModel"
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural" AdornmentColor="Color.Info"
Adornment="Adornment.Start" Validation="@this.providerValidation.ValidatingModel">
@foreach (var model in this.availableModels)
{
2025-04-27 10:27:10 +00:00
<MudSelectItem Value="@model">
@model
</MudSelectItem>
2025-04-24 09:43:16 +00:00
}
</MudSelect>
}
}
</MudStack>
</MudField>
2024-07-03 18:31:04 +00:00
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataInstanceName"
2025-04-27 10:27:10 +00:00
Label="@T("Instance Name")"
2024-07-03 18:31:04 +00:00
Class="mb-3"
2024-09-08 19:01:51 +00:00
MaxLength="40"
Counter="40"
Immediate="@true"
2024-07-03 18:31:04 +00:00
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
AdornmentColor="Color.Info"
2024-12-03 14:24:40 +00:00
Validation="@this.providerValidation.ValidatingInstanceName"
2024-07-16 08:28:13 +00:00
UserAttributes="@SPELLCHECK_ATTRIBUTES"
2024-07-03 18:31:04 +00:00
/>
2024-05-19 14:12:07 +00:00
2024-04-19 19:25:44 +00:00
</MudForm>
2024-07-28 11:53:22 +00:00
<Issues IssuesData="@this.dataIssues"/>
2024-04-19 19:25:44 +00:00
</DialogContent>
<DialogActions>
2025-04-27 10:27:10 +00:00
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
2024-04-20 15:06:50 +00:00
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
2025-04-27 10:27:10 +00:00
@T("Update")
2024-04-20 15:06:50 +00:00
}
else
{
2025-04-27 10:27:10 +00:00
@T("Add")
2024-04-20 15:06:50 +00:00
}
</MudButton>
2024-04-19 19:25:44 +00:00
</DialogActions>
</MudDialog>