add TextChunker Service for AI Project ...

This commit is contained in:
2026-10-25 17:23:03 +03:30
parent 4b857de518
commit 429b97cded
9 changed files with 760 additions and 6 deletions
+38
View File
@@ -0,0 +1,38 @@
namespace xAiApi.Models
{
/// <summary>
/// Represents a Chunk of a Text which Produced by Text Chunker ...
/// </summary>
public class XTextChunk
{
/// <summary>
/// Zero Based Index of Chunk in Source Text ...
/// </summary>
public int Index { get; set; }
/// <summary>
/// Chunk Text Content ...
/// </summary>
public string Text { get; set; } = string.Empty;
/// <summary>
/// Source Name (e.g. File Name) which Chunk Extracted From ...
/// </summary>
public string Source { get; set; }
/// <summary>
/// Doc and Chunk Identifier (e.g. "file.pdf#3") ...
/// </summary>
public string Identifier { get; set; }
/// <summary>
/// Start Offset of Chunk in Normalized Source Text ...
/// </summary>
public int StartOffset { get; set; }
/// <summary>
/// Length of Chunk Text ...
/// </summary>
public int Length => Text?.Length ?? 0;
}
}
+33
View File
@@ -0,0 +1,33 @@
namespace xAiApi.Models
{
/// <summary>
/// Text Chunker Descriptor ...
/// </summary>
public class XTextChunkerDescriptor
{
/// <summary>
/// Maximum Characters Count of each Chunk ...
/// </summary>
public int ChunkSize { get; set; } = 800;
/// <summary>
/// Characters Count which Shared between two Consecutive Chunks ...
/// </summary>
public int ChunkOverlap { get; set; } = 150;
/// <summary>
/// Chunks Smaller than this Size will be Merged into Previous Chunk ...
/// </summary>
public int MinChunkSize { get; set; } = 50;
/// <summary>
/// Chunck Identifier Separator ...
/// </summary>
public string ChunkIdentifierSeparator { get; set; } = "#";
/// <summary>
/// Normalize Line Endings and Repeated Whitespaces before Chunking ...
/// </summary>
public bool NormalizeWhitespace { get; set; } = true;
}
}