Skip to main content

Vecto

Initializes a new Vecto object with the provided configuration.

user_vecto = Vecto(token, vector_space_id)

Args:

  • token (str): The API token used for authentication with the Vecto API. Defaults to the value of the VECTO_API_KEY environment variable.
  • vector_space_id (Union[int, str]): The ID of the vector space to interact with.
  • vecto_base_url (str): The base URL of the Vecto API. Defaults to "https://api.vecto.ai".
  • client: The HTTP client used to send requests to the Vecto API. Defaults to the "requests" library.

Ingest

ingest

ingest(self, ingest_data: Union[VectoIngestData, List[VectoIngestData]], modality:str, **kwargs) -> IngestResponse

A function to ingest data into Vecto.

Args:

  • ingest_data (VectoIngestData or list of VectoIngestData): you can also provide a dict, but ensure that it complies with VectoIngestData.
  • modality (str): 'IMAGE' or 'TEXT'

Returns:

  • IngestResponse: named tuple that contains the list of index of ingested objects.

ingest_image

ingest_image(self, batch_path_list:Union[str, list], attribute_list:Union[str, list], **kwargs) -> IngestResponse

A function that accepts a str or list of image paths and their attribute, formats it in a list of dicts to be accepted by the ingest function.

Args:

  • batch_path_list (str or list): Str or list of image paths.
  • attribute_list (str or list): Str or list of image attribute.

Returns:

  • IngestResponse: named tuple that contains the list of index of ingested objects.

ingest_all_images

ingest_all_images(self, path_list:list, attribute_list:list, batch_size:int=64) -> List[IngestResponse]

A function that accepts a list of image paths and their attribute, then send them to the ingest_image function in batches.

Args:

  • path_list (list): List of image paths.
  • attribute_list (list): List of image attribute.
  • batch_size (int): batch size of images to be sent at one request. Default 64.

Returns:

  • IngestResponse: named tuple that contains the list of index of ingested objects.

ingest_text

ingest_text(self, batch_text_list:Union[str, list], attribute_list:Union[str, list], **kwargs) -> IngestResponse

A function that accepts a str or list of text and their attribute, formats it in a list of dicts to be accepted by the ingest function.

Args:

  • batch_text_list (str or list): Str or list of text.
  • attribute_list (str or list): Str or list of the text attribute.

Returns:

  • IngestResponse: named tuple that contains the list of index of ingested objects.

ingest_all_text

ingest_all_text(self, text_list:list, attribute_list:list, batch_size=64) -> List[IngestResponse]

A function that accepts a list of text and their attribute, then send them to the ingest_text function in batches.

Args:

  • text_list (list): List of text paths.
  • attribute_list (list): List of text attribute.
  • batch_size (int): batch size of text to be sent at one request. Default 64.

Returns:

  • IngestResponse: named tuple that contains the list of index of ingested objects.

Lookup

lookup

