using System.Text.Json.Serialization; namespace AIStudio.Chat; public record FileAttachmentImage(string FileName, string FilePath, long FileSizeBytes) : FileAttachment(FileAttachmentType.IMAGE, FileName, FilePath, FileSizeBytes), IImageSource { /// /// The type of the image source. /// /// /// Is the image source a URL, a local file path, a base64 string, etc.? /// public ContentImageSource SourceType { get; init; } = ContentImageSource.LOCAL_PATH; /// /// The image source. /// /// /// An attached image is a file, so its source is the path of that file. It is not stored a second /// time: the stored file path is relative when the image lies below the data directory, and the /// source has to follow it when the chat is read again, on whatever computer that happens. /// [JsonIgnore] public string Source { get; set; } = FilePath; /// public override FileAttachment WithFilePath(string filePath) => new FileAttachmentImage(this.FileName, filePath, this.FileSizeBytes) { SourceType = this.SourceType, Source = this.SourceType is ContentImageSource.LOCAL_PATH ? filePath : this.Source, }; }