morpheus.service.vdb.vector_db_service.VectorDBService

class VectorDBService[source]

Bases: abc.ABC

Class used for vectorstore specific implementation.

Methods

close() Close connection to the vector database.
count(name, **kwargs) Returns number of rows/entities in the given resource.
create(name[, overwrite]) Create resources in the vector database.
create_from_dataframe(name, df[, overwrite]) Create resources in the vector database.
delete(name, expr, **kwargs) Delete data in the vector database.
delete_by_keys(name, keys, **kwargs) Delete vectors by keys from the resource.
describe(name, **kwargs) Describe resource in the vector database.
drop(name, **kwargs) Drop resources from the vector database.
has_store_object(name) Check if a resource exists in the vector database.
insert(name, data, **kwargs) Insert data into the vector database.
insert_dataframe(name, df, **kwargs) Converts dataframe to rows and insert into the vector database resource.
list_store_objects(**kwargs) List existing resources in the vector database.
query(name, query, **kwargs) Query a resource in the vector database.
release_resource(name) Release a loaded resource from the memory.
retrieve_by_keys(name, keys, **kwargs) Retrieve the inserted vectors using keys from the resource.
similarity_search(name, **kwargs) Perform a similarity search within the vector database.
transform(data, **kwargs) Transform data according to the specific vector database implementation.
update(name, data, **kwargs) Update data in the vector database.
load_resource
abstract close()[source]

Close connection to the vector database.

abstract count(name, **kwargs)[source]

Returns number of rows/entities in the given resource.

Parameters
name

Name of the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
int

Returns number of rows/entities in the given resource.

abstract create(name, overwrite=False, **kwargs)[source]

Create resources in the vector database.

Parameters
name

Name of the resource.

overwrite

Whether to overwrite the resource if it already exists.

**kwargs

Extra keyword arguments specific to the vector database implementation.

abstract create_from_dataframe(name, df, overwrite=False, **kwargs)[source]

Create resources in the vector database.

Parameters
name

Name of the resource.

df

The dataframe to create the resource from.

overwrite

Whether to overwrite the resource if it already exists. Default is False.

**kwargs

Extra keyword arguments specific to the vector database implementation.

abstract delete(name, expr, **kwargs)[source]

Delete data in the vector database.

Parameters
name

Name of the resource.

expr

Delete expression.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
dict[str, typing.Any]

Returns result of the delete operation stats.

abstract delete_by_keys(name, keys, **kwargs)[source]

Delete vectors by keys from the resource.

Parameters
name

Name of the resource.

keys

Primary keys to delete vectors.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
typing.Any

Returns vectors of the given keys that are delete from the resource.

abstract describe(name, **kwargs)[source]

Describe resource in the vector database.

Parameters
name

Name of the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
dict

Returns resource information.

abstract drop(name, **kwargs)[source]

Drop resources from the vector database.

Parameters
name

Name of the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

abstract has_store_object(name)[source]

Check if a resource exists in the vector database.

Parameters
name

Name of the resource.

Returns
bool

Returns True if resource exists in the vector database, otherwise False.

abstract insert(name, data, **kwargs)[source]

Insert data into the vector database.

Parameters
name

Name of the resource.

data

Data to be inserted into the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
dict

Returns response content as a dictionary.

abstract insert_dataframe(name, df, **kwargs)[source]

Converts dataframe to rows and insert into the vector database resource.

Parameters
name

Name of the resource to be inserted.

df

Dataframe to be inserted.

**kwargs

Additional keyword arguments containing collection configuration.

Returns
dict

Returns response content as a dictionary.

Raises
RuntimeError

If the resource not exists exists.

abstract list_store_objects(**kwargs)[source]

List existing resources in the vector database.

Parameters
**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
list[str]

Returns available resouce names in the vector database.

abstract query(name, query, **kwargs)[source]

Query a resource in the vector database.

Parameters
name

Name of the resource.

query

Query to execute on the given resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
typing.Any

Returns search results.

abstract release_resource(name)[source]

Release a loaded resource from the memory.

Parameters
name

Name of the resource to release.

abstract retrieve_by_keys(name, keys, **kwargs)[source]

Retrieve the inserted vectors using keys from the resource.

Parameters
name

Name of the resource.

keys

Primary keys to get vectors.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
list[typing.Any]

Returns rows of the given keys that exists in the resource.

Perform a similarity search within the vector database.

Parameters
name

Name of the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
list[list[dict]]

Returns a list of lists, where each inner list contains dictionaries representing the results of the similarity search.

transform(data, **kwargs)[source]

Transform data according to the specific vector database implementation.

Parameters
data

Data to be updated in the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
typing.Any

Returns transformed data as per the implementation.

abstract update(name, data, **kwargs)[source]

Update data in the vector database.

Parameters
name

Name of the resource.

data

Data to be updated in the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
dict[str, typing.Any]

Returns result of the updated operation stats.

Previous morpheus.service.vdb.vector_db_service.VectorDBResourceService
Next morpheus.stages
© Copyright 2024, NVIDIA. Last updated on Apr 11, 2024.