VectorIndexes

Note

The VectorIndexes class primarily focuses on the creation of an asset, assuming the vector index already exists externally. Additional steps (such as parsing documents, splitting them into chunks, creating embeddings, and uploading them to the external vector database) are required to ensure functionality in the absence of aforementioned vector index in the external vector store.

class ibm_watsonx_ai.foundation_models.utils.VectorIndexes(api_client)[source]

Bases: WMLResource

Initiate the Vector Indexes class.

Parameters:

api_client (APIClient) – instance of APIClient with default project_id set

Example:

vector_indexes = VectorIndexes(api_client=api_client)
create(name, description=None, store=None, settings=None, tags=None, sample_questions=None, **kwargs)[source]

Creates a new Vector Index Asset.

Parameters:
  • name (str) – name for vector index asset

  • description (str | None) – optional description for the vector index asset, defaults to None

  • store (dict | None, optional) – store parameters, defaults to None

  • settings (dict | None, optional) – settings of vector index, defaults to None

  • tags (list[str] | None, optional) – tags attached to the asset, defaults to None

  • sample_questions (list[str] | None, optional) – sample asked questions, defaults to None

  • data_assets (list[str] | None, optional) – IDs of the associated data assets used in the vector index, defaults to None

  • build (dict | None, optional) – the associated build to process the data for external vector stores, defaults to None

  • status (str | None, optional) – the status of the vector index, defaults to None

Returns:

metadata of the created Vector Index Asset

Return type:

dict

Example:

params = dict(
    name="test_sdk_vector_index",
    description="Description",
    settings={
        "embedding_model_id": "<model_id>",
        "top_k": 1,
        "schema_fields": {"text": "text"},
    },
    store={
        "type": "watsonx.data",
        "connection_id": "<connection_id>",
        "index": "<index_name>",
        "new_index": False,
        "database": "default",
    },
    tags=["test_tag"],
    sample_questions=["Sample question"],
    status="ready",
)

vector_index_details = vector_indexes.create(**params)
delete(index_id)[source]

Delete a vector index with the given id.

Parameters:

index_id (str) – Vector Index id

Returns:

“SUCCESS” if delete successfully

Return type:

str

Example:

vector_indexes.delete(index_id)
get_details(index_id)[source]

Get details of Vector Index Asset with given index_id.

Parameters:

index_id (str) – Vector Index id

Returns:

details of Vector Index Asset with given index_id

Return type:

dict

Example:

vector_indexes.get_details(index_id)
list(*, limit=None)[source]

List all available Vector Index Assets in the DataFrame format.

Parameters:

limit (int, optional) – limit number of fetched records, defaults to None.

Returns:

DataFrame of fundamental properties of available Vector Index Assets.

Return type:

pandas.core.frame.DataFrame

Example:

vector_indexes.list(limit=5)    # list of 5 recently created vector index assets
update(index_id, name=None, description=None, store=None, settings=None, tags=None, sample_questions=None, **kwargs)[source]

Update a Vector Index Asset with the given id.

Parameters:
  • index_id (str) – Vector Index ids

  • name (str | None) – name for vector index asset, defaults to None

  • description (str | None) – optional description for the vector index asset, defaults to None

  • store (dict | None, optional) – store parameters, defaults to None

  • settings (dict | None, optional) – settings of vector index, defaults to None

  • tags (list[str] | None, optional) – tags attached to the asset, defaults to None

  • sample_questions (list[str] | None, optional) – sample asked questions, defaults to None

  • data_assets (list[str] | None, optional) – IDs of the associated data assets used in the vector index, defaults to None

  • build (dict | None, optional) – the associated build to process the data for external vector stores, defaults to None

  • status (str | None, optional) – the status of the vector index, defaults to None

Returns:

metadata of the created Vector Index Asset

Return type:

dict

Example:

vector_indexes.update(index_id, name="new_name", description="new_description")