autointent.context.vector_index_client.VectorIndexClient#

class autointent.context.vector_index_client.VectorIndexClient(embedder_device, db_dir, embedder_batch_size=32, embedder_max_length=None, embedder_use_cache=False)#

Client interface for managing vector indexes.

This class provides methods for creating, persisting, loading, and deleting vector indexes. Indexes are stored in a specified directory and associated with embedding models.

Parameters:
  • embedder_device (str)

  • db_dir (str | pathlib.Path | None)

  • embedder_batch_size (int)

  • embedder_max_length (int | None)

  • embedder_use_cache (bool)

embedder_device#
db_dir#
embedder_batch_size = 32#
embedder_max_length = None#
embedder_use_cache = False#
create_index(model_name, utterances=None, labels=None)#

Create a new vector index for the specified model.

Parameters:
  • model_name (str) – Name of the embedding model (Hugging Face repo, not a local path).

  • utterances (list[str] | None) – Optional list of utterances to add to the index.

  • labels (list[autointent.custom_types.LabelType] | None) – Optional list of labels corresponding to the utterances.

Returns:

A VectorIndex instance.

Raises:

ValueError – If only one of utterances or labels is provided.

Return type:

autointent.context.vector_index_client._vector_index.VectorIndex

dump(index)#

Persist the vector index to disk.

Parameters:

index (autointent.context.vector_index_client._vector_index.VectorIndex) – The VectorIndex instance to save.

Return type:

None

delete_index(model_name)#

Delete a vector index and its associated data.

Parameters:

model_name (str) – Name of the model.

Return type:

None

get_index(model_name)#

Load a vector index for a given model.

Parameters:

model_name (str) – Name of the model.

Returns:

The loaded VectorIndex instance.

Raises:

NonExistingIndexError – If the index does not exist.

Return type:

autointent.context.vector_index_client._vector_index.VectorIndex

exists(model_name)#

Check if a vector index exists for a given model.

Parameters:

model_name (str) – Name of the model.

Returns:

True if the index exists, False otherwise.

Return type:

bool

delete_db()#

Delete all vector indexes and their associated data from disk.

Return type:

None