morpheus_llm.service.vdb.vector_db_service.VectorDBResourceService#
- class VectorDBResourceService[source]#
Bases:
ABCAbstract base class for a Vector Database Resource Service.
Methods
count(**kwargs)Returns number of rows/entities in the given resource.
delete(expr, **kwargs)Delete data in the vector database.
delete_by_keys(keys, **kwargs)Delete vectors by keys from the resource.
describe(**kwargs)Provide a description of the vector database.
insert(data, **kwargs)Insert data into the vector database.
insert_dataframe(df, **kwargs)Insert a dataframe into the vector database.
retrieve_by_keys(keys, **kwargs)Retrieve the inserted vectors using keys from the resource.
similarity_search(embeddings[, k])Perform a similarity search within the vector database.
update(data, **kwargs)Update data in the vector database.
- abstractmethod count(**kwargs)[source]#
Returns number of rows/entities in the given resource.
- Parameters:
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- int
Returns number of rows/entities in the given resource.
- abstractmethod delete(expr, **kwargs)[source]#
Delete data in the vector database.
- Parameters:
- exprtyping.Any
Delete expression.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict[str, typing.Any]
Returns result of the delete operation stats.
- abstractmethod delete_by_keys(keys, **kwargs)[source]#
Delete vectors by keys from the resource.
- Parameters:
- keysint | str | list
Primary keys to delete vectors.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- typing.Any
Returns vectors of the given keys that are delete from the resource.
- abstractmethod describe(**kwargs)[source]#
Provide a description of the vector database.
- Parameters:
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict
Returns response content as a dictionary.
- abstractmethod insert(data, **kwargs)[source]#
Insert data into the vector database.
- Parameters:
- datalist[list] | list[dict]
Data to be inserted into the resource.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict
Returns response content as a dictionary.
- abstractmethod insert_dataframe(df, **kwargs)[source]#
Insert a dataframe into the vector database.
- Parameters:
- dfDataFrameType
Dataframe to be inserted into the resource.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict
Returns response content as a dictionary.
- abstractmethod retrieve_by_keys(keys, **kwargs)[source]#
Retrieve the inserted vectors using keys from the resource.
- Parameters:
- keystyping.Any
Primary keys to get vectors.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- list[typing.Any]
Returns rows of the given keys that exists in the resource.
- abstractmethod async similarity_search(embeddings, k=4, **kwargs)[source]#
Perform a similarity search within the vector database.
- Parameters:
- embeddingslist[list[float]]
Embeddings for which to perform the similarity search.
- kint, optional
The number of nearest neighbors to return, by default 4.
- **kwargsdict[str, typing.Any]
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.
- abstractmethod update(data, **kwargs)[source]#
Update data in the vector database.
- Parameters:
- datalist[typing.Any]
Data to be updated in the resource.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict[str, typing.Any]
Returns result of the updated operation stats.