SemanticRetriever class

Multimodal semantic retrieval task for indexing and querying text, image, and audio documents.

Signature:

export declare class SemanticRetriever 

Methods

Method Modifiers Description
close() Closes the retriever and releases resources held by the underlying vector store and chunker.
createFromComponents(components) static Creates a new SemanticRetriever instance from configured SemanticRetrieverComponents.
delete(recordId) Deletes a record (and any associated child chunks) from the vector store by ID.
deleteAll() Deletes all records from the vector store.
getAllRecordIds() Returns all top-level record IDs currently stored in the vector store.
insertAudio(id, samples, sampleRate, metadata) Embeds and indexes an audio clip in the vector store.
insertContent(id, content, metadata) Embeds and indexes a multimodal sequence of TaskPart items in the vector store.
insertDocument(id, text, metadata) Chunks (if a text chunker is configured), embeds, and indexes a text document in the vector store.
insertImage(id, image, metadata) Embeds and indexes an image in the vector store.
retrieve(query, options) Embeds a text or multimodal query and returns the top-k matching records ordered by descending similarity score.

SemanticRetriever.close()

Closes the retriever and releases resources held by the underlying vector store and chunker.

Signature:

close(): Promise<void>;

Returns:

Promise<void>

SemanticRetriever.createFromComponents()

Creates a new SemanticRetriever instance from configured SemanticRetrieverComponents.

Signature:

static createFromComponents(components: SemanticRetrieverComponents): Promise<SemanticRetriever>;

Parameters

Parameter Type Description
components SemanticRetrieverComponents Configured embedding providers, vector store, and optional text chunker.

Returns:

Promise<SemanticRetriever>

SemanticRetriever.delete()

Deletes a record (and any associated child chunks) from the vector store by ID.

Signature:

delete(recordId: string): Promise<void>;

Parameters

Parameter Type Description
recordId string The ID of the record to remove.

Returns:

Promise<void>

SemanticRetriever.deleteAll()

Deletes all records from the vector store.

Signature:

deleteAll(): Promise<void>;

Returns:

Promise<void>

SemanticRetriever.getAllRecordIds()

Returns all top-level record IDs currently stored in the vector store.

Signature:

getAllRecordIds(): Promise<string[]>;

Returns:

Promise<string[]>

SemanticRetriever.insertAudio()

Embeds and indexes an audio clip in the vector store.

Signature:

insertAudio(id: string, samples: Float32Array, sampleRate: number, metadata?: Record<string, string>): Promise<void>;

Parameters

Parameter Type Description
id string Unique identifier for the audio record.
samples Float32Array Mono PCM audio samples in the range [-1.0, 1.0].
sampleRate number Sample rate of the audio in Hz.
metadata Record<string, string> Optional key-value metadata tags.

Returns:

Promise<void>

SemanticRetriever.insertContent()

Embeds and indexes a multimodal sequence of TaskPart items in the vector store.

Signature:

insertContent(id: string, content: TaskPart[], metadata?: Record<string, string>): Promise<void>;

Parameters

Parameter Type Description
id string Unique identifier for the record.
content TaskPart[] Array of text, image, or audio parts.
metadata Record<string, string> Optional key-value metadata tags.

Returns:

Promise<void>

SemanticRetriever.insertDocument()

Chunks (if a text chunker is configured), embeds, and indexes a text document in the vector store.

Signature:

insertDocument(id: string, text: string, metadata?: Record<string, string>): Promise<void>;

Parameters

Parameter Type Description
id string Unique identifier for the document.
text string Document text to index.
metadata Record<string, string> Optional key-value metadata tags.

Returns:

Promise<void>

SemanticRetriever.insertImage()

Embeds and indexes an image in the vector store.

Signature:

insertImage(id: string, image: ImageSource, metadata?: Record<string, string>): Promise<void>;

Parameters

Parameter Type Description
id string Unique identifier for the image record.
image ImageSource Image element, bitmap, canvas, or ImageData to index.
metadata Record<string, string> Optional key-value metadata tags.

Returns:

Promise<void>

SemanticRetriever.retrieve()

Embeds a text or multimodal query and returns the top-k matching records ordered by descending similarity score.

Signature:

retrieve(query: string | TaskPart[], options?: SemanticRetrieverOptions): Promise<RetrievalResult[]>;

Parameters

Parameter Type Description
query string | TaskPart[] A text query string or an array of multimodal TaskPart items.
options SemanticRetrieverOptions Optional retrieval options such as limit and metadataFilter.

Returns:

Promise<RetrievalResult[]>