Skip to content

KnowledgeIngestionService

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Management (operator) surface for document ingestion, semantic search, and source management.

public sealed class KnowledgeIngestionService

objectKnowledgeIngestionService

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

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.

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)

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.

ArgumentNullException

A required dependency is null.

Whether the knowledge base is supported in this setup.

public bool IsSupported { get; }

bool

true only while both an IVectorSearchStore (today: PostgreSQL only) AND an IEmbeddingGenerator<string, Embedding<float>> are registered.

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)

collection string

The collection name.

sourceId string

The source identity to delete.

cancellationToken CancellationToken

The cancellation token.

ValueTask<int>

The number of chunks deleted.

AgentPrismException

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)

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.

ValueTask<int>

The number of chunks written.

AgentPrismException

KnowledgeIngestionService.IsSupported is false.

ArgumentException

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)

collection string

The collection name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<string>>

The source identities.

AgentPrismException

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)

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.

ValueTask<IReadOnlyList<VectorSearchHit>>

Results sorted by ascending distance.

AgentPrismException

KnowledgeIngestionService.IsSupported is false.