last ...
This commit is contained in:
@@ -191,6 +191,67 @@ namespace xAiModels.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate a File Extraction Result ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XFileExtractionResult source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
(
|
||||
source.Images.HasChild() ||
|
||||
!source.Text.IsNullOrEmpty() ||
|
||||
!source.AudioTranscript.IsNullOrEmpty()
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a File Extraction Result to AI Contents ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static IList<AIContent> ToAIContents(this XFileExtractionResult source)
|
||||
{
|
||||
//
|
||||
var result = new List<AIContent>();
|
||||
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a Collection Contains Default Project for Specified Owner or not ...
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user