relevanceai.client.client#

Relevance AI’s base Client class - primarily used to login and access the Dataset class or ClusterOps class. The recomended way to log in is using: .. code-block:: from relevanceai import Client client = Client() client.list_datasets() If the user already knows their project and API key, they can log in this way:

from relevanceai import Client
project = ""
api_key = ""
client = Client(project=project, api_key=api_key, firebase_uid=firebase_uid)
client.list_datasets()

If you need to change your token, simply run:

from relevanceai import Client
client = Client(token="...")

Module Contents#

class relevanceai.client.client.Client(token: Optional[str] = None, authenticate: bool = True)#

Batch API client

docs#
check_auth(self)#
create_dataset(self, dataset_id: str, schema: Optional[Dict] = None)#

A dataset can store documents to be searched, retrieved, filtered and aggregated (similar to Collections in MongoDB, Tables in SQL, Indexes in ElasticSearch). A powerful and core feature of RelevanceAI is that you can store both your metadata and vectors in the same document. When specifying the schema of a dataset and inserting your own vector use the suffix (ends with) “_vector_” for the field name, and specify the length of the vector in dataset_schema.

For example:

These are the field types supported in our datasets: [“text”, “numeric”, “date”, “dict”, “chunks”, “vector”, “chunkvector”].

For example:

{
    "product_text_description" : "text",
    "price" : "numeric",
    "created_date" : "date",
    "product_texts_chunk_": "chunks",
    "product_text_chunkvector_" : 1024
}

You don’t have to specify the schema of every single field when creating a dataset, as RelevanceAI will automatically detect the appropriate data type for each field (vectors will be automatically identified by its “_vector_” suffix). Infact you also don’t always have to use this endpoint to create a dataset as /datasets/bulk_insert will infer and create the dataset and schema as you insert new documents.

Note

  • A dataset name/id can only contain undercase letters, dash, underscore and numbers.

  • “_id” is reserved as the key and id of a document.

  • Once a schema is set for a dataset it cannot be altered. If it has to be altered, utlise the copy dataset endpoint.

Parameters
  • dataset_id (str) – The unique name of your dataset

  • schema (dict) – Schema for specifying the field that are vectors and its length

Example

from relevanceai import Client
client = Client()
client.create_dataset("sample_dataset_id")
list_datasets(self, verbose=False)#

List Datasets

Example

from relevanceai import Client
client = Client()
client.list_datasets()
delete_dataset(self, dataset_id)#

Delete a dataset

Parameters

dataset_id (str) – The ID of a dataset

Example

from relevanceai import Client
client = Client()
client.delete_dataset("sample_dataset_id")
Dataset(self, dataset_id: str, fields: Optional[relevanceai.client.helpers.List[str]] = None, image_fields: Optional[relevanceai.client.helpers.List[str]] = None, audio_fields: Optional[relevanceai.client.helpers.List[str]] = None, highlight_fields: Optional[Dict[str, relevanceai.client.helpers.List]] = None, text_fields: Optional[relevanceai.client.helpers.List[str]] = None)#
send_dataset(self, dataset_id: str, receiver_project: str, receiver_api_key: str)#

Send an individual a dataset. For this, you must know their API key.

Parameters
  • dataset_id (str) – The name of the dataset

  • receiver_project (str) – The project name that will receive the dataset

  • receiver_api_key (str) – The project API key that will receive the dataset

Example

client = Client()
client.send_dataset(
    dataset_id="research",
    receiver_project="...",
    receiver_api_key="..."
)
receive_dataset(self, dataset_id: str, sender_project: str, sender_api_key: str)#

Recieve an individual a dataset.

Example

>>> client = Client()
>>> client.admin.receive_dataset(
    dataset_id="research",
    sender_project="...",
    sender_api_key="..."
)
Parameters
  • dataset_id (str) – The name of the dataset

  • sender_project (str) – The project name that will send the dataset

  • sender_api_key (str) – The project API key that will send the dataset

clone_dataset(self, source_dataset_id: str, new_dataset_id: Optional[str] = None, source_project: Optional[str] = None, source_api_key: Optional[str] = None, project: Optional[str] = None, api_key: Optional[str] = None)#

Clone a dataset from another user’s projects into your project.

Parameters
  • dataset_id – The dataset to copy

  • source_dataset_id – The original dataset

  • source_project – The original project to copy from

  • source_api_key – The original API key of the project

  • project – The original project

  • api_key – The original API key

Example

client = Client()
client.clone_dataset(
    dataset_id="research",
    source_project="...",
    source_api_key="..."
)
property references(self)#
search_datasets(self, query: str)#

Search through your datasets.

disable_analytics_tracking(self)#

Disable analytics tracking if you would prefer not to send usage data to improve the product. Analytics allows us to improve your experience by examining the most popular flows, dedicating more resources to popular product features and improve user experience.