diff --git a/src/LlamaIndex.Core/Retrievers/BaseRetriever.cs b/src/LlamaIndex.Core/Retrievers/BaseRetriever.cs index 1d3a192..d7c6061 100644 --- a/src/LlamaIndex.Core/Retrievers/BaseRetriever.cs +++ b/src/LlamaIndex.Core/Retrievers/BaseRetriever.cs @@ -5,9 +5,17 @@ namespace LlamaIndex.Core.Retrievers { + /// + /// Provides an abstraction for retreivers that retrieve nodes from a data source. + /// public abstract class BaseRetriever { - + /// + /// Given a query, retrieves nodes from the data source. + /// + /// An input query used to retreive similar nodes. + /// Propagates notification for operations to be cancelled. + /// A collection of nodes. See public Task RetrieveAsync(string query, CancellationToken cancellationToken = default) { return RetrieveNodesAsync(query, cancellationToken); diff --git a/src/LlamaIndex.Core/Retrievers/BaseRetrieverClient.cs b/src/LlamaIndex.Core/Retrievers/BaseRetrieverClient.cs index 632d145..1e4abe0 100644 --- a/src/LlamaIndex.Core/Retrievers/BaseRetrieverClient.cs +++ b/src/LlamaIndex.Core/Retrievers/BaseRetrieverClient.cs @@ -10,8 +10,19 @@ namespace LlamaIndex.Core.Retrievers; +/// +/// A client for retrieving nodes from a data source. +/// +/// The URI host for the data source +/// The name of the collection where nodes are stored. public class RetrieverClient(Uri host, string vectorDbCollectionName) : BaseRetriever { + /// + /// Retrieves nodes from the data source. + /// + /// An input query used to retreive similar nodes. + /// Propagates notification for operations to be cancelled. + /// A collection of nodes. See protected override async Task RetrieveNodesAsync(string query, CancellationToken cancellationToken) { var client = new HttpClient(); diff --git a/src/LlamaIndex.Core/Schema/BaseNodeConverter.cs b/src/LlamaIndex.Core/Schema/BaseNodeConverter.cs index d7c5433..224e735 100644 --- a/src/LlamaIndex.Core/Schema/BaseNodeConverter.cs +++ b/src/LlamaIndex.Core/Schema/BaseNodeConverter.cs @@ -5,13 +5,29 @@ namespace LlamaIndex.Core.Schema; +/// +/// Converts nodes to and from JSON. +/// public class BaseNodeConverter : JsonConverter { + /// + /// Checks whether a node can be converted into the specified type. + /// + /// The type to convert the node into. + /// Whether the node can be converted into the specified type public override bool CanConvert(Type typeToConvert) { return typeof(BaseNode).IsAssignableFrom(typeToConvert); } + /// + /// + /// + /// The JSON reader + /// The type to convert the node into. + /// JSON serialization options. + /// A + /// public override BaseNode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { using var jsonDoc = JsonDocument.ParseValue(ref reader); diff --git a/src/LlamaIndex.Core/Schema/Document.cs b/src/LlamaIndex.Core/Schema/Document.cs index fd81c3a..55c6b02 100644 --- a/src/LlamaIndex.Core/Schema/Document.cs +++ b/src/LlamaIndex.Core/Schema/Document.cs @@ -2,6 +2,13 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents a document node. +/// +/// The node ID +/// The text contents of a node +/// The data type represented in the node +/// Additional metadata for the node public class Document( string id, string? text = null, diff --git a/src/LlamaIndex.Core/Schema/ImageDocument.cs b/src/LlamaIndex.Core/Schema/ImageDocument.cs index b409b5d..2d54511 100644 --- a/src/LlamaIndex.Core/Schema/ImageDocument.cs +++ b/src/LlamaIndex.Core/Schema/ImageDocument.cs @@ -2,6 +2,17 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents an image node. +/// +/// The node ID +/// A text description of the image. For example, alt-text. +/// A string representation of the image. +/// A file path where the image is located. +/// A URL where the image is located. +/// The mime type for the image. +/// The mime type for the node. +/// Additional node metadata. public class ImageDocument( string id, string? text = null, diff --git a/src/LlamaIndex.Core/Schema/NodeType.cs b/src/LlamaIndex.Core/Schema/NodeType.cs index f596bbc..351dda2 100644 --- a/src/LlamaIndex.Core/Schema/NodeType.cs +++ b/src/LlamaIndex.Core/Schema/NodeType.cs @@ -1,5 +1,8 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents the type of node. +/// public enum NodeType { TextNode = 1, diff --git a/src/LlamaIndex.Core/Schema/RelatedNodeInfo.cs b/src/LlamaIndex.Core/Schema/RelatedNodeInfo.cs index 3090504..29c12d3 100644 --- a/src/LlamaIndex.Core/Schema/RelatedNodeInfo.cs +++ b/src/LlamaIndex.Core/Schema/RelatedNodeInfo.cs @@ -2,6 +2,12 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents a related node. +/// +/// The node ID. +/// The node type. +/// Additional node metadata. public class RelatedNodeInfo(string nodeId, NodeType nodeType, Dictionary? metadata = null) { public string NodeId { get; } = nodeId; diff --git a/src/LlamaIndex.Core/Schema/RelationshipType.cs b/src/LlamaIndex.Core/Schema/RelationshipType.cs index 652b181..bfe8bf0 100644 --- a/src/LlamaIndex.Core/Schema/RelationshipType.cs +++ b/src/LlamaIndex.Core/Schema/RelationshipType.cs @@ -2,6 +2,9 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents the type of relationship between nodes. +/// public enum RelationshipType { Source = 1, @@ -11,8 +14,17 @@ public enum RelationshipType Child = 5 } +/// +/// Provides extension methods for . +/// public static class RelationshipTypeExtensions { + /// + /// Converts a to a relationship name. + /// + /// The + /// The name of the relationship type. + /// public static string ToRelationshipName(this RelationshipType relationshipType) { return relationshipType switch @@ -26,6 +38,12 @@ public static string ToRelationshipName(this RelationshipType relationshipType) }; } + /// + /// Converts a to a relationship key. + /// + /// The + /// The key of the relationship type. + /// public static string ToRelationshipKey(this RelationshipType relationshipType) { return relationshipType switch diff --git a/src/LlamaIndex.Core/Schema/TextNode.cs b/src/LlamaIndex.Core/Schema/TextNode.cs index 1e363ed..a5249f8 100644 --- a/src/LlamaIndex.Core/Schema/TextNode.cs +++ b/src/LlamaIndex.Core/Schema/TextNode.cs @@ -3,6 +3,15 @@ namespace LlamaIndex.Core.Schema; +/// +/// Represents a text node. +/// +/// The node ID. +/// The text contents of the node. +/// The index where the node starts. +/// The index where the node ends. +/// The node mime type. +/// Additional node metadata [JsonConverter(typeof(BaseNodeConverter))] public class TextNode( string id, @@ -19,6 +28,17 @@ public class TextNode( public string? MimeType { get; } = mimeType; } +/// +/// Represents an image node. +/// +/// The node ID +/// The text description of the image. +/// The representation of the image. +/// The file path image location. +/// The URL image location. +/// The mime type of the image. +/// The mime type of the node. +/// Additional node metadata. [JsonConverter(typeof(BaseNodeConverter))] public class ImageNode( string id, diff --git a/src/LlamaParse/ItemType.cs b/src/LlamaParse/ItemType.cs index 9d58411..b5a5528 100644 --- a/src/LlamaParse/ItemType.cs +++ b/src/LlamaParse/ItemType.cs @@ -2,6 +2,9 @@ namespace LlamaParse; +/// +/// Represents the type of item in a document. +/// [Flags] public enum ItemType { diff --git a/src/LlamaParse/Languages.cs b/src/LlamaParse/Languages.cs index b6491b1..80b3bd0 100644 --- a/src/LlamaParse/Languages.cs +++ b/src/LlamaParse/Languages.cs @@ -1,5 +1,8 @@ namespace LlamaParse; +/// +/// The languages supported by LlamaParse. +/// public enum Languages { Baza, diff --git a/src/LlamaParse/LlamaParseClient.cs b/src/LlamaParse/LlamaParseClient.cs index 0adc8f9..e087848 100644 --- a/src/LlamaParse/LlamaParseClient.cs +++ b/src/LlamaParse/LlamaParseClient.cs @@ -11,12 +11,21 @@ namespace LlamaParse; +/// +/// The LlamaParseClient class provides methods for parsing data from files using the LlamaParse service. +/// public partial class LlamaParseClient { internal Configuration Configuration { get; } private readonly LlamaParseApiClient _client; + /// + /// The LlamaParseClient constructor. + /// + /// The used to make requests to the LlamaParse service. + /// The LlamaParse + /// public LlamaParseClient(HttpClient client, Configuration configuration) { if (string.IsNullOrWhiteSpace(configuration.ApiKey)) @@ -112,7 +121,7 @@ public async IAsyncEnumerable LoadDataRawAsync( /// The type of result to retrieve. (Optional) /// Additional metadata for the document. (Optional) /// Language (Optional) - /// The cancellation token. (Optional) + /// The (Optional) /// An asynchronous enumerable of RawResult objects representing the loaded data. public async IAsyncEnumerable LoadDataRawAsync( IEnumerable files, @@ -156,7 +165,7 @@ public async IAsyncEnumerable LoadDataRawAsync( /// Loads images from a document asynchronously. /// /// The document containing the image metadata. - /// The cancellation token. + /// The /// An asynchronous enumerable of ImageDocument objects representing the loaded images. public async IAsyncEnumerable LoadImagesAsync(Document document, [EnumeratorCancellation] CancellationToken cancellationToken = default) { @@ -169,6 +178,12 @@ public async IAsyncEnumerable LoadImagesAsync(Document document, } } + /// + /// Loads images from a document asynchronously. + /// + /// The from a parsing job. + /// The + /// An asynchronous enumerable of ImageDocument objects representing the loaded images. public IAsyncEnumerable LoadImagesAsync(RawResult rawResult, CancellationToken cancellationToken = default) { var jobId = rawResult.JobId; @@ -176,6 +191,13 @@ public IAsyncEnumerable LoadImagesAsync(RawResult rawResult, Canc return LoadImagesAsync(jobId, rawResult.Metadata, cancellationToken); } + /// + /// Loads images from a document asynchronously. + /// + /// The parse job ID + /// Additional document metadata. + /// The + /// public async IAsyncEnumerable LoadImagesAsync(string jobId, Dictionary? documentMetadata = null, [EnumeratorCancellation] CancellationToken cancellationToken = default) { var metadata = documentMetadata ?? new Dictionary(); diff --git a/src/LlamaParse/LlamaParseClientExtensions.cs b/src/LlamaParse/LlamaParseClientExtensions.cs index 2998a6d..4bb72c8 100644 --- a/src/LlamaParse/LlamaParseClientExtensions.cs +++ b/src/LlamaParse/LlamaParseClientExtensions.cs @@ -11,6 +11,9 @@ namespace LlamaParse; +/// +/// The LlamaParseClientExtensions class provides extension methods for the LlamaParseClient class. +/// public static class LlamaParseClientExtensions { ///