Renamed the Providers enum to LLMProviders for better clarity (#144)

This commit is contained in:
Thorsten Sommer 2024-09-13 21:50:00 +02:00 committed by GitHub
parent 5fa2f3c822
commit 1cac1a7913
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 125 additions and 124 deletions

View File

@ -100,7 +100,7 @@
@if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)
{
<ConfidenceInfo Mode="ConfidenceInfoMode.BUTTON" Provider="@this.providerSettings.UsedProvider"/>
<ConfidenceInfo Mode="ConfidenceInfoMode.BUTTON" LLMProvider="@this.providerSettings.UsedLLMProvider"/>
}
@if (this.AllowProfiles && this.ShowProfileSelection)

View File

@ -114,11 +114,11 @@ public abstract partial class AssistantBase : ComponentBase
#endregion
private string SubmitButtonStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedProvider.GetConfidence(this.SettingsManager).StyleBorder() : string.Empty;
private string SubmitButtonStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedLLMProvider.GetConfidence(this.SettingsManager).StyleBorder() : string.Empty;
protected string? ValidatingProvider(AIStudio.Settings.Provider provider)
{
if(provider.UsedProvider == Providers.NONE)
if(provider.UsedLLMProvider == LLMProviders.NONE)
return "Please select a provider.";
return null;

View File

@ -3,11 +3,11 @@
<MudTooltip Text="Shows and hides the confidence card with information about the selected LLM provider.">
@if (this.Mode is ConfidenceInfoMode.ICON)
{
<MudIconButton Icon="@Icons.Material.Filled.Security" Class="confidence-icon" Style="@this.Provider.GetConfidence(this.SettingsManager).SetColorStyle()" OnClick="@(() => this.ToggleConfidence())"/>
<MudIconButton Icon="@Icons.Material.Filled.Security" Class="confidence-icon" Style="@this.LLMProvider.GetConfidence(this.SettingsManager).SetColorStyle()" OnClick="@(() => this.ToggleConfidence())"/>
}
else
{
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Security" IconClass="confidence-icon" Style="@this.Provider.GetConfidence(this.SettingsManager).SetColorStyle()" OnClick="@(() => this.ToggleConfidence())">
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Security" IconClass="confidence-icon" Style="@this.LLMProvider.GetConfidence(this.SettingsManager).SetColorStyle()" OnClick="@(() => this.ToggleConfidence())">
Confidence
</MudButton>
}

View File

@ -11,7 +11,7 @@ public partial class ConfidenceInfo : ComponentBase
public ConfidenceInfoMode Mode { get; set; } = ConfidenceInfoMode.BUTTON;
[Parameter]
public Providers Provider { get; set; }
public LLMProviders LLMProvider { get; set; }
[Inject]
private SettingsManager SettingsManager { get; init; } = null!;
@ -21,14 +21,14 @@ public partial class ConfidenceInfo : ComponentBase
public ConfidenceInfo()
{
this.currentConfidence = Providers.NONE.GetConfidence(this.SettingsManager);
this.currentConfidence = LLMProviders.NONE.GetConfidence(this.SettingsManager);
}
#region Overrides of ComponentBase
protected override async Task OnParametersSetAsync()
{
this.currentConfidence = this.Provider.GetConfidence(this.SettingsManager);
this.currentConfidence = this.LLMProvider.GetConfidence(this.SettingsManager);
await base.OnParametersSetAsync();
}

View File

@ -6,8 +6,8 @@
<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.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)))
<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>
}

View File