lookup(self, query:IO, modality:str, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to search on Vecto, based on the lookup item.

Args:

  • query (IO): A IO file-like object. You can use open(path, 'rb') for IMAGE queries and io.StringIO(text) for TEXT queries.
  • modality (str): The type of the file - "IMAGE" or "TEXT"
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_image_from_url

lookup_image_from_url(self, query:str, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform image search on Vecto by passing it an url.

Args:

  • query (str): url str to an image resource
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_image_from_filepath

lookup_image_from_filepath(self, query:Union[str, pathlib.Path, os.PathLike], top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform image search on Vecto by passing it an image path.

Args:

  • query (Union[str, pathlib.Path, os.PathLike]): the path to the image query
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_image_from_binary

lookup_image_from_binary(self, query:IO, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform image search on Vecto.

Args:

  • query (IO): query already in IO form
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_text_from_str

lookup_text_from_str(self, query:str, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform text search on Vecto by passing it a string.

Args:

  • query(str): query in string
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_text_from_filepath

lookup_text_from_filepath(self, query:Union[str, pathlib.Path, os.PathLike], top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform text search on Vecto by providing it a readable text file path.

Args:

  • query (Union[str, IO, pathlib.Path, os.PathLike]): If query is a path-like object or file-like object, it will be read as a text file.
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

lookup_text_from_url

lookup_text_from_url(self, query:str, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform text search on Vecto by passing it an url.

Args:

  • query (str): url str to an text resource
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples. , where LookResult is named tuple with data, id, and similarity keys.

lookup_text_from_binary

lookup_text_from_binary(self, query:IO, top_k:int, ids:list=None, **kwargs) -> List[LookupResult]

A function to perform text search on Vecto by passing it an IO object.

Args:

  • query (IO): query already in IO form
  • top_k (int): The number of results to return
  • ids (list): A list of vector ids to search on aka subset of vectors, defaults to None

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

Analogy

compute_analogy

compute_analogy(self, query:IO, analogy_start_end:Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]], top_k:int, modality:str, **kwargs) -> List[LookupResult]

A function to compute an analogy using Vecto. It is also possible to do multiple analogies in one request body. The computed analogy is not stored in Vecto.

Args:

  • query (IO): query in the form of an IO object query.
  • analogy_start_end (VectoAnalogyStartEnd or list of VectoAnalogyStartEnd): start and end analogy to be computed. Use open(path, 'rb') for IMAGE or io.StringIO(text) for TEXT analogies.
  • top_k (int): The number of results to return
  • modality (str): The type of the file, 'IMAGE' or 'TEXT'

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

compute_text_analogy

compute_text_analogy(self, query: IO, analogy_start_end: Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]], top_k: int, **kwargs) -> List[LookupResult]

A function to compute a Text analogy using Vecto. It is also possible to do multiple analogies in one request body. The computed analogy is not stored in Vecto.

Args:

  • query (IO): query in the form of an IO object query.
  • analogy_start_end (VectoAnalogyStartEnd or list of VectoAnalogyStartEnd): start and end analogy to be computed. You may use io.StringIO(text) for TEXT data.
  • top_k (int): The number of results to return

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

compute_image_analogy

compute_image_analogy(self, query: IO, analogy_start_end: Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]], top_k: int, **kwargs) -> List[LookupResult]

A function to compute an IMAGE analogy using Vecto. It is also possible to do multiple analogies in one request body. The computed analogy is not stored in Vecto.

Args:

  • query (IO): query in the form of an IO object query.
  • analogy_start_end (VectoAnalogyStartEnd or list of VectoAnalogyStartEnd): start and end analogy to be computed. Use open(path, 'rb') for IMAGE data.
  • top_k (int): The number of results to return

Returns:

  • list of LookupResult named tuples, where LookResult is named tuple with data, id, and similarity keys.

Update

update_vector_embeddings

update_vector_embeddings(self, embedding_data: Union[VectoEmbeddingData, List[VectoEmbeddingData]], modality:str, **kwargs) -> object

A function to update current vector embeddings with new one.

Args:

  • embedding_data (VectoEmbeddingData or list of VectoEmbeddingData): data that contains the embedding data to be updated.
  • modality (str): The type of the file - "IMAGE" or "TEXT"

Returns:

  • dict: Client response body

update_vector_attribute

update_vector_attribute(self, update_attribute: Union[VectoAttribute, List[VectoAttribute]], **kwargs) -> object

A function to update current vector attribute with new one.

Args:

update_attribute (VectoAttribute or list of VectoAttribute) : attribute to be updated.


delete_vector_embeddings

delete_vector_embeddings(self, vector_ids:list, **kwargs)

A function to delete vector embeddings that is stored in Vecto.

Args:

  • vector_ids (list): A list of vector ids to be deleted

delete_vector_space_entries

delete_vector_space_entries(self, **kwargs)

Delete all entries and stored analogies within a vector space.

Args:


Management

list_models

list_models(self, **kwargs) -> List[VectoModel]

List all available models in the user's account.

Returns:

    • List[VectoModel]: A list of available VectoModel instances.

list_vector_spaces

list_vector_spaces(self, **kwargs) -> List[VectoVectorSpace]

List all available vector spaces in the user's account.

Returns:

    • List[VectoVectorSpace]: A list of available VectoVectorSpace instances.

create_vector_space

create_vector_space(self, name:str, model: Union[int, str], **kwargs) -> VectoVectorSpace

Create a new vector space in the user's account.

Args:

  • name (str): The name of the new vector space.
  • model (int or str): The model identifier or name.

Returns:

  • VectoVectorSpace: The newly created VectoVectorSpace instance.

get_vector_space

get_vector_space(self, id:int, **kwargs) -> VectoVectorSpace

Retrieve a vector space by its ID.

Args:

  • id (int): The ID of the vector space.

Returns:

  • VectoVectorSpace: The VectoVectorSpace instance with the specified ID.

get_vector_space_by_name

get_vector_space_by_name(self, name:str, **kwargs) -> List[VectoVectorSpace]

Retrieve a list of vector spaces by their name.

Args:

  • name (str): The name of the vector spaces.

Returns:

    • List[VectoVectorSpace]: A list of matching VectoVectorSpace instances.

rename_vector_space

rename_vector_space(self, id:str, new_name:str, **kwargs) -> VectoVectorSpace

Rename an existing vector space by its ID.

Args:

  • id (str): The ID of the vector space.
  • new_name (str): The new name for the vector space.

Returns:

  • VectoVectorSpace: The renamed VectoVectorSpace instance.

delete_vector_space

delete_vector_space(self, id, **kwargs)

Delete a vector space by its ID.

Args:

  • id: The ID of the vector space to be deleted.

delete_all_vector_spaces

delete_all_vector_spaces(self, **kwargs)

Delete all vector spaces in the user's account.

Returns:

  • object: None if the operation is successful.

get_user_information

get_user_information(self, **kwargs) -> VectoUser

Retrieve the user information associated with the account.

Returns:

  • VectoUser: A VectoUser instance containing the user's information.

list_tokens

list_tokens(self, **kwargs) -> List[VectoToken]

List all available tokens in the user's account.

Returns:

    • List[VectoToken]: A list of available VectoToken instances.

create_token

create_token(self, token_name:str, tokenType:str, vectorSpaceIds:List[int], allowsAccessToAllVectorSpaces:bool, **kwargs) -> VectoNewTokenResponse

Create a new token for the user's account.

Args:

  • token_name (str): The name of the new token.
  • tokenType (str): The type of the token, must be one of 'USAGE', 'PUBLIC', or 'ACCOUNT_MANAGEMENT'.
  • vectorSpaceIds (List[int]): A list of vector space IDs the token is associated with.
  • allowsAccessToAllVectorSpaces (bool): A flag indicating if the token allows access to all vector spaces.

Returns:

  • VectoNewTokenResponse: A VectoNewTokenResponse instance containing the newly created token information.

delete_token

delete_token(self, token_id:int, **kwargs)

Delete a token by its ID.

Args:

  • token_id (int): The ID of the token to be deleted.

list_vector_space_data

list_vector_space_data(self, vector_space_id: int, limit: int = None, offset: int = None, **kwargs) -> DataPage

List the attributes of entries in the given vector space.

Args:

  • vector_space_id (int): The ID of the vector space.
  • limit (int, optional): The maximum number of entries to return. Defaults to 0, which will not return any element.
  • offset (int, optional): The offset from the start of the list to begin returning entries. Defaults to None.
  • **kwargs: Other keyword arguments for clients other than requests.

Returns:

  • DataPage: A DataPage instance which contains a count of a vector space's data entries and elements of DataEntry, specified by the limit and offset.

delete_vector_space_entry

delete_vector_space_entry(self, vector_space_id: int, entry_id: int, **kwargs)

Delete an entry in a vector space.

Args:

  • vector_space_id (int): The ID of the vector space.
  • entry_id (int): The ID of the entry to be deleted.
  • **kwargs: Other keyword arguments for clients other than requests.

Note:

This method does not return a value. It performs a delete operation on the specified entry.


Metrics

usage

usage(self, vector_space_id: int, year: int, month: int, **kwargs) -> MonthlyUsageResponse:

Return the usage metrics for the selected month.

Args:

  • year (int): The year for the usage data.
  • month (int): The month for the usage data.
  • vector_space_id (int, optional): The ID of the vector space. If not provided, will fallback to self vector id.
  • **kwargs: Other keyword arguments for clients other than requests

Returns:

  • MonthlyUsageResponse: Named tuple that contains the usage metrics for a specified vector space and month.