mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 13:21:38 +00:00
Introduce FileAttachmentImage for improved image handling and refactor FileAttachment creation logic
This commit is contained in:
parent
19cc1de84b
commit
8778feee30
@ -9,7 +9,7 @@ namespace AIStudio.Chat;
|
|||||||
/// <param name="FileName">The name of the file, including extension.</param>
|
/// <param name="FileName">The name of the file, including extension.</param>
|
||||||
/// <param name="FilePath">The full path to the file, including the filename and extension.</param>
|
/// <param name="FilePath">The full path to the file, including the filename and extension.</param>
|
||||||
/// <param name="FileSizeBytes">The size of the file in bytes.</param>
|
/// <param name="FileSizeBytes">The size of the file in bytes.</param>
|
||||||
public readonly record struct FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes)
|
public record FileAttachment(FileAttachmentType Type, string FileName, string FilePath, long FileSizeBytes)
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the file type is forbidden and should not be attached.
|
/// Gets a value indicating whether the file type is forbidden and should not be attached.
|
||||||
@ -55,7 +55,13 @@ public readonly record struct FileAttachment(FileAttachmentType Type, string Fil
|
|||||||
var fileSize = File.Exists(filePath) ? new FileInfo(filePath).Length : 0;
|
var fileSize = File.Exists(filePath) ? new FileInfo(filePath).Length : 0;
|
||||||
var type = DetermineFileType(filePath);
|
var type = DetermineFileType(filePath);
|
||||||
|
|
||||||
return new FileAttachment(type, fileName, filePath, fileSize);
|
return type switch
|
||||||
|
{
|
||||||
|
FileAttachmentType.DOCUMENT => new FileAttachment(type, fileName, filePath, fileSize),
|
||||||
|
FileAttachmentType.IMAGE => new FileAttachmentImage(fileName, filePath, fileSize),
|
||||||
|
|
||||||
|
_ => new FileAttachment(type, fileName, filePath, fileSize),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
17
app/MindWork AI Studio/Chat/FileAttachmentImage.cs
Normal file
17
app/MindWork AI Studio/Chat/FileAttachmentImage.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
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>
|
||||||
|
public string Source { get; set; } = FilePath;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user