mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-16 11:33:48 +00:00
Add agenda assistant (#69)
This commit is contained in:
1 parent
1ec86ec1a6
commit
6b7800b615
60 files changed
+1873
-582
No files matched your search
@@ -13,6 +13,7 @@ public partial class Changelog
|
||||
|
||||
public static readonly Log[] LOGS =
|
||||
[
|
||||
new (169, "v0.8.7, build 169 (2024-08-01 19:08 UTC)", "v0.8.7.md"),
|
||||
new (168, "v0.8.6, build 168 (2024-08-01 19:50 UTC)", "v0.8.6.md"),
|
||||
new (167, "v0.8.5, build 167 (2024-07-28 16:44 UTC)", "v0.8.5.md"),
|
||||
new (166, "v0.8.4, build 166 (2024-07-26 06:53 UTC)", "v0.8.4.md"),
|
||||
|
||||
@@ -42,10 +42,35 @@ public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct
|
||||
[Parameter]
|
||||
public Action<T> ValueUpdate { get; set; } = _ => { };
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await this.EnsureMinMax();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await this.EnsureMinMax();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task OptionChanged(T updatedValue)
|
||||
{
|
||||
this.ValueUpdate(updatedValue);
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.InformAboutChange();
|
||||
}
|
||||
|
||||
private async Task EnsureMinMax()
|
||||
{
|
||||
if (this.Value() < this.Min)
|
||||
await this.OptionChanged(this.Min);
|
||||
|
||||
else if(this.Value() > this.Max)
|
||||
await this.OptionChanged(this.Max);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@typeparam T
|
||||
@inherits EnumSelectionBase
|
||||
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
||||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection">
|
||||
@foreach (var value in Enum.GetValues<T>())
|
||||
{
|
||||
<MudSelectItem Value="@value">
|
||||
@this.NameFunc(value)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
@if (this.AllowOther && this.Value.Equals(this.OtherValue))
|
||||
{
|
||||
<MudTextField T="string" Text="@this.OtherInput" TextChanged="this.OtherInputChanged" Validation="@this.ValidateOther" Label="@this.LabelOther" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Immediate="@true"/>
|
||||
}
|
||||
</MudStack>
|
||||
@@ -0,0 +1,79 @@
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum
|
||||
{
|
||||
[Parameter]
|
||||
public T Value { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<T> ValueChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool AllowOther { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public T OtherValue { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string OtherInput { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> OtherInputChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string LabelOther { get; set; } = "Other";
|
||||
|
||||
[Parameter]
|
||||
public Func<T, string?> ValidateSelection { get; set; } = _ => null;
|
||||
|
||||
[Parameter]
|
||||
public Func<string, string?> ValidateOther { get; set; } = _ => null;
|
||||
|
||||
[Parameter]
|
||||
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom name function for selecting the display name of an enum value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
/// <param name="value">The enum value.</param>
|
||||
/// <returns>The display name of the enum value.</returns>
|
||||
[Parameter]
|
||||
public Func<T, string> NameFunc { get; set; } = value => value.ToString();
|
||||
|
||||
[Parameter]
|
||||
public Func<T, Task> SelectionUpdated { get; set; } = _ => Task.CompletedTask;
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; set; } = null!;
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Configure the spellchecking for the user input:
|
||||
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task SelectionChanged(T value)
|
||||
{
|
||||
await this.ValueChanged.InvokeAsync(value);
|
||||
await this.SelectionUpdated(value);
|
||||
}
|
||||
|
||||
private async Task OtherValueChanged(string value)
|
||||
{
|
||||
await this.OtherInputChanged.InvokeAsync(value);
|
||||
await this.SelectionUpdated(this.Value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public abstract class EnumSelectionBase : ComponentBase
|
||||
{
|
||||
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@typeparam T
|
||||
|
||||
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled()">
|
||||
<MudSlider T="@T" Size="Size.Medium" Value="@this.Value" ValueChanged="@this.ValueUpdated" Min="@this.Min" Max="@this.Max" Step="@this.Step" Immediate="@true" Disabled="@this.Disabled()">
|
||||
@this.Value @this.Unit
|
||||
</MudSlider>
|
||||
</MudField>
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Numerics;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public partial class MudTextSlider<T> : ComponentBase where T : struct, INumber<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The minimum value for the slider.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public T Min { get; set; } = T.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value for the slider.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public T Max { get; set; } = T.One;
|
||||
|
||||
/// <summary>
|
||||
/// The step size for the slider.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public T Step { get; set; } = T.One;
|
||||
|
||||
/// <summary>
|
||||
/// The unit to display next to the slider's value.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public T Value { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<T> ValueChanged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The label to display above the slider.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public Func<bool> Disabled { get; set; } = () => false;
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await this.EnsureMinMax();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await this.EnsureMinMax();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task EnsureMinMax()
|
||||
{
|
||||
if (this.Value < this.Min)
|
||||
await this.ValueUpdated(this.Min);
|
||||
|
||||
else if(this.Value > this.Max)
|
||||
await this.ValueUpdated(this.Max);
|
||||
}
|
||||
|
||||
private async Task ValueUpdated(T value)
|
||||
{
|
||||
this.Value = value;
|
||||
await this.ValueChanged.InvokeAsync(this.Value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled">
|
||||
<MudSwitch T="bool" Value="@this.Value" ValueChanged="@this.ValueChanged" Color="@this.Color" Validation="@this.Validation" Disabled="@this.Disabled">
|
||||
@(this.Value ? this.LabelOn : this.LabelOff)
|
||||
</MudSwitch>
|
||||
</MudField>
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public partial class MudTextSwitch : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Value { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> ValueChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Color Color { get; set; } = Color.Primary;
|
||||
|
||||
[Parameter]
|
||||
public Func<bool, string?> Validation { get; set; } = _ => null;
|
||||
|
||||
[Parameter]
|
||||
public string LabelOn { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string LabelOff { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
@typeparam T
|
||||
|
||||
@if (this.ShowProgressAnimation)
|
||||
{
|
||||
<div class="pa-1">
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true"/>
|
||||
</div>
|
||||
}
|
||||
<div class="pa-6">
|
||||
<MudSlider T="int" Disabled="@true" Value="@this.StepValue" Min="@this.process.Min" Max="@this.process.Max" TickMarks="@true" Size="Size.Large" Variant="Variant.Filled" TickMarkLabels="@this.process.Labels" Class="mb-12"/>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
using AIStudio.Tools;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public partial class ProcessComponent<T> : ComponentBase where T : struct, Enum
|
||||
{
|
||||
[Parameter]
|
||||
public bool ShowProgressAnimation { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public ProcessStepValue StepValue { get; set; }
|
||||
|
||||
private readonly Process<T> process = Process<T>.INSTANCE;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@using AIStudio.Settings
|
||||
|
||||
<MudSelect T="Provider" Value="@this.ProviderSettings" ValueChanged="@this.SelectionChanged" Validation="@this.ValidateProvider" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Apps" Margin="Margin.Dense" Label="Provider" Class="mb-3 rounded-lg" Variant="Variant.Outlined">
|
||||
@foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
|
||||
{
|
||||
<MudSelectItem Value="@provider"/>
|
||||
}
|
||||
</MudSelect>
|
||||
@@ -0,0 +1,26 @@
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components.Blocks;
|
||||
|
||||
public partial class ProviderSelection : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public Settings.Provider ProviderSettings { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<Settings.Provider> ProviderSettingsChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Func<Settings.Provider, string?> ValidateProvider { get; set; } = _ => null;
|
||||
|
||||
[Inject]
|
||||
protected SettingsManager SettingsManager { get; set; } = null!;
|
||||
|
||||
private async Task SelectionChanged(Settings.Provider provider)
|
||||
{
|
||||
this.ProviderSettings = provider;
|
||||
await this.ProviderSettingsChanged.InvokeAsync(provider);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,8 @@
|
||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
||||
<MudField Label="Read content from web?" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.AgentIsRunning">
|
||||
<MudSwitch T="bool" @bind-Value="@this.showWebContentReader" Color="Color.Primary" Disabled="@this.AgentIsRunning">
|
||||
@(this.showWebContentReader ? "Show web content options" : "Hide web content options")
|
||||
</MudSwitch>
|
||||
</MudField>
|
||||
|
||||
<MudTextSwitch Label="Read content from web?" Disabled="@this.AgentIsRunning" @bind-Value="@this.showWebContentReader" LabelOn="Show web content options" LabelOff="Hide web content options" />
|
||||
@if (this.showWebContentReader)
|
||||
{
|
||||
<MudField Label="Cleanup content by using a LLM agent?" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.AgentIsRunning">
|
||||
<MudSwitch T="bool" @bind-Value="@this.useContentCleanerAgent" Color="Color.Primary" Validation="@this.ValidateProvider" Disabled="@this.AgentIsRunning">
|
||||
@(this.useContentCleanerAgent ? "The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used." : "No content cleaning")
|
||||
</MudSwitch>
|
||||
</MudField>
|
||||
<MudTextSwitch Label="Cleanup content by using a LLM agent?" @bind-Value="@this.useContentCleanerAgent" Validation="@this.ValidateProvider" Disabled="@this.AgentIsRunning" LabelOn="The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used." LabelOff="No content cleaning" />
|
||||
<MudStack Row="@true" AlignItems="@AlignItems.Baseline" Class="mb-3">
|
||||
<MudTextField T="string" Label="URL from which to load the content" @bind-Value="@this.providedURL" Validation="@this.ValidateURL" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Link" Placeholder="https://..." HelperText="Loads the content from your URL. Does not work when the content is hidden behind a paywall." Variant="Variant.Outlined" Immediate="@true" Disabled="@this.AgentIsRunning"/>
|
||||
<MudButton Disabled="@(!this.IsReady || this.AgentIsRunning)" Variant="Variant.Filled" Size="Size.Large" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Download" OnClick="() => this.LoadFromWeb()">
|
||||
@@ -20,12 +11,7 @@
|
||||
</MudStack>
|
||||
@if (this.AgentIsRunning)
|
||||
{
|
||||
<div class="pa-1">
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class=""/>
|
||||
</div>
|
||||
<div class="pa-6">
|
||||
<MudSlider T="int" Disabled="@true" Value="@this.processStep" Min="@this.process.Min" Max="@this.process.Max" TickMarks="@true" Size="Size.Large" Variant="Variant.Filled" TickMarkLabels="@this.process.Labels" Class="mb-12"/>
|
||||
</div>
|
||||
<ProcessComponent T="ReadWebContentSteps" StepValue="@this.processStep" ShowProgressAnimation="@true"/>
|
||||
}
|
||||
}
|
||||
</MudPaper>
|
||||
@@ -17,10 +17,7 @@ public partial class ReadWebContent : ComponentBase
|
||||
|
||||
[Inject]
|
||||
protected SettingsManager SettingsManager { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JsRuntime { get; init; } = null!;
|
||||
|
||||
|
||||
[Parameter]
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
@@ -63,8 +60,8 @@ public partial class ReadWebContent : ComponentBase
|
||||
if(this.PreselectContentCleanerAgent)
|
||||
this.useContentCleanerAgent = true;
|
||||
|
||||
if (this.SettingsManager.ConfigurationData.PreselectAgentTextContentCleanerOptions)
|
||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedAgentTextContentCleanerProvider);
|
||||
if (this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)
|
||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectedAgentProvider);
|
||||
else
|
||||
this.providerSettings = this.ProviderSettings;
|
||||
|
||||
@@ -73,7 +70,7 @@ public partial class ReadWebContent : ComponentBase
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (!this.SettingsManager.ConfigurationData.PreselectAgentTextContentCleanerOptions)
|
||||
if (!this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)
|
||||
this.providerSettings = this.ProviderSettings;
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
|
||||
Reference in new issue
Block a user