Optimized provider dialog

This commit is contained in:
Thorsten Sommer 2024-07-02 20:34:55 +02:00
parent 29face9f1f
commit df009cd35d
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 32 additions and 20 deletions

View File

@ -4,26 +4,16 @@
<MudDialog> <MudDialog>
<DialogContent> <DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues"> <MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@* ReSharper disable once CSharpWarnings::CS8974 *@ <MudStack Row="@true" AlignItems="AlignItems.Center">
<MudTextField @* ReSharper disable once CSharpWarnings::CS8974 *@
T="string" <MudSelect @bind-Value="@this.DataProvider" Label="Provider" Class="mb-3" OpenIcon="@Icons.Material.Filled.AccountBalance" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.ValidatingProvider">
@bind-Text="@this.DataInstanceName" @foreach (Providers provider in Enum.GetValues(typeof(Providers)))
Label="Instance Name" {
Class="mb-3" <MudSelectItem Value="@provider">@provider</MudSelectItem>
Adornment="Adornment.Start" }
AdornmentIcon="@Icons.Material.Filled.Lightbulb" </MudSelect>
AdornmentColor="Color.Info" <MudButton Disabled="@(this.DataProvider is Providers.NONE or Providers.SELF_HOSTED)" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.GetProviderCreationURL()" Target="_blank">Create account</MudButton>
Validation="@this.ValidatingInstanceName" </MudStack>
UserAttributes="@INSTANCE_NAME_ATTRIBUTES"
/>
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudSelect @bind-Value="@this.DataProvider" Label="Provider" Class="mb-3" OpenIcon="@Icons.Material.Filled.AccountBalance" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.ValidatingProvider">
@foreach (Providers provider in Enum.GetValues(typeof(Providers)))
{
<MudSelectItem Value="@provider">@provider</MudSelectItem>
}
</MudSelect>
@* ReSharper disable once CSharpWarnings::CS8974 *@ @* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField <MudTextField
@ -47,6 +37,19 @@
} }
</MudSelect> </MudSelect>
</MudStack> </MudStack>
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataInstanceName"
Label="Instance Name"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
AdornmentColor="Color.Info"
Validation="@this.ValidatingInstanceName"
UserAttributes="@INSTANCE_NAME_ATTRIBUTES"
/>
</MudForm> </MudForm>

View File

@ -233,4 +233,13 @@ public partial class ProviderDialog : ComponentBase
this.availableModels.Clear(); this.availableModels.Clear();
this.availableModels.AddRange(orderedModels); this.availableModels.AddRange(orderedModels);
} }
private string GetProviderCreationURL() => this.DataProvider switch
{
Providers.OPEN_AI => "https://platform.openai.com/signup",
Providers.MISTRAL => "https://console.mistral.ai/",
Providers.ANTHROPIC => "https://console.anthropic.com/dashboard",
_ => string.Empty,
};
} }