2026-10-15 16:42:02 +02:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
2025-12-30 18:30:32 +01:00
|
|
|
namespace AIStudio.Chat;
|
|
|
|
|
|
|
|
|
|
public record FileAttachmentImage(string FileName, string FilePath, long FileSizeBytes) : FileAttachment(FileAttachmentType.IMAGE, FileName, FilePath, FileSizeBytes), IImageSource
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The type of the image source.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Is the image source a URL, a local file path, a base64 string, etc.?
|
|
|
|
|
/// </remarks>
|
|
|
|
|
public ContentImageSource SourceType { get; init; } = ContentImageSource.LOCAL_PATH;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The image source.
|
|
|
|
|
/// </summary>
|
2026-10-15 16:42:02 +02:00
|
|
|
/// <remarks>
|
|
|
|
|
/// 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.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
[JsonIgnore]
|
2025-12-30 18:30:32 +01:00
|
|
|
public string Source { get; set; } = FilePath;
|
2026-10-15 16:42:02 +02:00
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
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,
|
|
|
|
|
};
|
2025-12-30 18:30:32 +01:00
|
|
|
}
|