From 53dd6a61442618e652853ef90df442a6c4693040 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Mon, 10 Feb 2025 16:11:27 +0100 Subject: [PATCH] Refactored image content type --- .../Chat/ContentBlockComponent.razor | 4 ++-- app/MindWork AI Studio/Chat/ContentImage.cs | 11 +++++++---- app/MindWork AI Studio/Chat/ContentImageSource.cs | 8 ++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 app/MindWork AI Studio/Chat/ContentImageSource.cs diff --git a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor index ca61acc2..826cfdc0 100644 --- a/app/MindWork AI Studio/Chat/ContentBlockComponent.razor +++ b/app/MindWork AI Studio/Chat/ContentBlockComponent.razor @@ -78,9 +78,9 @@ break; case ContentType.IMAGE: - if (this.Content is ContentImage imageContent) + if (this.Content is ContentImage { SourceType: ContentImageSource.URL or ContentImageSource.LOCAL_PATH } imageContent) { - + } break; diff --git a/app/MindWork AI Studio/Chat/ContentImage.cs b/app/MindWork AI Studio/Chat/ContentImage.cs index 314ba93c..84df02fc 100644 --- a/app/MindWork AI Studio/Chat/ContentImage.cs +++ b/app/MindWork AI Studio/Chat/ContentImage.cs @@ -37,12 +37,15 @@ public sealed class ContentImage : IContent #endregion /// - /// The URL of the image. + /// The type of the image source. /// - public string URL { get; set; } = string.Empty; + /// + /// Is the image source a URL, a local file path, a base64 string, etc.? + /// + public required ContentImageSource SourceType { get; init; } /// - /// The local path of the image. + /// The image source. /// - public string LocalPath { get; set; } = string.Empty; + public required string Source { get; set; } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Chat/ContentImageSource.cs b/app/MindWork AI Studio/Chat/ContentImageSource.cs new file mode 100644 index 00000000..ec009661 --- /dev/null +++ b/app/MindWork AI Studio/Chat/ContentImageSource.cs @@ -0,0 +1,8 @@ +namespace AIStudio.Chat; + +public enum ContentImageSource +{ + URL, + LOCAL_PATH, + BASE64, +} \ No newline at end of file