diff --git a/app/MindWork AI Studio/Chat/ChatRole.cs b/app/MindWork AI Studio/Chat/ChatRole.cs index d292b71b..85a3c51d 100644 --- a/app/MindWork AI Studio/Chat/ChatRole.cs +++ b/app/MindWork AI Studio/Chat/ChatRole.cs @@ -14,68 +14,4 @@ public enum ChatRole USER, AI, AGENT, -} - -/// -/// Extensions for the ChatRole enum. -/// -public static class ExtensionsChatRole -{ - private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ChatRole).Namespace, nameof(ChatRole)); - - /// - /// Returns the name of the role. - /// - /// The role. - /// The name of the role. - public static string ToName(this ChatRole role) => role switch - { - ChatRole.SYSTEM => TB("System"), - ChatRole.USER => TB("You"), - ChatRole.AI => TB("AI"), - - _ => TB("Unknown"), - }; - - /// - /// Returns the color of the role. - /// - /// The role. - /// The color of the role. - public static Color ToColor(this ChatRole role) => role switch - { - ChatRole.SYSTEM => Color.Info, - ChatRole.USER => Color.Primary, - ChatRole.AI => Color.Tertiary, - - _ => Color.Error, - }; - - /// - /// Returns the icon of the role. - /// - /// The role. - /// The icon of the role. - public static string ToIcon(this ChatRole role) => role switch - { - ChatRole.SYSTEM => Icons.Material.Filled.Settings, - ChatRole.USER => Icons.Material.Filled.Person, - ChatRole.AI => Icons.Material.Filled.AutoAwesome, - - _ => Icons.Material.Filled.Help, - }; - - /// - /// Returns the specific name of the role for the chat template. - /// - /// The role. - /// The name of the role. - public static string ToChatTemplateName(this ChatRole role) => role switch - { - ChatRole.SYSTEM => TB("System"), - ChatRole.USER => TB("User"), - ChatRole.AI => TB("Assistant"), - - _ => TB("Unknown"), - }; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Chat/ChatRoleExtensions.cs b/app/MindWork AI Studio/Chat/ChatRoleExtensions.cs new file mode 100644 index 00000000..40987d09 --- /dev/null +++ b/app/MindWork AI Studio/Chat/ChatRoleExtensions.cs @@ -0,0 +1,75 @@ +using AIStudio.Tools.PluginSystem; + +namespace AIStudio.Chat; + +public static class ChatRoleExtensions +{ + private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ChatRoleExtensions).Namespace, nameof(ChatRoleExtensions)); + + /// + /// Returns the name of the role. + /// + /// The role. + /// The name of the role. + public static string ToName(this ChatRole role) => role switch + { + ChatRole.SYSTEM => TB("System"), + ChatRole.USER => TB("You"), + ChatRole.AI => TB("AI"), + + _ => TB("Unknown"), + }; + + /// + /// Returns the color of the role. + /// + /// The role. + /// The color of the role. + public static Color ToColor(this ChatRole role) => role switch + { + ChatRole.SYSTEM => Color.Info, + ChatRole.USER => Color.Primary, + ChatRole.AI => Color.Tertiary, + + _ => Color.Error, + }; + + /// + /// Returns the icon of the role. + /// + /// The role. + /// The icon of the role. + public static string ToIcon(this ChatRole role) => role switch + { + ChatRole.SYSTEM => Icons.Material.Filled.Settings, + ChatRole.USER => Icons.Material.Filled.Person, + ChatRole.AI => Icons.Material.Filled.AutoAwesome, + + _ => Icons.Material.Filled.Help, + }; + + /// + /// Returns the specific name of the role for the chat template. + /// + /// The role. + /// The name of the role. + public static string ToChatTemplateName(this ChatRole role) => role switch + { + ChatRole.SYSTEM => TB("System"), + ChatRole.USER => TB("User"), + ChatRole.AI => TB("Assistant"), + + _ => TB("Unknown"), + }; + + /// + /// Selects the next role for a chat template. + /// + /// The current role. + /// The next role for the chat template. + public static ChatRole SelectNextRoleForTemplate(this ChatRole currentRole) => currentRole switch + { + ChatRole.USER => ChatRole.AI, + _ => ChatRole.USER, + }; +} \ No newline at end of file