last ...
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXAudioFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXDocxFileContentExtractor : IXFileContentExtractor
|
||||
public interface IXDocxFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXExcelFileContentExtractor : IXFileContentExtractor
|
||||
public interface IXExcelFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -6,9 +8,9 @@ using xAiModels.Models;
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
/// <summary>
|
||||
/// a Service for Extracting File Content ...
|
||||
/// a Base Service for Extracting File Content ...
|
||||
/// </summary>
|
||||
public interface IXFileContentExtractor
|
||||
public interface IXFileContentExtractorBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if this extractor supports the specified MIME type ...
|
||||
@@ -39,4 +41,54 @@ namespace xAiApi.Interfaces.Extractors
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a Service for Extracting File Content ...
|
||||
/// </summary>
|
||||
public interface IXFileContentExtractor
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if this extractor supports the specified MIME type ...
|
||||
/// </summary>
|
||||
/// <param name="mimeType"></param>
|
||||
/// <param name="extractors"></param>
|
||||
/// <returns></returns>
|
||||
bool CanExtract(
|
||||
string mimeType,
|
||||
string[] extractors = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Extract text content from file stream ...
|
||||
/// </summary>
|
||||
/// <param name="fileStream"></param>
|
||||
/// <param name="mimeType"></param>
|
||||
/// <param name="extractors"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> ExtractAsync(
|
||||
Stream fileStream,
|
||||
string mimeType,
|
||||
string[] extractors = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Extract content from stream as Rich Result ...
|
||||
/// </summary>
|
||||
/// <param name="fileStream"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="mimeType"></param>
|
||||
/// <param name="extractors"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XFileExtractionResult> ExtractRichAsync(
|
||||
Stream fileStream,
|
||||
string fileName,
|
||||
string mimeType,
|
||||
string[] extractors = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXImageFileContentExtractor : IXFileContentExtractor
|
||||
public interface IXImageFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXPdfFileContentExtractor : IXFileContentExtractor
|
||||
public interface IXPdfFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXPlainTextFileContentExtractor : IXFileContentExtractor
|
||||
public interface IXPlainTextFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace xAiApi.Interfaces.Extractors
|
||||
{
|
||||
public interface IXVisionFileContentExtractor : IXFileContentExtractorBase
|
||||
{ }
|
||||
}
|
||||
@@ -51,19 +51,6 @@ namespace xAiApi.Interfaces
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get LLM Client instance for Communicating with LLM ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IChatClient GetClient();
|
||||
|
||||
/// <summary>
|
||||
/// Create Custom HttpClient for Communicating with LLM API ...
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
HttpClient GetHttpClient(string url = null);
|
||||
|
||||
/// <summary>
|
||||
/// Prepare a Message History List for LLM Communication based on Prompt ...
|
||||
/// </summary>
|
||||
@@ -209,6 +196,22 @@ namespace xAiApi.Interfaces
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Content Extraction ...
|
||||
/// <summary>
|
||||
/// Try to Extract Files Content ...
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <param name="extractors"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> ExtractContent(
|
||||
IFormFileCollection files,
|
||||
string[] extractors = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Data Actions ...
|
||||
|
||||
@@ -5,8 +5,8 @@ using xAiModels.Models;
|
||||
using xAiModels.Models.Dtos;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xAiApi.Interfaces
|
||||
{
|
||||
@@ -152,6 +152,24 @@ namespace xAiApi.Interfaces
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Content Extraction ...
|
||||
/// <summary>
|
||||
/// Extract Files Content ...
|
||||
/// </summary>
|
||||
/// <param name="files"></param>
|
||||
/// <param name="extractors"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("ExtractContent")]
|
||||
[Consumes("multipart/form-data")]
|
||||
Task<ActionResult<string>> ExtractContent(
|
||||
[FromForm] IFormFileCollection files,
|
||||
[FromForm] string extractors = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Data Actions ...
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user