<br />

SemanticRetriever coordinates document chunking, multimodal embedding, and high-dimensional vector search.

**Signature:**

```typescript
export declare class SemanticRetriever 
```

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromComponents(components)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrievercreatefromcomponents) | `static` | Creates a SemanticRetriever from SemanticRetrieverComponents. |
| [insertDocument(id, text, metadata)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverinsertdocument) |   | Inserts a text document into the retriever with automatic chunking. |
| [insertContent(id, parts, metadata)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverinsertcontent) |   | Inserts multimodal content parts under a single unique ID. |
| [insertImage(id, imageBytes, metadata)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverinsertimage) |   | Inserts an image into the retriever. |
| [insertAudio(id, audioData, metadata)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverinsertaudio) |   | Inserts pre-decoded PCM float audio samples into the retriever. |
| [retrieve(query, options)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverretrieve) |   | Retrieves top-K nearest matching records based on a text or multimodal query. |
| [delete(idsOrFilter)](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverdelete) |   | Deletes records and their chunks by ID(s), or records matching metadata filter. |
| [getAllRecordIds()](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrievergetallrecordids) |   | Retrieves all unique top-level record IDs stored in the retriever. |
| [deleteAll()](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverdeleteall) |   | Deletes all records from the retriever. |
| [close()](https://developers.google.com/edge/api/mediapipe/js/tasks-retrieval.semanticretriever.md.txt#semanticretrieverclose) |   | Closes the retriever and frees resources. |

## SemanticRetriever.createFromComponents()

Creates a SemanticRetriever from SemanticRetrieverComponents.

**Signature:**

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

### Parameters

| Parameter | Type | Description |
|---|---|---|
| components | SemanticRetrieverComponents | The SemanticRetriever components. |

**Returns:**

Promise\<SemanticRetriever\>

## SemanticRetriever.insertDocument()

Inserts a text document into the retriever with automatic chunking.

**Signature:**

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

### Parameters

| Parameter | Type | Description |
|---|---|---|
| id | string |   |
| text | string |   |
| metadata | Record\<string, string\> |   |

**Returns:**

Promise\<void\>

## SemanticRetriever.insertContent()

Inserts multimodal content parts under a single unique ID.

**Signature:**

```typescript
insertContent(id: string, parts: readonly ContentPart[], metadata?: Record<string, string>): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| id | string |   |
| parts | readonly ContentPart\[\] |   |
| metadata | Record\<string, string\> |   |

**Returns:**

Promise\<void\>

## SemanticRetriever.insertImage()

Inserts an image into the retriever.

**Signature:**

```typescript
insertImage(id: string, imageBytes: Uint8Array, metadata?: Record<string, string>): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| id | string |   |
| imageBytes | Uint8Array |   |
| metadata | Record\<string, string\> |   |

**Returns:**

Promise\<void\>

## SemanticRetriever.insertAudio()

Inserts pre-decoded PCM float audio samples into the retriever.

**Signature:**

```typescript
insertAudio(id: string, audioData: Float32Array, metadata?: Record<string, string>): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| id | string |   |
| audioData | Float32Array |   |
| metadata | Record\<string, string\> |   |

**Returns:**

Promise\<void\>

## SemanticRetriever.retrieve()

Retrieves top-K nearest matching records based on a text or multimodal query.

**Signature:**

```typescript
retrieve(query: string | readonly ContentPart[], options?: RetrievalOptions): Promise<RetrievalResult[]>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| query | string \| readonly ContentPart\[\] |   |
| options | RetrievalOptions |   |

**Returns:**

Promise\<RetrievalResult\[\]\>

## SemanticRetriever.delete()

Deletes records and their chunks by ID(s), or records matching metadata filter.

**Signature:**

```typescript
delete(idsOrFilter: string | readonly string[] | Record<string, string>): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| idsOrFilter | string \| readonly string\[\] \| Record\<string, string\> |   |

**Returns:**

Promise\<void\>

## SemanticRetriever.getAllRecordIds()

Retrieves all unique top-level record IDs stored in the retriever.

**Signature:**

```typescript
getAllRecordIds(): Promise<string[]>;
```

**Returns:**

Promise\<string\[\]\>

## SemanticRetriever.deleteAll()

Deletes all records from the retriever.

**Signature:**

```typescript
deleteAll(): Promise<void>;
```

**Returns:**

Promise\<void\>

## SemanticRetriever.close()

Closes the retriever and frees resources.

**Signature:**

```typescript
close(): void;
```

**Returns:**

void