diff --git a/Extensions/XAiModelsExtensions.cs b/Extensions/XAiModelsExtensions.cs
index ab16409..8db7348 100644
--- a/Extensions/XAiModelsExtensions.cs
+++ b/Extensions/XAiModelsExtensions.cs
@@ -191,6 +191,67 @@ namespace xAiModels.Extensions
return result;
}
+ ///
+ /// Validate a File Extraction Result ...
+ ///
+ ///
+ ///
+ public static bool IsValid(this XFileExtractionResult source)
+ {
+ //
+ var result =
+ !source.IsNullOrDefault() &&
+ (
+ source.Images.HasChild() ||
+ !source.Text.IsNullOrEmpty() ||
+ !source.AudioTranscript.IsNullOrEmpty()
+ );
+ return result;
+ }
+
+ ///
+ /// Converts a File Extraction Result to AI Contents ...
+ ///
+ ///
+ ///
+ public static IList ToAIContents(this XFileExtractionResult source)
+ {
+ //
+ var result = new List();
+
+ //
+ if (source.IsValid())
+ {
+ //
+ // Main Text ...
+ if (!source.Text.IsNullOrEmpty())
+ {
+ result.Add(new TextContent(source.Text));
+ }
+
+ //
+ // Images ...
+ if (source.Images.HasChild())
+ {
+ //
+ foreach (var img in source.Images)
+ {
+ result.Add(new DataContent(img.Bytes, img.MimeType));
+ }
+ }
+
+ //
+ // Transcripted Audio ...
+ if (!source.AudioTranscript.IsNullOrEmpty())
+ {
+ result.Add(new TextContent($"[Audio Transcript]\n{source.AudioTranscript}"));
+ }
+ }
+
+ //
+ return result;
+ }
+
///
/// Check a Collection Contains Default Project for Specified Owner or not ...
///
diff --git a/Models/XFileExtractionResult.cs b/Models/XFileExtractionResult.cs
new file mode 100644
index 0000000..c4df075
--- /dev/null
+++ b/Models/XFileExtractionResult.cs
@@ -0,0 +1,71 @@
+using System.Collections.Generic;
+
+namespace xAiModels.Models
+{
+ ///
+ /// Holds File Extraction Result ...
+ ///
+ public class XFileExtractionResult
+ {
+ ///
+ /// Extracted String Content ...
+ ///
+ public string Text { get; set; } = string.Empty;
+
+ ///
+ /// Extracted Images for Vision Model ...
+ ///
+ public IList Images { get; set; } = [];
+
+ ///
+ /// Extracted Content from Audio File ...
+ ///
+ public string AudioTranscript { get; set; } = string.Empty;
+
+ ///
+ /// Main File Name ...
+ ///
+ public string FileName { get; set; }
+
+ ///
+ /// Main File MIME Type ...
+ ///
+ public string MimeType { get; set; }
+
+ ///
+ /// Specified Fallback done using Images or not ...
+ ///
+ public bool UsedImageFallback { get; set; } = false;
+
+ ///
+ /// Error Message ...
+ ///
+ public string ErrorMessage { get; set; }
+ }
+
+ ///
+ /// Extracted Image ...
+ ///
+ public class XExtractedImage
+ {
+ ///
+ /// Content as Byte ...
+ ///
+ public byte[] Bytes { get; set; }
+
+ ///
+ /// MIME Type of Image ...
+ ///
+ public string MimeType { get; set; } = "image/png";
+
+ ///
+ /// for PDF Files ...
+ ///
+ public int? PageNumber { get; set; }
+
+ ///
+ /// Describe Image ...
+ ///
+ public string Description { get; set; }
+ }
+}
\ No newline at end of file