mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 21:59:48 +00:00
Implemented confidence information
This commit is contained in:
parent
25194985b7
commit
31da842276
@ -98,6 +98,11 @@
|
||||
Reset
|
||||
</MudButton>
|
||||
|
||||
@if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)
|
||||
{
|
||||
<ConfidenceInfo Mode="ConfidenceInfoMode.BUTTON" Provider="@this.providerSettings.UsedProvider"/>
|
||||
}
|
||||
|
||||
@if (this.AllowProfiles && this.ShowProfileSelection)
|
||||
{
|
||||
<ProfileSelection MarginLeft="" @bind-CurrentProfile="@this.currentProfile"/>
|
||||
|
@ -114,6 +114,8 @@ public abstract partial class AssistantBase : ComponentBase
|
||||
|
||||
#endregion
|
||||
|
||||
private string SubmitButtonStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedProvider.GetConfidence(this.SettingsManager).StyleBorder() : string.Empty;
|
||||
|
||||
protected string? ValidatingProvider(AIStudio.Settings.Provider provider)
|
||||
{
|
||||
if(provider.UsedProvider == Providers.NONE)
|
||||
|
56
app/MindWork AI Studio/Components/ConfidenceInfo.razor
Normal file
56
app/MindWork AI Studio/Components/ConfidenceInfo.razor
Normal file
@ -0,0 +1,56 @@
|
||||
@using AIStudio.Provider
|
||||
<div class="d-flex">
|
||||
@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())"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Security" IconClass="confidence-icon" Style="@this.Provider.GetConfidence(this.SettingsManager).SetColorStyle()" OnClick="@(() => this.ToggleConfidence())">
|
||||
Confidence
|
||||
</MudButton>
|
||||
}
|
||||
|
||||
<MudPopover Open="@this.showConfidence" AnchorOrigin="Origin.TopLeft" TransformOrigin="Origin.BottomLeft" Style="@this.GetPopoverStyle()" DropShadow="@true" Class="border-solid border-4 rounded-lg">
|
||||
<MudCard>
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudText Typo="Typo.h5">Confidence Card</MudText>
|
||||
</CardHeaderContent>
|
||||
</MudCardHeader>
|
||||
<MudCardContent>
|
||||
<MudText Typo="Typo.h6">Description</MudText>
|
||||
<MudMarkdown Value="@this.currentConfidence.Description"/>
|
||||
|
||||
@if (this.currentConfidence.Sources.Count > 0)
|
||||
{
|
||||
<MudText Typo="Typo.h6">Sources</MudText>
|
||||
<MudList T="@string">
|
||||
@foreach (var sourceTuple in this.GetConfidenceSources())
|
||||
{
|
||||
<MudListItem Icon="@Icons.Material.Filled.Link" Href="@sourceTuple.Source" Target="_blank" Text="@sourceTuple.Index"/>
|
||||
}
|
||||
</MudList>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrWhiteSpace(this.currentConfidence.Region))
|
||||
{
|
||||
<MudText Typo="Typo.h6">Region</MudText>
|
||||
<MudText Typo="Typo.body1" Class="mb-3">
|
||||
<b>@this.currentConfidence.Region</b>
|
||||
</MudText>
|
||||
}
|
||||
|
||||
<MudText Typo="Typo.h6">Confidence Level</MudText>
|
||||
<MudText Typo="Typo.body1" Style="@this.GetCurrentConfidenceColor()">
|
||||
<b>@this.currentConfidence.Level.GetName()</b>
|
||||
</MudText>
|
||||
</MudCardContent>
|
||||
<MudCardActions>
|
||||
<MudButton Variant="Variant.Filled" OnClick="@(() => this.HideConfidence())">
|
||||
Close
|
||||
</MudButton>
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
</MudPopover>
|
||||
</div>
|
57
app/MindWork AI Studio/Components/ConfidenceInfo.razor.cs
Normal file
57
app/MindWork AI Studio/Components/ConfidenceInfo.razor.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
public partial class ConfidenceInfo : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public ConfidenceInfoMode Mode { get; set; } = ConfidenceInfoMode.BUTTON;
|
||||
|
||||
[Parameter]
|
||||
public Providers Provider { get; set; }
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; init; } = null!;
|
||||
|
||||
private Confidence currentConfidence;
|
||||
private bool showConfidence;
|
||||
|
||||
public ConfidenceInfo()
|
||||
{
|
||||
this.currentConfidence = Providers.NONE.GetConfidence(this.SettingsManager);
|
||||
}
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
this.currentConfidence = this.Provider.GetConfidence(this.SettingsManager);
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ToggleConfidence()
|
||||
{
|
||||
this.showConfidence = !this.showConfidence;
|
||||
}
|
||||
|
||||
private void HideConfidence()
|
||||
{
|
||||
this.showConfidence = false;
|
||||
}
|
||||
|
||||
private IEnumerable<(string Index, string Source)> GetConfidenceSources()
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var source in this.currentConfidence.Sources)
|
||||
yield return ($"Source {++index}", source);
|
||||
}
|
||||
|
||||
private string GetCurrentConfidenceColor() => $"color: {this.currentConfidence.Level.GetColor()};";
|
||||
|
||||
private string GetPopoverStyle() => $"border-color: {this.currentConfidence.Level.GetColor()}; max-width: calc(35vw);";
|
||||
}
|
7
app/MindWork AI Studio/Components/ConfidenceInfoMode.cs
Normal file
7
app/MindWork AI Studio/Components/ConfidenceInfoMode.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace AIStudio.Components;
|
||||
|
||||
public enum ConfidenceInfoMode
|
||||
{
|
||||
BUTTON,
|
||||
ICON,
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
</ChildContent>
|
||||
<FooterContent>
|
||||
<MudElement Style="flex: 0 0 auto;">
|
||||
<MudTextField T="string" @ref="@this.inputField" @bind-Text="@this.userInput" Variant="Variant.Outlined" AutoGrow="@true" Lines="3" MaxLines="12" Label="@this.InputLabel" Placeholder="@this.ProviderPlaceholder" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Send" OnAdornmentClick="() => this.SendMessage()" ReadOnly="!this.IsProviderSelected || this.isStreaming" Immediate="@true" OnKeyUp="this.InputKeyEvent" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||
<MudTextField T="string" @ref="@this.inputField" @bind-Text="@this.userInput" Variant="Variant.Outlined" AutoGrow="@true" Lines="3" MaxLines="12" Label="@this.InputLabel" Placeholder="@this.ProviderPlaceholder" Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Send" OnAdornmentClick="() => this.SendMessage()" ReadOnly="!this.IsProviderSelected || this.isStreaming" Immediate="@true" OnKeyUp="this.InputKeyEvent" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="@this.UserInputClass" Style="@this.UserInputStyle"/>
|
||||
</MudElement>
|
||||
<MudToolBar WrapContent="true" Gutters="@false" Class="border border-solid rounded" Style="border-color: lightgrey;">
|
||||
@if (this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is not WorkspaceStorageBehavior.DISABLE_WORKSPACES)
|
||||
@ -70,6 +70,11 @@
|
||||
</MudTooltip>
|
||||
}
|
||||
|
||||
@if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)
|
||||
{
|
||||
<ConfidenceInfo Mode="ConfidenceInfoMode.ICON" Provider="@this.providerSettings.UsedProvider"/>
|
||||
}
|
||||
|
||||
<ProfileSelection CurrentProfile="@this.currentProfile" CurrentProfileChanged="@this.ProfileWasChanged" />
|
||||
</MudToolBar>
|
||||
</FooterContent>
|
||||
|
@ -120,6 +120,10 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
||||
|
||||
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 UserInputClass => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? "confidence-border" : string.Empty;
|
||||
|
||||
private void ProfileWasChanged(Profile profile)
|
||||
{
|
||||
this.currentProfile = profile;
|
||||
|
@ -17,7 +17,7 @@
|
||||
task. As an LLM provider, you can also choose local providers. However, to use this app, you must
|
||||
configure at least one provider.
|
||||
</MudJustifiedText>
|
||||
<MudTable Items="@this.SettingsManager.ConfigurationData.Providers" Class="border-dashed border rounded-lg">
|
||||
<MudTable Items="@this.SettingsManager.ConfigurationData.Providers" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<ColGroup>
|
||||
<col style="width: 3em;"/>
|
||||
<col style="width: 12em;"/>
|
||||
@ -72,6 +72,56 @@
|
||||
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddProvider">
|
||||
Add Provider
|
||||
</MudButton>
|
||||
|
||||
<MudText Typo="Typo.h4" Class="mb-3">LLM Provider Confidence</MudText>
|
||||
<MudJustifiedText Class="mb-3">
|
||||
Do you want to always be able to recognize how trustworthy your LLM providers are? This way,
|
||||
you keep control over which provider you send your data to. You have two options for this:
|
||||
Either you choose a common schema, or you configure the trust levels for each LLM provider yourself.
|
||||
</MudJustifiedText>
|
||||
|
||||
<ConfigurationOption OptionDescription="Show provider's confidence level?" LabelOn="Yes, show me the confidence level" LabelOff="No, please hide the confidence level" State="@(() => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence = updatedState)" OptionHelp="When enabled, we show you the confidence level for the selected provider in the app. This helps you assess where you are sending your data at any time. Example: are you currently working with sensitive data? Then choose a particularly trustworthy provider, etc."/>
|
||||
@if (this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence)
|
||||
{
|
||||
<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">
|
||||
<ColGroup>
|
||||
<col style="width: 12em;"/>
|
||||
<col/>
|
||||
<col style="width: 22em;"/>
|
||||
</ColGroup>
|
||||
<HeaderContent>
|
||||
<MudTh>LLM Provider</MudTh>
|
||||
<MudTh>Description</MudTh>
|
||||
<MudTh>Confidence Level</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd Style="vertical-align: top;">
|
||||
@context.ToName()
|
||||
</MudTd>
|
||||
<MudTd>
|
||||
<MudMarkdown Value="@context.GetConfidence(this.SettingsManager).Description"/>
|
||||
</MudTd>
|
||||
<MudTd Style="vertical-align: top;">
|
||||
<MudMenu StartIcon="@Icons.Material.Filled.Security" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.GetCurrentConfidenceLevelName(context)" Variant="Variant.Filled" Style="@this.SetCurrentConfidenceLevelColorStyle(context)">
|
||||
@foreach (var confidenceLevel in Enum.GetValues<ConfidenceLevel>().OrderBy(n => n))
|
||||
{
|
||||
if(confidenceLevel is ConfidenceLevel.NONE or ConfidenceLevel.UNKNOWN)
|
||||
continue;
|
||||
|
||||
<MudMenuItem OnClick="@(async () => await this.ChangeCustomConfidenceLevel(context, confidenceLevel))">
|
||||
@confidenceLevel.GetName()
|
||||
</MudMenuItem>
|
||||
}
|
||||
</MudMenu>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
}
|
||||
|
||||
</ExpansionPanel>
|
||||
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Person4" HeaderText="Configure Profiles">
|
||||
@ -88,7 +138,7 @@
|
||||
code. In these profiles, you can record how much experience you have or which methods you like or
|
||||
dislike using. Later, you can choose when and where you want to use each profile.
|
||||
</MudJustifiedText>
|
||||
<MudTable Items="@this.SettingsManager.ConfigurationData.Profiles" Class="border-dashed border rounded-lg">
|
||||
<MudTable Items="@this.SettingsManager.ConfigurationData.Profiles" Hover="@true" Class="border-dashed border rounded-lg">
|
||||
<ColGroup>
|
||||
<col style="width: 3em;"/>
|
||||
<col/>
|
||||
|
@ -160,6 +160,28 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
|
||||
this.availableProviders.Add(new (provider.InstanceName, provider.Id));
|
||||
}
|
||||
|
||||
private string GetCurrentConfidenceLevelName(Providers provider)
|
||||
{
|
||||
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(provider, out var level))
|
||||
return level.GetName();
|
||||
|
||||
return "Not yet configured";
|
||||
}
|
||||
|
||||
private string SetCurrentConfidenceLevelColorStyle(Providers provider)
|
||||
{
|
||||
if (this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme.TryGetValue(provider, out var level))
|
||||
return $"background-color: {level.GetColor()};";
|
||||
|
||||
return $"background-color: {ConfidenceLevel.UNKNOWN.GetColor()};";
|
||||
}
|
||||
|
||||
private async Task ChangeCustomConfidenceLevel(Providers provider, ConfidenceLevel level)
|
||||
{
|
||||
this.SettingsManager.ConfigurationData.LLMProviders.CustomConfidenceScheme[provider] = level;
|
||||
await this.SettingsManager.StoreSettings();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profile related
|
||||
|
65
app/MindWork AI Studio/Provider/Confidence.cs
Normal file
65
app/MindWork AI Studio/Provider/Confidence.cs
Normal file
@ -0,0 +1,65 @@
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
public sealed record Confidence
|
||||
{
|
||||
public ConfidenceLevel Level { get; private init; } = ConfidenceLevel.UNKNOWN;
|
||||
|
||||
public string Region { get; private init; } = string.Empty;
|
||||
|
||||
public string Description { get; private init; } = string.Empty;
|
||||
|
||||
public List<string> Sources { get; private init; } = [];
|
||||
|
||||
private Confidence()
|
||||
{
|
||||
}
|
||||
|
||||
public Confidence WithSources(params string[] sources) => this with { Sources = sources.ToList() };
|
||||
|
||||
public Confidence WithRegion(string region) => this with { Region = region };
|
||||
|
||||
public Confidence WithLevel(ConfidenceLevel level) => this with { Level = level };
|
||||
|
||||
public string StyleBorder() => $"border: 2px solid {this.Level.GetColor()}; border-radius: 6px;";
|
||||
|
||||
public string SetColorStyle() => $"--confidence-color: {this.Level.GetColor()};";
|
||||
|
||||
public static readonly Confidence NONE = new()
|
||||
{
|
||||
Level = ConfidenceLevel.NONE,
|
||||
Description =
|
||||
"""
|
||||
No provider selected. Please select a provider to get see its confidence level.
|
||||
""",
|
||||
};
|
||||
|
||||
public static readonly Confidence USA_NOT_TRUSTED = new()
|
||||
{
|
||||
Level = ConfidenceLevel.UNTRUSTED,
|
||||
Description = "The provider operates its service from the USA and is subject to **U.S. jurisdiction**. In case of suspicion, authorities in the USA can access your data. The provider's terms of service state that **all your data can be used by the provider at will.**",
|
||||
};
|
||||
|
||||
public static readonly Confidence UNKNOWN = new()
|
||||
{
|
||||
Level = ConfidenceLevel.UNKNOWN,
|
||||
Description = "The trust level of this provider **has not yet** been thoroughly **investigated and evaluated**. We do not know if your data is safe.",
|
||||
};
|
||||
|
||||
public static readonly Confidence USA_NO_TRAINING = new()
|
||||
{
|
||||
Level = ConfidenceLevel.MODERATE,
|
||||
Description = "The provider operates its service from the USA and is subject to **US jurisdiction**. In case of suspicion, authorities in the USA can access your data. However, **your data is not used for training** purposes.",
|
||||
};
|
||||
|
||||
public static readonly Confidence GDPR_NO_TRAINING = new()
|
||||
{
|
||||
Level = ConfidenceLevel.MEDIUM,
|
||||
Description = "The provider is located in the EU and is subject to the **GDPR** (General Data Protection Regulation). Additionally, the provider states that **your data is not used for training**.",
|
||||
};
|
||||
|
||||
public static readonly Confidence SELF_HOSTED = new()
|
||||
{
|
||||
Level = ConfidenceLevel.HIGH,
|
||||
Description = "You or your organization operate the LLM locally or within your trusted network. In terms of data processing and security, this is the best possible way.",
|
||||
};
|
||||
}
|
18
app/MindWork AI Studio/Provider/ConfidenceLevel.cs
Normal file
18
app/MindWork AI Studio/Provider/ConfidenceLevel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
public enum ConfidenceLevel
|
||||
{
|
||||
NONE = 0,
|
||||
UNTRUSTED = 1,
|
||||
|
||||
UNKNOWN = 10,
|
||||
|
||||
VERY_LOW = 90,
|
||||
LOW = 100,
|
||||
|
||||
MODERATE = 150,
|
||||
|
||||
MEDIUM = 200,
|
||||
|
||||
HIGH = 300,
|
||||
}
|
34
app/MindWork AI Studio/Provider/ConfidenceLevelExtensions.cs
Normal file
34
app/MindWork AI Studio/Provider/ConfidenceLevelExtensions.cs
Normal file
@ -0,0 +1,34 @@
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
public static class ConfidenceLevelExtensions
|
||||
{
|
||||
public static string GetName(this ConfidenceLevel level) => level switch
|
||||
{
|
||||
ConfidenceLevel.NONE => "No provider selected",
|
||||
|
||||
ConfidenceLevel.UNTRUSTED => "Untrusted",
|
||||
ConfidenceLevel.VERY_LOW => "Very Low",
|
||||
ConfidenceLevel.LOW => "Low",
|
||||
ConfidenceLevel.MODERATE => "Moderate",
|
||||
ConfidenceLevel.MEDIUM => "Medium",
|
||||
ConfidenceLevel.HIGH => "High",
|
||||
|
||||
_ => "Unknown confidence level",
|
||||
};
|
||||
|
||||
public static string GetColor(this ConfidenceLevel level) => level switch
|
||||
{
|
||||
ConfidenceLevel.NONE => "#cccccc",
|
||||
|
||||
ConfidenceLevel.UNTRUSTED => "#ff0000",
|
||||
ConfidenceLevel.VERY_LOW => "#ff6600",
|
||||
ConfidenceLevel.LOW => "#ffcc00",
|
||||
ConfidenceLevel.MODERATE => "#99cc00",
|
||||
ConfidenceLevel.MEDIUM => "#86b300",
|
||||
ConfidenceLevel.HIGH => "#009933",
|
||||
|
||||
_ => "#cc6600",
|
||||
};
|
||||
|
||||
public static string SetColorStyle(this ConfidenceLevel level) => $"--confidence-color: {level.GetColor()};";
|
||||
}
|
@ -3,6 +3,7 @@ using AIStudio.Provider.Fireworks;
|
||||
using AIStudio.Provider.Mistral;
|
||||
using AIStudio.Provider.OpenAI;
|
||||
using AIStudio.Provider.SelfHosted;
|
||||
using AIStudio.Settings;
|
||||
|
||||
namespace AIStudio.Provider;
|
||||
|
||||
@ -28,6 +29,33 @@ public static class ProvidersExtensions
|
||||
_ => "Unknown",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Get a provider's confidence.
|
||||
/// </summary>
|
||||
/// <param name="provider">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
|
||||
{
|
||||
Providers.NONE => Confidence.NONE,
|
||||
|
||||
Providers.FIREWORKS => Confidence.USA_NOT_TRUSTED.WithRegion("America, U.S.").WithSources("https://fireworks.ai/terms-of-service").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
|
||||
|
||||
Providers.OPEN_AI => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources(
|
||||
"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)),
|
||||
|
||||
Providers.ANTHROPIC => Confidence.USA_NO_TRAINING.WithRegion("America, U.S.").WithSources("https://www.anthropic.com/legal/commercial-terms").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
|
||||
|
||||
Providers.MISTRAL => Confidence.GDPR_NO_TRAINING.WithRegion("Europe, France").WithSources("https://mistral.ai/terms/#terms-of-service-la-plateforme").WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
|
||||
|
||||
Providers.SELF_HOSTED => Confidence.SELF_HOSTED.WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
|
||||
|
||||
_ => Confidence.UNKNOWN.WithLevel(settingsManager.GetConfiguredConfidenceLevel(provider)),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new provider instance based on the provider value.
|
||||
/// </summary>
|
||||
|
@ -136,4 +136,10 @@ public static class ConfigurationSelectDataFactory
|
||||
foreach (var profile in profiles.GetAllProfiles())
|
||||
yield return new(profile.Name, profile.Id);
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigurationSelectData<ConfidenceSchemes>> GetConfidenceSchemesData()
|
||||
{
|
||||
foreach (var scheme in Enum.GetValues<ConfidenceSchemes>())
|
||||
yield return new(scheme.GetListDescription(), scheme);
|
||||
}
|
||||
}
|
@ -16,6 +16,11 @@ public sealed class Data
|
||||
/// </summary>
|
||||
public List<Provider> Providers { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Settings concerning the LLM providers.
|
||||
/// </summary>
|
||||
public DataLLMProviders LLMProviders { get; init; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// List of configured profiles.
|
||||
/// </summary>
|
||||
|
@ -0,0 +1,21 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataLLMProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we show the provider confidence level?
|
||||
/// </summary>
|
||||
public bool ShowProviderConfidence { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Which confidence scheme to use.
|
||||
/// </summary>
|
||||
public ConfidenceSchemes ConfidenceScheme { get; set; } = ConfidenceSchemes.TRUST_USA_EUROPE;
|
||||
|
||||
/// <summary>
|
||||
/// Provide custom confidence levels for each LLM provider.
|
||||
/// </summary>
|
||||
public Dictionary<Providers, ConfidenceLevel> CustomConfidenceScheme { get; set; } = new();
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
// ReSharper disable NotAccessedPositionalProperty.Local
|
||||
@ -160,4 +161,57 @@ public sealed class SettingsManager(ILogger<SettingsManager> logger)
|
||||
preselection = this.ConfigurationData.Profiles.FirstOrDefault(x => x.Id == this.ConfigurationData.App.PreselectedProfile);
|
||||
return preselection != default ? preselection : Profile.NO_PROFILE;
|
||||
}
|
||||
|
||||
public ConfidenceLevel GetConfiguredConfidenceLevel(Providers provider)
|
||||
{
|
||||
if(provider is Providers.NONE)
|
||||
return ConfidenceLevel.NONE;
|
||||
|
||||
switch (this.ConfigurationData.LLMProviders.ConfidenceScheme)
|
||||
{
|
||||
case ConfidenceSchemes.TRUST_USA_EUROPE:
|
||||
return provider switch
|
||||
{
|
||||
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
|
||||
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
|
||||
|
||||
_ => ConfidenceLevel.MEDIUM,
|
||||
};
|
||||
|
||||
case ConfidenceSchemes.TRUST_USA:
|
||||
return provider switch
|
||||
{
|
||||
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
|
||||
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
|
||||
Providers.MISTRAL => ConfidenceLevel.LOW,
|
||||
|
||||
_ => ConfidenceLevel.MEDIUM,
|
||||
};
|
||||
|
||||
case ConfidenceSchemes.TRUST_EUROPE:
|
||||
return provider switch
|
||||
{
|
||||
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
|
||||
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
|
||||
Providers.MISTRAL => ConfidenceLevel.MEDIUM,
|
||||
|
||||
_ => ConfidenceLevel.LOW,
|
||||
};
|
||||
|
||||
case ConfidenceSchemes.LOCAL_TRUST_ONLY:
|
||||
return provider switch
|
||||
{
|
||||
Providers.SELF_HOSTED => ConfidenceLevel.HIGH,
|
||||
Providers.FIREWORKS => ConfidenceLevel.UNTRUSTED,
|
||||
|
||||
_ => ConfidenceLevel.VERY_LOW,
|
||||
};
|
||||
|
||||
case ConfidenceSchemes.CUSTOM:
|
||||
return this.ConfigurationData.LLMProviders.CustomConfidenceScheme.GetValueOrDefault(provider, ConfidenceLevel.UNKNOWN);
|
||||
|
||||
default:
|
||||
return ConfidenceLevel.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
12
app/MindWork AI Studio/Tools/ConfidenceSchemes.cs
Normal file
12
app/MindWork AI Studio/Tools/ConfidenceSchemes.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public enum ConfidenceSchemes
|
||||
{
|
||||
TRUST_USA_EUROPE = 0,
|
||||
TRUST_USA = 1,
|
||||
TRUST_EUROPE = 2,
|
||||
|
||||
LOCAL_TRUST_ONLY = 3,
|
||||
|
||||
CUSTOM = 10_000,
|
||||
}
|
16
app/MindWork AI Studio/Tools/ConfidenceSchemesExtensions.cs
Normal file
16
app/MindWork AI Studio/Tools/ConfidenceSchemesExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
public static class ConfidenceSchemesExtensions
|
||||
{
|
||||
public static string GetListDescription(this ConfidenceSchemes scheme) => scheme switch
|
||||
{
|
||||
ConfidenceSchemes.TRUST_USA_EUROPE => "Trust LLM providers from the USA and Europe",
|
||||
ConfidenceSchemes.TRUST_USA => "Trust LLM providers from the USA",
|
||||
ConfidenceSchemes.TRUST_EUROPE => "Trust LLM providers from Europe",
|
||||
ConfidenceSchemes.LOCAL_TRUST_ONLY => "Trust only local LLM providers",
|
||||
|
||||
ConfidenceSchemes.CUSTOM => "Configure your own confidence scheme",
|
||||
|
||||
_ => "Unknown confidence scheme"
|
||||
};
|
||||
}
|
@ -34,3 +34,16 @@
|
||||
.mud-text-list .mud-list-item-icon {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
:root {
|
||||
--confidence-color: #000000;
|
||||
}
|
||||
|
||||
.confidence-icon {
|
||||
color: var(--confidence-color);
|
||||
}
|
||||
|
||||
.confidence-border > .mud-input-control-input-container > .mud-input > .mud-input-outlined-border {
|
||||
border-width: 2px;
|
||||
border-color: var(--confidence-color) !important;
|
||||
}
|
7
app/MindWork AI Studio/wwwroot/changelog/v0.9.9.md
Normal file
7
app/MindWork AI Studio/wwwroot/changelog/v0.9.9.md
Normal file
@ -0,0 +1,7 @@
|
||||
# v0.9.9, build 184 (2024-09-12 xx:xx UTC)
|
||||
- Added confidence information to LLM providers.
|
||||
- Added the possibility to choose from predefined confidence schemes.
|
||||
- Added the possibility to define your own confidence scheme.
|
||||
- Added an option to show/hide confidence information in the app.
|
||||
- Added a visual indicator for confidence in the chat and all assistants.
|
||||
- Added a confidence card to the chat and all assistants.
|
Loading…
Reference in New Issue
Block a user