Compare commits

...
8 Commits
157 changed files with 993 additions and 374 deletions

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
# MindWork AI Studio # MindWork AI Studio
![MindWork AI Studio](documentation/AI%20Studio.png) ![MindWork AI Studio - Home](documentation/AI%20Studio%20Home.png)
![MindWork AI Studio - Assistants](documentation/AI%20Studio%20Assistants.png)
MindWork AI Studio is a desktop application available for macOS, Windows, and Linux. It provides a unified chat interface for Large Language Models (LLMs). You bring your own API key for the respective LLM provider to use the models. The API keys are securely stored by the operating system. MindWork AI Studio is a desktop application available for macOS, Windows, and Linux. It provides a unified chat interface for Large Language Models (LLMs). You bring your own API key for the respective LLM provider to use the models. The API keys are securely stored by the operating system.
+30
View File
@@ -0,0 +1,30 @@
@using Microsoft.AspNetCore.Components.Web
@* ReSharper disable Html.PathError *@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MindWork AI Studio</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/"/>
<link rel="icon" type="image/png" href="favicon.png"/>
<link href="system/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="system/MudBlazor.Markdown/MudBlazor.Markdown.min.css" rel="stylesheet" />
<link href="app.css" rel="stylesheet" />
<HeadOutlet/>
<script src="diff.js"></script>
</head>
<body style="overflow: hidden;">
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)"/>
<script src="_framework/blazor.web.js" autostart="false"></script>
<script src="boot.js"></script>
<script src="system/MudBlazor/MudBlazor.min.js"></script>
<script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
<script src="app.js"></script>
</body>
</html>
@@ -1,5 +1,4 @@
@page "/assistant/agenda" @attribute [Route(Routes.ASSISTANT_AGENDA)]
@using AIStudio.Tools
@inherits AssistantBaseCore @inherits AssistantBaseCore
<MudTextField T="string" @bind-Text="@this.inputName" Validation="@this.ValidateName" Label="Meeting Name" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Tag" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Name the meeting, seminar, etc." Placeholder="Weekly jour fixe" Class="mb-3"/> <MudTextField T="string" @bind-Text="@this.inputName" Validation="@this.ValidateName" Label="Meeting Name" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Tag" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Name the meeting, seminar, etc." Placeholder="Weekly jour fixe" Class="mb-3"/>
@@ -1,8 +1,9 @@
using System.Text; using System.Text;
using AIStudio.Chat;
using AIStudio.Tools; using AIStudio.Tools;
namespace AIStudio.Components.Pages.Agenda; namespace AIStudio.Assistants.Agenda;
public partial class AssistantAgenda : AssistantBaseCore public partial class AssistantAgenda : AssistantBaseCore
{ {
@@ -93,6 +94,78 @@ public partial class AssistantAgenda : AssistantBaseCore
- Mary Jane: Work package 3 - Mary Jane: Work package 3
"""; """;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new SendToButton
{
Self = SendTo.AGENDA_ASSISTANT,
},
];
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
};
protected override void ResetFrom()
{
this.inputContent = string.Empty;
this.contentLines.Clear();
this.selectedFoci = [];
this.justBriefly = [];
this.inputWhoIsPresenting = string.Empty;
if (!this.MightPreselectValues())
{
this.inputTopic = string.Empty;
this.inputName = string.Empty;
this.inputDuration = string.Empty;
this.inputStartTime = string.Empty;
this.inputObjective = string.Empty;
this.inputModerator = string.Empty;
this.selectedTargetLanguage = CommonLanguages.AS_IS;
this.customTargetLanguage = string.Empty;
this.introduceParticipants = false;
this.isMeetingVirtual = true;
this.inputLocation = string.Empty;
this.goingToDinner = false;
this.doingSocialActivity = false;
this.needToArriveAndDepart = false;
this.durationLunchBreak = 0;
this.durationBreaks = 0;
this.activeParticipation = false;
this.numberParticipants = NumberParticipants.NOT_SPECIFIED;
}
}
protected override bool MightPreselectValues()
{
if (this.SettingsManager.ConfigurationData.Agenda.PreselectOptions)
{
this.inputTopic = this.SettingsManager.ConfigurationData.Agenda.PreselectTopic;
this.inputName = this.SettingsManager.ConfigurationData.Agenda.PreselectName;
this.inputDuration = this.SettingsManager.ConfigurationData.Agenda.PreselectDuration;
this.inputStartTime = this.SettingsManager.ConfigurationData.Agenda.PreselectStartTime;
this.inputObjective = this.SettingsManager.ConfigurationData.Agenda.PreselectObjective;
this.inputModerator = this.SettingsManager.ConfigurationData.Agenda.PreselectModerator;
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.Agenda.PreselectedTargetLanguage;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Agenda.PreselectedOtherLanguage;
this.introduceParticipants = this.SettingsManager.ConfigurationData.Agenda.PreselectIntroduceParticipants;
this.isMeetingVirtual = this.SettingsManager.ConfigurationData.Agenda.PreselectIsMeetingVirtual;
this.inputLocation = this.SettingsManager.ConfigurationData.Agenda.PreselectLocation;
this.goingToDinner = this.SettingsManager.ConfigurationData.Agenda.PreselectJointDinner;
this.doingSocialActivity = this.SettingsManager.ConfigurationData.Agenda.PreselectSocialActivity;
this.needToArriveAndDepart = this.SettingsManager.ConfigurationData.Agenda.PreselectArriveAndDepart;
this.durationLunchBreak = this.SettingsManager.ConfigurationData.Agenda.PreselectLunchTime;
this.durationBreaks = this.SettingsManager.ConfigurationData.Agenda.PreselectBreakTime;
this.activeParticipation = this.SettingsManager.ConfigurationData.Agenda.PreselectActiveParticipation;
this.numberParticipants = this.SettingsManager.ConfigurationData.Agenda.PreselectNumberParticipants;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Agenda.PreselectedProvider);
return true;
}
return false;
}
private string inputTopic = string.Empty; private string inputTopic = string.Empty;
private string inputName = string.Empty; private string inputName = string.Empty;
private string inputContent = string.Empty; private string inputContent = string.Empty;
@@ -122,28 +195,10 @@ public partial class AssistantAgenda : AssistantBaseCore
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (this.SettingsManager.ConfigurationData.Agenda.PreselectOptions) this.MightPreselectValues();
{ var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_AGENDA_ASSISTANT).FirstOrDefault();
this.inputTopic = this.SettingsManager.ConfigurationData.Agenda.PreselectTopic; if (deferredContent is not null)
this.inputName = this.SettingsManager.ConfigurationData.Agenda.PreselectName; this.inputContent = deferredContent;
this.inputDuration = this.SettingsManager.ConfigurationData.Agenda.PreselectDuration;
this.inputStartTime = this.SettingsManager.ConfigurationData.Agenda.PreselectStartTime;
this.inputObjective = this.SettingsManager.ConfigurationData.Agenda.PreselectObjective;
this.inputModerator = this.SettingsManager.ConfigurationData.Agenda.PreselectModerator;
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.Agenda.PreselectedTargetLanguage;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Agenda.PreselectedOtherLanguage;
this.introduceParticipants = this.SettingsManager.ConfigurationData.Agenda.PreselectIntroduceParticipants;
this.isMeetingVirtual = this.SettingsManager.ConfigurationData.Agenda.PreselectIsMeetingVirtual;
this.inputLocation = this.SettingsManager.ConfigurationData.Agenda.PreselectLocation;
this.goingToDinner = this.SettingsManager.ConfigurationData.Agenda.PreselectJointDinner;
this.doingSocialActivity = this.SettingsManager.ConfigurationData.Agenda.PreselectSocialActivity;
this.needToArriveAndDepart = this.SettingsManager.ConfigurationData.Agenda.PreselectArriveAndDepart;
this.durationLunchBreak = this.SettingsManager.ConfigurationData.Agenda.PreselectLunchTime;
this.durationBreaks = this.SettingsManager.ConfigurationData.Agenda.PreselectBreakTime;
this.activeParticipation = this.SettingsManager.ConfigurationData.Agenda.PreselectActiveParticipation;
this.numberParticipants = this.SettingsManager.ConfigurationData.Agenda.PreselectNumberParticipants;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Agenda.PreselectedProvider);
}
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.Agenda; namespace AIStudio.Assistants.Agenda;
public enum NumberParticipants public enum NumberParticipants
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.Agenda; namespace AIStudio.Assistants.Agenda;
public static class NumberParticipantsExtensions public static class NumberParticipantsExtensions
{ {
@@ -0,0 +1,79 @@
@using AIStudio.Chat
<MudText Typo="Typo.h3" Class="mb-2 mr-3">
@(this.Title)
</MudText>
<InnerScrolling HeaderHeight="12.3em">
<ChildContent>
<MudForm @ref="@(this.form)" @bind-IsValid="@(this.inputIsValid)" @bind-Errors="@(this.inputIssues)" Class="pr-2">
<MudText Typo="Typo.body1" Align="Align.Justify" Class="mb-6">
@(this.Description)
</MudText>
@if (this.Body is not null)
{
@(this.Body)
}
</MudForm>
<Issues IssuesData="@(this.inputIssues)"/>
@if (this.ShowDedicatedProgress && this.isProcessing)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-6" />
}
<div id="@RESULT_DIV_ID" class="mr-2 mt-3">
</div>
@if (this.ShowResult && this.resultingContentBlock is not null)
{
<ContentBlockComponent Role="@(this.resultingContentBlock.Role)" Type="@(this.resultingContentBlock.ContentType)" Time="@(this.resultingContentBlock.Time)" Content="@(this.resultingContentBlock.Content)"/>
}
<div id="@AFTER_RESULT_DIV_ID" class="mt-3">
</div>
@if (this.FooterButtons.Count > 0)
{
<MudStack Row="@true" Wrap="Wrap.Wrap" Class="mt-3 mr-2">
@foreach (var button in this.FooterButtons)
{
switch (button)
{
case ButtonData buttonData when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
<MudTooltip Text="@buttonData.Tooltip">
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
@buttonData.Text
</MudButton>
</MudTooltip>
break;
case ButtonData buttonData:
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
@buttonData.Text
</MudButton>
break;
case SendToButton sendToButton:
<MudMenu StartIcon="@Icons.Material.Filled.Apps" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Send to ..." Variant="Variant.Filled" Color="Color.Info">
@foreach (var assistant in Enum.GetValues<SendTo>().OrderBy(n => n.Name().Length))
{
if(assistant is SendTo.NONE || sendToButton.Self == assistant)
continue;
<MudMenuItem OnClick="() => this.SendToAssistant(assistant, sendToButton)">
@assistant.Name()
</MudMenuItem>
}
</MudMenu>
break;
}
}
<MudButton Variant="Variant.Filled" Color="Color.Warning" StartIcon="@Icons.Material.Filled.Refresh" OnClick="() => this.InnerResetForm()">
Reset
</MudButton>
</MudStack>
}
</ChildContent>
</InnerScrolling>
@@ -5,7 +5,7 @@ using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components; namespace AIStudio.Assistants;
public abstract partial class AssistantBase : ComponentBase public abstract partial class AssistantBase : ComponentBase
{ {
@@ -24,14 +24,21 @@ public abstract partial class AssistantBase : ComponentBase
[Inject] [Inject]
protected Rust Rust { get; init; } = null!; protected Rust Rust { get; init; } = null!;
[Inject]
protected NavigationManager NavigationManager { get; init; } = null!;
internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult"; internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult";
internal const string ASSISTANT_RESULT_DIV_ID = "assistantResult"; internal const string RESULT_DIV_ID = "assistantResult";
protected abstract string Title { get; } protected abstract string Title { get; }
protected abstract string Description { get; } protected abstract string Description { get; }
protected abstract string SystemPrompt { get; } protected abstract string SystemPrompt { get; }
protected abstract void ResetFrom();
protected abstract bool MightPreselectValues();
private protected virtual RenderFragment? Body => null; private protected virtual RenderFragment? Body => null;
@@ -39,7 +46,9 @@ public abstract partial class AssistantBase : ComponentBase
protected virtual bool ShowDedicatedProgress => false; protected virtual bool ShowDedicatedProgress => false;
protected virtual IReadOnlyList<ButtonData> FooterButtons => []; protected virtual ChatThread ConvertToChatThread => this.chatThread ?? new();
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new(); protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
@@ -47,7 +56,7 @@ public abstract partial class AssistantBase : ComponentBase
protected MudForm? form; protected MudForm? form;
protected bool inputIsValid; protected bool inputIsValid;
private ChatThread? chatThread; protected ChatThread? chatThread;
private ContentBlock? resultingContentBlock; private ContentBlock? resultingContentBlock;
private string[] inputIssues = []; private string[] inputIssues = [];
private bool isProcessing; private bool isProcessing;
@@ -157,4 +166,64 @@ public abstract partial class AssistantBase : ComponentBase
return icon; return icon;
} }
private Task SendToAssistant(SendTo destination, SendToButton sendToButton)
{
var contentToSend = sendToButton.UseResultingContentBlockData switch
{
false => sendToButton.GetText(),
true => this.resultingContentBlock?.Content switch
{
ContentText textBlock => textBlock.Text,
_ => string.Empty,
},
};
var (eventItem, path) = destination switch
{
SendTo.AGENDA_ASSISTANT => (Event.SEND_TO_AGENDA_ASSISTANT, Routes.ASSISTANT_AGENDA),
SendTo.CODING_ASSISTANT => (Event.SEND_TO_CODING_ASSISTANT, Routes.ASSISTANT_CODING),
SendTo.REWRITE_ASSISTANT => (Event.SEND_TO_REWRITE_ASSISTANT, Routes.ASSISTANT_REWRITE),
SendTo.TRANSLATION_ASSISTANT => (Event.SEND_TO_TRANSLATION_ASSISTANT, Routes.ASSISTANT_TRANSLATION),
SendTo.ICON_FINDER_ASSISTANT => (Event.SEND_TO_ICON_FINDER_ASSISTANT, Routes.ASSISTANT_ICON_FINDER),
SendTo.GRAMMAR_SPELLING_ASSISTANT => (Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT, Routes.ASSISTANT_GRAMMAR_SPELLING),
SendTo.TEXT_SUMMARIZER_ASSISTANT => (Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT, Routes.ASSISTANT_SUMMARIZER),
SendTo.CHAT => (Event.SEND_TO_CHAT, Routes.CHAT),
_ => (Event.NONE, Routes.ASSISTANTS),
};
switch (destination)
{
case SendTo.CHAT:
MessageBus.INSTANCE.DeferMessage(this, eventItem, this.ConvertToChatThread);
break;
default:
MessageBus.INSTANCE.DeferMessage(this, eventItem, contentToSend);
break;
}
this.NavigationManager.NavigateTo(path);
return Task.CompletedTask;
}
private async Task InnerResetForm()
{
this.resultingContentBlock = null;
this.providerSettings = default;
await this.JsRuntime.ClearDiv(RESULT_DIV_ID);
await this.JsRuntime.ClearDiv(AFTER_RESULT_DIV_ID);
this.ResetFrom();
this.inputIsValid = false;
this.inputIssues = [];
this.form?.ResetValidation();
this.StateHasChanged();
this.form?.ResetValidation();
}
} }
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering; using Microsoft.AspNetCore.Components.Rendering;
namespace AIStudio.Components; namespace AIStudio.Assistants;
// //
// See https://stackoverflow.com/a/77300384/2258393 for why this class is necessary // See https://stackoverflow.com/a/77300384/2258393 for why this class is necessary
@@ -1,4 +1,4 @@
@page "/assistant/coding" @attribute [Route(Routes.ASSISTANT_CODING)]
@inherits AssistantBaseCore @inherits AssistantBaseCore
<MudExpansionPanels Class="mb-3"> <MudExpansionPanels Class="mb-3">
@@ -1,6 +1,8 @@
using System.Text; using System.Text;
namespace AIStudio.Components.Pages.Coding; using AIStudio.Tools;
namespace AIStudio.Assistants.Coding;
public partial class AssistantCoding : AssistantBaseCore public partial class AssistantCoding : AssistantBaseCore
{ {
@@ -24,6 +26,37 @@ public partial class AssistantCoding : AssistantBaseCore
When the user asks in a different language than English, you answer in the same language! When the user asks in a different language than English, you answer in the same language!
"""; """;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new SendToButton
{
Self = SendTo.CODING_ASSISTANT,
},
];
protected override void ResetFrom()
{
this.codingContexts.Clear();
this.compilerMessages = string.Empty;
this.questions = string.Empty;
if (!this.MightPreselectValues())
{
this.provideCompilerMessages = false;
}
}
protected override bool MightPreselectValues()
{
if (this.SettingsManager.ConfigurationData.Coding.PreselectOptions)
{
this.provideCompilerMessages = this.SettingsManager.ConfigurationData.Coding.PreselectCompilerMessages;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Coding.PreselectedProvider);
return true;
}
return false;
}
private readonly List<CodingContext> codingContexts = new(); private readonly List<CodingContext> codingContexts = new();
private bool provideCompilerMessages; private bool provideCompilerMessages;
private string compilerMessages = string.Empty; private string compilerMessages = string.Empty;
@@ -33,11 +66,10 @@ public partial class AssistantCoding : AssistantBaseCore
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (this.SettingsManager.ConfigurationData.Coding.PreselectOptions) this.MightPreselectValues();
{ var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CODING_ASSISTANT).FirstOrDefault();
this.provideCompilerMessages = this.SettingsManager.ConfigurationData.Coding.PreselectCompilerMessages; if (deferredContent is not null)
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Coding.PreselectedProvider); this.questions = deferredContent;
}
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -87,9 +119,13 @@ public partial class AssistantCoding : AssistantBaseCore
foreach (var codingContext in this.codingContexts) foreach (var codingContext in this.codingContexts)
{ {
sbContext.AppendLine($"ID: {codingContext.Id}"); sbContext.AppendLine($"ID: {codingContext.Id}");
sbContext.AppendLine($"Language: {codingContext.Language.Name()}");
sbContext.AppendLine($"Other Language: {codingContext.OtherLanguage}"); if(codingContext.Language is not CommonCodingLanguages.OTHER)
sbContext.AppendLine($"Content:"); sbContext.AppendLine($"Language: {codingContext.Language.Name()}");
else
sbContext.AppendLine($"Language: {codingContext.OtherLanguage}");
sbContext.AppendLine("Content:");
sbContext.AppendLine("```"); sbContext.AppendLine("```");
sbContext.AppendLine(codingContext.Code); sbContext.AppendLine(codingContext.Code);
sbContext.AppendLine("```"); sbContext.AppendLine("```");
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.Coding; namespace AIStudio.Assistants.Coding;
public sealed class CodingContext(string id, CommonCodingLanguages language, string otherLanguage, string code) public sealed class CodingContext(string id, CommonCodingLanguages language, string otherLanguage, string code)
{ {
@@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Pages.Coding; namespace AIStudio.Assistants.Coding;
public partial class CodingContextItem : ComponentBase public partial class CodingContextItem : ComponentBase
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.Coding; namespace AIStudio.Assistants.Coding;
public static class CommonCodingLanguageExtensions public static class CommonCodingLanguageExtensions
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.Coding; namespace AIStudio.Assistants.Coding;
public enum CommonCodingLanguages public enum CommonCodingLanguages
{ {
@@ -1,5 +1,4 @@
@using AIStudio.Tools @attribute [Route(Routes.ASSISTANT_GRAMMAR_SPELLING)]
@page "/assistant/grammar-spelling"
@inherits AssistantBaseCore @inherits AssistantBaseCore
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to check" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/> <MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to check" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Tools; using AIStudio.Tools;
namespace AIStudio.Components.Pages.GrammarSpelling; namespace AIStudio.Assistants.GrammarSpelling;
public partial class AssistantGrammarSpelling : AssistantBaseCore public partial class AssistantGrammarSpelling : AssistantBaseCore
{ {
@@ -25,22 +26,55 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
protected override bool ShowDedicatedProgress => true; protected override bool ShowDedicatedProgress => true;
protected override IReadOnlyList<ButtonData> FooterButtons => new[] protected override IReadOnlyList<IButtonData> FooterButtons =>
{ [
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.correctedText)), new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.correctedText)),
new SendToButton
{
Self = SendTo.GRAMMAR_SPELLING_ASSISTANT,
UseResultingContentBlockData = false,
GetText = () => string.IsNullOrWhiteSpace(this.correctedText) ? this.inputText : this.correctedText
},
];
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
}; };
#region Overrides of ComponentBase protected override void ResetFrom()
{
this.inputText = string.Empty;
this.correctedText = string.Empty;
if (!this.MightPreselectValues())
{
this.selectedTargetLanguage = CommonLanguages.AS_IS;
this.customTargetLanguage = string.Empty;
}
}
protected override async Task OnInitializedAsync() protected override bool MightPreselectValues()
{ {
if (this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectOptions) if (this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectOptions)
{ {
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedTargetLanguage; this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedTargetLanguage;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedOtherLanguage; this.customTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedOtherLanguage;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedProvider); this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedProvider);
return true;
} }
return false;
}
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
this.MightPreselectValues();
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT).FirstOrDefault();
if (deferredContent is not null)
this.inputText = deferredContent;
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -1,4 +1,4 @@
@page "/assistant/icons" @attribute [Route(Routes.ASSISTANT_ICON_FINDER)]
@inherits AssistantBaseCore @inherits AssistantBaseCore
<MudTextField T="string" @bind-Text="@this.inputContext" Validation="@this.ValidatingContext" AdornmentIcon="@Icons.Material.Filled.Description" Adornment="Adornment.Start" Label="Your context" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/> <MudTextField T="string" @bind-Text="@this.inputContext" Validation="@this.ValidatingContext" AdornmentIcon="@Icons.Material.Filled.Description" Adornment="Adornment.Start" Label="Your context" Variant="Variant.Outlined" Lines="3" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,25 +1,12 @@
namespace AIStudio.Components.Pages.IconFinder; using AIStudio.Tools;
namespace AIStudio.Assistants.IconFinder;
public partial class AssistantIconFinder : AssistantBaseCore public partial class AssistantIconFinder : AssistantBaseCore
{ {
private string inputContext = string.Empty; private string inputContext = string.Empty;
private IconSources selectedIconSource; private IconSources selectedIconSource;
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
if (this.SettingsManager.ConfigurationData.IconFinder.PreselectOptions)
{
this.selectedIconSource = this.SettingsManager.ConfigurationData.IconFinder.PreselectedSource;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.IconFinder.PreselectedProvider);
}
await base.OnInitializedAsync();
}
#endregion
protected override string Title => "Icon Finder"; protected override string Title => "Icon Finder";
protected override string Description => protected override string Description =>
@@ -40,7 +27,50 @@ public partial class AssistantIconFinder : AssistantBaseCore
related to the keyword "buildings" might be the best match. Provide your keywords in a Markdown list without related to the keyword "buildings" might be the best match. Provide your keywords in a Markdown list without
quotation marks. quotation marks.
"""; """;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new SendToButton
{
Self = SendTo.ICON_FINDER_ASSISTANT,
},
];
protected override void ResetFrom()
{
this.inputContext = string.Empty;
if (!this.MightPreselectValues())
{
this.selectedIconSource = IconSources.GENERIC;
}
}
protected override bool MightPreselectValues()
{
if (this.SettingsManager.ConfigurationData.IconFinder.PreselectOptions)
{
this.selectedIconSource = this.SettingsManager.ConfigurationData.IconFinder.PreselectedSource;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.IconFinder.PreselectedProvider);
return true;
}
return false;
}
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
this.MightPreselectValues();
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_ICON_FINDER_ASSISTANT).FirstOrDefault();
if (deferredContent is not null)
this.inputContext = deferredContent;
await base.OnInitializedAsync();
}
#endregion
private string? ValidatingContext(string context) private string? ValidatingContext(string context)
{ {
if(string.IsNullOrWhiteSpace(context)) if(string.IsNullOrWhiteSpace(context))
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.IconFinder; namespace AIStudio.Assistants.IconFinder;
public static class IconSourceExtensions public static class IconSourceExtensions
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.IconFinder; namespace AIStudio.Assistants.IconFinder;
public enum IconSources public enum IconSources
{ {
@@ -1,5 +1,4 @@
@using AIStudio.Tools @attribute [Route(Routes.ASSISTANT_REWRITE)]
@page "/assistant/rewrite-improve"
@inherits AssistantBaseCore @inherits AssistantBaseCore
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to improve" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/> <MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidateText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input to improve" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Tools; using AIStudio.Tools;
namespace AIStudio.Components.Pages.RewriteImprove; namespace AIStudio.Assistants.RewriteImprove;
public partial class AssistantRewriteImprove : AssistantBaseCore public partial class AssistantRewriteImprove : AssistantBaseCore
{ {
@@ -24,20 +25,37 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
protected override bool ShowResult => false; protected override bool ShowResult => false;
#region Overrides of AssistantBase
protected override bool ShowDedicatedProgress => true; protected override bool ShowDedicatedProgress => true;
#endregion protected override IReadOnlyList<IButtonData> FooterButtons =>
[
protected override IReadOnlyList<ButtonData> FooterButtons => new[]
{
new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.rewrittenText)), new ButtonData("Copy result", Icons.Material.Filled.ContentCopy, Color.Default, string.Empty, () => this.CopyToClipboard(this.rewrittenText)),
}; new SendToButton
{
Self = SendTo.REWRITE_ASSISTANT,
UseResultingContentBlockData = false,
GetText = () => string.IsNullOrWhiteSpace(this.rewrittenText) ? this.inputText : this.rewrittenText,
},
];
#region Overrides of ComponentBase protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
};
protected override async Task OnInitializedAsync() protected override void ResetFrom()
{
this.inputText = string.Empty;
this.rewrittenText = string.Empty;
if (!this.MightPreselectValues())
{
this.selectedTargetLanguage = CommonLanguages.AS_IS;
this.customTargetLanguage = string.Empty;
this.selectedWritingStyle = WritingStyles.NOT_SPECIFIED;
}
}
protected override bool MightPreselectValues()
{ {
if (this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions) if (this.SettingsManager.ConfigurationData.RewriteImprove.PreselectOptions)
{ {
@@ -45,8 +63,21 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
this.customTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage; this.customTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider); this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider);
this.selectedWritingStyle = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle; this.selectedWritingStyle = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedWritingStyle;
return true;
} }
return false;
}
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
this.MightPreselectValues();
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_REWRITE_ASSISTANT).FirstOrDefault();
if (deferredContent is not null)
this.inputText = deferredContent;
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.RewriteImprove; namespace AIStudio.Assistants.RewriteImprove;
public enum WritingStyles public enum WritingStyles
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.RewriteImprove; namespace AIStudio.Assistants.RewriteImprove;
public static class WritingStylesExtensions public static class WritingStylesExtensions
{ {
@@ -1,5 +1,4 @@
@page "/assistant/summarizer" @attribute [Route(Routes.ASSISTANT_SUMMARIZER)]
@using AIStudio.Tools
@inherits AssistantBaseCore @inherits AssistantBaseCore
@if (!this.SettingsManager.ConfigurationData.TextSummarizer.HideWebContentReader) @if (!this.SettingsManager.ConfigurationData.TextSummarizer.HideWebContentReader)
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Tools; using AIStudio.Tools;
namespace AIStudio.Components.Pages.TextSummarizer; namespace AIStudio.Assistants.TextSummarizer;
public partial class AssistantTextSummarizer : AssistantBaseCore public partial class AssistantTextSummarizer : AssistantBaseCore
{ {
@@ -23,6 +24,46 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
a summary with the requested complexity. In any case, do not add any information. a summary with the requested complexity. In any case, do not add any information.
"""; """;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new SendToButton
{
Self = SendTo.TEXT_SUMMARIZER_ASSISTANT,
},
];
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
};
protected override void ResetFrom()
{
this.inputText = string.Empty;
if(!this.MightPreselectValues())
{
this.selectedTargetLanguage = CommonLanguages.AS_IS;
this.customTargetLanguage = string.Empty;
this.selectedComplexity = Complexity.NO_CHANGE;
this.expertInField = string.Empty;
}
}
protected override bool MightPreselectValues()
{
if (this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions)
{
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedTargetLanguage;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedOtherLanguage;
this.selectedComplexity = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedComplexity;
this.expertInField = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedExpertInField;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedProvider);
return true;
}
return false;
}
private string inputText = string.Empty; private string inputText = string.Empty;
private bool isAgentRunning; private bool isAgentRunning;
private CommonLanguages selectedTargetLanguage; private CommonLanguages selectedTargetLanguage;
@@ -34,14 +75,10 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions) this.MightPreselectValues();
{ var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT).FirstOrDefault();
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedTargetLanguage; if (deferredContent is not null)
this.customTargetLanguage = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedOtherLanguage; this.inputText = deferredContent;
this.selectedComplexity = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedComplexity;
this.expertInField = this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedExpertInField;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.TextSummarizer.PreselectedProvider);
}
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.TextSummarizer; namespace AIStudio.Assistants.TextSummarizer;
public enum Complexity public enum Complexity
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Pages.TextSummarizer; namespace AIStudio.Assistants.TextSummarizer;
public static class ComplexityExtensions public static class ComplexityExtensions
{ {
@@ -1,5 +1,4 @@
@page "/assistant/translation" @attribute [Route(Routes.ASSISTANT_TRANSLATION)]
@using AIStudio.Tools
@inherits AssistantBaseCore @inherits AssistantBaseCore
@if (!this.SettingsManager.ConfigurationData.Translation.HideWebContentReader) @if (!this.SettingsManager.ConfigurationData.Translation.HideWebContentReader)
@@ -1,6 +1,7 @@
using AIStudio.Chat;
using AIStudio.Tools; using AIStudio.Tools;
namespace AIStudio.Components.Pages.Translation; namespace AIStudio.Assistants.Translation;
public partial class AssistantTranslation : AssistantBaseCore public partial class AssistantTranslation : AssistantBaseCore
{ {
@@ -19,6 +20,45 @@ public partial class AssistantTranslation : AssistantBaseCore
language requires, e.g., shorter sentences, you should split the text into shorter sentences. language requires, e.g., shorter sentences, you should split the text into shorter sentences.
"""; """;
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new SendToButton
{
Self = SendTo.TRANSLATION_ASSISTANT,
},
];
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
{
SystemPrompt = SystemPrompts.DEFAULT,
};
protected override void ResetFrom()
{
this.inputText = string.Empty;
this.inputTextLastTranslation = string.Empty;
if (!this.MightPreselectValues())
{
this.liveTranslation = false;
this.selectedTargetLanguage = CommonLanguages.AS_IS;
this.customTargetLanguage = string.Empty;
}
}
protected override bool MightPreselectValues()
{
if (this.SettingsManager.ConfigurationData.Translation.PreselectOptions)
{
this.liveTranslation = this.SettingsManager.ConfigurationData.Translation.PreselectLiveTranslation;
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectedTargetLanguage;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectOtherLanguage;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Translation.PreselectedProvider);
return true;
}
return false;
}
private bool liveTranslation; private bool liveTranslation;
private bool isAgentRunning; private bool isAgentRunning;
private string inputText = string.Empty; private string inputText = string.Empty;
@@ -30,13 +70,10 @@ public partial class AssistantTranslation : AssistantBaseCore
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (this.SettingsManager.ConfigurationData.Translation.PreselectOptions) this.MightPreselectValues();
{ var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TRANSLATION_ASSISTANT).FirstOrDefault();
this.liveTranslation = this.SettingsManager.ConfigurationData.Translation.PreselectLiveTranslation; if (deferredContent is not null)
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectedTargetLanguage; this.inputText = deferredContent;
this.customTargetLanguage = this.SettingsManager.ConfigurationData.Translation.PreselectOtherLanguage;
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Translation.PreselectedProvider);
}
await base.OnInitializedAsync(); await base.OnInitializedAsync();
} }
@@ -0,0 +1,4 @@
@using AIStudio
@using AIStudio.Tools
@using AIStudio.Components
@using MudBlazor
+1 -1
View File
@@ -3,7 +3,7 @@ namespace AIStudio.Chat;
/// <summary> /// <summary>
/// Data structure for a chat thread. /// Data structure for a chat thread.
/// </summary> /// </summary>
public sealed class ChatThread public sealed record ChatThread
{ {
/// <summary> /// <summary>
/// The unique identifier of the chat thread. /// The unique identifier of the chat thread.
@@ -0,0 +1,6 @@
namespace AIStudio.Chat;
public static class SystemPrompts
{
public const string DEFAULT = "You are a helpful assistant!";
}
@@ -1,28 +0,0 @@
@* ReSharper disable Html.PathError *@
<!DOCTYPE html>
<html lang="en">
<head>
<title>MindWork AI Studio</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<base href="/"/>
<link rel="icon" type="image/png" href="favicon.png"/>
<link href="system/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
<link href="system/MudBlazor.Markdown/MudBlazor.Markdown.min.css" rel="stylesheet" />
<link href="app.css" rel="stylesheet" />
<HeadOutlet/>
<script src="diff.js"></script>
</head>
<body style="overflow: hidden;">
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)"/>
<script src="_framework/blazor.web.js" autostart="false"></script>
<script src="boot.js"></script>
<script src="system/MudBlazor/MudBlazor.min.js"></script>
<script src="system/MudBlazor.Markdown/MudBlazor.Markdown.min.js"></script>
<script src="app.js"></script>
</body>
</html>
@@ -1,59 +0,0 @@
@using AIStudio.Chat
<MudText Typo="Typo.h3" Class="mb-2 mr-3">
@this.Title
</MudText>
<InnerScrolling HeaderHeight="12.3em">
<ChildContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.inputIsValid" @bind-Errors="@this.inputIssues" Class="pr-2">
<MudText Typo="Typo.body1" Align="Align.Justify" Class="mb-6">
@this.Description
</MudText>
@if (this.Body is not null)
{
@this.Body
}
</MudForm>
<Issues IssuesData="@this.inputIssues"/>
@if (this.ShowDedicatedProgress && this.isProcessing)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="mb-6" />
}
<div id="@ASSISTANT_RESULT_DIV_ID" class="mr-2 mt-3">
@if (this.ShowResult && this.resultingContentBlock is not null)
{
<ContentBlockComponent Role="@this.resultingContentBlock.Role" Type="@this.resultingContentBlock.ContentType" Time="@this.resultingContentBlock.Time" Content="@this.resultingContentBlock.Content"/>
}
</div>
<div id="@AFTER_RESULT_DIV_ID" class="mt-3">
</div>
@if (this.FooterButtons.Count > 0)
{
<MudStack Row="@true" Wrap="Wrap.Wrap" Class="mt-3 mr-2">
@foreach (var buttonData in this.FooterButtons)
{
switch (buttonData)
{
case var _ when !string.IsNullOrWhiteSpace(buttonData.Tooltip):
<MudTooltip Text="@buttonData.Tooltip">
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
@buttonData.Text
</MudButton>
</MudTooltip>
break;
default:
<MudButton Variant="Variant.Filled" Color="@buttonData.Color" StartIcon="@GetButtonIcon(buttonData.Icon)" OnClick="async () => await buttonData.AsyncAction()">
@buttonData.Text
</MudButton>
break;
}
}
</MudStack>
}
</ChildContent>
</InnerScrolling>
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class AssistantBlock : ComponentBase public partial class AssistantBlock : ComponentBase
{ {
@@ -1,3 +0,0 @@
namespace AIStudio.Components.Blocks;
public interface ITreeItem;
@@ -1,3 +0,0 @@
namespace AIStudio.Components.Blocks;
public readonly record struct TreeDivider : ITreeItem;
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Changelog public partial class Changelog
{ {
@@ -13,6 +13,9 @@ public partial class Changelog
public static readonly Log[] LOGS = public static readonly Log[] LOGS =
[ [
new (173, "v0.8.11, build 173 (2024-08-21 07:03 UTC)", "v0.8.11.md"),
new (172, "v0.8.10, build 172 (2024-08-18 19:44 UTC)", "v0.8.10.md"),
new (171, "v0.8.9, build 171 (2024-08-18 10:35 UTC)", "v0.8.9.md"),
new (170, "v0.8.8, build 170 (2024-08-14 06:30 UTC)", "v0.8.8.md"), new (170, "v0.8.8, build 170 (2024-08-14 06:30 UTC)", "v0.8.8.md"),
new (169, "v0.8.7, build 169 (2024-08-01 19:08 UTC)", "v0.8.7.md"), 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 (168, "v0.8.6, build 168 (2024-08-01 19:50 UTC)", "v0.8.6.md"),
@@ -1,4 +1,3 @@
@using AIStudio.Tools
<MudSelect T="Log" @bind-Value="@this.SelectedLog" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Schedule" Margin="Margin.Dense" Label="Changelog" Class="mb-2 rounded-lg" Variant="Variant.Outlined" SelectedValuesChanged="() => this.ReadLogAsync()" OnKeyUp="() => this.ReadLogAsync()"> <MudSelect T="Log" @bind-Value="@this.SelectedLog" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Schedule" Margin="Margin.Dense" Label="Changelog" Class="mb-2 rounded-lg" Variant="Variant.Outlined" SelectedValuesChanged="() => this.ReadLogAsync()" OnKeyUp="() => this.ReadLogAsync()">
@foreach (var log in LOGS) @foreach (var log in LOGS)
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Changelog : ComponentBase public partial class Changelog : ComponentBase
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
/// <summary> /// <summary>
/// Configuration component for any boolean option. /// Configuration component for any boolean option.
@@ -3,7 +3,7 @@ using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ConfigurationProviderSelection : ComponentBase, IMessageBusReceiver, IDisposable public partial class ConfigurationProviderSelection : ComponentBase, IMessageBusReceiver, IDisposable
{ {
@@ -2,7 +2,7 @@ using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
/// <summary> /// <summary>
/// Configuration component for selecting a value from a list. /// Configuration component for selecting a value from a list.
@@ -2,7 +2,7 @@ using System.Numerics;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct, INumber<T> public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct, INumber<T>
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ConfigurationText : ConfigurationBase public partial class ConfigurationText : ConfigurationBase
{ {
@@ -2,7 +2,7 @@ using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public abstract class EnumSelectionBase : ComponentBase public abstract class EnumSelectionBase : ComponentBase
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ExpansionPanel : ComponentBase public partial class ExpansionPanel : ComponentBase
{ {
@@ -0,0 +1,3 @@
namespace AIStudio.Components;
public interface ITreeItem;
@@ -1,9 +1,9 @@
using AIStudio.Components.Layout; using AIStudio.Layout;
using AIStudio.Tools; using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class InnerScrolling : MSGComponentBase public partial class InnerScrolling : MSGComponentBase
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Issues : ComponentBase public partial class Issues : ComponentBase
{ {
@@ -1,3 +0,0 @@
namespace AIStudio.Components.Layout;
public record NavBarItem(string Name, string Icon, Color IconColor, string Path, bool MatchAll);
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Motivation : ComponentBase public partial class Motivation : ComponentBase
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class MudTextList : ComponentBase public partial class MudTextList : ComponentBase
{ {
@@ -2,7 +2,7 @@ using System.Numerics;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class MudTextSlider<T> : ComponentBase where T : struct, INumber<T> public partial class MudTextSlider<T> : ComponentBase where T : struct, INumber<T>
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class MudTextSwitch : ComponentBase public partial class MudTextSwitch : ComponentBase
{ {
@@ -1,5 +0,0 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Pages;
public partial class Assistants : ComponentBase;
@@ -2,7 +2,7 @@ using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ProcessComponent<T> : ComponentBase where T : struct, Enum public partial class ProcessComponent<T> : ComponentBase where T : struct, Enum
{ {
@@ -2,7 +2,7 @@ using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ProviderSelection : ComponentBase public partial class ProviderSelection : ComponentBase
{ {
@@ -5,7 +5,7 @@ using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ReadWebContent : ComponentBase public partial class ReadWebContent : ComponentBase
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public enum ReadWebContentSteps public enum ReadWebContentSteps
{ {
@@ -0,0 +1,24 @@
@typeparam T
<MudButtonGroup Color="@this.Color" Variant="Variant.Filled">
@if (string.IsNullOrWhiteSpace(this.Icon))
{
<MudButton OnClick="() => this.OnClick(this.selectedValue)">
@this.SelectedValueName()
</MudButton>
}
else
{
<MudButton StartIcon="@this.Icon" OnClick="() => this.OnClick(this.selectedValue)">
@this.SelectedValueName()
</MudButton>
}
<MudMenu Icon="@Icons.Material.Filled.ArrowDropDown" Style="align-self: auto;">
@foreach(var item in this.Items)
{
<MudMenuItem OnClick="() => this.SelectItem(item)">
@this.NameFunc(item)
</MudMenuItem>
}
</MudMenu>
</MudButtonGroup>
@@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public partial class SplitButton<T> : ComponentBase
{
[Parameter]
public Color Color { get; set; } = Color.Default;
[Parameter]
public string Icon { get; set; } = string.Empty;
[Parameter]
public IReadOnlyCollection<T> Items { get; set; } = [];
[Parameter]
public Func<T, string> NameFunc { get; set; } = _ => string.Empty;
[Parameter]
public T? PreselectedValue { get; set; }
[Parameter]
public Func<T?, Task> OnClick { get; set; } = _ => Task.CompletedTask;
/// <summary>
/// What happens when the user selects an item by the dropdown?
/// Immediate = true means that the OnClick event is triggered immediately
/// after the user selects an item. Immediate = false means that the OnClick
/// event is triggered only when the user clicks the button.
/// </summary>
[Parameter]
public bool Immediate { get; set; }
#region Overrides of ComponentBase
protected override async Task OnInitializedAsync()
{
if(this.PreselectedValue is not null)
this.selectedValue = this.PreselectedValue;
else
this.selectedValue = this.Items.FirstOrDefault();
await base.OnInitializedAsync();
}
#endregion
private T? selectedValue;
private string SelectedValueName()
{
if(this.selectedValue is null)
return "Select...";
return this.NameFunc(this.selectedValue!);
}
private void SelectItem(T item)
{
this.selectedValue = item;
if(this.Immediate)
this.OnClick(this.selectedValue);
}
}
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class ThirdPartyComponent : ComponentBase public partial class ThirdPartyComponent : ComponentBase
{ {
@@ -1,3 +1,3 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public readonly record struct TreeButton(WorkspaceBranch Branch, int Depth, string Text, string Icon, Func<Task> Action) : ITreeItem; public readonly record struct TreeButton(WorkspaceBranch Branch, int Depth, string Text, string Icon, Func<Task> Action) : ITreeItem;
@@ -0,0 +1,3 @@
namespace AIStudio.Components;
public readonly record struct TreeDivider : ITreeItem;
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public class TreeItemData : ITreeItem public class TreeItemData : ITreeItem
{ {
@@ -8,7 +8,7 @@ public class TreeItemData : ITreeItem
public string Text { get; init; } = string.Empty; public string Text { get; init; } = string.Empty;
public string ShortenedText => Text.Length > 30 ? this.Text[..30] + "..." : this.Text; public string ShortenedText => this.Text.Length > 30 ? this.Text[..30] + "..." : this.Text;
public string Icon { get; init; } = string.Empty; public string Icon { get; init; } = string.Empty;
@@ -18,5 +18,7 @@ public class TreeItemData : ITreeItem
public bool Expandable { get; init; } = true; public bool Expandable { get; init; } = true;
public DateTimeOffset LastEditTime { get; init; }
public IReadOnlyCollection<TreeItemData<ITreeItem>> Children { get; init; } = []; public IReadOnlyCollection<TreeItemData<ITreeItem>> Children { get; init; } = [];
} }
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public enum TreeItemType public enum TreeItemType
{ {
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Vision : ComponentBase public partial class Vision : ComponentBase
{ {
@@ -1,4 +1,4 @@
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public enum WorkspaceBranch public enum WorkspaceBranch
{ {
@@ -3,15 +3,15 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using AIStudio.Chat; using AIStudio.Chat;
using AIStudio.Components.CommonDialogs; using AIStudio.Dialogs;
using AIStudio.Settings; using AIStudio.Settings;
using AIStudio.Tools; using AIStudio.Tools;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using DialogOptions = AIStudio.Components.CommonDialogs.DialogOptions; using DialogOptions = AIStudio.Dialogs.DialogOptions;
namespace AIStudio.Components.Blocks; namespace AIStudio.Components;
public partial class Workspaces : ComponentBase public partial class Workspaces : ComponentBase
{ {
@@ -109,42 +109,44 @@ public partial class Workspaces : ComponentBase
private async Task<IReadOnlyCollection<TreeItemData<ITreeItem>>> LoadTemporaryChats() private async Task<IReadOnlyCollection<TreeItemData<ITreeItem>>> LoadTemporaryChats()
{ {
var tempChildren = new List<TreeItemData<ITreeItem>>(); var tempChildren = new List<TreeItemData>();
// // Get the temp root directory:
// Search for workspace folders in the data directory:
//
// Get the workspace root directory:
var temporaryDirectories = Path.Join(SettingsManager.DataDirectory, "tempChats"); var temporaryDirectories = Path.Join(SettingsManager.DataDirectory, "tempChats");
// Ensure the directory exists: // Ensure the directory exists:
Directory.CreateDirectory(temporaryDirectories); Directory.CreateDirectory(temporaryDirectories);
// Enumerate the workspace directories: // Enumerate the chat directories:
foreach (var tempChatDirPath in Directory.EnumerateDirectories(temporaryDirectories)) foreach (var tempChatDirPath in Directory.EnumerateDirectories(temporaryDirectories))
{ {
// Read the `name` file: // Read the `name` file:
var chatNamePath = Path.Join(tempChatDirPath, "name"); var chatNamePath = Path.Join(tempChatDirPath, "name");
var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8);
tempChildren.Add(new TreeItemData<ITreeItem> // Read the last change time of the chat:
var chatThreadPath = Path.Join(tempChatDirPath, "thread.json");
var lastEditTime = File.GetLastWriteTimeUtc(chatThreadPath);
tempChildren.Add(new TreeItemData
{ {
Type = TreeItemType.CHAT,
Depth = 1,
Branch = WorkspaceBranch.TEMPORARY_CHATS,
Text = chatName,
Icon = Icons.Material.Filled.Timer,
Expandable = false, Expandable = false,
Value = new TreeItemData Path = tempChatDirPath,
{ LastEditTime = lastEditTime,
Type = TreeItemType.CHAT,
Depth = 1,
Branch = WorkspaceBranch.TEMPORARY_CHATS,
Text = chatName,
Icon = Icons.Material.Filled.Timer,
Expandable = false,
Path = tempChatDirPath,
},
}); });
} }
return tempChildren; var result = new List<TreeItemData<ITreeItem>>(tempChildren.OrderByDescending(n => n.LastEditTime).Select(n => new TreeItemData<ITreeItem>
{
Expandable = false,
Value = n,
}));
return result;
} }
public async Task<string> LoadWorkspaceName(Guid workspaceId) public async Task<string> LoadWorkspaceName(Guid workspaceId)
@@ -205,7 +207,7 @@ public partial class Workspaces : ComponentBase
private async Task<IReadOnlyCollection<TreeItemData<ITreeItem>>> LoadWorkspaceChats(string workspacePath) private async Task<IReadOnlyCollection<TreeItemData<ITreeItem>>> LoadWorkspaceChats(string workspacePath)
{ {
var workspaceChats = new List<TreeItemData<ITreeItem>>(); var workspaceChats = new List<TreeItemData>();
// Enumerate the workspace directory: // Enumerate the workspace directory:
foreach (var chatPath in Directory.EnumerateDirectories(workspacePath)) foreach (var chatPath in Directory.EnumerateDirectories(workspacePath))
@@ -213,30 +215,37 @@ public partial class Workspaces : ComponentBase
// Read the `name` file: // Read the `name` file:
var chatNamePath = Path.Join(chatPath, "name"); var chatNamePath = Path.Join(chatPath, "name");
var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8); var chatName = await File.ReadAllTextAsync(chatNamePath, Encoding.UTF8);
// Read the last change time of the chat:
var chatThreadPath = Path.Join(chatPath, "thread.json");
var lastEditTime = File.GetLastWriteTimeUtc(chatThreadPath);
workspaceChats.Add(new TreeItemData<ITreeItem> workspaceChats.Add(new TreeItemData
{ {
Type = TreeItemType.CHAT,
Depth = 2,
Branch = WorkspaceBranch.WORKSPACES,
Text = chatName,
Icon = Icons.Material.Filled.Chat,
Expandable = false, Expandable = false,
Value = new TreeItemData Path = chatPath,
{ LastEditTime = lastEditTime,
Type = TreeItemType.CHAT,
Depth = 2,
Branch = WorkspaceBranch.WORKSPACES,
Text = chatName,
Icon = Icons.Material.Filled.Chat,
Expandable = false,
Path = chatPath,
},
}); });
} }
workspaceChats.Add(new TreeItemData<ITreeItem> var result = new List<TreeItemData<ITreeItem>>(workspaceChats.OrderByDescending(n => n.LastEditTime).Select(n => new TreeItemData<ITreeItem>
{
Expandable = false,
Value = n,
}));
result.Add(new()
{ {
Expandable = false, Expandable = false,
Value = new TreeButton(WorkspaceBranch.WORKSPACES, 2, "Add chat",Icons.Material.Filled.AddComment, () => this.AddChat(workspacePath)), Value = new TreeButton(WorkspaceBranch.WORKSPACES, 2, "Add chat",Icons.Material.Filled.AddComment, () => this.AddChat(workspacePath)),
}); });
return workspaceChats; return result;
} }
public async Task StoreChat(ChatThread chat) public async Task StoreChat(ChatThread chat)
@@ -1,12 +1,3 @@
@using System.Net.Http @using AIStudio
@using System.Net.Http.Json @using AIStudio.Tools
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using AIStudio
@using AIStudio.Components
@using AIStudio.Components.Blocks
@using MudBlazor @using MudBlazor
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.CommonDialogs; namespace AIStudio.Dialogs;
/// <summary> /// <summary>
/// A confirmation dialog that can be used to ask the user for confirmation. /// A confirmation dialog that can be used to ask the user for confirmation.
@@ -1,4 +1,4 @@
namespace AIStudio.Components.CommonDialogs; namespace AIStudio.Dialogs;
public static class DialogOptions public static class DialogOptions
{ {
@@ -2,7 +2,7 @@ using AIStudio.Settings;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace AIStudio.Components.CommonDialogs; namespace AIStudio.Dialogs;
public partial class SingleInputDialog : ComponentBase public partial class SingleInputDialog : ComponentBase
{ {
Loaded 100 of 157 files, more files were not shown because too many files have changed in this diff. Show more