Implement support for self-hosted and local LLMs (#20)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2024-07-03 20:31:04 +02:00
1 parent 6cc1d37db8
commit 29263660fc
21 files changed
+418 -62

No files matched your search

@@ -13,6 +13,7 @@ public partial class Changelog
public static readonly Log[] LOGS =
[
new (159, "v0.6.3, build 159 (2024-07-03 18:26 UTC)", "v0.6.3.md"),
new (158, "v0.6.2, build 158 (2024-07-01 18:03 UTC)", "v0.6.2.md"),
new (157, "v0.6.1, build 157 (2024-06-30 19:00 UTC)", "v0.6.1.md"),
new (156, "v0.6.0, build 156 (2024-06-30 12:49 UTC)", "v0.6.0.md"),
@@ -101,7 +101,7 @@ public partial class Chat : ComponentBase
// Use the selected provider to get the AI response.
// By awaiting this line, we wait for the entire
// content to be streamed.
await aiText.CreateFromProviderAsync(this.selectedProvider.UsedProvider.CreateProvider(this.selectedProvider.InstanceName), this.JsRuntime, this.SettingsManager, this.selectedProvider.Model, this.chatThread);
await aiText.CreateFromProviderAsync(this.selectedProvider.UsedProvider.CreateProvider(this.selectedProvider.InstanceName, this.selectedProvider.Hostname), this.JsRuntime, this.SettingsManager, this.selectedProvider.Model, this.chatThread);
// Disable the stream state:
this.isStreaming = false;
@@ -1,4 +1,5 @@
@page "/settings"
@using AIStudio.Provider
<MudText Typo="Typo.h3" Class="mb-12">Settings</MudText>
@@ -11,7 +12,7 @@
<col style="width: 12em;"/>
<col style="width: 12em;"/>
<col/>
<col style="width: 20em;"/>
<col style="width: 34em;"/>
</ColGroup>
<HeaderContent>
<MudTh>#</MudTh>
@@ -24,12 +25,20 @@
<MudTd>@context.Num</MudTd>
<MudTd>@context.InstanceName</MudTd>
<MudTd>@context.UsedProvider</MudTd>
<MudTd>@context.Model</MudTd>
<MudTd>
@if(context.UsedProvider is not Providers.SELF_HOSTED)
@context.Model
else
@("as selected by provider")
</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="mr-2" OnClick="() => this.EditProvider(context)">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.OpenInBrowser" Class="ma-2" Href="@this.GetProviderDashboardURL(context.UsedProvider)" Target="_blank" Disabled="@(context.UsedProvider is Providers.NONE or Providers.SELF_HOSTED)">
Open Dashboard
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditProvider(context)">
Edit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="mr-2" OnClick="() => this.DeleteProvider(context)">
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteProvider(context)">
Delete
</MudButton>
</MudTd>
@@ -50,6 +50,8 @@ public partial class Settings : ComponentBase
{ x => x.DataInstanceName, provider.InstanceName },
{ x => x.DataProvider, provider.UsedProvider },
{ x => x.DataModel, provider.Model },
{ x => x.DataHostname, provider.Hostname },
{ x => x.IsSelfHosted, provider.IsSelfHosted },
{ x => x.IsEditing, true },
};
@@ -81,7 +83,7 @@ public partial class Settings : ComponentBase
if (dialogResult.Canceled)
return;
var providerInstance = provider.UsedProvider.CreateProvider(provider.InstanceName);
var providerInstance = provider.UsedProvider.CreateProvider(provider.InstanceName, provider.Hostname);
var deleteSecretResponse = await this.SettingsManager.DeleteAPIKey(this.JsRuntime, providerInstance);
if(deleteSecretResponse.Success)
{
@@ -89,6 +91,15 @@ public partial class Settings : ComponentBase
await this.SettingsManager.StoreSettings();
}
}
private string GetProviderDashboardURL(Providers provider) => provider switch
{
Providers.OPEN_AI => "https://platform.openai.com/usage",
Providers.MISTRAL => "https://console.mistral.ai/usage/",
Providers.ANTHROPIC => "https://console.anthropic.com/settings/plans",
_ => string.Empty,
};
#endregion
}