Vectors Class#

class Vectors(name: str, auth_key: str | None = None, environment: str = 'default', env_var: str = 'JAI_AUTH', verbose: int = 1, safe_mode: bool = False)#

Vectors task class.

An authorization key is needed to use the Jai API.

Parameters:
  • name (str) – String with the name of a database in your JAI environment.

  • environment (str) – Jai environment id or name to use. Defaults to “default”

  • env_var (str) – The environment variable that contains the JAI authentication token. Defaults to “JAI_AUTH”.

  • verbose (int) – The level of verbosity. Defaults to 1.

  • safe_mode (bool) – When safe_mode is True, responses from Jai API are validated. If the validation fails, the current version you are using is probably incompatible with the current API version. We advise updating it to a newer version. If the problem persists and you are on the latest SDK version, please open an issue so we can work on a fix. Defaults to False.

Example

>>> from jai import Vectors
...
>>> vectors = Vectors(name)
property db_type#
delete_database()#

Delete a database and everything that goes with it (I thank you all).

Parameters:

name (str) – String with the name of a database in your JAI environment.

Returns:

response – Dictionary with the API response.

Return type:

dict

Example

>>> from jai import Vectors
...
>>> vectors = Vectors(name)
>>> vectors.delete_database()
delete_raw_data()#

Delete raw data. It is good practice to do this after training a model.

Returns:

response – Dictionary with the API response.

Return type:

dict

Example

>>> from jai import Vectors
...
>>> vectors = Vectors(name)
>>> vectors.delete_raw_data()
describe()#

Get the database hyperparameters and parameters of a specific database.

Parameters:

name (str) – String with the name of a database in your JAI environment.

Returns:

response – Dictionary with database description.

Return type:

dict

insert_vectors(data, batch_size: int = 1048576, overwrite: bool = False, append: bool = False)#

Insert raw vectors database directly into JAI without any need of fit.

Parameters:
  • data (pd.DataFrame, pd.Series or np.ndarray) – Database data to be inserted.

  • name (str) – String with the name of a database in your JAI environment.

  • batch_size (int, optional) – Size of batch to send the data. Defaults to 2**20 (1.048.576).

  • overwrite (bool, optional) – If True, then the vector database is always recriated. Default is False.

  • append (bool, optional) – If True, then the inserted data will be added to the existent database. Default is False.

Returns:

insert_responses – Dictionary of responses for each batch. Each response contains information of whether or not that particular batch was successfully inserted.

Return type:

dict

Example

>>> from jai import Vectors
...
>>> vectors = Vectors(name)
>>> vectors.insert_vectors(data)
is_valid()#

Check if a given name is a valid database name (i.e., if it is in your environment).

Returns:

response – True if name is in your environment. False, otherwise.

Return type:

bool

property name#
property url#

Get name and type of each database in your environment.