Skip to main content

LocalIndex Objects

add

Add embeddings to the index. Arguments:
  • embeddings (List[List[float]]): List of embeddings to add to the index.
  • routes (List[str]): List of routes to add to the index.
  • utterances (List[str]): List of utterances to add to the index.
  • function_schemas (Optional[List[Dict[str, Any]]]): List of function schemas to add to the index.
  • metadata_list (List[Dict[str, Any]]): List of metadata to add to the index.

get_utterances

Gets a list of route and utterance objects currently stored in the index. Arguments:
  • include_metadata: Whether to include function schemas and metadata in the returned Utterance objects - LocalIndex now includes metadata if present.
Returns: List[Utterance]: A list of Utterance objects.

describe

Describe the index. Returns: IndexConfig: An IndexConfig object.

is_ready

Checks if the index is ready to be used. Returns: bool: True if the index is ready, False otherwise.

ais_ready

Checks if the index is ready to be used asynchronously. Returns: bool: True if the index is ready, False otherwise.

query

Search the index for the query and return top_k results. Arguments:
  • vector (np.ndarray): The vector to search for.
  • top_k (int): The number of results to return.
  • route_filter (Optional[List[str]]): The routes to filter the search by.
  • sparse_vector (dict[int, float] | SparseEmbedding | None): The sparse vector to search for.
Returns: Tuple[np.ndarray, List[str]]: A tuple containing the query vector and a list of route names.

aquery

Search the index for the query and return top_k results. Arguments:
  • vector (np.ndarray): The vector to search for.
  • top_k (int): The number of results to return.
  • route_filter (Optional[List[str]]): The routes to filter the search by.
  • sparse_vector (dict[int, float] | SparseEmbedding | None): The sparse vector to search for.
Returns: Tuple[np.ndarray, List[str]]: A tuple containing the query vector and a list of route names.

aget_routes

Get all routes from the index. Returns: List[str]: A list of routes.

delete

Delete all records of a specific route from the index. Arguments:
  • route_name (str): The name of the route to delete.

adelete

Delete all records of a specific route from the index. Note that this just points to the sync delete method as async makes no difference for the local computations of the LocalIndex. Arguments:
  • route_name (str): The name of the route to delete.

delete_index

Deletes the index, effectively clearing it and setting it to None. Returns: None: None

adelete_index

Deletes the index, effectively clearing it and setting it to None. Note that this just points to the sync delete_index method as async makes no difference for the local computations of the LocalIndex. Returns: None: None