From b9a9f2d823db98fd87cc4821028468ac5aa1b38e Mon Sep 17 00:00:00 2001 From: nilsk Date: Mon, 21 Jul 2025 14:38:08 +0200 Subject: [PATCH] WIP: Working out a data model and an example lua file to turn it into assistants --- .../Plugins/assistants/plugin.lua | 85 +++++++++++++++++++ .../Assistants/DataModel/AssistantButton.cs | 24 ++++++ .../DataModel/AssistantComponentBase.cs | 8 ++ .../Assistants/DataModel/AssistantDropdown.cs | 29 +++++++ .../DataModel/AssistantDropdownItem.cs | 7 ++ .../Assistants/DataModel/AssistantForm.cs | 8 ++ .../DataModel/AssistantProviderSelection.cs | 19 +++++ .../Assistants/DataModel/AssistantTextArea.cs | 26 ++++++ .../DataModel/AssistantUiCompontentType.cs | 11 +++ .../DataModel/IAssistantComponent.cs | 8 ++ .../Assistants/PluginAssistants.cs | 19 +++++ .../Tools/PluginSystem/PluginCategory.cs | 1 + 12 files changed, 245 insertions(+) create mode 100644 app/MindWork AI Studio/Plugins/assistants/plugin.lua create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantButton.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantComponentBase.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdown.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdownItem.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantForm.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantProviderSelection.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantTextArea.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantUiCompontentType.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/IAssistantComponent.cs create mode 100644 app/MindWork AI Studio/Tools/PluginSystem/Assistants/PluginAssistants.cs diff --git a/app/MindWork AI Studio/Plugins/assistants/plugin.lua b/app/MindWork AI Studio/Plugins/assistants/plugin.lua new file mode 100644 index 00000000..58176671 --- /dev/null +++ b/app/MindWork AI Studio/Plugins/assistants/plugin.lua @@ -0,0 +1,85 @@ +require("icon") + +-- The ID for this plugin: +ID = "43065dbc-78d0-45b7-92be-f14c2926e2dc" + +-- The icon for the plugin: +ICON_SVG = SVG + +-- The name of the plugin: +NAME = "MindWork AI Studio - German / Deutsch" + +-- The description of the plugin: +DESCRIPTION = "Dieses Plugin bietet deutsche Sprachunterstützung für MindWork AI Studio." + +-- The version of the plugin: +VERSION = "1.0.0" + +-- The type of the plugin: +TYPE = "LANGUAGE" + +-- The authors of the plugin: +AUTHORS = {"MindWork AI Community"} + +-- The support contact for the plugin: +SUPPORT_CONTACT = "MindWork AI Community" + +-- The source URL for the plugin: +SOURCE_URL = "https://github.com/MindWorkAI/AI-Studio" + +-- The categories for the plugin: +CATEGORIES = { "ASSISTANT" } + +-- The target groups for the plugin: +TARGET_GROUPS = { "EVERYONE" } + +-- The flag for whether the plugin is maintained: +IS_MAINTAINED = true + +-- When the plugin is deprecated, this message will be shown to users: +DEPRECATION_MESSAGE = "" + +ASSISTANT = { + Name = "Grammatik- und Rechtschreibprüfung", + Description = "Grammatik und Rechtschreibung eines Textes überprüfen.", + UI = { + Type = "Form", + Children = { + { + Type = "TextArea", + Props = { + Name = "input", + Label = "Ihre Eingabe zur Überprüfung" + } + }, + { + Type = "Dropdown", + Props = { + Name = "language", + Label = "Sprache", + Default = "Sprache nicht angeben", + Items = { + { Value = "de-DE", Display = "Deutsch" }, + { Value = "en-UK", Display = "Englisch (UK)" }, + { Value = "en-US", Display = "Englisch (US)" }, + } + } + }, + { + Type = "ProviderSelection", + Props = { + Name = "Anbieter", + Label = "LLM auswählen" + } + }, + { + Type = "Button", + Props = { + Name = "submit", + Text = "Korrekturlesen", + Action = "OnSubmit" + } + }, + } + }, +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantButton.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantButton.cs new file mode 100644 index 00000000..76cd2250 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantButton.cs @@ -0,0 +1,24 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantButton : AssistantComponentBase +{ + public override AssistantUiCompontentType Type => AssistantUiCompontentType.BUTTON; + public Dictionary Props { get; set; } = new(); + public List Children { get; set; } = new(); + + public string Name + { + get => this.Props.TryGetValue(nameof(this.Name), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Name)] = value; + } + public string Text + { + get => this.Props.TryGetValue(nameof(this.Text), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Text)] = value; + } + public string Action + { + get => this.Props.TryGetValue(nameof(this.Action), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Action)] = value; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantComponentBase.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantComponentBase.cs new file mode 100644 index 00000000..260b4ef3 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantComponentBase.cs @@ -0,0 +1,8 @@ +namespace AIStudio.Tools.PluginSystem; + +public abstract class AssistantComponentBase : IAssistantComponent +{ + public abstract AssistantUiCompontentType Type { get; } + public Dictionary Props { get; } + public List Children { get; } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdown.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdown.cs new file mode 100644 index 00000000..0f204979 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdown.cs @@ -0,0 +1,29 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantDropdown : AssistantComponentBase +{ + public override AssistantUiCompontentType Type => AssistantUiCompontentType.DROPDOWN; + public Dictionary Props { get; set; } = new(); + public List Children { get; set; } = new(); + + public string Name + { + get => this.Props.TryGetValue(nameof(this.Name), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Name)] = value; + } + public string Label + { + get => this.Props.TryGetValue(nameof(this.Label), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Label)] = value; + } + public string Default + { + get => this.Props.TryGetValue(nameof(this.Default), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Default)] = value; + } + public List Items + { + get => this.Props.TryGetValue(nameof(this.Items), out var v) && v is List list ? list : []; + set => this.Props[nameof(this.Items)] = value; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdownItem.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdownItem.cs new file mode 100644 index 00000000..d2968301 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantDropdownItem.cs @@ -0,0 +1,7 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantDropdownItem +{ + public string Value { get; set; } = string.Empty; + public string Display { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantForm.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantForm.cs new file mode 100644 index 00000000..1bc490f3 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantForm.cs @@ -0,0 +1,8 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantForm : AssistantComponentBase +{ + public override AssistantUiCompontentType Type => AssistantUiCompontentType.FORM; + public Dictionary Props { get; set; } = new(); + public List Children { get; set; } = new(); +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantProviderSelection.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantProviderSelection.cs new file mode 100644 index 00000000..af886db1 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantProviderSelection.cs @@ -0,0 +1,19 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantProviderSelection : AssistantComponentBase +{ + public override AssistantUiCompontentType Type => AssistantUiCompontentType.PROVIDER_SELECTION; + public Dictionary Props { get; set; } = new(); + public List Children { get; set; } = new(); + + public string Name + { + get => this.Props.TryGetValue(nameof(this.Name), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Name)] = value; + } + public string Label + { + get => this.Props.TryGetValue(nameof(this.Label), out var v) ? v.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Label)] = value; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantTextArea.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantTextArea.cs new file mode 100644 index 00000000..943fd3ed --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantTextArea.cs @@ -0,0 +1,26 @@ +namespace AIStudio.Tools.PluginSystem; + +public class AssistantTextArea : AssistantComponentBase +{ + public override AssistantUiCompontentType Type => AssistantUiCompontentType.TEXT_AREA; + public Dictionary Props { get; set; } = new(); + public List Children { get; set; } = new(); + + public string Name + { + get => this.Props.TryGetValue(nameof(this.Name), out var val) ? val.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Name)] = value; + } + + public string Label + { + get => this.Props.TryGetValue(nameof(this.Label), out var val) ? val.ToString() ?? string.Empty : string.Empty; + set => this.Props[nameof(this.Label)] = value; + } + + public bool ReadOnly + { + get => this.Props.TryGetValue(nameof(this.ReadOnly), out var val) && val is true; + set => this.Props[nameof(this.ReadOnly)] = value; + } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantUiCompontentType.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantUiCompontentType.cs new file mode 100644 index 00000000..6d4bc4fb --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/AssistantUiCompontentType.cs @@ -0,0 +1,11 @@ +namespace AIStudio.Tools.PluginSystem; + +public enum AssistantUiCompontentType +{ + FORM, + TEXT_AREA, + BUTTON, + CHECKBOX, + DROPDOWN, + PROVIDER_SELECTION, +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/IAssistantComponent.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/IAssistantComponent.cs new file mode 100644 index 00000000..5c74a41f --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/DataModel/IAssistantComponent.cs @@ -0,0 +1,8 @@ +namespace AIStudio.Tools.PluginSystem; + +public interface IAssistantComponent +{ + AssistantUiCompontentType Type { get; } + Dictionary Props { get; } + List Children { get; } +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/Assistants/PluginAssistants.cs b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/PluginAssistants.cs new file mode 100644 index 00000000..c34e2785 --- /dev/null +++ b/app/MindWork AI Studio/Tools/PluginSystem/Assistants/PluginAssistants.cs @@ -0,0 +1,19 @@ +using Lua; + +namespace AIStudio.Tools.PluginSystem; + +public sealed class PluginAssistants : PluginBase +{ + private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(PluginAssistants).Namespace, nameof(PluginAssistants)); + private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(); + + public string AssistantTitle { get; set;} = string.Empty; + private string AssistantDescription {get; set;} = string.Empty; + + public PluginAssistants(bool isInternal, LuaState state, PluginType type) : base(isInternal, state, type) + { + + } + + +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginCategory.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginCategory.cs index 00afcd0e..b3c39e0c 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginCategory.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginCategory.cs @@ -30,4 +30,5 @@ public enum PluginCategory FICTION, WRITING, CONTENT_CREATION, + ASSISTANT, } \ No newline at end of file