@ -56,7 +56,7 @@ public partial class ProviderDialog : ComponentBase
/// The provider to use.
/// </summary>
[Parameter]
public Providers DataProvider { get; set; } = Providers.NONE;
public LLMProviders DataLLMProvider { get; set; } = LLMProviders.NONE;
/// <summary>
/// The LLM model to use, e.g., GPT-4o.
@ -104,9 +104,9 @@ public partial class ProviderDialog : ComponentBase
Num = this.DataNum,
Id = this.DataId,
InstanceName = this.DataInstanceName,
UsedProvider = this.DataProvider,
Model = this.DataProvider is Providers.FIREWORKS ? new Model(this.dataManuallyModel) : this.DataModel,
IsSelfHosted = this.DataProvider is Providers.SELF_HOSTED,
UsedLLMProvider = this.DataLLMProvider,
Model = this.DataLLMProvider is LLMProviders.FIREWORKS ? new Model(this.dataManuallyModel) : this.DataModel,
IsSelfHosted = this.DataLLMProvider is LLMProviders.SELF_HOSTED,
Hostname = this.DataHostname.EndsWith('/') ? this.DataHostname[..^1] : this.DataHostname,
Host = this.DataHost,
};
@ -127,13 +127,13 @@ public partial class ProviderDialog : ComponentBase
this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();
// When using Fireworks, we must copy the model name:
if (this.DataProvider is Providers.FIREWORKS)
if (this.DataLLMProvider is LLMProviders.FIREWORKS)
this.dataManuallyModel = this.DataModel.Id;
//
// We cannot load the API key for self-hosted providers:
//
if (this.DataProvider is Providers.SELF_HOSTED)
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED)
{
await this.ReloadModels();
await base.OnInitializedAsync();
@ -192,7 +192,7 @@ public partial class ProviderDialog : ComponentBase
// Use the data model to store the provider.
// We just return this data to the parent component:
var addedProviderSettings = this.CreateProviderSettings();
if (addedProviderSettings.UsedProvider != Providers.SELF_HOSTED)
if (addedProviderSettings.UsedLLMProvider != LLMProviders.SELF_HOSTED)
{
// We need to instantiate the provider to store the API key:
var provider = addedProviderSettings.CreateProvider(this.Logger);
@ -210,9 +210,9 @@ public partial class ProviderDialog : ComponentBase
this.MudDialog.Close(DialogResult.Ok(addedProviderSettings));
}
private string? ValidatingProvider(Providers provider)
private string? ValidatingProvider(LLMProviders llmProvider)
{
if (provider == Providers.NONE)
if (llmProvider == LLMProviders.NONE)
return "Please select a provider.";
return null;
@ -220,7 +220,7 @@ public partial class ProviderDialog : ComponentBase
private string? ValidatingHost(Host host)
{
if(this.DataProvider is not Providers.SELF_HOSTED)
if(this.DataLLMProvider is not LLMProviders.SELF_HOSTED)
return null;
if (host == Host.NONE)
@ -231,7 +231,7 @@ public partial class ProviderDialog : ComponentBase
private string? ValidateManuallyModel(string manuallyModel)
{
if (this.DataProvider is Providers.FIREWORKS && string.IsNullOrWhiteSpace(manuallyModel))
if (this.DataLLMProvider is LLMProviders.FIREWORKS && string.IsNullOrWhiteSpace(manuallyModel))
return "Please enter a model name.";
return null;
@ -239,7 +239,7 @@ public partial class ProviderDialog : ComponentBase
private string? ValidatingModel(Model model)
{
if(this.DataProvider is Providers.SELF_HOSTED && this.DataHost == Host.LLAMACPP)
if(this.DataLLMProvider is LLMProviders.SELF_HOSTED && this.DataHost == Host.LLAMACPP)
return null;
if (model == default)
@ -266,7 +266,7 @@ public partial class ProviderDialog : ComponentBase
private string? ValidatingAPIKey(string apiKey)
{
if(this.DataProvider is Providers.SELF_HOSTED)
if(this.DataLLMProvider is LLMProviders.SELF_HOSTED)
return null;
if(!string.IsNullOrWhiteSpace(this.dataAPIKeyStorageIssue))
@ -280,7 +280,7 @@ public partial class ProviderDialog : ComponentBase
private string? ValidatingHostname(string hostname)
{
if(this.DataProvider != Providers.SELF_HOSTED)
if(this.DataLLMProvider != LLMProviders.SELF_HOSTED)
return null;
if(string.IsNullOrWhiteSpace(hostname))
@ -315,7 +315,7 @@ public partial class ProviderDialog : ComponentBase
private bool CanLoadModels()
{
if (this.DataProvider is Providers.SELF_HOSTED)
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED)
{
switch (this.DataHost)
{
@ -336,7 +336,7 @@ public partial class ProviderDialog : ComponentBase
}
}
if(this.DataProvider is Providers.NONE)
if(this.DataLLMProvider is LLMProviders.NONE)
return false;
if(string.IsNullOrWhiteSpace(this.dataAPIKey))
@ -345,63 +345,63 @@ public partial class ProviderDialog : ComponentBase
return true;
}
private bool ShowRegisterButton => this.DataProvider switch
private bool ShowRegisterButton => this.DataLLMProvider switch
{
Providers.OPEN_AI => true,
Providers.MISTRAL => true,
Providers.ANTHROPIC => true,
LLMProviders.OPEN_AI => true,
LLMProviders.MISTRAL => true,
LLMProviders.ANTHROPIC => true,
Providers.FIREWORKS => true,
LLMProviders.FIREWORKS => true,
_ => false,
};
private bool NeedAPIKey => this.DataProvider switch
private bool NeedAPIKey => this.DataLLMProvider switch
{
Providers.OPEN_AI => true,
Providers.MISTRAL => true,
Providers.ANTHROPIC => true,
LLMProviders.OPEN_AI => true,
LLMProviders.MISTRAL => true,
LLMProviders.ANTHROPIC => true,
Providers.FIREWORKS => true,
LLMProviders.FIREWORKS => true,
_ => false,
};
private bool NeedHostname => this.DataProvider switch
private bool NeedHostname => this.DataLLMProvider switch
{
Providers.SELF_HOSTED => true,
LLMProviders.SELF_HOSTED => true,
_ => false,
};
private bool NeedHost => this.DataProvider switch
private bool NeedHost => this.DataLLMProvider switch
{
Providers.SELF_HOSTED => true,
LLMProviders.SELF_HOSTED => true,
_ => false,
};
private bool ProvideModelManually => this.DataProvider switch
private bool ProvideModelManually => this.DataLLMProvider switch
{
Providers.FIREWORKS => true,
LLMProviders.FIREWORKS => true,
_ => false,
};
private string GetModelOverviewURL() => this.DataProvider switch
private string GetModelOverviewURL() => this.DataLLMProvider switch
{
Providers.FIREWORKS => "https://fireworks.ai/models?show=Serverless",
LLMProviders.FIREWORKS => "https://fireworks.ai/models?show=Serverless",
_ => string.Empty,
};
private string GetProviderCreationURL() => this.DataProvider switch
private string GetProviderCreationURL() => this.DataLLMProvider switch
{
Providers.OPEN_AI => "https://platform.openai.com/signup",
Providers.MISTRAL => "https://console.mistral.ai/",
Providers.ANTHROPIC => "https://console.anthropic.com/dashboard",
LLMProviders.OPEN_AI => "https://platform.openai.com/signup",
LLMProviders.MISTRAL => "https://console.mistral.ai/",
LLMProviders.ANTHROPIC => "https://console.anthropic.com/dashboard",
Providers.FIREWORKS => "https://fireworks.ai/login",
LLMProviders.FIREWORKS => "https://fireworks.ai/login",
_ => string.Empty,
};
private bool IsNoneProvider => this.DataProvider is Providers.NONE;
private bool IsNoneProvider => this.DataLLMProvider is LLMProviders.NONE;
}

View File

@ -72,7 +72,7 @@
@if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)
{
<ConfidenceInfo Mode="ConfidenceInfoMode.ICON" Provider="@this.providerSettings.UsedProvider"/>
<ConfidenceInfo Mode="ConfidenceInfoMode.ICON" LLMProvider="@this.providerSettings.UsedLLMProvider"/>
}
<ProfileSelection CurrentProfile="@this.currentProfile" CurrentProfileChanged="@this.ProfileWasChanged" />

View File

@ -110,17 +110,17 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
#endregion
private bool IsProviderSelected => this.providerSettings.UsedProvider != Providers.NONE;
private bool IsProviderSelected => this.providerSettings.UsedLLMProvider != LLMProviders.NONE;
private string ProviderPlaceholder => this.IsProviderSelected ? "Type your input here..." : "Select a provider first";
private string InputLabel => this.IsProviderSelected ? $"Your Prompt (use selected instance '{this.providerSettings.InstanceName}', provider '{this.providerSettings.UsedProvider.ToName()}')" : "Select a provider first";
private string InputLabel => this.IsProviderSelected ? $"Your Prompt (use selected instance '{this.providerSettings.InstanceName}', provider '{this.providerSettings.UsedLLMProvider.ToName()}')" : "Select a provider first";
private bool CanThreadBeSaved => this.chatThread is not null && this.chatThread.Blocks.Count > 0;
private string TooltipAddChatToWorkspace => $"Start new chat in workspace \"{this.currentWorkspaceName}\"";
private string UserInputStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedProvider.GetConfidence(this.SettingsManager).SetColorStyle() : string.Empty;
private string UserInputStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedLLMProvider.GetConfidence(this.SettingsManager).SetColorStyle() : string.Empty;
private string UserInputClass => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? "confidence-border" : string.Empty;

View File

@ -35,13 +35,13 @@
<RowTemplate>
<MudTd>@context.Num</MudTd>
<MudTd>@context.InstanceName</MudTd>
<MudTd>@context.UsedProvider</MudTd>
<MudTd>@context.UsedLLMProvider</MudTd>
<MudTd>
@if (context.UsedProvider is not Providers.SELF_HOSTED)
@if (context.UsedLLMProvider is not LLMProviders.SELF_HOSTED)
{
@this.GetProviderModelName(context)
}
else if (context.UsedProvider is Providers.SELF_HOSTED && context.Host is not Host.LLAMACPP)
else if (context.UsedLLMProvider is LLMProviders.SELF_HOSTED && context.Host is not Host.LLAMACPP)
{
@this.GetProviderModelName(context)
}
@ -51,7 +51,7 @@
}
</MudTd>
<MudTd Style="text-align: left;">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.OpenInBrowser" Class="ma-2" Href="@this.GetProviderDashboardURL(context.UsedProvider)" Target="_blank" Disabled="@(!this.HasDashboard(context.UsedProvider))">
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.OpenInBrowser" Class="ma-2" Href="@this.GetProviderDashboardURL(context.UsedLLMProvider)" Target="_blank" Disabled="@(!this.HasDashboard(context.UsedLLMProvider))">
Open Dashboard
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditProvider(context)">
@ -86,7 +86,7 @@
<ConfigurationSelect OptionDescription="Select a confidence scheme" SelectedValue="@(() => this.SettingsManager.ConfigurationData.LLMProviders.ConfidenceScheme)" Data="@ConfigurationSelectDataFactory.GetConfidenceSchemesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.LLMProviders.ConfidenceScheme = selectedValue)" OptionHelp="Choose the scheme that best suits you and your life. Do you trust any western provider? Or only providers from the USA or exclusively European providers? Then choose the appropriate scheme. Alternatively, you can assign the confidence levels to each provider yourself."/>
@if (this.SettingsManager.ConfigurationData.LLMProviders.ConfidenceScheme is ConfidenceSchemes.CUSTOM)
{
<MudTable Items="@(Enum.GetValues<Providers>().Where(x => x is not Providers.NONE))" Hover="@true" Class="border-dashed border rounded-lg">
<MudTable Items="@(Enum.GetValues<LLMProviders>().Where(x => x is not LLMProviders.NONE))" Hover="@true" Class="border-dashed border rounded-lg">
<ColGroup>
<col style="width: 12em;"/>
<col/>

View File

@ -75,7 +75,7 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
{ x => x.DataNum, provider.Num },
{ x => x.DataId, provider.Id },
{ x => x.DataInstanceName, provider.InstanceName },
{ x => x.DataProvider, provider.UsedProvider },
{ x => x.DataLLMProvider, provider.UsedLLMProvider },
{ x => x.DataModel, provider.Model },
{ x => x.DataHostname, provider.Hostname },
{ x => x.IsSelfHosted, provider.IsSelfHosted },
@ -126,22 +126,22 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
private bool HasDashboard(Providers provider) => provider switch
private bool HasDashboard(LLMProviders llmProvider) => llmProvider switch
{
Providers.OPEN_AI => true,
Providers.MISTRAL => true,
Providers.ANTHROPIC => true,
Providers.FIREWORKS => true,
LLMProviders.OPEN_AI => true,
LLMProviders.MISTRAL => true,
LLMProviders.ANTHROPIC => true,
LLMProviders.FIREWORKS => true,
_ => false,
};
private string GetProviderDashboardURL(Providers provider) => provider switch
private string GetProviderDashboardURL(LLMProviders llmProvider) => llmProvider switch
{
Providers.OPEN_AI => "https://platform.openai.com/usage",
Providers.MISTRAL => "https://console.mistral.ai/usage/",
Providers.ANTHROPIC => "https://console.anthropic.com/settings/plans",
Providers.FIREWORKS => "https://fireworks.ai/account/billing",
LLMProviders.OPEN_AI => "https://platform.openai.com/usage",
LLMProviders.MISTRAL => "https://console.mistral.ai/usage/",
LLMProviders.ANTHROPIC => "https://console.anthropic.com/settings/plans",
LLMProviders.FIREWORKS => "https://fireworks.ai/account/billing",
_ => string.Empty,
};
@ -160,25 +160,25 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
this.availableProviders.Add(new (provider.InstanceName, provider.Id));
}
private string GetCurrentConfidenceLevelName(Providers provider)
private string GetCurrentConfidenceLevelName(LLMProviders llmProvider)
{
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(provider, out var level))
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level))
return level.GetName();
return "Not yet configured";
}
private string SetCurrentConfidenceLevelColorStyle(Providers provider)
private string SetCurrentConfidenceLevelColorStyle(LLMProviders llmProvider)
{
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(provider, out var level))
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(llmProvider, out var level))
return $"background-color: {level.GetColor()};";
return $"background-color: {ConfidenceLevel.UNKNOWN.GetColor()};";
}
private async Task ChangeCustomConfidenceLevel(Providers provider, ConfidenceLevel level)
private async Task ChangeCustomConfidenceLevel(LLMProviders llmProvider, ConfidenceLevel level)
{
this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[provider] = level;
this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[llmProvider] = level;
await this.SettingsManager.StoreSettings();
}

