Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add agenda assistant #69

Merged
merged 16 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/MindWork AI Studio/Chat/ContentText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ await Task.Run(async () =>
// Notify the UI that the content has changed,
// depending on the energy saving mode:
var now = DateTimeOffset.Now;
switch (settings.ConfigurationData.IsSavingEnergy)
switch (settings.ConfigurationData.App.IsSavingEnergy)
{
// Energy saving mode is off. We notify the UI
// as fast as possible -- no matter the odds:
Expand Down
1 change: 1 addition & 0 deletions app/MindWork AI Studio/Components/Blocks/Changelog.Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public readonly record struct Log(int Build, string Display, string Filename)

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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
17 changes: 17 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/EnumSelection.razor
Original file line number Diff line number Diff line change
@@ -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>
79 changes: 79 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/EnumSelection.razor.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
8 changes: 8 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/EnumSelectionBase.cs
Original file line number Diff line number Diff line change
@@ -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();
}
7 changes: 7 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/MudTextSlider.razor
Original file line number Diff line number Diff line change
@@ -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>
78 changes: 78 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/MudTextSlider.razor.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
5 changes: 5 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor
Original file line number Diff line number Diff line change
@@ -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>
30 changes: 30 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 11 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/ProcessComponent.razor
Original file line number Diff line number Diff line change
@@ -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>
16 changes: 16 additions & 0 deletions app/MindWork AI Studio/Components/Blocks/ProcessComponent.razor.cs
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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);
}
}
20 changes: 3 additions & 17 deletions app/MindWork AI Studio/Components/Blocks/ReadWebContent.razor
Original file line number Diff line number Diff line change
@@ -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()">
Expand All @@ -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>
Loading