diff --git a/app/MindWork AI Studio/Settings/ProviderDialog.razor b/app/MindWork AI Studio/Settings/ProviderDialog.razor index d90e4355..eb71343c 100644 --- a/app/MindWork AI Studio/Settings/ProviderDialog.razor +++ b/app/MindWork AI Studio/Settings/ProviderDialog.razor @@ -13,7 +13,7 @@ @provider } - Create account + Create account @* ReSharper disable once CSharpWarnings::CS8974 *@ @@ -21,7 +21,7 @@ T="string" @bind-Text="@this.dataAPIKey" Label="API Key" - Disabled="@this.IsSelfHostedOrNone" + Disabled="@(!this.NeedAPIKey)" Class="mb-3" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.VpnKey" @@ -34,7 +34,7 @@ T="string" @bind-Text="@this.DataHostname" Label="Hostname" - Disabled="@this.IsCloudProvider" + Disabled="@(!this.NeedHostname)" Class="mb-3" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Dns" @@ -43,7 +43,7 @@ UserAttributes="@SPELLCHECK_ATTRIBUTES" /> - + @foreach (Host host in Enum.GetValues(typeof(Host))) { @host.Name() @@ -51,13 +51,31 @@ - Load - - @foreach (var model in this.availableModels) - { - @model - } - + @if (this.ProvideModelManually) + { + Show available models + + } + else + { + Load + + @foreach (var model in this.availableModels) + { + @model + } + + } @* ReSharper disable once CSharpWarnings::CS8974 *@ diff --git a/app/MindWork AI Studio/Settings/ProviderDialog.razor.cs b/app/MindWork AI Studio/Settings/ProviderDialog.razor.cs index 1c76e88b..4d688a0b 100644 --- a/app/MindWork AI Studio/Settings/ProviderDialog.razor.cs +++ b/app/MindWork AI Studio/Settings/ProviderDialog.razor.cs @@ -86,6 +86,7 @@ public partial class ProviderDialog : ComponentBase private bool dataIsValid; private string[] dataIssues = []; private string dataAPIKey = string.Empty; + private string dataManuallyModel = string.Empty; private string dataAPIKeyStorageIssue = string.Empty; private string dataEditingPreviousInstanceName = string.Empty; @@ -100,7 +101,7 @@ public partial class ProviderDialog : ComponentBase Id = this.DataId, InstanceName = this.DataInstanceName, UsedProvider = this.DataProvider, - Model = this.DataModel, + Model = this.DataProvider is Providers.FIREWORKS ? new Model(this.dataManuallyModel) : this.DataModel, IsSelfHosted = this.DataProvider is Providers.SELF_HOSTED, Hostname = this.DataHostname.EndsWith('/') ? this.DataHostname[..^1] : this.DataHostname, Host = this.DataHost, @@ -220,6 +221,14 @@ public partial class ProviderDialog : ComponentBase return null; } + private string? ValidateManuallyModel(string manuallyModel) + { + if (this.DataProvider is Providers.FIREWORKS && string.IsNullOrWhiteSpace(manuallyModel)) + return "Please enter a model name."; + + return null; + } + private string? ValidatingModel(Model model) { if(this.DataProvider is Providers.SELF_HOSTED && this.DataHost == Host.LLAMACPP) @@ -354,11 +363,52 @@ public partial class ProviderDialog : ComponentBase return true; } - private bool IsCloudProvider => this.DataProvider is not Providers.SELF_HOSTED; + private bool ShowRegisterButton => this.DataProvider switch + { + Providers.OPEN_AI => true, + Providers.MISTRAL => true, + Providers.ANTHROPIC => true, + + Providers.FIREWORKS => true, + + _ => false, + }; + + private bool NeedAPIKey => this.DataProvider switch + { + Providers.OPEN_AI => true, + Providers.MISTRAL => true, + Providers.ANTHROPIC => true, + + Providers.FIREWORKS => true, + + _ => false, + }; + + private bool NeedHostname => this.DataProvider switch + { + Providers.SELF_HOSTED => true, + _ => false, + }; - private bool IsSelfHostedOrNone => this.DataProvider is Providers.SELF_HOSTED or Providers.NONE; + private bool NeedHost => this.DataProvider switch + { + Providers.SELF_HOSTED => true, + _ => false, + }; - private bool IsNoneProvider => this.DataProvider is Providers.NONE; + private bool ProvideModelManually => this.DataProvider switch + { + Providers.FIREWORKS => true, + _ => false, + }; + + private string GetModelOverviewURL() => this.DataProvider switch + { + Providers.FIREWORKS => "https://fireworks.ai/models?show=Serverless", + + _ => string.Empty, + }; private string GetProviderCreationURL() => this.DataProvider switch { @@ -366,6 +416,10 @@ public partial class ProviderDialog : ComponentBase Providers.MISTRAL => "https://console.mistral.ai/", Providers.ANTHROPIC => "https://console.anthropic.com/dashboard", + Providers.FIREWORKS => "https://fireworks.ai/login", + _ => string.Empty, }; + + private bool IsNoneProvider => this.DataProvider is Providers.NONE; } \ No newline at end of file