AI-Studio/app/MindWork AI Studio/Dialogs/ProviderDialog.razor

112 lines
5.2 KiB
Plaintext
Raw Normal View History

2024-04-19 19:25:44 +00:00
@using AIStudio.Provider
2024-07-16 08:28:13 +00:00
@using AIStudio.Provider.SelfHosted
2024-04-19 19:25:44 +00:00
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
<MudStack Row="@true" AlignItems="AlignItems.Center">
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudSelect @bind-Value="@this.DataLLMProvider" Label="Provider" Class="mb-3" OpenIcon="@Icons.Material.Filled.AccountBalance" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.ValidatingProvider">
@foreach (LLMProviders provider in Enum.GetValues(typeof(LLMProviders)))
{
<MudSelectItem Value="@provider">@provider</MudSelectItem>
}
</MudSelect>
2024-07-25 13:29:44 +00:00
<MudButton Disabled="@(!this.ShowRegisterButton)" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.GetProviderCreationURL()" Target="_blank">Create account</MudButton>
</MudStack>
2024-04-19 21:27:38 +00:00
@* ReSharper disable once CSharpWarnings::CS8974 *@
2024-04-19 19:25:44 +00:00
<MudTextField
T="string"
@bind-Text="@this.dataAPIKey"
Label="@this.APIKeyText"
2024-07-25 13:29:44 +00:00
Disabled="@(!this.NeedAPIKey)"
Class="mb-3"
2024-04-19 19:25:44 +00:00
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.VpnKey"
2024-04-19 19:25:44 +00:00
AdornmentColor="Color.Info"
InputType="InputType.Password"
Validation="@this.ValidatingAPIKey"
2024-04-19 19:25:44 +00:00
/>
2024-04-20 15:06:50 +00:00
<MudTextField
T="string"
@bind-Text="@this.DataHostname"
Label="Hostname"
2024-07-25 13:29:44 +00:00
Disabled="@(!this.NeedHostname)"
Class="mb-3"
2024-04-20 15:06:50 +00:00
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Dns"
2024-04-20 15:06:50 +00:00
AdornmentColor="Color.Info"
Validation="@this.ValidatingHostname"
2024-07-16 08:28:13 +00:00
UserAttributes="@SPELLCHECK_ATTRIBUTES"
2024-04-20 15:06:50 +00:00
/>
2024-05-19 14:12:07 +00:00
2024-07-25 13:29:44 +00:00
<MudSelect Disabled="@(!this.NeedHost)" @bind-Value="@this.DataHost" Label="Host" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.ValidatingHost">
2024-07-16 08:28:13 +00:00
@foreach (Host host in Enum.GetValues(typeof(Host)))
{
<MudSelectItem Value="@host">@host.Name()</MudSelectItem>
}
</MudSelect>
2024-05-19 14:12:07 +00:00
<MudStack Row="@true" AlignItems="AlignItems.Center">
2024-07-25 13:29:44 +00:00
@if (this.ProvideModelManually)
{
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.GetModelOverviewURL()" Target="_blank">Show available models</MudButton>
<MudTextField
T="string"
@bind-Text="@this.dataManuallyModel"
Label="Model"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Dns"
AdornmentColor="Color.Info"
Validation="@this.ValidateManuallyModel"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
/>
}
else
{
<MudButton Disabled="@(!this.CanLoadModels())" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Refresh" OnClick="this.ReloadModels">Load</MudButton>
<MudSelect Disabled="@this.IsNoneProvider" @bind-Value="@this.DataModel" Label="Model" Class="mb-3" OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.ValidatingModel">
@foreach (var model in this.availableModels)
{
<MudSelectItem Value="@model">@model</MudSelectItem>
}
</MudSelect>
}
2024-05-19 14:12:07 +00:00
</MudStack>
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataInstanceName"
Label="Instance Name"
Class="mb-3"
2024-09-08 19:01:51 +00:00
MaxLength="40"
Counter="40"
Immediate="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
AdornmentColor="Color.Info"
Validation="@this.ValidatingInstanceName"
2024-07-16 08:28:13 +00:00
UserAttributes="@SPELLCHECK_ATTRIBUTES"
/>
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>
2024-04-20 15:06:50 +00:00
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">Cancel</MudButton>
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
@:Update
}
else
{
@:Add
}
</MudButton>
2024-04-19 19:25:44 +00:00
</DialogActions>
</MudDialog>