diff --git a/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor b/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor new file mode 100644 index 00000000..0f1328b4 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor @@ -0,0 +1,15 @@ +@attribute [Route(Routes.ASSISTANT_LEGAL_CHECK)] +@inherits AssistantBaseCore + +@if (!this.SettingsManager.ConfigurationData.LegalCheck.HideWebContentReader) +{ + +} + + + + + + + Ask your questions + diff --git a/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor.cs b/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor.cs new file mode 100644 index 00000000..af2138e5 --- /dev/null +++ b/app/MindWork AI Studio/Assistants/LegalCheck/AssistantLegalCheck.razor.cs @@ -0,0 +1,103 @@ +using AIStudio.Tools; + +namespace AIStudio.Assistants.LegalCheck; + +public partial class AssistantLegalCheck : AssistantBaseCore +{ + protected override string Title => "Legal Check"; + + protected override string Description => + """ + Provide a legal document and ask a question about it. This assistant does not + replace legal advice. Consult a lawyer to get professional advice. Remember + that LLMs can invent answers and facts. Please do not rely on this answers. + """; + + protected override string SystemPrompt => + """ + You are an expert in legal matters. You have studied international law and are familiar with the law in + various countries. You receive a legal document and answer the user's questions. You are a friendly and + professional assistant. You respond to the user in the language in which the questions were asked. If + you are unsure, unfamiliar with the legal area, or do not know the answers, you inform the user. + Never invent facts! + """; + + protected override IReadOnlyList FooterButtons => + [ + new SendToButton + { + Self = SendTo.LEGAL_CHECK_ASSISTANT, + }, + ]; + + protected override void ResetFrom() + { + this.inputLegalDocument = string.Empty; + this.inputQuestions = string.Empty; + this.MightPreselectValues(); + } + + protected override bool MightPreselectValues() + { + if (this.SettingsManager.ConfigurationData.LegalCheck.PreselectOptions) + { + this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.LegalCheck.PreselectedProvider); + return true; + } + + return false; + } + + private bool isAgentRunning; + private string inputLegalDocument = string.Empty; + private string inputQuestions = string.Empty; + + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + this.MightPreselectValues(); + var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages(Event.SEND_TO_LEGAL_CHECK_ASSISTANT).FirstOrDefault(); + if (deferredContent is not null) + this.inputQuestions = deferredContent; + + await base.OnInitializedAsync(); + } + + #endregion + + private string? ValidatingLegalDocument(string text) + { + if(string.IsNullOrWhiteSpace(text)) + return "Please provide a legal document as input. You might copy the desired text from a document or a website."; + + return null; + } + + private string? ValidatingQuestions(string text) + { + if(string.IsNullOrWhiteSpace(text)) + return "Please provide your questions as input."; + + return null; + } + + private async Task AksQuestions() + { + await this.form!.Validate(); + if (!this.inputIsValid) + return; + + this.CreateChatThread(); + var time = this.AddUserRequest( + $""" + # The legal document + {this.inputLegalDocument} + + # The questions + {this.inputQuestions} + """); + + await this.AddAIResponseAsync(time); + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Pages/Assistants.razor b/app/MindWork AI Studio/Pages/Assistants.razor index 6fecfd6b..9627fcb6 100644 --- a/app/MindWork AI Studio/Pages/Assistants.razor +++ b/app/MindWork AI Studio/Pages/Assistants.razor @@ -22,6 +22,7 @@ + diff --git a/app/MindWork AI Studio/Pages/Settings.razor b/app/MindWork AI Studio/Pages/Settings.razor index 59d701cc..e7c94ddd 100644 --- a/app/MindWork AI Studio/Pages/Settings.razor +++ b/app/MindWork AI Studio/Pages/Settings.razor @@ -216,6 +216,16 @@ + + + + + + + + + + diff --git a/app/MindWork AI Studio/Routes.razor.cs b/app/MindWork AI Studio/Routes.razor.cs index f94fee16..584eef39 100644 --- a/app/MindWork AI Studio/Routes.razor.cs +++ b/app/MindWork AI Studio/Routes.razor.cs @@ -18,5 +18,6 @@ public sealed partial class Routes public const string ASSISTANT_CODING = "/assistant/coding"; public const string ASSISTANT_AGENDA = "/assistant/agenda"; public const string ASSISTANT_EMAIL = "/assistant/email"; + public const string ASSISTANT_LEGAL_CHECK = "/assistant/legal-check"; // ReSharper restore InconsistentNaming } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/Data.cs b/app/MindWork AI Studio/Settings/DataModel/Data.cs index 66d50f1b..ffc1f956 100644 --- a/app/MindWork AI Studio/Settings/DataModel/Data.cs +++ b/app/MindWork AI Studio/Settings/DataModel/Data.cs @@ -44,4 +44,6 @@ public sealed class Data public DataRewriteImprove RewriteImprove { get; init; } = new(); public DataEMail EMail { get; set; } = new(); + + public DataLegalCheck LegalCheck { get; set; } = new(); } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs b/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs new file mode 100644 index 00000000..80dc53f6 --- /dev/null +++ b/app/MindWork AI Studio/Settings/DataModel/DataLegalCheck.cs @@ -0,0 +1,29 @@ +namespace AIStudio.Settings.DataModel; + +public class DataLegalCheck +{ + /// + /// Do you want to preselect any legal check options? + /// + public bool PreselectOptions { get; set; } + + /// + /// Hide the web content reader? + /// + public bool HideWebContentReader { get; set; } + + /// + /// Preselect the web content reader? + /// + public bool PreselectWebContentReader { get; set; } + + /// + /// Preselect the content cleaner agent? + /// + public bool PreselectContentCleanerAgent { get; set; } + + /// + /// The preselected translator provider. + /// + public string PreselectedProvider { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/Event.cs b/app/MindWork AI Studio/Tools/Event.cs index c5cfad7f..a99bc1de 100644 --- a/app/MindWork AI Studio/Tools/Event.cs +++ b/app/MindWork AI Studio/Tools/Event.cs @@ -26,4 +26,5 @@ public enum Event SEND_TO_TEXT_SUMMARIZER_ASSISTANT, SEND_TO_CHAT, SEND_TO_EMAIL_ASSISTANT, + SEND_TO_LEGAL_CHECK_ASSISTANT, } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/SendTo.cs b/app/MindWork AI Studio/Tools/SendTo.cs index b29483ab..66d74e66 100644 --- a/app/MindWork AI Studio/Tools/SendTo.cs +++ b/app/MindWork AI Studio/Tools/SendTo.cs @@ -12,6 +12,7 @@ public enum SendTo CODING_ASSISTANT, TEXT_SUMMARIZER_ASSISTANT, EMAIL_ASSISTANT, + LEGAL_CHECK_ASSISTANT, CHAT, } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/SendToExtensions.cs b/app/MindWork AI Studio/Tools/SendToExtensions.cs index 6407dd32..abfed730 100644 --- a/app/MindWork AI Studio/Tools/SendToExtensions.cs +++ b/app/MindWork AI Studio/Tools/SendToExtensions.cs @@ -12,6 +12,7 @@ public static class SendToExtensions SendTo.AGENDA_ASSISTANT => "Agenda Assistant", SendTo.CODING_ASSISTANT => "Coding Assistant", SendTo.EMAIL_ASSISTANT => "E-Mail Assistant", + SendTo.LEGAL_CHECK_ASSISTANT => "Legal Check Assistant", SendTo.CHAT => "New Chat", @@ -28,6 +29,7 @@ public static class SendToExtensions SendTo.ICON_FINDER_ASSISTANT => new(Event.SEND_TO_ICON_FINDER_ASSISTANT, Routes.ASSISTANT_ICON_FINDER), SendTo.GRAMMAR_SPELLING_ASSISTANT => new(Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT, Routes.ASSISTANT_GRAMMAR_SPELLING), SendTo.TEXT_SUMMARIZER_ASSISTANT => new(Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT, Routes.ASSISTANT_SUMMARIZER), + SendTo.LEGAL_CHECK_ASSISTANT => new(Event.SEND_TO_LEGAL_CHECK_ASSISTANT, Routes.ASSISTANT_LEGAL_CHECK), SendTo.CHAT => new(Event.SEND_TO_CHAT, Routes.CHAT), diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.8.13.md b/app/MindWork AI Studio/wwwroot/changelog/v0.8.13.md new file mode 100644 index 00000000..7ffbf925 --- /dev/null +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.8.13.md @@ -0,0 +1,2 @@ +# v0.8.13, build 175 +- Added a legal check assistant & the possibility to preselect some options. \ No newline at end of file