mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-20 04:38:00 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50bf0baff7 | ||
|
|
83fe126c9f | ||
|
|
37b38e6a40 | ||
|
|
1d1af91f3e | ||
|
|
a18cb22263 | ||
|
|
f8e06faea5 | ||
|
|
8aeeda5dca | ||
|
|
909fbe89bb | ||
|
|
ea0ead58f8 | ||
|
|
3e59f23193 | ||
|
|
05a7e44de4 | ||
|
|
77e7e044e3 | ||
|
|
6b7800b615 | ||
|
|
1ec86ec1a6 | ||
|
|
e08687a5ca | ||
|
|
ab0b855769 | ||
|
|
4cb49d9f27 | ||
|
|
2cea53d2a9 | ||
|
|
155c2d72f8 | ||
|
|
60febfec86 |
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
# MindWork AI Studio
|
# MindWork AI Studio
|
||||||

|

|
||||||
|

|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Provider;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
namespace AIStudio.Agents;
|
||||||
|
|
||||||
|
public abstract class AgentBase(SettingsManager settingsManager, IJSRuntime jsRuntime, ThreadSafeRandom rng) : IAgent
|
||||||
|
{
|
||||||
|
protected SettingsManager SettingsManager { get; init; } = settingsManager;
|
||||||
|
|
||||||
|
protected IJSRuntime JsRuntime { get; init; } = jsRuntime;
|
||||||
|
|
||||||
|
protected ThreadSafeRandom RNG { get; init; } = rng;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the type or category of this agent.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract Type Type { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the agent.
|
||||||
|
/// </summary>
|
||||||
|
public abstract string Id { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The agent's job description. Will be used for the system prompt.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract string JobDescription { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the system prompt provided for the agent.
|
||||||
|
/// </summary>
|
||||||
|
protected abstract string SystemPrompt(string additionalData);
|
||||||
|
|
||||||
|
#region Implementation of IAgent
|
||||||
|
|
||||||
|
public abstract AIStudio.Settings.Provider? ProviderSettings { get; set; }
|
||||||
|
|
||||||
|
public abstract Task<ChatThread> ProcessContext(ChatThread chatThread, IDictionary<string, string> additionalData);
|
||||||
|
|
||||||
|
public abstract Task<ContentBlock> ProcessInput(ContentBlock input, IDictionary<string, string> additionalData);
|
||||||
|
|
||||||
|
public abstract Task<bool> MadeDecision(ContentBlock input);
|
||||||
|
|
||||||
|
public abstract IReadOnlyCollection<ContentBlock> GetContext();
|
||||||
|
|
||||||
|
public abstract IReadOnlyCollection<ContentBlock> GetAnswers();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected ChatThread CreateChatThread(string systemPrompt) => new()
|
||||||
|
{
|
||||||
|
WorkspaceId = Guid.Empty,
|
||||||
|
ChatId = Guid.NewGuid(),
|
||||||
|
Name = string.Empty,
|
||||||
|
Seed = this.RNG.Next(),
|
||||||
|
SystemPrompt = systemPrompt,
|
||||||
|
Blocks = [],
|
||||||
|
};
|
||||||
|
|
||||||
|
protected DateTimeOffset AddUserRequest(ChatThread thread, string request)
|
||||||
|
{
|
||||||
|
var time = DateTimeOffset.Now;
|
||||||
|
thread.Blocks.Add(new ContentBlock
|
||||||
|
{
|
||||||
|
Time = time,
|
||||||
|
ContentType = ContentType.TEXT,
|
||||||
|
Role = ChatRole.USER,
|
||||||
|
Content = new ContentText
|
||||||
|
{
|
||||||
|
Text = request,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task AddAIResponseAsync(ChatThread thread, DateTimeOffset time)
|
||||||
|
{
|
||||||
|
if(this.ProviderSettings is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var providerSettings = this.ProviderSettings.Value;
|
||||||
|
var aiText = new ContentText
|
||||||
|
{
|
||||||
|
// We have to wait for the remote
|
||||||
|
// for the content stream:
|
||||||
|
InitialRemoteWait = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
var resultingContentBlock = new ContentBlock
|
||||||
|
{
|
||||||
|
Time = time,
|
||||||
|
ContentType = ContentType.TEXT,
|
||||||
|
Role = ChatRole.AI,
|
||||||
|
Content = aiText,
|
||||||
|
};
|
||||||
|
|
||||||
|
thread.Blocks.Add(resultingContentBlock);
|
||||||
|
|
||||||
|
// Use the selected provider to get the AI response.
|
||||||
|
// By awaiting this line, we wait for the entire
|
||||||
|
// content to be streamed.
|
||||||
|
await aiText.CreateFromProviderAsync(providerSettings.CreateProvider(), this.JsRuntime, this.SettingsManager, providerSettings.Model, thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
namespace AIStudio.Agents;
|
||||||
|
|
||||||
|
public sealed class AgentTextContentCleaner(SettingsManager settingsManager, IJSRuntime jsRuntime, ThreadSafeRandom rng) : AgentBase(settingsManager, jsRuntime, rng)
|
||||||
|
{
|
||||||
|
private static readonly ContentBlock EMPTY_BLOCK = new()
|
||||||
|
{
|
||||||
|
Content = null,
|
||||||
|
ContentType = ContentType.NONE,
|
||||||
|
Role = ChatRole.AGENT,
|
||||||
|
Time = DateTimeOffset.UtcNow,
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly List<ContentBlock> context = new();
|
||||||
|
private readonly List<ContentBlock> answers = new();
|
||||||
|
|
||||||
|
#region Overrides of AgentBase
|
||||||
|
|
||||||
|
public override Settings.Provider? ProviderSettings { get; set; }
|
||||||
|
|
||||||
|
protected override Type Type => Type.SYSTEM;
|
||||||
|
|
||||||
|
public override string Id => "Text Content Cleaner";
|
||||||
|
|
||||||
|
protected override string JobDescription =>
|
||||||
|
"""
|
||||||
|
You receive a Markdown document as input. Your goal is to identify the main content of the document
|
||||||
|
and return it including Markdown formatting. Remove areas that do not belong to the main part of the
|
||||||
|
document. For a blog article, return only the text of the article with its formatting. For a scientific
|
||||||
|
paper, only the contents of the paper. Delete elements of navigation, advertisements, HTML artifacts,
|
||||||
|
cookie banners, etc. If the content contains images, these images remain. The same applies to links.
|
||||||
|
Ensure that links and images are present as valid Markdown:
|
||||||
|
|
||||||
|
- Syntax of links: [link text](URL)
|
||||||
|
- Syntax of images: 
|
||||||
|
|
||||||
|
If you find relative links or images with relative paths, correct them to absolute paths. For this
|
||||||
|
purpose, here is the source URL:
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override string SystemPrompt(string additionalData) => $"{this.JobDescription} `{additionalData}`.";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override async Task<ChatThread> ProcessContext(ChatThread chatThread, IDictionary<string, string> additionalData)
|
||||||
|
{
|
||||||
|
// We process the last block of the chat thread. Then, we add the result
|
||||||
|
// to the chat thread as the last block:
|
||||||
|
var answer = await this.ProcessInput(chatThread.Blocks[^1], additionalData);
|
||||||
|
chatThread.Blocks.Add(answer);
|
||||||
|
|
||||||
|
this.context.Clear();
|
||||||
|
this.context.AddRange(chatThread.Blocks);
|
||||||
|
|
||||||
|
return chatThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <inheritdoc />
|
||||||
|
public override async Task<ContentBlock> ProcessInput(ContentBlock input, IDictionary<string, string> additionalData)
|
||||||
|
{
|
||||||
|
if (input.Content is not ContentText text)
|
||||||
|
return EMPTY_BLOCK;
|
||||||
|
|
||||||
|
if(text.InitialRemoteWait || text.IsStreaming)
|
||||||
|
return EMPTY_BLOCK;
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(text.Text))
|
||||||
|
return EMPTY_BLOCK;
|
||||||
|
|
||||||
|
if(!additionalData.TryGetValue("sourceURL", out var sourceURL) || string.IsNullOrWhiteSpace(sourceURL))
|
||||||
|
return EMPTY_BLOCK;
|
||||||
|
|
||||||
|
var thread = this.CreateChatThread(this.SystemPrompt(sourceURL));
|
||||||
|
var time = this.AddUserRequest(thread, text.Text);
|
||||||
|
await this.AddAIResponseAsync(thread, time);
|
||||||
|
|
||||||
|
var answer = thread.Blocks[^1];
|
||||||
|
this.answers.Add(answer);
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <inheritdoc />
|
||||||
|
public override Task<bool> MadeDecision(ContentBlock input) => Task.FromResult(true);
|
||||||
|
|
||||||
|
// <inheritdoc />
|
||||||
|
public override IReadOnlyCollection<ContentBlock> GetContext() => this.context;
|
||||||
|
|
||||||
|
// <inheritdoc />
|
||||||
|
public override IReadOnlyCollection<ContentBlock> GetAnswers() => this.answers;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
|
||||||
|
namespace AIStudio.Agents;
|
||||||
|
|
||||||
|
public interface IAgent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the agent.
|
||||||
|
/// </summary>
|
||||||
|
public string Id { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The provider to use for this agent.
|
||||||
|
/// </summary>
|
||||||
|
public AIStudio.Settings.Provider? ProviderSettings { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes a chat thread (i.e., context) and returns the updated thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="chatThread">The chat thread to process. The thread is the context for the agent.</param>
|
||||||
|
/// <param name="additionalData">Additional data to use for processing the chat thread.</param>
|
||||||
|
/// <returns>The updated chat thread. The last content block of the thread is the agent's response.</returns>
|
||||||
|
public Task<ChatThread> ProcessContext(ChatThread chatThread, IDictionary<string, string> additionalData);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes the input content block and returns the agent's response.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">The content block to process. It represents the input.</param>
|
||||||
|
/// <param name="additionalData">Additional data to use for processing the input.</param>
|
||||||
|
/// <returns>The content block representing the agent's response.</returns>
|
||||||
|
public Task<ContentBlock> ProcessInput(ContentBlock input, IDictionary<string, string> additionalData);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The agent makes a decision based on the input.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">The content block to process. Should be a question or a request.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// True if a decision has been made based on the input, false otherwise.
|
||||||
|
/// </returns>
|
||||||
|
public Task<bool> MadeDecision(ContentBlock input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the context of the agent.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The collection of content blocks representing the agent's context. This includes the user's and the other agent's messages.</returns>
|
||||||
|
public IReadOnlyCollection<ContentBlock> GetContext();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the answers from the agent's context.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The collection of content blocks representing the answers provided by this agent.
|
||||||
|
/// </returns>
|
||||||
|
public IReadOnlyCollection<ContentBlock> GetAnswers();
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
namespace AIStudio.Agents;
|
||||||
|
|
||||||
|
public enum Type
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an unspecified agent type.
|
||||||
|
/// </summary>
|
||||||
|
UNSPECIFIED = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a conversational agent who produces human-like responses and feedback (depending on the context and its job description).
|
||||||
|
/// For example, an expert agent for a specific domain. Answers might be detailed and informative.
|
||||||
|
/// </summary>
|
||||||
|
CONVERSATIONAL,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a worker agent type who performs tasks and provides information or services (depending on the context and its job description).
|
||||||
|
/// For example, a quality assurance agent who assesses the quality of a product or service. Answers might be short and concise.
|
||||||
|
/// </summary>
|
||||||
|
WORKER,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the system agent type who processes the input and provides a specific response (depending on the context and its job description).
|
||||||
|
/// For example, a HTML content agent who processes the arbitrary HTML content and provides a structured Markdown response. Answers might be structured and formatted.
|
||||||
|
/// </summary>
|
||||||
|
SYSTEM,
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
@attribute [Route(Routes.ASSISTANT_AGENDA)]
|
||||||
|
@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.inputTopic" Validation="@this.ValidateTopic" Label="Topic" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.EventNote" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Describe the topic of the meeting, seminar, etc. Is it about quantum computing, software engineering, or is it a general business meeting?" Placeholder="Project meeting" Class="mb-3"/>
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputContent" Validation="@this.ValidateContent" Label="Content list" Variant="Variant.Outlined" Lines="6" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Bullet list the content of the meeting, seminar, etc. roughly. Use dashes (-) to separate the items." Placeholder="@PLACEHOLDER_CONTENT" Class="mb-3" Immediate="@false" DebounceInterval="1_000" OnDebounceIntervalElapsed="@this.OnContentChanged" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.ListAlt"/>
|
||||||
|
<MudSelect T="string" Label="(Optional) What topics should be the focus?" MultiSelection="@true" @bind-SelectedValues="@this.selectedFoci" Variant="Variant.Outlined" Class="mb-3" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.ListAlt">
|
||||||
|
@foreach (var contentLine in this.contentLines)
|
||||||
|
{
|
||||||
|
@if(!this.justBriefly.Contains(contentLine))
|
||||||
|
{
|
||||||
|
<MudSelectItem T="string" Value="@contentLine">@contentLine</MudSelectItem>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</MudSelect>
|
||||||
|
|
||||||
|
<MudSelect T="string" Label="(Optional) What topics should only be briefly addressed?" MultiSelection="@true" @bind-SelectedValues="@this.justBriefly" Variant="Variant.Outlined" Class="mb-3" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.ListAlt">
|
||||||
|
@foreach (var contentLine in this.contentLines)
|
||||||
|
{
|
||||||
|
@if(!this.selectedFoci.Contains(contentLine))
|
||||||
|
{
|
||||||
|
<MudSelectItem T="string" Value="@contentLine">@contentLine</MudSelectItem>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</MudSelect>
|
||||||
|
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputObjective" Validation="@this.ValidateObjective" Label="Objective" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Flag" Variant="Variant.Outlined" Lines="3" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Describe the objective(s) of the meeting, seminar, etc. What should be achieved?" Placeholder="Discuss the current project status and plan the next steps." Class="mb-3"/>
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputModerator" Validation="@this.ValidateModerator" Label="Moderator" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Person3" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Who will moderate the meeting, seminar, etc.?" Placeholder="Jane Doe" Class="mb-3" />
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputDuration" Validation="@this.ValidateDuration" Label="Duration" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Schedule" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="How long will the meeting, seminar, etc. last? E.g., '2 hours', or '2 days (first day 8 hours, then 4 hours)', etc." Placeholder="2 hours" Class="mb-3"/>
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputStartTime" Validation="@this.ValidateStartTime" Label="Start time" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Schedule" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="When will the meeting, seminar, etc. start? E.g., '9:00 AM', or '9:00 AM (CET)', etc. When the meeting is a multi-day event, specify the start time for each day." Placeholder="9:00 AM" Class="mb-3"/>
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputWhoIsPresenting" Label="(Optional) Who is presenting?" Variant="Variant.Outlined" Lines="6" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="(Optional) List the persons who will present at the meeting, seminar, etc. Use dashes (-) to separate the items." Placeholder="@PLACEHOLDER_WHO_IS_PRESENTING" Class="mb-3"/>
|
||||||
|
<MudTextSwitch Label="Do the participants need to get to know each other first?" @bind-Value="@this.introduceParticipants" LabelOn="Yes, introduce participants" LabelOff="No, participants know each other" />
|
||||||
|
<EnumSelection T="NumberParticipants" @bind-Value="@this.numberParticipants" NameFunc="@(participants => participants.Name())" Icon="@Icons.Material.Filled.Group" Label="Number of participants" ValidateSelection="@this.ValidateNumberParticipants"/>
|
||||||
|
<MudTextSwitch Label="Should the participants be involved passively or actively?" @bind-Value="@this.activeParticipation" LabelOn="Active participation, like world café, discussions, etc." LabelOff="Passive participation, like presentations, lectures, etc." />
|
||||||
|
<MudTextSwitch Label="Is this a virtual event, e.g., a call or webinar?" @bind-Value="@this.isMeetingVirtual" LabelOn="Yes, this is a virtual event" LabelOff="No, this is a physical event" />
|
||||||
|
@if (!this.isMeetingVirtual)
|
||||||
|
{
|
||||||
|
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
||||||
|
<MudTextField T="string" @bind-Text="@this.inputLocation" Validation="@this.ValidateLocation" Label="Location" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.MyLocation" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" HelperText="Where will the meeting, seminar, etc. take place?" Placeholder="Hamburg, Germany" Class="mb-3"/>
|
||||||
|
<MudTextSwitch Label="Should there be a joint dinner?" @bind-Value="@this.goingToDinner" LabelOn="Yes, there should be a joint dinner" LabelOff="No, there should be no joint dinner" />
|
||||||
|
<MudTextSwitch Label="Should there be a social activity?" @bind-Value="@this.doingSocialActivity" LabelOn="Yes, there should be a social activity" LabelOff="No, there should be no social activity" />
|
||||||
|
<MudTextSwitch Label="Do participants need to arrive and depart?" @bind-Value="@this.needToArriveAndDepart" LabelOn="Yes, participants need to arrive and depart" LabelOff="No, participants do not need to arrive and depart" />
|
||||||
|
<MudStack Row="@true" Wrap="Wrap.Wrap">
|
||||||
|
<MudTextSlider T="int" Label="Approx. duration of the lunch break" @bind-Value="@this.durationLunchBreak" Min="30" Max="120" Step="5" Unit="minutes"/>
|
||||||
|
<MudTextSlider T="int" Label="Approx. duration of the coffee or tea breaks" @bind-Value="@this.durationBreaks" Min="10" Max="60" Step="5" Unit="minutes"/>
|
||||||
|
</MudStack>
|
||||||
|
</MudPaper>
|
||||||
|
}
|
||||||
|
|
||||||
|
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelecting())" @bind-Value="@this.selectedTargetLanguage" ValidateSelection="@this.ValidateTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Target language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom target language" />
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.CreateAgenda()">
|
||||||
|
Create agenda
|
||||||
|
</MudButton>
|
||||||
@@ -0,0 +1,507 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
namespace AIStudio.Assistants.Agenda;
|
||||||
|
|
||||||
|
public partial class AssistantAgenda : AssistantBaseCore
|
||||||
|
{
|
||||||
|
protected override string Title => "Agenda Planner";
|
||||||
|
|
||||||
|
protected override string Description =>
|
||||||
|
"""
|
||||||
|
This agenda planner helps you create a structured agenda for your meeting or seminar. Just provide some basic
|
||||||
|
information about the event, and the assistant will generate an agenda for you. You can also specify the
|
||||||
|
duration, the start time, the location, the target language, and other details.
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override string SystemPrompt =>
|
||||||
|
$"""
|
||||||
|
You are a friendly assistant who supports the planning and consultation of events. You receive
|
||||||
|
metadata about an event and create an agenda from it. Additionally, you provide advice on what
|
||||||
|
the organizer and moderator should consider. When creating the agenda, you take into account that
|
||||||
|
time for questions and discussions needs to be scheduled. For large events, you take into account
|
||||||
|
the logistical challenges that come with an increasing number of participants.
|
||||||
|
|
||||||
|
If the user is planning interactions with participants, you know various methods. For example:
|
||||||
|
|
||||||
|
- **Townhall Meeting**: An open assembly where participants can ask questions and provide feedback directly to leaders or speakers. Good moderation is necessary to queue contributions and hand the floor to the respective person. Additionally, one person should take notes visible to all. Ideally, this should not be the moderator.
|
||||||
|
|
||||||
|
- **Speed Dating**: Short, structured interaction rounds where participants get the chance to quickly introduce themselves and make initial connections. A long row of tables is needed so that two people can sit opposite each other. A moderator with a stopwatch must ensure that participants rotate and change seats every 3 to 5 minutes.
|
||||||
|
|
||||||
|
- **World Café**: Participants discuss in small groups at tables and rotate after set intervals to exchange thoughts and develop ideas further. Each table needs a host. Notes should be taken on a flipchart or digitally at each table. At the end, the table hosts could present their insights to all participants in a plenary session.
|
||||||
|
|
||||||
|
- **Fishbowl**: A group discusses in an inner circle while a larger group listens from the outside. Occasionally, listeners can move into the inner circle to actively participate.
|
||||||
|
|
||||||
|
- **BarCamp (Unconference)**: Participants contribute to part of the agenda themselves and can act as both presenters and listeners. Anyone can propose and lead a session. However, there should be initial moderation to guide this meta-process.
|
||||||
|
|
||||||
|
- **Open Space Technology**: A method for large groups where participants bring up their own topics and then work intensively in small groups. At the end, the groups can present their findings to all participants in a plenary session.
|
||||||
|
|
||||||
|
- **Panel Discussion**: A group of experts discusses a specific topic in front of an audience, followed by a question-and-answer session.
|
||||||
|
|
||||||
|
- **Breakout Sessions**: Larger groups are divided into smaller, topic-related groups to discuss specific issues more deeply and interactively.
|
||||||
|
|
||||||
|
- **Interactive Polling**: Real-time surveys during the meeting or seminar using digital technology to collect immediate feedback from participants. With an increasing number of participants, technical requirements also become more complex: not every Wi-Fi router can handle several hundred or thousand devices. Additionally, the moderator or speaker must have a stable network connection to display the results. It would be problematic if the speaker depends on the same Wi-Fi as the participants: if the Wi-Fi crashes due to the high number of participants, the speaker cannot show the results. Therefore, a LAN for the speaker or the use of a mobile hotspot would be a better choice.
|
||||||
|
|
||||||
|
- **Peer Learning Groups**: Small groups of participants work together to learn from each other and collaboratively develop solutions for specific challenges.
|
||||||
|
|
||||||
|
- **Role Play/Simulation**: Participants take on roles to simulate certain scenarios, gaining practical experience and promoting dynamic discussions.
|
||||||
|
|
||||||
|
- **Round Table Discussions**: Small group discussions on specific topics, often without formal moderation, to encourage open and equal dialogue.
|
||||||
|
|
||||||
|
- **Mind Mapping**: A method for visualizing ideas and concepts, which can foster creative exchange within groups.
|
||||||
|
|
||||||
|
- **Case Study Analysis**: Groups analyze real or hypothetical case studies and present their solutions or insights.
|
||||||
|
|
||||||
|
- **Silent Meeting/Writing**: Participants write down their thoughts and questions, which are then collected and discussed to balance out loud or dominant voices.
|
||||||
|
|
||||||
|
- **Debate**: Participants argue for or against a specific topic, often with a moderator who ensures that the discussion remains constructive.
|
||||||
|
|
||||||
|
- **Workshops**: Interactive sessions where participants work together on specific tasks or challenges.
|
||||||
|
|
||||||
|
- **Brainstorming**: A method for generating ideas in a group setting, often with a focus on quantity and creativity.
|
||||||
|
|
||||||
|
- **Design Thinking**: A structured approach to innovation solutions. Design thinking is structured in six phases: understand, observe, point of view, ideate, prototype, and test. Depending on the number of participants, there are two moderates needed. One moderator leads the process, the other supports the participants in their work. Design thinking may takes up to two days.
|
||||||
|
|
||||||
|
You output the agenda in the following Markdown format:
|
||||||
|
|
||||||
|
# [Agenda Title]
|
||||||
|
- 09:00 - 09:05 (5 minutes): Welcome
|
||||||
|
- 09:05 - 09:15 (10 minutes): Introduction
|
||||||
|
- ...
|
||||||
|
{this.SystemPromptSocialActivity()}
|
||||||
|
{this.SystemPromptDinner()}
|
||||||
|
|
||||||
|
# Organizational notes
|
||||||
|
[Your advice for the organizer goes here, like room setup, technical requirements, etc.]
|
||||||
|
|
||||||
|
# Moderation notes
|
||||||
|
[Your advice for the moderator goes here]
|
||||||
|
|
||||||
|
Output the agenda in the following language: {this.PromptLanguage()}.
|
||||||
|
""";
|
||||||
|
|
||||||
|
private const string PLACEHOLDER_CONTENT = """
|
||||||
|
- Project status
|
||||||
|
- We need to discuss how to proceed
|
||||||
|
- Problem solving in work package 3 possible?
|
||||||
|
- Concerns of the members
|
||||||
|
""";
|
||||||
|
|
||||||
|
private const string PLACEHOLDER_WHO_IS_PRESENTING = """
|
||||||
|
- John Doe: Project status
|
||||||
|
- 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 inputName = string.Empty;
|
||||||
|
private string inputContent = string.Empty;
|
||||||
|
private string inputDuration = string.Empty;
|
||||||
|
private string inputStartTime = string.Empty;
|
||||||
|
private IEnumerable<string> selectedFoci = new HashSet<string>();
|
||||||
|
private IEnumerable<string> justBriefly = new HashSet<string>();
|
||||||
|
private string inputObjective = string.Empty;
|
||||||
|
private string inputModerator = string.Empty;
|
||||||
|
private CommonLanguages selectedTargetLanguage;
|
||||||
|
private string customTargetLanguage = string.Empty;
|
||||||
|
private bool introduceParticipants;
|
||||||
|
private bool isMeetingVirtual = true;
|
||||||
|
private string inputLocation = string.Empty;
|
||||||
|
private bool goingToDinner;
|
||||||
|
private bool doingSocialActivity;
|
||||||
|
private bool needToArriveAndDepart;
|
||||||
|
private int durationLunchBreak;
|
||||||
|
private int durationBreaks;
|
||||||
|
private bool activeParticipation;
|
||||||
|
private NumberParticipants numberParticipants;
|
||||||
|
private string inputWhoIsPresenting = string.Empty;
|
||||||
|
|
||||||
|
private readonly List<string> contentLines = [];
|
||||||
|
|
||||||
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
this.MightPreselectValues();
|
||||||
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_AGENDA_ASSISTANT).FirstOrDefault();
|
||||||
|
if (deferredContent is not null)
|
||||||
|
this.inputContent = deferredContent;
|
||||||
|
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void OnContentChanged(string content)
|
||||||
|
{
|
||||||
|
var previousSelectedFoci = new HashSet<string>();
|
||||||
|
var previousJustBriefly = new HashSet<string>();
|
||||||
|
|
||||||
|
this.contentLines.Clear();
|
||||||
|
foreach (var line in content.AsSpan().EnumerateLines())
|
||||||
|
{
|
||||||
|
var trimmedLine = line.Trim();
|
||||||
|
if (trimmedLine.StartsWith("-"))
|
||||||
|
trimmedLine = trimmedLine[1..].Trim();
|
||||||
|
|
||||||
|
if (trimmedLine.Length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var finalLine = trimmedLine.ToString();
|
||||||
|
if(this.selectedFoci.Any(x => x.StartsWith(finalLine, StringComparison.InvariantCultureIgnoreCase)))
|
||||||
|
previousSelectedFoci.Add(finalLine);
|
||||||
|
|
||||||
|
if(this.justBriefly.Any(x => x.StartsWith(finalLine, StringComparison.InvariantCultureIgnoreCase)))
|
||||||
|
previousJustBriefly.Add(finalLine);
|
||||||
|
|
||||||
|
this.contentLines.Add(finalLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selectedFoci = previousSelectedFoci;
|
||||||
|
this.justBriefly = previousJustBriefly;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateLocation(string location)
|
||||||
|
{
|
||||||
|
if(!this.isMeetingVirtual && string.IsNullOrWhiteSpace(location))
|
||||||
|
return "Please provide a location for the meeting or the seminar.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateNumberParticipants(NumberParticipants selectedSize)
|
||||||
|
{
|
||||||
|
if(selectedSize is NumberParticipants.NOT_SPECIFIED)
|
||||||
|
return "Please select the number of participants.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateTargetLanguage(CommonLanguages language)
|
||||||
|
{
|
||||||
|
if(language is CommonLanguages.AS_IS)
|
||||||
|
return "Please select a target language for the agenda.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateDuration(string duration)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(duration))
|
||||||
|
return "Please provide a duration for the meeting or the seminar, e.g. '2 hours', or '2 days (8 hours and 4 hours)', etc.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateStartTime(string startTime)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(startTime))
|
||||||
|
return "Please provide a start time for the meeting or the seminar. When the meeting is a multi-day event, specify the start time for each day, e.g. '9:00 AM, 10:00 AM', etc.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateCustomLanguage(string language)
|
||||||
|
{
|
||||||
|
if(this.selectedTargetLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
||||||
|
return "Please provide a custom language.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateTopic(string topic)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(topic))
|
||||||
|
return "Please provide a topic for the agenda. What is the meeting or the seminar about?";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateName(string name)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(name))
|
||||||
|
return "Please provide a name for the meeting or the seminar.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateContent(string content)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(content))
|
||||||
|
return "Please provide some content for the agenda. What are the main points of the meeting or the seminar?";
|
||||||
|
|
||||||
|
var lines = content.Split('\n');
|
||||||
|
foreach (var line in lines)
|
||||||
|
if(!line.TrimStart().StartsWith('-'))
|
||||||
|
return "Please start each line of your content list with a dash (-) to create a bullet point list.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateObjective(string objective)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(objective))
|
||||||
|
return "Please provide an objective for the meeting or the seminar. What do you want to achieve?";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateModerator(string moderator)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(moderator))
|
||||||
|
return "Please provide a moderator for the meeting or the seminar. Who will lead the discussion?";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CreateAgenda()
|
||||||
|
{
|
||||||
|
await this.form!.Validate();
|
||||||
|
if (!this.inputIsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.CreateChatThread();
|
||||||
|
var time = this.AddUserRequest(
|
||||||
|
$"""
|
||||||
|
Create an agenda for the meeting or seminar wit the title '{this.inputName}' using the following details:
|
||||||
|
|
||||||
|
- The overall topic is '{this.inputTopic}'.
|
||||||
|
- The objective of the meeting is '{this.inputObjective}'.
|
||||||
|
- The moderator is '{this.inputModerator}'.
|
||||||
|
- The planned duration is '{this.inputDuration}'.
|
||||||
|
- The planned start time is '{this.inputStartTime}'.
|
||||||
|
{this.PromptGettingToKnowEachOther()}
|
||||||
|
- The number of participants is '{this.numberParticipants.Name()}'.
|
||||||
|
{this.PromptActiveParticipation()}
|
||||||
|
{this.PromptVirtualMeeting()}
|
||||||
|
{this.PromptPhysicalMeeting()}
|
||||||
|
|
||||||
|
Here is draft what was planned for the meeting:
|
||||||
|
{this.inputContent}
|
||||||
|
|
||||||
|
Please do not follow this draft strictly. It is just a suggestion.
|
||||||
|
{this.PromptFoci()}
|
||||||
|
{this.PromptBriefly()}
|
||||||
|
{this.PromptWhoIsPresenting()}
|
||||||
|
""");
|
||||||
|
|
||||||
|
await this.AddAIResponseAsync(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptLanguage()
|
||||||
|
{
|
||||||
|
if(this.selectedTargetLanguage is CommonLanguages.OTHER)
|
||||||
|
return this.customTargetLanguage;
|
||||||
|
|
||||||
|
return this.selectedTargetLanguage.Name();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptPhysicalMeeting()
|
||||||
|
{
|
||||||
|
if(this.isMeetingVirtual)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return $"""
|
||||||
|
- The meeting takes place at the following location: '{this.inputLocation}'.
|
||||||
|
{this.PromptJoiningDinner()}
|
||||||
|
{this.PromptSocialActivity()}
|
||||||
|
{this.PromptArriveAndDepart()}
|
||||||
|
- In case a lunch break is necessary, the break should about {this.durationLunchBreak} minutes long.
|
||||||
|
- In case any breaks are necessary, the breaks should be about {this.durationBreaks} minutes long.
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptArriveAndDepart()
|
||||||
|
{
|
||||||
|
if (this.needToArriveAndDepart)
|
||||||
|
return "- The participants should have time to arrive and depart.";
|
||||||
|
|
||||||
|
return "- The participants do not need to arrive and depart.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptSocialActivity()
|
||||||
|
{
|
||||||
|
if (this.doingSocialActivity)
|
||||||
|
return "- The participants will engage in a social activity after the meeting or seminar. This can be a team-building exercise, a sightseeing tour, or a visit to a local attraction. Please make a recommendation for an activity at '{this.inputLocation}'.";
|
||||||
|
|
||||||
|
return "- The participants will not engage in a social activity after the meeting or seminar.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SystemPromptSocialActivity()
|
||||||
|
{
|
||||||
|
if(this.doingSocialActivity)
|
||||||
|
return """
|
||||||
|
- 16:00 Departure to the social event [Consider the time needed to get to the location].
|
||||||
|
- 17:00 [Insert your advice for the social activity here].
|
||||||
|
""";
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SystemPromptDinner()
|
||||||
|
{
|
||||||
|
if(this.goingToDinner)
|
||||||
|
return """
|
||||||
|
- 19:00 Departure to the restaurant [Consider the time needed to get to the restaurant].
|
||||||
|
- 20:00 [Insert your advice for the dinner here.].
|
||||||
|
""";
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptJoiningDinner()
|
||||||
|
{
|
||||||
|
if (this.goingToDinner)
|
||||||
|
return $"- The participants will join for a dinner after the meeting or seminar. Please make a recommendation for a restaurant at '{this.inputLocation}'.";
|
||||||
|
|
||||||
|
return "- The participants will not join for a dinner after the meeting or seminar.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptVirtualMeeting()
|
||||||
|
{
|
||||||
|
if (this.isMeetingVirtual)
|
||||||
|
return "- The meeting or seminar will be held virtually, e.g, a call or webinar. The participants will join online.";
|
||||||
|
|
||||||
|
return "- The meeting or seminar will be held in person.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptActiveParticipation()
|
||||||
|
{
|
||||||
|
if (this.activeParticipation)
|
||||||
|
return "- The participants should actively participate in the meeting or seminar. This can be done through discussions, questions, and contributions to the content.";
|
||||||
|
|
||||||
|
return "- The participants do not need to actively participate.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptGettingToKnowEachOther()
|
||||||
|
{
|
||||||
|
if (this.introduceParticipants)
|
||||||
|
return "- The participants should introduce themselves to get to know each other. This can be done in a round or in pairs. The moderator should ensure that everyone has the opportunity to speak.";
|
||||||
|
|
||||||
|
return "- The participants do not need to introduce themselves.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptFoci()
|
||||||
|
{
|
||||||
|
if (this.selectedFoci.Any())
|
||||||
|
{
|
||||||
|
return $"""
|
||||||
|
|
||||||
|
Out of this content, the following points should be focused on:
|
||||||
|
{this.ConvertItemsToMarkdown(this.selectedFoci)}
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptBriefly()
|
||||||
|
{
|
||||||
|
if (this.justBriefly.Any())
|
||||||
|
{
|
||||||
|
return $"""
|
||||||
|
|
||||||
|
The following points should be just briefly mentioned:
|
||||||
|
{this.ConvertItemsToMarkdown(this.justBriefly)}
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PromptWhoIsPresenting()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(this.inputWhoIsPresenting))
|
||||||
|
{
|
||||||
|
return $"""
|
||||||
|
|
||||||
|
The following persons will present the content:
|
||||||
|
{this.inputWhoIsPresenting}
|
||||||
|
""";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConvertItemsToMarkdown(IEnumerable<string> items)
|
||||||
|
{
|
||||||
|
var markdown = new StringBuilder();
|
||||||
|
foreach (var item in items)
|
||||||
|
markdown.AppendLine($"- {item}");
|
||||||
|
|
||||||
|
return markdown.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
namespace AIStudio.Assistants.Agenda;
|
||||||
|
|
||||||
|
public enum NumberParticipants
|
||||||
|
{
|
||||||
|
NOT_SPECIFIED,
|
||||||
|
|
||||||
|
PEER_TO_PEER, // 2 participants
|
||||||
|
|
||||||
|
SMALL_GROUP, // 3 - 5 participants
|
||||||
|
LARGE_GROUP, // 6 - 12 participants
|
||||||
|
MULTIPLE_SMALL_GROUPS, // 13 - 20 participants
|
||||||
|
MULTIPLE_LARGE_GROUPS, // 21 - 30 participants
|
||||||
|
|
||||||
|
SYMPOSIUM, // 31 - 100 participants
|
||||||
|
CONFERENCE, // 101 - 200 participants
|
||||||
|
CONGRESS, // 201 - 1000 participants
|
||||||
|
LARGE_EVENT, // 1000+ participants
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
namespace AIStudio.Assistants.Agenda;
|
||||||
|
|
||||||
|
public static class NumberParticipantsExtensions
|
||||||
|
{
|
||||||
|
public static string Name(this NumberParticipants numberParticipants) => numberParticipants switch
|
||||||
|
{
|
||||||
|
NumberParticipants.NOT_SPECIFIED => "Please select how many participants are expected",
|
||||||
|
|
||||||
|
NumberParticipants.PEER_TO_PEER => "2 (peer to peer)",
|
||||||
|
|
||||||
|
NumberParticipants.SMALL_GROUP => "3 - 5 (small group)",
|
||||||
|
NumberParticipants.LARGE_GROUP => "6 - 12 (large group)",
|
||||||
|
NumberParticipants.MULTIPLE_SMALL_GROUPS => "13 - 20 (multiple small groups)",
|
||||||
|
NumberParticipants.MULTIPLE_LARGE_GROUPS => "21 - 30 (multiple large groups)",
|
||||||
|
|
||||||
|
NumberParticipants.SYMPOSIUM => "31 - 100 (symposium)",
|
||||||
|
NumberParticipants.CONFERENCE => "101 - 200 (conference)",
|
||||||
|
NumberParticipants.CONGRESS => "201 - 1,000 (congress)",
|
||||||
|
|
||||||
|
NumberParticipants.LARGE_EVENT => "1,000+ (large event)",
|
||||||
|
|
||||||
|
_ => "Unknown"
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Provider;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Assistants;
|
||||||
|
|
||||||
|
public abstract partial class AssistantBase : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject]
|
||||||
|
protected SettingsManager SettingsManager { get; set; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected IJSRuntime JsRuntime { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected ThreadSafeRandom RNG { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected ISnackbar Snackbar { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected Rust Rust { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected NavigationManager NavigationManager { get; init; } = null!;
|
||||||
|
|
||||||
|
internal const string AFTER_RESULT_DIV_ID = "afterAssistantResult";
|
||||||
|
internal const string RESULT_DIV_ID = "assistantResult";
|
||||||
|
|
||||||
|
protected abstract string Title { get; }
|
||||||
|
|
||||||
|
protected abstract string Description { get; }
|
||||||
|
|
||||||
|
protected abstract string SystemPrompt { get; }
|
||||||
|
|
||||||
|
protected abstract void ResetFrom();
|
||||||
|
|
||||||
|
protected abstract bool MightPreselectValues();
|
||||||
|
|
||||||
|
private protected virtual RenderFragment? Body => null;
|
||||||
|
|
||||||
|
protected virtual bool ShowResult => true;
|
||||||
|
|
||||||
|
protected virtual bool ShowDedicatedProgress => false;
|
||||||
|
|
||||||
|
protected virtual ChatThread ConvertToChatThread => this.chatThread ?? new();
|
||||||
|
|
||||||
|
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
||||||
|
|
||||||
|
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
|
|
||||||
|
protected AIStudio.Settings.Provider providerSettings;
|
||||||
|
protected MudForm? form;
|
||||||
|
protected bool inputIsValid;
|
||||||
|
|
||||||
|
protected ChatThread? chatThread;
|
||||||
|
private ContentBlock? resultingContentBlock;
|
||||||
|
private string[] inputIssues = [];
|
||||||
|
private bool isProcessing;
|
||||||
|
|
||||||
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
// Configure the spellchecking for the user input:
|
||||||
|
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
||||||
|
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
// Reset the validation when not editing and on the first render.
|
||||||
|
// We don't want to show validation errors when the user opens the dialog.
|
||||||
|
if(firstRender)
|
||||||
|
this.form?.ResetValidation();
|
||||||
|
|
||||||
|
await base.OnAfterRenderAsync(firstRender);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected string? ValidatingProvider(AIStudio.Settings.Provider provider)
|
||||||
|
{
|
||||||
|
if(provider.UsedProvider == Providers.NONE)
|
||||||
|
return "Please select a provider.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CreateChatThread()
|
||||||
|
{
|
||||||
|
this.chatThread = new()
|
||||||
|
{
|
||||||
|
WorkspaceId = Guid.Empty,
|
||||||
|
ChatId = Guid.NewGuid(),
|
||||||
|
Name = string.Empty,
|
||||||
|
Seed = this.RNG.Next(),
|
||||||
|
SystemPrompt = this.SystemPrompt,
|
||||||
|
Blocks = [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DateTimeOffset AddUserRequest(string request)
|
||||||
|
{
|
||||||
|
var time = DateTimeOffset.Now;
|
||||||
|
this.chatThread!.Blocks.Add(new ContentBlock
|
||||||
|
{
|
||||||
|
Time = time,
|
||||||
|
ContentType = ContentType.TEXT,
|
||||||
|
Role = ChatRole.USER,
|
||||||
|
Content = new ContentText
|
||||||
|
{
|
||||||
|
Text = request,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task<string> AddAIResponseAsync(DateTimeOffset time)
|
||||||
|
{
|
||||||
|
var aiText = new ContentText
|
||||||
|
{
|
||||||
|
// We have to wait for the remote
|
||||||
|
// for the content stream:
|
||||||
|
InitialRemoteWait = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.resultingContentBlock = new ContentBlock
|
||||||
|
{
|
||||||
|
Time = time,
|
||||||
|
ContentType = ContentType.TEXT,
|
||||||
|
Role = ChatRole.AI,
|
||||||
|
Content = aiText,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.chatThread?.Blocks.Add(this.resultingContentBlock);
|
||||||
|
this.isProcessing = true;
|
||||||
|
this.StateHasChanged();
|
||||||
|
|
||||||
|
// Use the selected provider to get the AI response.
|
||||||
|
// By awaiting this line, we wait for the entire
|
||||||
|
// content to be streamed.
|
||||||
|
await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(), this.JsRuntime, this.SettingsManager, this.providerSettings.Model, this.chatThread);
|
||||||
|
|
||||||
|
this.isProcessing = false;
|
||||||
|
this.StateHasChanged();
|
||||||
|
|
||||||
|
// Return the AI response:
|
||||||
|
return aiText.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task CopyToClipboard(string text)
|
||||||
|
{
|
||||||
|
await this.Rust.CopyText2Clipboard(this.JsRuntime, this.Snackbar, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? GetButtonIcon(string icon)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(icon))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
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 needed
|
// See https://stackoverflow.com/a/77300384/2258393 for why this class is necessary
|
||||||
//
|
//
|
||||||
|
|
||||||
public abstract class AssistantBaseCore : AssistantBase
|
public abstract class AssistantBaseCore : AssistantBase
|
||||||
+3
-12
@@ -1,5 +1,4 @@
|
|||||||
@page "/assistant/coding"
|
@attribute [Route(Routes.ASSISTANT_CODING)]
|
||||||
@using AIStudio.Settings
|
|
||||||
@inherits AssistantBaseCore
|
@inherits AssistantBaseCore
|
||||||
|
|
||||||
<MudExpansionPanels Class="mb-3">
|
<MudExpansionPanels Class="mb-3">
|
||||||
@@ -16,9 +15,7 @@
|
|||||||
</MudButton>
|
</MudButton>
|
||||||
|
|
||||||
<MudStack Row="@false" Class="mb-3">
|
<MudStack Row="@false" Class="mb-3">
|
||||||
<MudSwitch T="bool" @bind-Value="@this.provideCompilerMessages" Color="Color.Primary">
|
<MudTextSwitch Label="Do you want to provide compiler messages?" @bind-Value="@this.provideCompilerMessages" LabelOn="Yes, provide compiler messages" LabelOff="No, there are no compiler messages" />
|
||||||
@(this.provideCompilerMessages ? "Provide compiler messages" : "Provide no compiler messages")
|
|
||||||
</MudSwitch>
|
|
||||||
@if (this.provideCompilerMessages)
|
@if (this.provideCompilerMessages)
|
||||||
{
|
{
|
||||||
<MudTextField T="string" @bind-Text="@this.compilerMessages" Validation="@this.ValidatingCompilerMessages" AdornmentIcon="@Icons.Material.Filled.Error" Adornment="Adornment.Start" Label="Compiler messages" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
<MudTextField T="string" @bind-Text="@this.compilerMessages" Validation="@this.ValidatingCompilerMessages" AdornmentIcon="@Icons.Material.Filled.Error" Adornment="Adornment.Start" Label="Compiler messages" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||||
@@ -26,13 +23,7 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudTextField T="string" @bind-Text="@this.questions" Validation="@this.ValidateQuestions" AdornmentIcon="@Icons.Material.Filled.QuestionMark" Adornment="Adornment.Start" Label="Your question(s)" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
<MudTextField T="string" @bind-Text="@this.questions" Validation="@this.ValidateQuestions" AdornmentIcon="@Icons.Material.Filled.QuestionMark" Adornment="Adornment.Start" Label="Your question(s)" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
<MudSelect T="Provider" @bind-Value="@this.providerSettings" Validation="@this.ValidatingProvider" 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>
|
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="() => this.GetSupport()" Class="mb-3">
|
<MudButton Variant="Variant.Filled" Color="Color.Info" OnClick="() => this.GetSupport()" Class="mb-3">
|
||||||
Get support
|
Get support
|
||||||
+47
-11
@@ -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.PreselectCodingOptions)
|
this.MightPreselectValues();
|
||||||
{
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CODING_ASSISTANT).FirstOrDefault();
|
||||||
this.provideCompilerMessages = this.SettingsManager.ConfigurationData.PreselectCodingCompilerMessages;
|
if (deferredContent is not null)
|
||||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedCodingProvider);
|
this.questions = deferredContent;
|
||||||
}
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
@@ -68,8 +100,8 @@ public partial class AssistantCoding : AssistantBaseCore
|
|||||||
this.codingContexts.Add(new()
|
this.codingContexts.Add(new()
|
||||||
{
|
{
|
||||||
Id = $"Context {this.codingContexts.Count + 1}",
|
Id = $"Context {this.codingContexts.Count + 1}",
|
||||||
Language = this.SettingsManager.ConfigurationData.PreselectCodingOptions ? this.SettingsManager.ConfigurationData.PreselectedCodingLanguage : default,
|
Language = this.SettingsManager.ConfigurationData.Coding.PreselectOptions ? this.SettingsManager.ConfigurationData.Coding.PreselectedProgrammingLanguage : default,
|
||||||
OtherLanguage = this.SettingsManager.ConfigurationData.PreselectCodingOptions ? this.SettingsManager.ConfigurationData.PreselectedCodingOtherLanguage : string.Empty,
|
OtherLanguage = this.SettingsManager.ConfigurationData.Coding.PreselectOptions ? this.SettingsManager.ConfigurationData.Coding.PreselectedOtherProgrammingLanguage : string.Empty,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
-1
@@ -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)
|
||||||
{
|
{
|
||||||
File renamed without changes.
+1
-1
@@ -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
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.Coding;
|
namespace AIStudio.Assistants.Coding;
|
||||||
|
|
||||||
public static class CommonCodingLanguageExtensions
|
public static class CommonCodingLanguageExtensions
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.Coding;
|
namespace AIStudio.Assistants.Coding;
|
||||||
|
|
||||||
public enum CommonCodingLanguages
|
public enum CommonCodingLanguages
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@attribute [Route(Routes.ASSISTANT_GRAMMAR_SPELLING)]
|
||||||
|
@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"/>
|
||||||
|
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.ProofreadText()">
|
||||||
|
Proofread
|
||||||
|
</MudButton>
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
namespace AIStudio.Assistants.GrammarSpelling;
|
||||||
|
|
||||||
|
public partial class AssistantGrammarSpelling : AssistantBaseCore
|
||||||
|
{
|
||||||
|
protected override string Title => "Grammar & Spelling Checker";
|
||||||
|
|
||||||
|
protected override string Description =>
|
||||||
|
"""
|
||||||
|
Check the grammar and spelling of a text.
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override string SystemPrompt =>
|
||||||
|
$"""
|
||||||
|
You are an expert in languages and their rules. For example, you know how US and UK English or German in
|
||||||
|
Germany and German in Austria differ. You receive text as input. You check the spelling and grammar of
|
||||||
|
this text according to the rules of {this.SystemPromptLanguage()}. You never add information. You
|
||||||
|
never ask the user for additional information. You do not attempt to improve the wording of the text.
|
||||||
|
Your response includes only the corrected text. Do not explain your changes. If no changes are needed,
|
||||||
|
you return the text unchanged.
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override bool ShowResult => false;
|
||||||
|
|
||||||
|
protected override bool ShowDedicatedProgress => true;
|
||||||
|
|
||||||
|
protected override IReadOnlyList<IButtonData> FooterButtons =>
|
||||||
|
[
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
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 bool MightPreselectValues()
|
||||||
|
{
|
||||||
|
if (this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectOptions)
|
||||||
|
{
|
||||||
|
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedTargetLanguage;
|
||||||
|
this.customTargetLanguage = this.SettingsManager.ConfigurationData.GrammarSpelling.PreselectedOtherLanguage;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private string inputText = string.Empty;
|
||||||
|
private CommonLanguages selectedTargetLanguage;
|
||||||
|
private string customTargetLanguage = string.Empty;
|
||||||
|
private string correctedText = string.Empty;
|
||||||
|
|
||||||
|
private string? ValidateText(string text)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(text))
|
||||||
|
return "Please provide a text as input. You might copy the desired text from a document or a website.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateCustomLanguage(string language)
|
||||||
|
{
|
||||||
|
if(this.selectedTargetLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
||||||
|
return "Please provide a custom language.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SystemPromptLanguage()
|
||||||
|
{
|
||||||
|
var lang = this.selectedTargetLanguage switch
|
||||||
|
{
|
||||||
|
CommonLanguages.AS_IS => "the source language",
|
||||||
|
CommonLanguages.OTHER => this.customTargetLanguage,
|
||||||
|
|
||||||
|
_ => $"{this.selectedTargetLanguage.Name()}",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(lang))
|
||||||
|
return "the source language";
|
||||||
|
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ProofreadText()
|
||||||
|
{
|
||||||
|
await this.form!.Validate();
|
||||||
|
if (!this.inputIsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.CreateChatThread();
|
||||||
|
var time = this.AddUserRequest(this.inputText);
|
||||||
|
|
||||||
|
this.correctedText = await this.AddAIResponseAsync(time);
|
||||||
|
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.correctedText);
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-9
@@ -1,5 +1,4 @@
|
|||||||
@page "/assistant/icons"
|
@attribute [Route(Routes.ASSISTANT_ICON_FINDER)]
|
||||||
@using AIStudio.Settings
|
|
||||||
@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"/>
|
||||||
@@ -16,13 +15,7 @@
|
|||||||
<MudButton Href="@this.selectedIconSource.URL()" Target="_blank" Variant="Variant.Filled" Size="Size.Medium">Open website</MudButton>
|
<MudButton Href="@this.selectedIconSource.URL()" Target="_blank" Variant="Variant.Filled" Size="Size.Medium">Open website</MudButton>
|
||||||
}
|
}
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
<MudSelect T="Provider" @bind-Value="@this.providerSettings" Validation="@this.ValidatingProvider" 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>
|
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.FindIcon()">
|
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.FindIcon()">
|
||||||
Find icon
|
Find icon
|
||||||
+46
-16
@@ -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.PreselectIconOptions)
|
|
||||||
{
|
|
||||||
this.selectedIconSource = this.SettingsManager.ConfigurationData.PreselectedIconSource;
|
|
||||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedIconProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
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
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.IconFinder;
|
namespace AIStudio.Assistants.IconFinder;
|
||||||
|
|
||||||
public static class IconSourceExtensions
|
public static class IconSourceExtensions
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.IconFinder;
|
namespace AIStudio.Assistants.IconFinder;
|
||||||
|
|
||||||
public enum IconSources
|
public enum IconSources
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@attribute [Route(Routes.ASSISTANT_REWRITE)]
|
||||||
|
@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"/>
|
||||||
|
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelectingOptional())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom language" />
|
||||||
|
<EnumSelection T="WritingStyles" NameFunc="@(style => style.Name())" @bind-Value="@this.selectedWritingStyle" Icon="@Icons.Material.Filled.Edit" Label="Writing style" AllowOther="@false" />
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.RewriteText()">
|
||||||
|
Improve
|
||||||
|
</MudButton>
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
namespace AIStudio.Assistants.RewriteImprove;
|
||||||
|
|
||||||
|
public partial class AssistantRewriteImprove : AssistantBaseCore
|
||||||
|
{
|
||||||
|
protected override string Title => "Rewrite & Improve Text";
|
||||||
|
|
||||||
|
protected override string Description =>
|
||||||
|
"""
|
||||||
|
Rewrite and improve your text. Please note, that the capabilities of the different LLM providers will vary.
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override string SystemPrompt =>
|
||||||
|
$"""
|
||||||
|
You are an expert in language and style. You receive a text as input. First, you review the text. If no
|
||||||
|
changes are needed, you return the text without modifications. If a change is necessary, you improve the
|
||||||
|
text. You can also correct spelling and grammar issues. You never add additional information. You never
|
||||||
|
ask the user for additional information. Your response only contains the improved text. You do not explain
|
||||||
|
your changes. If no changes are needed, you return the text unchanged.
|
||||||
|
The style of the text: {this.selectedWritingStyle.Prompt()}. You follow the rules according
|
||||||
|
to {this.SystemPromptLanguage()} in all your changes.
|
||||||
|
""";
|
||||||
|
|
||||||
|
protected override bool ShowResult => false;
|
||||||
|
|
||||||
|
protected override bool ShowDedicatedProgress => true;
|
||||||
|
|
||||||
|
protected override IReadOnlyList<IButtonData> FooterButtons =>
|
||||||
|
[
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedTargetLanguage;
|
||||||
|
this.customTargetLanguage = this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedOtherLanguage;
|
||||||
|
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.RewriteImprove.PreselectedProvider);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private string inputText = string.Empty;
|
||||||
|
private CommonLanguages selectedTargetLanguage;
|
||||||
|
private string customTargetLanguage = string.Empty;
|
||||||
|
private string rewrittenText = string.Empty;
|
||||||
|
private WritingStyles selectedWritingStyle;
|
||||||
|
|
||||||
|
private string? ValidateText(string text)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(text))
|
||||||
|
return "Please provide a text as input. You might copy the desired text from a document or a website.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateCustomLanguage(string language)
|
||||||
|
{
|
||||||
|
if(this.selectedTargetLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
||||||
|
return "Please provide a custom language.";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SystemPromptLanguage()
|
||||||
|
{
|
||||||
|
var lang = this.selectedTargetLanguage switch
|
||||||
|
{
|
||||||
|
CommonLanguages.AS_IS => "the source language",
|
||||||
|
CommonLanguages.OTHER => this.customTargetLanguage,
|
||||||
|
|
||||||
|
_ => $"{this.selectedTargetLanguage.Name()}",
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(lang))
|
||||||
|
return "the source language";
|
||||||
|
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RewriteText()
|
||||||
|
{
|
||||||
|
await this.form!.Validate();
|
||||||
|
if (!this.inputIsValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.CreateChatThread();
|
||||||
|
var time = this.AddUserRequest(this.inputText);
|
||||||
|
|
||||||
|
this.rewrittenText = await this.AddAIResponseAsync(time);
|
||||||
|
await this.JsRuntime.GenerateAndShowDiff(this.inputText, this.rewrittenText);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace AIStudio.Assistants.RewriteImprove;
|
||||||
|
|
||||||
|
public enum WritingStyles
|
||||||
|
{
|
||||||
|
NOT_SPECIFIED = 0,
|
||||||
|
|
||||||
|
EVERYDAY,
|
||||||
|
BUSINESS,
|
||||||
|
SCIENTIFIC,
|
||||||
|
JOURNALISTIC,
|
||||||
|
LITERARY,
|
||||||
|
TECHNICAL,
|
||||||
|
MARKETING,
|
||||||
|
ACADEMIC,
|
||||||
|
LEGAL,
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
namespace AIStudio.Assistants.RewriteImprove;
|
||||||
|
|
||||||
|
public static class WritingStylesExtensions
|
||||||
|
{
|
||||||
|
public static string Name(this WritingStyles style)
|
||||||
|
{
|
||||||
|
return style switch
|
||||||
|
{
|
||||||
|
WritingStyles.EVERYDAY => "Everyday (personal texts, social media)",
|
||||||
|
WritingStyles.BUSINESS => "Business (business emails, reports, presentations)",
|
||||||
|
WritingStyles.SCIENTIFIC => "Scientific (scientific papers, research reports)",
|
||||||
|
WritingStyles.JOURNALISTIC => "Journalistic (magazines, newspapers, news)",
|
||||||
|
WritingStyles.LITERARY => "Literary (fiction, poetry)",
|
||||||
|
WritingStyles.TECHNICAL => "Technical (manuals, documentation)",
|
||||||
|
WritingStyles.MARKETING => "Marketing (advertisements, sales texts)",
|
||||||
|
WritingStyles.ACADEMIC => "Academic (essays, seminar papers)",
|
||||||
|
WritingStyles.LEGAL => "Legal (legal texts, contracts)",
|
||||||
|
|
||||||
|
_ => "Not specified",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Prompt(this WritingStyles style)
|
||||||
|
{
|
||||||
|
return style switch
|
||||||
|
{
|
||||||
|
WritingStyles.EVERYDAY => "Use a everyday style like for personal texts, social media, and informal communication.",
|
||||||
|
WritingStyles.BUSINESS => "Use a business style like for business emails, reports, and presentations. Most important is clarity and professionalism.",
|
||||||
|
WritingStyles.SCIENTIFIC => "Use a scientific style like for scientific papers, research reports, and academic writing. Most important is precision and objectivity.",
|
||||||
|
WritingStyles.JOURNALISTIC => "Use a journalistic style like for magazines, newspapers, and news. Most important is readability and engaging content.",
|
||||||
|
WritingStyles.LITERARY => "Use a literary style like for fiction, poetry, and creative writing. Most important is creativity and emotional impact.",
|
||||||
|
WritingStyles.TECHNICAL => "Use a technical style like for manuals, documentation, and technical writing. Most important is clarity and precision.",
|
||||||
|
WritingStyles.MARKETING => "Use a marketing style like for advertisements, sales texts, and promotional content. Most important is persuasiveness and engagement.",
|
||||||
|
WritingStyles.ACADEMIC => "Use a academic style like for essays, seminar papers, and academic writing. Most important is clarity and objectivity.",
|
||||||
|
WritingStyles.LEGAL => "Use a legal style like for legal texts, contracts, and official documents. Most important is precision and legal correctness. Use formal legal language.",
|
||||||
|
|
||||||
|
_ => "Keep the style of the text as it is.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
@attribute [Route(Routes.ASSISTANT_SUMMARIZER)]
|
||||||
|
@inherits AssistantBaseCore
|
||||||
|
|
||||||
|
@if (!this.SettingsManager.ConfigurationData.TextSummarizer.HideWebContentReader)
|
||||||
|
{
|
||||||
|
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" Preselect="@(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions && this.SettingsManager.ConfigurationData.TextSummarizer.PreselectWebContentReader)" PreselectContentCleanerAgent="@(this.SettingsManager.ConfigurationData.TextSummarizer.PreselectOptions && this.SettingsManager.ConfigurationData.TextSummarizer.PreselectContentCleanerAgent)"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
<MudTextField T="string" Disabled="@this.isAgentRunning" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||||
|
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.Name())" @bind-Value="@this.selectedTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Target language" AllowOther="@true" @bind-OtherInput="@this.customTargetLanguage" OtherValue="CommonLanguages.OTHER" LabelOther="Custom target language" ValidateOther="@this.ValidateCustomLanguage" />
|
||||||
|
<EnumSelection T="Complexity" NameFunc="@(complexity => complexity.Name())" @bind-Value="@this.selectedComplexity" Icon="@Icons.Material.Filled.Layers" Label="Target complexity" AllowOther="@true" @bind-OtherInput="@this.expertInField" OtherValue="Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS" LabelOther="Your expertise" ValidateOther="@this.ValidateExpertInField" />
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.SummarizeText()" Disabled="@this.isAgentRunning">
|
||||||
|
Summarize
|
||||||
|
</MudButton>
|
||||||
+48
-10
@@ -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,7 +24,48 @@ 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 CommonLanguages selectedTargetLanguage;
|
private CommonLanguages selectedTargetLanguage;
|
||||||
private string customTargetLanguage = string.Empty;
|
private string customTargetLanguage = string.Empty;
|
||||||
private Complexity selectedComplexity;
|
private Complexity selectedComplexity;
|
||||||
@@ -33,14 +75,10 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if(this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)
|
this.MightPreselectValues();
|
||||||
{
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT).FirstOrDefault();
|
||||||
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.PreselectedTextSummarizerTargetLanguage;
|
if (deferredContent is not null)
|
||||||
this.customTargetLanguage = this.SettingsManager.ConfigurationData.PreselectedTextSummarizerOtherLanguage;
|
this.inputText = deferredContent;
|
||||||
this.selectedComplexity = this.SettingsManager.ConfigurationData.PreselectedTextSummarizerComplexity;
|
|
||||||
this.expertInField = this.SettingsManager.ConfigurationData.PreselectedTextSummarizerExpertInField;
|
|
||||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedTextSummarizerProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
@@ -80,7 +118,7 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
|
|||||||
this.CreateChatThread();
|
this.CreateChatThread();
|
||||||
var time = this.AddUserRequest(
|
var time = this.AddUserRequest(
|
||||||
$"""
|
$"""
|
||||||
{this.selectedTargetLanguage.Prompt(this.customTargetLanguage)}
|
{this.selectedTargetLanguage.PromptSummarizing(this.customTargetLanguage)}
|
||||||
{this.selectedComplexity.Prompt(this.expertInField)}
|
{this.selectedComplexity.Prompt(this.expertInField)}
|
||||||
|
|
||||||
Please summarize the following text:
|
Please summarize the following text:
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.TextSummarizer;
|
namespace AIStudio.Assistants.TextSummarizer;
|
||||||
|
|
||||||
public enum Complexity
|
public enum Complexity
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Pages.TextSummarizer;
|
namespace AIStudio.Assistants.TextSummarizer;
|
||||||
|
|
||||||
public static class ComplexityExtensions
|
public static class ComplexityExtensions
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
@attribute [Route(Routes.ASSISTANT_TRANSLATION)]
|
||||||
|
@inherits AssistantBaseCore
|
||||||
|
|
||||||
|
@if (!this.SettingsManager.ConfigurationData.Translation.HideWebContentReader)
|
||||||
|
{
|
||||||
|
<ReadWebContent @bind-Content="@this.inputText" ProviderSettings="@this.providerSettings" @bind-AgentIsRunning="@this.isAgentRunning" Preselect="@(this.SettingsManager.ConfigurationData.Translation.PreselectOptions && this.SettingsManager.ConfigurationData.Translation.PreselectWebContentReader)" PreselectContentCleanerAgent="@(this.SettingsManager.ConfigurationData.Translation.PreselectOptions && this.SettingsManager.ConfigurationData.Translation.PreselectContentCleanerAgent)"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
<MudTextSwitch Label="Live translation" @bind-Value="@this.liveTranslation" LabelOn="Live translation" LabelOff="No live translation"/>
|
||||||
|
@if (this.liveTranslation)
|
||||||
|
{
|
||||||
|
<MudTextField T="string" Disabled="@this.isAgentRunning" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" Immediate="@true" DebounceInterval="@this.SettingsManager.ConfigurationData.Translation.DebounceIntervalMilliseconds" OnDebounceIntervalElapsed="() => this.TranslateText(force: false)" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudTextField T="string" Disabled="@this.isAgentRunning" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelecting())" @bind-Value="@this.selectedTargetLanguage" ValidateSelection="@this.ValidatingTargetLanguage" Icon="@Icons.Material.Filled.Translate" Label="Target language" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="Custom target language" />
|
||||||
|
<ProviderSelection @bind-ProviderSettings="@this.providerSettings" ValidateProvider="@this.ValidatingProvider"/>
|
||||||
|
|
||||||
|
<MudButton Disabled="@this.isAgentRunning" Variant="Variant.Filled" Class="mb-3" OnClick="() => this.TranslateText(force: true)">
|
||||||
|
Translate
|
||||||
|
</MudButton>
|
||||||
+49
-10
@@ -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,7 +20,47 @@ 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 string inputText = string.Empty;
|
private string inputText = string.Empty;
|
||||||
private string inputTextLastTranslation = string.Empty;
|
private string inputTextLastTranslation = string.Empty;
|
||||||
private CommonLanguages selectedTargetLanguage;
|
private CommonLanguages selectedTargetLanguage;
|
||||||
@@ -29,13 +70,10 @@ public partial class AssistantTranslation : AssistantBaseCore
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (this.SettingsManager.ConfigurationData.PreselectTranslationOptions)
|
this.MightPreselectValues();
|
||||||
{
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TRANSLATION_ASSISTANT).FirstOrDefault();
|
||||||
this.liveTranslation = this.SettingsManager.ConfigurationData.PreselectLiveTranslation;
|
if (deferredContent is not null)
|
||||||
this.selectedTargetLanguage = this.SettingsManager.ConfigurationData.PreselectedTranslationTargetLanguage;
|
this.inputText = deferredContent;
|
||||||
this.customTargetLanguage = this.SettingsManager.ConfigurationData.PreselectTranslationOtherLanguage;
|
|
||||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedTranslationProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
@@ -65,9 +103,10 @@ public partial class AssistantTranslation : AssistantBaseCore
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task TranslateText(bool force)
|
private async Task TranslateText(bool force)
|
||||||
{
|
{
|
||||||
|
await this.form!.Validate();
|
||||||
if (!this.inputIsValid)
|
if (!this.inputIsValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -78,7 +117,7 @@ public partial class AssistantTranslation : AssistantBaseCore
|
|||||||
this.CreateChatThread();
|
this.CreateChatThread();
|
||||||
var time = this.AddUserRequest(
|
var time = this.AddUserRequest(
|
||||||
$"""
|
$"""
|
||||||
{this.selectedTargetLanguage.Prompt(this.customTargetLanguage)}
|
{this.selectedTargetLanguage.PromptTranslation(this.customTargetLanguage)}
|
||||||
|
|
||||||
The given text is:
|
The given text is:
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
@using AIStudio
|
||||||
|
@using AIStudio.Tools
|
||||||
|
@using AIStudio.Components
|
||||||
|
@using MudBlazor
|
||||||
@@ -11,6 +11,7 @@ public enum ChatRole
|
|||||||
SYSTEM,
|
SYSTEM,
|
||||||
USER,
|
USER,
|
||||||
AI,
|
AI,
|
||||||
|
AGENT,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public sealed class ContentText : IContent
|
|||||||
// Notify the UI that the content has changed,
|
// Notify the UI that the content has changed,
|
||||||
// depending on the energy saving mode:
|
// depending on the energy saving mode:
|
||||||
var now = DateTimeOffset.Now;
|
var now = DateTimeOffset.Now;
|
||||||
switch (settings.ConfigurationData.IsSavingEnergy)
|
switch (settings.ConfigurationData.App.IsSavingEnergy)
|
||||||
{
|
{
|
||||||
// Energy saving mode is off. We notify the UI
|
// Energy saving mode is off. We notify the UI
|
||||||
// as fast as possible -- no matter the odds:
|
// as fast as possible -- no matter the odds:
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AIStudio.Chat;
|
||||||
|
|
||||||
|
public static class SystemPrompts
|
||||||
|
{
|
||||||
|
public const string DEFAULT = "You are a helpful assistant!";
|
||||||
|
}
|
||||||
@@ -1,27 +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/>
|
|
||||||
</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,25 +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.resultingContentBlock is not null)
|
|
||||||
{
|
|
||||||
<ContentBlockComponent Role="@this.resultingContentBlock.Role" Type="@this.resultingContentBlock.ContentType" Time="@this.resultingContentBlock.Time" Content="@this.resultingContentBlock.Content" Class="mr-2"/>
|
|
||||||
}
|
|
||||||
</ChildContent>
|
|
||||||
</InnerScrolling>
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
using AIStudio.Chat;
|
|
||||||
using AIStudio.Provider;
|
|
||||||
using AIStudio.Settings;
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace AIStudio.Components;
|
|
||||||
|
|
||||||
public abstract partial class AssistantBase : ComponentBase
|
|
||||||
{
|
|
||||||
[Inject]
|
|
||||||
protected SettingsManager SettingsManager { get; set; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
|
||||||
protected IJSRuntime JsRuntime { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
|
||||||
protected Random RNG { get; set; } = null!;
|
|
||||||
|
|
||||||
protected abstract string Title { get; }
|
|
||||||
|
|
||||||
protected abstract string Description { get; }
|
|
||||||
|
|
||||||
protected abstract string SystemPrompt { get; }
|
|
||||||
|
|
||||||
private protected virtual RenderFragment? Body => null;
|
|
||||||
|
|
||||||
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
|
||||||
|
|
||||||
protected AIStudio.Settings.Provider providerSettings;
|
|
||||||
protected MudForm? form;
|
|
||||||
protected bool inputIsValid;
|
|
||||||
|
|
||||||
private ChatThread? chatThread;
|
|
||||||
private ContentBlock? resultingContentBlock;
|
|
||||||
private string[] inputIssues = [];
|
|
||||||
|
|
||||||
#region Overrides of ComponentBase
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
// Configure the spellchecking for the user input:
|
|
||||||
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
|
|
||||||
|
|
||||||
await base.OnParametersSetAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
||||||
{
|
|
||||||
// Reset the validation when not editing and on the first render.
|
|
||||||
// We don't want to show validation errors when the user opens the dialog.
|
|
||||||
if(firstRender)
|
|
||||||
this.form?.ResetValidation();
|
|
||||||
|
|
||||||
await base.OnAfterRenderAsync(firstRender);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
protected string? ValidatingProvider(AIStudio.Settings.Provider provider)
|
|
||||||
{
|
|
||||||
if(provider.UsedProvider == Providers.NONE)
|
|
||||||
return "Please select a provider.";
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CreateChatThread()
|
|
||||||
{
|
|
||||||
this.chatThread = new()
|
|
||||||
{
|
|
||||||
WorkspaceId = Guid.Empty,
|
|
||||||
ChatId = Guid.NewGuid(),
|
|
||||||
Name = string.Empty,
|
|
||||||
Seed = this.RNG.Next(),
|
|
||||||
SystemPrompt = this.SystemPrompt,
|
|
||||||
Blocks = [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DateTimeOffset AddUserRequest(string request)
|
|
||||||
{
|
|
||||||
var time = DateTimeOffset.Now;
|
|
||||||
this.chatThread!.Blocks.Add(new ContentBlock
|
|
||||||
{
|
|
||||||
Time = time,
|
|
||||||
ContentType = ContentType.TEXT,
|
|
||||||
Role = ChatRole.USER,
|
|
||||||
Content = new ContentText
|
|
||||||
{
|
|
||||||
Text = request,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task AddAIResponseAsync(DateTimeOffset time)
|
|
||||||
{
|
|
||||||
var aiText = new ContentText
|
|
||||||
{
|
|
||||||
// We have to wait for the remote
|
|
||||||
// for the content stream:
|
|
||||||
InitialRemoteWait = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.resultingContentBlock = new ContentBlock
|
|
||||||
{
|
|
||||||
Time = time,
|
|
||||||
ContentType = ContentType.TEXT,
|
|
||||||
Role = ChatRole.AI,
|
|
||||||
Content = aiText,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.chatThread?.Blocks.Add(this.resultingContentBlock);
|
|
||||||
|
|
||||||
// Use the selected provider to get the AI response.
|
|
||||||
// By awaiting this line, we wait for the entire
|
|
||||||
// content to be streamed.
|
|
||||||
await aiText.CreateFromProviderAsync(this.providerSettings.CreateProvider(), this.JsRuntime, this.SettingsManager, this.providerSettings.Model, this.chatThread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<MudCard Outlined="@true" Style="border-width: 2px; border-color: #0d47a1; border-radius: 12px; border-style: solid; max-width: 20em;">
|
||||||
|
<MudCardHeader>
|
||||||
|
<CardHeaderContent>
|
||||||
|
<MudStack AlignItems="AlignItems.Center" Row="@true">
|
||||||
|
<MudIcon Icon="@this.Icon" Size="Size.Large" Color="Color.Primary"/>
|
||||||
|
<MudText Typo="Typo.h6">
|
||||||
|
@this.Name
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</CardHeaderContent>
|
||||||
|
</MudCardHeader>
|
||||||
|
<MudCardContent>
|
||||||
|
<MudStack>
|
||||||
|
<MudText>
|
||||||
|
@this.Description
|
||||||
|
</MudText>
|
||||||
|
</MudStack>
|
||||||
|
</MudCardContent>
|
||||||
|
<MudCardActions>
|
||||||
|
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link">
|
||||||
|
@this.ButtonText
|
||||||
|
</MudButton>
|
||||||
|
</MudCardActions>
|
||||||
|
</MudCard>
|
||||||
+1
-1
@@ -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,26 +0,0 @@
|
|||||||
<MudItem xs="3">
|
|
||||||
<MudCard Outlined="@true" Style="border-width: 2px; border-color: #0d47a1; border-radius: 12px; border-style: solid;">
|
|
||||||
<MudCardHeader>
|
|
||||||
<CardHeaderContent>
|
|
||||||
<MudStack AlignItems="AlignItems.Center" Row="@true">
|
|
||||||
<MudIcon Icon="@this.Icon" Size="Size.Large" Color="Color.Primary"/>
|
|
||||||
<MudText Typo="Typo.h6">
|
|
||||||
@this.Name
|
|
||||||
</MudText>
|
|
||||||
</MudStack>
|
|
||||||
</CardHeaderContent>
|
|
||||||
</MudCardHeader>
|
|
||||||
<MudCardContent>
|
|
||||||
<MudStack>
|
|
||||||
<MudText>
|
|
||||||
@this.Description
|
|
||||||
</MudText>
|
|
||||||
</MudStack>
|
|
||||||
</MudCardContent>
|
|
||||||
<MudCardActions>
|
|
||||||
<MudButton Size="Size.Large" Variant="Variant.Filled" StartIcon="@this.Icon" Color="Color.Default" Href="@this.Link">
|
|
||||||
@this.ButtonText
|
|
||||||
</MudButton>
|
|
||||||
</MudCardActions>
|
|
||||||
</MudCard>
|
|
||||||
</MudItem>
|
|
||||||
@@ -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;
|
|
||||||
+7
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace AIStudio.Components.Blocks;
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
public partial class Changelog
|
public partial class Changelog
|
||||||
{
|
{
|
||||||
@@ -13,6 +13,12 @@ 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 (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 (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"),
|
new (166, "v0.8.4, build 166 (2024-07-26 06:53 UTC)", "v0.8.4.md"),
|
||||||
new (165, "v0.8.3, build 165 (2024-07-25 13:25 UTC)", "v0.8.3.md"),
|
new (165, "v0.8.3, build 165 (2024-07-25 13:25 UTC)", "v0.8.3.md"),
|
||||||
-1
@@ -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
-1
@@ -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
|
||||||
{
|
{
|
||||||
File renamed without changes.
+1
-1
@@ -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.
|
||||||
File renamed without changes.
+1
-1
@@ -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
|
||||||
{
|
{
|
||||||
File renamed without changes.
+1
-1
@@ -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.
|
||||||
File renamed without changes.
+26
-1
@@ -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>
|
||||||
{
|
{
|
||||||
@@ -42,10 +42,35 @@ public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public Action<T> ValueUpdate { get; set; } = _ => { };
|
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)
|
private async Task OptionChanged(T updatedValue)
|
||||||
{
|
{
|
||||||
this.ValueUpdate(updatedValue);
|
this.ValueUpdate(updatedValue);
|
||||||
await this.SettingsManager.StoreSettings();
|
await this.SettingsManager.StoreSettings();
|
||||||
await this.InformAboutChange();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
+1
-1
@@ -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
|
||||||
{
|
{
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public abstract class EnumSelectionBase : ComponentBase
|
||||||
|
{
|
||||||
|
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
|
}
|
||||||
File renamed without changes.
+1
-1
@@ -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;
|
||||||
File renamed without changes.
+2
-2
@@ -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
|
||||||
{
|
{
|
||||||
File renamed without changes.
+1
-1
@@ -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);
|
|
||||||
File renamed without changes.
+1
-1
@@ -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
|
||||||
{
|
{
|
||||||
File renamed without changes.
+1
-1
@@ -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
|
||||||
{
|
{
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
@page "/assistants"
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h3" Class="mb-2 mr-3">
|
|
||||||
Assistants
|
|
||||||
</MudText>
|
|
||||||
|
|
||||||
<MudGrid>
|
|
||||||
<AssistantBlock Name="Icon Finder" Description="Using a LLM to find an icon for a given context." Icon="@Icons.Material.Filled.FindInPage" Link="/assistant/icons"/>
|
|
||||||
<AssistantBlock Name="Text Summarizer" Description="Using a LLM to summarize a given text." Icon="@Icons.Material.Filled.TextSnippet" Link="/assistant/summarizer"/>
|
|
||||||
<AssistantBlock Name="Translation" Description="Translate text into another language." Icon="@Icons.Material.Filled.Translate" Link="/assistant/translation"/>
|
|
||||||
<AssistantBlock Name="Coding" Description="Get coding and debugging support from a LLM." Icon="@Icons.Material.Filled.Code" Link="/assistant/coding"/>
|
|
||||||
</MudGrid>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages;
|
|
||||||
|
|
||||||
public partial class Assistants : ComponentBase;
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
@page "/settings"
|
|
||||||
@using AIStudio.Components.Pages.Coding
|
|
||||||
@using AIStudio.Components.Pages.TextSummarizer
|
|
||||||
@using AIStudio.Provider
|
|
||||||
@using AIStudio.Settings
|
|
||||||
@using AIStudio.Tools
|
|
||||||
@using Host = AIStudio.Provider.SelfHosted.Host
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h3" Class="mb-12">Settings</MudText>
|
|
||||||
|
|
||||||
<InnerScrolling HeaderHeight="6em">
|
|
||||||
<MudPaper Class="pa-3 mb-8 border-solid border rounded-lg">
|
|
||||||
<MudText Typo="Typo.h4" Class="mb-3">Configured Providers</MudText>
|
|
||||||
<MudTable Items="@this.SettingsManager.ConfigurationData.Providers" Class="border-dashed border rounded-lg">
|
|
||||||
<ColGroup>
|
|
||||||
<col style="width: 3em;"/>
|
|
||||||
<col style="width: 12em;"/>
|
|
||||||
<col style="width: 12em;"/>
|
|
||||||
<col/>
|
|
||||||
<col style="width: 34em;"/>
|
|
||||||
</ColGroup>
|
|
||||||
<HeaderContent>
|
|
||||||
<MudTh>#</MudTh>
|
|
||||||
<MudTh>Instance Name</MudTh>
|
|
||||||
<MudTh>Provider</MudTh>
|
|
||||||
<MudTh>Model</MudTh>
|
|
||||||
<MudTh Style="text-align: left;">Actions</MudTh>
|
|
||||||
</HeaderContent>
|
|
||||||
<RowTemplate>
|
|
||||||
<MudTd>@context.Num</MudTd>
|
|
||||||
<MudTd>@context.InstanceName</MudTd>
|
|
||||||
<MudTd>@context.UsedProvider</MudTd>
|
|
||||||
<MudTd>
|
|
||||||
@if (context.UsedProvider is not Providers.SELF_HOSTED)
|
|
||||||
{
|
|
||||||
@this.GetProviderModelName(context)
|
|
||||||
}
|
|
||||||
else if (context.UsedProvider is Providers.SELF_HOSTED && context.Host is not Host.LLAMACPP)
|
|
||||||
{
|
|
||||||
@this.GetProviderModelName(context)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@("as selected by provider")
|
|
||||||
}
|
|
||||||
</MudTd>
|
|
||||||
<MudTd Style="text-align: left;">
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.OpenInBrowser" Class="ma-2" Href="@this.GetProviderDashboardURL(context.UsedProvider)" Target="_blank" Disabled="@(!this.HasDashboard(context.UsedProvider))">
|
|
||||||
Open Dashboard
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditProvider(context)">
|
|
||||||
Edit
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteProvider(context)">
|
|
||||||
Delete
|
|
||||||
</MudButton>
|
|
||||||
</MudTd>
|
|
||||||
</RowTemplate>
|
|
||||||
</MudTable>
|
|
||||||
|
|
||||||
@if(this.SettingsManager.ConfigurationData.Providers.Count == 0)
|
|
||||||
{
|
|
||||||
<MudText Typo="Typo.h6" Class="mt-3">No providers configured yet.</MudText>
|
|
||||||
}
|
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Color="@Color.Primary" StartIcon="@Icons.Material.Filled.AddRoad" Class="mt-3 mb-6" OnClick="@this.AddProvider">
|
|
||||||
Add Provider
|
|
||||||
</MudButton>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h4" Class="mb-3">App Options</MudText>
|
|
||||||
<ConfigurationOption OptionDescription="Save energy?" LabelOn="Energy saving is enabled" LabelOff="Energy saving is disabled" State="@(() => this.SettingsManager.ConfigurationData.IsSavingEnergy)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.IsSavingEnergy = updatedState)" OptionHelp="When enabled, streamed content from the AI is updated once every third second. When disabled, streamed content will be updated as soon as it is available."/>
|
|
||||||
<ConfigurationOption OptionDescription="Enable spellchecking?" LabelOn="Spellchecking is enabled" LabelOff="Spellchecking is disabled" State="@(() => this.SettingsManager.ConfigurationData.EnableSpellchecking)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.EnableSpellchecking = updatedState)" OptionHelp="When enabled, spellchecking will be active in all input fields. Depending on your operating system, errors may not be visually highlighted, but right-clicking may still offer possible corrections." />
|
|
||||||
<ConfigurationSelect OptionDescription="Check for updates" SelectedValue="@(() => this.SettingsManager.ConfigurationData.UpdateBehavior)" Data="@ConfigurationSelectDataFactory.GetUpdateBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.UpdateBehavior = selectedValue)" OptionHelp="How often should we check for app updates?"/>
|
|
||||||
<ConfigurationSelect OptionDescription="Navigation bar behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.NavigationBehavior)" Data="@ConfigurationSelectDataFactory.GetNavBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.NavigationBehavior = selectedValue)" OptionHelp="Select the desired behavior for the navigation bar."/>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h4" Class="mb-3">Chat Options</MudText>
|
|
||||||
<ConfigurationSelect OptionDescription="Shortcut to send input" SelectedValue="@(() => this.SettingsManager.ConfigurationData.ShortcutSendBehavior)" Data="@ConfigurationSelectDataFactory.GetSendBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.ShortcutSendBehavior = selectedValue)" OptionHelp="Do you want to use any shortcut to send your input?"/>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h4" Class="mb-3">Workspace Options</MudText>
|
|
||||||
<ConfigurationSelect OptionDescription="Workspace behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior = selectedValue)" OptionHelp="Should we store your chats?"/>
|
|
||||||
<ConfigurationSelect OptionDescription="Workspace maintenance" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageTemporaryMaintenancePolicyData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy = selectedValue)" OptionHelp="If and when should we delete your temporary chats?"/>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h4" Class="mb-3">Assistants Options</MudText>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h5" Class="mb-3">Icon Finder Options</MudText>
|
|
||||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
|
||||||
<ConfigurationOption OptionDescription="Preselect icon options?" LabelOn="Icon options are preselected" LabelOff="No icon options are preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectIconOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectIconOptions = updatedState)" OptionHelp="When enabled, you can preselect the icon options. This is might be useful when you prefer a specific icon source or LLM model."/>
|
|
||||||
<ConfigurationSelect OptionDescription="Preselect the icon source" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectIconOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedIconSource)" Data="@ConfigurationSelectDataFactory.GetIconSourcesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedIconSource = selectedValue)" OptionHelp="Which icon source should be preselected?"/>
|
|
||||||
<ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectIconOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedIconProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedIconProvider = selectedValue)"/>
|
|
||||||
</MudPaper>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h5" Class="mb-3">Translator Options</MudText>
|
|
||||||
<ConfigurationSlider T="int" OptionDescription="How fast should the live translation react?" Min="500" Max="3_000" Step="100" Unit="milliseconds" Value="@(() => this.SettingsManager.ConfigurationData.LiveTranslationDebounceIntervalMilliseconds)" ValueUpdate="@(updatedValue => this.SettingsManager.ConfigurationData.LiveTranslationDebounceIntervalMilliseconds = updatedValue)"/>
|
|
||||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
|
||||||
<ConfigurationOption OptionDescription="Preselect translator options?" LabelOn="Translator options are preselected" LabelOff="No translator options are preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectTranslationOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectTranslationOptions = updatedState)" OptionHelp="When enabled, you can preselect the translator options. This is might be useful when you prefer a specific target language or LLM model."/>
|
|
||||||
<ConfigurationOption OptionDescription="Preselect live translation?" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTranslationOptions)" LabelOn="Live translation is preselected" LabelOff="Live translation is not preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectLiveTranslation)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectLiveTranslation = updatedState)" />
|
|
||||||
<ConfigurationSelect OptionDescription="Preselect the target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTranslationOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedTranslationTargetLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonLanguagesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedTranslationTargetLanguage = selectedValue)" OptionHelp="Which target language should be preselected?"/>
|
|
||||||
@if (this.SettingsManager.ConfigurationData.PreselectedTranslationTargetLanguage is CommonLanguages.OTHER)
|
|
||||||
{
|
|
||||||
<ConfigurationText OptionDescription="Preselect another target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTranslationOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.PreselectTranslationOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PreselectTranslationOtherLanguage = updatedText)"/>
|
|
||||||
}
|
|
||||||
<ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTranslationOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedTranslationProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedTranslationProvider = selectedValue)"/>
|
|
||||||
</MudPaper>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h5" Class="mb-3">Coding Options</MudText>
|
|
||||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
|
||||||
<ConfigurationOption OptionDescription="Preselect coding options?" LabelOn="Coding options are preselected" LabelOff="No coding options are preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectCodingOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectCodingOptions = updatedState)" OptionHelp="When enabled, you can preselect the coding options. This is might be useful when you prefer a specific programming language or LLM model."/>
|
|
||||||
<ConfigurationOption OptionDescription="Preselect compiler messages?" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectCodingOptions)" LabelOn="Compiler messages are preselected" LabelOff="Compiler messages are not preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectCodingCompilerMessages)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectCodingCompilerMessages = updatedState)" />
|
|
||||||
<ConfigurationSelect OptionDescription="Preselect a programming language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectCodingOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedCodingLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonCodingLanguagesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedCodingLanguage = selectedValue)" OptionHelp="Which programming language should be preselected for added contexts?"/>
|
|
||||||
@if (this.SettingsManager.ConfigurationData.PreselectedCodingLanguage is CommonCodingLanguages.OTHER)
|
|
||||||
{
|
|
||||||
<ConfigurationText OptionDescription="Preselect another programming language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectCodingOptions)" Icon="@Icons.Material.Filled.Code" Text="@(() => this.SettingsManager.ConfigurationData.PreselectedCodingOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PreselectedCodingOtherLanguage = updatedText)"/>
|
|
||||||
}
|
|
||||||
<ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectCodingOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedCodingProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedCodingProvider = selectedValue)"/>
|
|
||||||
</MudPaper>
|
|
||||||
|
|
||||||
<MudText Typo="Typo.h5" Class="mb-3">Text Summarizer Options</MudText>
|
|
||||||
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
|
||||||
<ConfigurationOption OptionDescription="Preselect summarizer options?" LabelOn="Summarizer options are preselected" LabelOff="No summarizer options are preselected" State="@(() => this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" StateUpdate="@(updatedState => this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions = updatedState)" OptionHelp="When enabled, you can preselect the text summarizer options. This is might be useful when you prefer a specific language, complexity, or LLM."/>
|
|
||||||
<ConfigurationSelect OptionDescription="Preselect the target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerTargetLanguage)" Data="@ConfigurationSelectDataFactory.GetCommonLanguagesData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerTargetLanguage = selectedValue)" OptionHelp="Which target language should be preselected?"/>
|
|
||||||
@if (this.SettingsManager.ConfigurationData.PreselectedTextSummarizerTargetLanguage is CommonLanguages.OTHER)
|
|
||||||
{
|
|
||||||
<ConfigurationText OptionDescription="Preselect another target language" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" Icon="@Icons.Material.Filled.Translate" Text="@(() => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerOtherLanguage)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerOtherLanguage = updatedText)"/>
|
|
||||||
}
|
|
||||||
<ConfigurationSelect OptionDescription="Preselect the summarizer complexity" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerComplexity)" Data="@ConfigurationSelectDataFactory.GetComplexityData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerComplexity = selectedValue)" OptionHelp="Which summarizer complexity should be preselected?"/>
|
|
||||||
@if(this.SettingsManager.ConfigurationData.PreselectedTextSummarizerComplexity is Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS)
|
|
||||||
{
|
|
||||||
<ConfigurationText OptionDescription="Preselect your expertise" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" Icon="@Icons.Material.Filled.Person" Text="@(() => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerExpertInField)" TextUpdate="@(updatedText => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerExpertInField = updatedText)"/>
|
|
||||||
}
|
|
||||||
<ConfigurationProviderSelection Data="@this.availableProviders" Disabled="@(() => !this.SettingsManager.ConfigurationData.PreselectTextSummarizerOptions)" SelectedValue="@(() => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerProvider)" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.PreselectedTextSummarizerProvider = selectedValue)"/>
|
|
||||||
</MudPaper>
|
|
||||||
</MudPaper>
|
|
||||||
</InnerScrolling>
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
@page "/assistant/summarizer"
|
|
||||||
@using AIStudio.Settings
|
|
||||||
@using AIStudio.Tools
|
|
||||||
@inherits AssistantBaseCore
|
|
||||||
|
|
||||||
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
|
|
||||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
|
||||||
<MudSelect T="CommonLanguages" @bind-Value="@this.selectedTargetLanguage" AdornmentIcon="@Icons.Material.Filled.Translate" Adornment="Adornment.Start" Label="Target language" Variant="Variant.Outlined" Margin="Margin.Dense">
|
|
||||||
@foreach (var targetLanguage in Enum.GetValues<CommonLanguages>())
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="@targetLanguage">@targetLanguage.Name()</MudSelectItem>
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
@if (this.selectedTargetLanguage is CommonLanguages.OTHER)
|
|
||||||
{
|
|
||||||
<MudTextField T="string" @bind-Text="@this.customTargetLanguage" Validation="@this.ValidateCustomLanguage" Label="Custom target language" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
}
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
|
||||||
<MudSelect T="Complexity" @bind-Value="@this.selectedComplexity" AdornmentIcon="@Icons.Material.Filled.Layers" Adornment="Adornment.Start" Label="Target complexity" Variant="Variant.Outlined" Margin="Margin.Dense">
|
|
||||||
@foreach (var targetComplexity in Enum.GetValues<Complexity>())
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="@targetComplexity">@targetComplexity.Name()</MudSelectItem>
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
@if (this.selectedComplexity is Complexity.SCIENTIFIC_LANGUAGE_OTHER_EXPERTS)
|
|
||||||
{
|
|
||||||
<MudTextField T="string" @bind-Text="@this.expertInField" Validation="@this.ValidateExpertInField" Label="Your expertise" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
}
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
<MudSelect T="Provider" @bind-Value="@this.providerSettings" Validation="@this.ValidatingProvider" 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>
|
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.SummarizeText()">
|
|
||||||
Summarize
|
|
||||||
</MudButton>
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using AIStudio.Tools;
|
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.TextSummarizer;
|
|
||||||
|
|
||||||
public static class CommonLanguagePrompts
|
|
||||||
{
|
|
||||||
public static string Prompt(this CommonLanguages language, string customLanguage) => language switch
|
|
||||||
{
|
|
||||||
CommonLanguages.AS_IS => "Do not change the language of the text.",
|
|
||||||
CommonLanguages.OTHER => $"Output you summary in {customLanguage}.",
|
|
||||||
|
|
||||||
_ => $"Output your summary in {language.Name()} ({language}).",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
@page "/assistant/translation"
|
|
||||||
@using AIStudio.Settings
|
|
||||||
@using AIStudio.Tools
|
|
||||||
@inherits AssistantBaseCore
|
|
||||||
|
|
||||||
<MudField Label="Live translation" Variant="Variant.Outlined" Class="mb-3">
|
|
||||||
<MudSwitch T="bool" @bind-Value="@this.liveTranslation" Color="Color.Primary">
|
|
||||||
@(this.liveTranslation ? "Live translation" : "No live translation")
|
|
||||||
</MudSwitch>
|
|
||||||
</MudField>
|
|
||||||
|
|
||||||
@if (this.liveTranslation)
|
|
||||||
{
|
|
||||||
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" Immediate="@true" DebounceInterval="1_000" OnDebounceIntervalElapsed="() => this.TranslateText(force: false)" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MudTextField T="string" @bind-Text="@this.inputText" Validation="@this.ValidatingText" AdornmentIcon="@Icons.Material.Filled.DocumentScanner" Adornment="Adornment.Start" Label="Your input" Variant="Variant.Outlined" Lines="6" AutoGrow="@true" MaxLines="12" Class="mb-3" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
}
|
|
||||||
|
|
||||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
|
||||||
<MudSelect T="CommonLanguages" @bind-Value="@this.selectedTargetLanguage" Validation="@this.ValidatingTargetLanguage" AdornmentIcon="@Icons.Material.Filled.Translate" Adornment="Adornment.Start" Label="Target language" Variant="Variant.Outlined" Margin="Margin.Dense">
|
|
||||||
@foreach (var targetLanguage in Enum.GetValues<CommonLanguages>())
|
|
||||||
{
|
|
||||||
if (targetLanguage is CommonLanguages.AS_IS)
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="@targetLanguage">Please select the target language</MudSelectItem>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="@targetLanguage">@targetLanguage.Name()</MudSelectItem>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
@if (this.selectedTargetLanguage is CommonLanguages.OTHER)
|
|
||||||
{
|
|
||||||
<MudTextField T="string" @bind-Text="@this.customTargetLanguage" Validation="@this.ValidateCustomLanguage" Label="Custom target language" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES"/>
|
|
||||||
}
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
<MudSelect T="Provider" @bind-Value="@this.providerSettings" Validation="@this.ValidatingProvider" 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>
|
|
||||||
|
|
||||||
<MudButton Variant="Variant.Filled" Class="mb-3" OnClick="() => this.TranslateText(force: true)">
|
|
||||||
Translate
|
|
||||||
</MudButton>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using AIStudio.Tools;
|
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.Translation;
|
|
||||||
|
|
||||||
public static class CommonLanguageExtension
|
|
||||||
{
|
|
||||||
public static string Prompt(this CommonLanguages language, string customLanguage) => language switch
|
|
||||||
{
|
|
||||||
CommonLanguages.OTHER => $"Translate the text in {customLanguage}.",
|
|
||||||
|
|
||||||
_ => $"Translate the given text in {language.Name()} ({language}).",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<MudPaper Class="pa-3 mb-8 border-dashed border rounded-lg">
|
||||||
|
<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)
|
||||||
|
{
|
||||||
|
<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()">
|
||||||
|
Fetch
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
@if (this.AgentIsRunning)
|
||||||
|
{
|
||||||
|
<ProcessComponent T="ReadWebContentSteps" StepValue="@this.processStep" ShowProgressAnimation="@true"/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</MudPaper>
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
using AIStudio.Agents;
|
||||||
|
using AIStudio.Chat;
|
||||||
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
|
public partial class ReadWebContent : ComponentBase
|
||||||
|
{
|
||||||
|
[Inject]
|
||||||
|
private HTMLParser HTMLParser { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private AgentTextContentCleaner AgentTextContentCleaner { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected SettingsManager SettingsManager { get; set; } = null!;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Content { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<string> ContentChanged { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public Settings.Provider ProviderSettings { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool AgentIsRunning { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<bool> AgentIsRunningChanged { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool Preselect { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool PreselectContentCleanerAgent { get; set; }
|
||||||
|
|
||||||
|
private Process<ReadWebContentSteps> process = Process<ReadWebContentSteps>.INSTANCE;
|
||||||
|
private ProcessStepValue processStep;
|
||||||
|
|
||||||
|
private bool showWebContentReader;
|
||||||
|
private bool useContentCleanerAgent;
|
||||||
|
private string providedURL = string.Empty;
|
||||||
|
private bool urlIsValid;
|
||||||
|
private bool isProviderValid;
|
||||||
|
|
||||||
|
private Settings.Provider providerSettings;
|
||||||
|
|
||||||
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if(this.Preselect)
|
||||||
|
this.showWebContentReader = true;
|
||||||
|
|
||||||
|
if(this.PreselectContentCleanerAgent)
|
||||||
|
this.useContentCleanerAgent = true;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
await base.OnInitializedAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
if (!this.SettingsManager.ConfigurationData.TextContentCleaner.PreselectAgentOptions)
|
||||||
|
this.providerSettings = this.ProviderSettings;
|
||||||
|
|
||||||
|
await base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private async Task LoadFromWeb()
|
||||||
|
{
|
||||||
|
if(!this.IsReady)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var markdown = string.Empty;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.processStep = this.process[ReadWebContentSteps.LOADING];
|
||||||
|
this.StateHasChanged();
|
||||||
|
|
||||||
|
var html = await this.HTMLParser.LoadWebContentHTML(new Uri(this.providedURL));
|
||||||
|
|
||||||
|
this.processStep = this.process[ReadWebContentSteps.PARSING];
|
||||||
|
this.StateHasChanged();
|
||||||
|
markdown = this.HTMLParser.ParseToMarkdown(html);
|
||||||
|
|
||||||
|
if (this.useContentCleanerAgent)
|
||||||
|
{
|
||||||
|
this.AgentTextContentCleaner.ProviderSettings = this.providerSettings;
|
||||||
|
var additionalData = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "sourceURL", this.providedURL },
|
||||||
|
};
|
||||||
|
|
||||||
|
this.processStep = this.process[ReadWebContentSteps.CLEANING];
|
||||||
|
this.AgentIsRunning = true;
|
||||||
|
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
|
||||||
|
this.StateHasChanged();
|
||||||
|
|
||||||
|
var contentBlock = await this.AgentTextContentCleaner.ProcessInput(new ContentBlock
|
||||||
|
{
|
||||||
|
Time = DateTimeOffset.UtcNow,
|
||||||
|
ContentType = ContentType.TEXT,
|
||||||
|
Role = ChatRole.USER,
|
||||||
|
Content = new ContentText
|
||||||
|
{
|
||||||
|
Text = markdown,
|
||||||
|
},
|
||||||
|
}, additionalData);
|
||||||
|
|
||||||
|
markdown = contentBlock.Content is ContentText text ? text.Text : markdown;
|
||||||
|
|
||||||
|
this.processStep = this.process[ReadWebContentSteps.DONE];
|
||||||
|
this.AgentIsRunning = false;
|
||||||
|
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (this.AgentIsRunning)
|
||||||
|
{
|
||||||
|
this.processStep = this.process[ReadWebContentSteps.START];
|
||||||
|
this.AgentIsRunning = false;
|
||||||
|
await this.AgentIsRunningChanged.InvokeAsync(this.AgentIsRunning);
|
||||||
|
this.StateHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Content = markdown;
|
||||||
|
await this.ContentChanged.InvokeAsync(this.Content);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsReady
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if(!this.urlIsValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(this.useContentCleanerAgent && !this.isProviderValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateProvider(bool shouldUseAgent)
|
||||||
|
{
|
||||||
|
if(shouldUseAgent && this.providerSettings == default)
|
||||||
|
{
|
||||||
|
this.isProviderValid = false;
|
||||||
|
return "Please select a provider to use the cleanup agent.";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isProviderValid = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? ValidateURL(string url)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(url))
|
||||||
|
{
|
||||||
|
this.urlIsValid = false;
|
||||||
|
return "Please provide a URL to load the content from.";
|
||||||
|
}
|
||||||
|
|
||||||
|
var urlParsingResult = Uri.TryCreate(url, UriKind.Absolute, out var uriResult);
|
||||||
|
if(!urlParsingResult)
|
||||||
|
{
|
||||||
|
this.urlIsValid = false;
|
||||||
|
return "Please provide a valid URL.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(uriResult is not { Scheme: "http" or "https" })
|
||||||
|
{
|
||||||
|
this.urlIsValid = false;
|
||||||
|
return "Please provide a valid HTTP or HTTPS URL.";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.urlIsValid = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
|
public enum ReadWebContentSteps
|
||||||
|
{
|
||||||
|
START,
|
||||||
|
LOADING,
|
||||||
|
PARSING,
|
||||||
|
CLEANING,
|
||||||
|
DONE,
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+1
-1
@@ -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
-1
@@ -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;
|
||||||
Loaded 100 of 198 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user