View File

@ -3,7 +3,7 @@ namespace AIStudio.Provider;
/// <summary>
/// Enum for all available providers.
/// </summary>
public enum Providers
public enum LLMProviders
{
NONE = 0,

View File

@ -12,19 +12,19 @@ public static class ProvidersExtensions
/// <summary>
/// Returns the human-readable name of the provider.
/// </summary>
/// <param name="provider">The provider.</param>
/// <param name="llmProvider">The provider.</param>
/// <returns>The human-readable name of the provider.</returns>
public static string ToName(this Providers provider) => provider switch
public static string ToName(this LLMProviders llmProvider) => llmProvider switch
{
Providers.NONE => "No provider selected",
LLMProviders.NONE => "No provider selected",
Providers.OPEN_AI => "OpenAI",
Providers.ANTHROPIC => "Anthropic",
Providers.MISTRAL => "Mistral",
LLMProviders.OPEN_AI => "OpenAI",
LLMProviders.ANTHROPIC => "Anthropic",
LLMProviders.MISTRAL => "Mistral",
Providers.FIREWORKS => "Fireworks.ai",
LLMProviders.FIREWORKS => "Fireworks.ai",
Providers.SELF_HOSTED => "Self-hosted",
LLMProviders.SELF_HOSTED => "Self-hosted",
_ => "Unknown",
};
@ -32,29 +32,29 @@ public static class ProvidersExtensions
/// <summary>
/// Get a provider's confidence.
/// </summary>
/// <param name="provider">The provider.</param>
/// <param name="llmProvider">The provider.</param>
/// <param name="settingsManager">The settings manager.</param>
/// <returns>The confidence of the provider.</returns>
public static Confidence GetConfidence(this Providers provider, SettingsManager settingsManager) => provider switch
public static Confidence GetConfidence(this LLMProviders llmProvider, SettingsManager settingsManager) => llmProvider switch
{
Providers.NONE => Confidence.NONE,
LLMProviders.NONE => Confidence.NONE,
Providers.FIREWORKS => Confidence.USA_NOT_TRUSTED.WithRegion("America, U.S.").WithSources("https://fireworks.ai/terms-of-service").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
LLMProviders.FIREWORKS => Confidence.USA_NOT_TRUSTED.WithRegion("America, U.S.").WithSources("https://fireworks.ai/terms-of-service").WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
Providers.OPEN_AI => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources(
LLMProviders.OPEN_AI => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources(
"https://platform.openai.com/docs/models/default-usage-policies-by-endpoint",
"https://openai.com/policies/terms-of-use/",
"https://help.openai.com/en/articles/5722486-how-your-data-is-used-to-improve-model-performance",
"https://openai.com/enterprise-privacy/"
).WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
).WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
Providers.ANTHROPIC => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources("https://www.anthropic.com/legal/commercial-terms").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
LLMProviders.ANTHROPIC => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources("https://www.anthropic.com/legal/commercial-terms").WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
Providers.MISTRAL => Confidence.GDPR_NO_TRAINING.WithRegion("Europe, France").WithSources("https://mistral.ai/terms/#terms-of-service-la-plateforme").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
LLMProviders.MISTRAL => Confidence.GDPR_NO_TRAINING.WithRegion("Europe, France").WithSources("https://mistral.ai/terms/#terms-of-service-la-plateforme").WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
Providers.SELF_HOSTED => Confidence.SELF_HOSTED.WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
LLMProviders.SELF_HOSTED => Confidence.SELF_HOSTED.WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
_ => Confidence.UNKNOWN.WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
_ => Confidence.UNKNOWN.WithLevel(settingsManager.GetConfiguredConfidenceLevel(llmProvider)),
};
/// <summary>
@ -67,15 +67,15 @@ public static class ProvidersExtensions
{
try
{
return providerSettings.UsedProvider switch
return providerSettings.UsedLLMProvider switch
{
Providers.OPEN_AI => new ProviderOpenAI(logger) { InstanceName = providerSettings.InstanceName },
Providers.ANTHROPIC => new ProviderAnthropic(logger) { InstanceName = providerSettings.InstanceName },
Providers.MISTRAL => new ProviderMistral(logger) { InstanceName = providerSettings.InstanceName },
LLMProviders.OPEN_AI => new ProviderOpenAI(logger) { InstanceName = providerSettings.InstanceName },
LLMProviders.ANTHROPIC => new ProviderAnthropic(logger) { InstanceName = providerSettings.InstanceName },
LLMProviders.MISTRAL => new ProviderMistral(logger) { InstanceName = providerSettings.InstanceName },
Providers.FIREWORKS => new ProviderFireworks(logger) { InstanceName = providerSettings.InstanceName },
LLMProviders.FIREWORKS => new ProviderFireworks(logger) { InstanceName = providerSettings.InstanceName },
Providers.SELF_HOSTED => new ProviderSelfHosted(logger, providerSettings) { InstanceName = providerSettings.InstanceName },
LLMProviders.SELF_HOSTED => new ProviderSelfHosted(logger, providerSettings) { InstanceName = providerSettings.InstanceName },
_ => new NoProvider(),
};

View File

@ -17,5 +17,5 @@ public sealed class DataLLMProviders
/// <summary>
/// Provide custom confidence levels for each LLM provider.
/// </summary>
public Dictionary<Providers, ConfidenceLevel> CustomConfidenceScheme { get; set; } = new();
public Dictionary<LLMProviders, ConfidenceLevel> CustomConfidenceScheme { get; set; } = new();
}

View File

@ -10,7 +10,7 @@ namespace AIStudio.Settings;
/// <param name="Num">The provider's number.</param>
/// <param name="Id">The provider's ID.</param>
/// <param name="InstanceName">The provider's instance name. Useful for multiple instances of the same provider, e.g., to distinguish between different OpenAI API keys.</param>
/// <param name="UsedProvider">The provider used.</param>
/// <param name="UsedLLMProvider">The provider used.</param>
/// <param name="IsSelfHosted">Whether the provider is self-hosted.</param>
/// <param name="Hostname">The hostname of the provider. Useful for self-hosted providers.</param>
/// <param name="Model">The LLM model to use for chat.</param>
@ -18,7 +18,7 @@ public readonly record struct Provider(
uint Num,
string Id,
string InstanceName,
Providers UsedProvider,
LLMProviders UsedLLMProvider,
Model Model,
bool IsSelfHosted = false,
string Hostname = "http://localhost:1234",
@ -34,9 +34,9 @@ public readonly record struct Provider(
public override string ToString()
{
if(this.IsSelfHosted)
return $"{this.InstanceName} ({this.UsedProvider.ToName()}, {this.Host}, {this.Hostname}, {this.Model})";
return $"{this.InstanceName} ({this.UsedLLMProvider.ToName()}, {this.Host}, {this.Hostname}, {this.Model})";
return $"{this.InstanceName} ({this.UsedProvider.ToName()}, {this.Model})";
return $"{this.InstanceName} ({this.UsedLLMProvider.ToName()}, {this.Model})";
}
#endregion

View File

@ -162,53 +162,53 @@ public sealed class SettingsManager(ILogger<SettingsManager> logger)
return preselection != default ? preselection : Profile.NO_PROFILE;
}
public ConfidenceLevel GetConfiguredConfidenceLevel(Providers provider)
public ConfidenceLevel GetConfiguredConfidenceLevel(LLMProviders llmProvider)
{
if(provider is Providers.NONE)
if(llmProvider is LLMProviders.NONE)
return ConfidenceLevel.NONE;
switch (this.ConfigurationData.LLMProviders.ConfidenceScheme)
{
case ConfidenceSchemes.TRUST_USA_EUROPE:
return provider switch
return llmProvider switch
{
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
LLMProviders.SELF_HOSTED => ConfidenceLevel.HIGH,
LLMProviders.FIREWORKS => ConfidenceLevel.UNTRUSTED,
_ => ConfidenceLevel.MEDIUM,
};
case ConfidenceSchemes.TRUST_USA:
return provider switch
return llmProvider switch
{
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
Providers.MISTRAL => ConfidenceLevel.LOW,
LLMProviders.SELF_HOSTED => ConfidenceLevel.HIGH,
LLMProviders.FIREWORKS => ConfidenceLevel.UNTRUSTED,
LLMProviders.MISTRAL => ConfidenceLevel.LOW,
_ => ConfidenceLevel.MEDIUM,
};
case ConfidenceSchemes.TRUST_EUROPE:
return provider switch
return llmProvider switch
{
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
Providers.MISTRAL => ConfidenceLevel.MEDIUM,
LLMProviders.SELF_HOSTED => ConfidenceLevel.HIGH,
LLMProviders.FIREWORKS => ConfidenceLevel.UNTRUSTED,
LLMProviders.MISTRAL => ConfidenceLevel.MEDIUM,
_ => ConfidenceLevel.LOW,
};
case ConfidenceSchemes.LOCAL_TRUST_ONLY:
return provider switch
return llmProvider switch
{
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
LLMProviders.SELF_HOSTED => ConfidenceLevel.HIGH,
LLMProviders.FIREWORKS => ConfidenceLevel.UNTRUSTED,
_ => ConfidenceLevel.VERY_LOW,
};
case ConfidenceSchemes.CUSTOM:
return this.ConfigurationData.LLMProviders.CustomConfidenceScheme.GetValueOrDefault(provider, ConfidenceLevel.UNKNOWN);
return this.ConfigurationData.LLMProviders.CustomConfidenceScheme.GetValueOrDefault(llmProvider, ConfidenceLevel.UNKNOWN);
default:
return ConfidenceLevel.UNKNOWN;

View File

@ -1,2 +1,3 @@
# v0.9.11, build 186
- Added a tooltip to the confidence card button.
- Added a tooltip to the confidence card button.
- Renamed the `Providers` enum to `LLMProviders` for better clarity. Renamed also all dependent variables and methods.