Class DocumentRag.DocumentMetadata
Represents metadata associated with a document during import into a DocumentRag instance.
public sealed class DocumentRag.DocumentMetadata
- Inheritance
-
DocumentRag.DocumentMetadata
- Inherited Members
Examples
// Basic usage with automatic document name and generated ID
var attachment = Attachment.FromFile("report.pdf");
var metadata = new DocumentMetadata(attachment);
// With source URI (e.g., URL or file path)
var metadataWithUri = new DocumentMetadata(attachment, sourceUri: "https://example.com/reports/q4-2024.pdf");
// With explicit ID
var metadataWithId = new DocumentMetadata(attachment, id: "doc-550e8400-e29b-41d4");
// With custom metadata
var customMetadata = new MetadataCollection
{
{ "author", "John Smith" },
{ "department", "Finance" },
{ "version", "2.1" }
};
var metadataFull = new DocumentMetadata(
attachment,
sourceUri: "internal://docs/123",
customMetadata: customMetadata);
// Import with metadata
var dataSource = await docRag.ImportDocumentAsync(attachment, "reports", documentMetadata: metadataFull);
Remarks
Document metadata is attached to each section created during document import, enabling source attribution when generating responses. The metadata includes a unique document identifier, the document name, an optional source URI, and any custom metadata fields.
When querying partitions via QueryPartitions(string, IEnumerable<PartitionSimilarity>, IConversation, CancellationToken) or QueryPartitionsAsync(string, IEnumerable<PartitionSimilarity>, IConversation, CancellationToken), the metadata is used to construct DocumentReference instances that identify the source document and page for each matched partition.
Constructors
- DocumentMetadata(Attachment, string, string, MetadataCollection)
Initializes a new instance of the DocumentRag.DocumentMetadata class.
- DocumentMetadata(string, string, string, MetadataCollection)
Initializes a new instance of the DocumentRag.DocumentMetadata class with a specified name.
Properties
- CustomMetadata
Gets or sets custom metadata to attach to all sections from this document.
- Id
Gets or sets the unique identifier for the document.
- Name
Gets or sets the display name of the document.
- SourceUri
Gets or sets an optional URI for the document source.