KnowledgeIngestionService
AgentPrism.Core.dllManagement (operator) surface for document ingestion, semantic search, and source management.
public sealed class KnowledgeIngestionServiceInheritance
Section titled “Inheritance”object ← KnowledgeIngestionService
Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Not the agent’s own job —
The agent side is the search_knowledge tool produced by
AgentPrism.VectorSearchToolFactory.
While KnowledgeIngestionService.IsSupported is false, every method throws AgentPrismException; it does not silently return an empty result.
Constructors
Section titled “Constructors”KnowledgeIngestionService(ITenantContext, IOptions<AgentPrismKnowledgeOptions>, IVectorSearchStore?, IEmbeddingGenerator<string, Embedding<float>>?)
Section titled “ KnowledgeIngestionService(ITenantContext, IOptions<AgentPrismKnowledgeOptions>, IVectorSearchStore?, IEmbeddingGenerator<string, Embedding<float>>?)”Creates a new knowledge base service.
public KnowledgeIngestionService(ITenantContext tenantContext, IOptions<AgentPrismKnowledgeOptions> options, IVectorSearchStore? store = null, IEmbeddingGenerator<string, Embedding<float>>? embeddings = null)Parameters
Section titled “Parameters”tenantContext ITenantContext
The tenant context.
options IOptions<AgentPrismKnowledgeOptions>
Knowledge base settings.
store IVectorSearchStore?
The vector store. If null, KnowledgeIngestionService.IsSupported is false (the replaceable-extension rule: no default implementation).
embeddings IEmbeddingGenerator<string, Embedding<float>>?
The embedding generator. If null, KnowledgeIngestionService.IsSupported is false; the consumer must register its own provider.
Exceptions
Section titled “Exceptions”A required dependency is null.
Properties
Section titled “Properties”IsSupported
Section titled “ IsSupported”Whether the knowledge base is supported in this setup.
public bool IsSupported { get; }Property Value
Section titled “Property Value”Remarks
Section titled “Remarks”true only while both an IVectorSearchStore
(today: PostgreSQL only) AND an
IEmbeddingGenerator<string, Embedding<float>> are registered.
Methods
Section titled “Methods”DeleteSourceAsync(string, string, CancellationToken)
Section titled “ DeleteSourceAsync(string, string, CancellationToken)”Deletes all chunks of a source.
public ValueTask<int> DeleteSourceAsync(string collection, string sourceId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”collection string
The collection name.
sourceId string
The source identity to delete.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The number of chunks deleted.
Exceptions
Section titled “Exceptions”KnowledgeIngestionService.IsSupported is false.
IngestAsync(string, string, string?, IReadOnlyList<VectorChunk>?, CancellationToken)
Section titled “ IngestAsync(string, string, string?, IReadOnlyList<VectorChunk>?, CancellationToken)”Ingests a document: chunks it (if not given), embeds it (if not given), and writes it.
public ValueTask<int> IngestAsync(string collection, string sourceId, string? text, IReadOnlyList<VectorChunk>? chunks, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”collection string
The collection name.
sourceId string
The source identity. Re-ingesting with the same identity replaces the old one.
text string?
Raw text. If given, it is chunked with
AgentPrismKnowledgeOptions.ChunkSize and
AgentPrismKnowledgeOptions.ChunkOverlap, and each chunk is
embedded. Cannot be given together with chunks.
chunks IReadOnlyList<VectorChunk>?
Ready-made chunks. Chunks with an empty VectorChunk.Embedding
are embedded here; chunks that already have one are written as is (the
consumer may bring its own embedding). Cannot be given together with
text.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The number of chunks written.
Exceptions
Section titled “Exceptions”KnowledgeIngestionService.IsSupported is false.
Neither text nor chunks is given,
both are given, or a chunk’s embedding length does not match the store’s dimension.
ListSourcesAsync(string, CancellationToken)
Section titled “ ListSourcesAsync(string, CancellationToken)”Lists all sources in a collection.
public ValueTask<IReadOnlyList<string>> ListSourcesAsync(string collection, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”collection string
The collection name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<string>>
The source identities.
Exceptions
Section titled “Exceptions”KnowledgeIngestionService.IsSupported is false.
SearchAsync(string, string, int?, CancellationToken)
Section titled “ SearchAsync(string, string, int?, CancellationToken)”Embeds a query text and returns the nearest chunks.
public ValueTask<IReadOnlyList<VectorSearchHit>> SearchAsync(string collection, string query, int? top = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”collection string
The collection name.
query string
The query text.
top int?
How many results to return. If not given, AgentPrismKnowledgeOptions.MaxResults.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<VectorSearchHit>>
Results sorted by ascending distance.