morpheus.service.vdb.vector_db_service.VectorDBService
- class VectorDBService[source]
Bases:
<a href="https://docs.python.org/3/library/abc.html#abc.ABC">abc.ABC</a>
Class used for vectorstore specific implementation.
Methods
<a href="#morpheus.service.vdb.vector_db_service.VectorDBService.close">close</a>
()Close connection to the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.count">count</a>
(name, **kwargs)Returns number of rows/entities in the given resource. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.create">create</a>
(name[, overwrite])Create resources in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.create_from_dataframe">create_from_dataframe</a>
(name, df[, overwrite])Create resources in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.delete">delete</a>
(name, expr, **kwargs)Delete data in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.delete_by_keys">delete_by_keys</a>
(name, keys, **kwargs)Delete vectors by keys from the resource. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.describe">describe</a>
(name, **kwargs)Describe resource in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.drop">drop</a>
(name, **kwargs)Drop resources from the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.has_store_object">has_store_object</a>
(name)Check if a resource exists in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.insert">insert</a>
(name, data, **kwargs)Insert data into the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.insert_dataframe">insert_dataframe</a>
(name, df, **kwargs)Converts dataframe to rows and insert into the vector database resource. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.list_store_objects">list_store_objects</a>
(**kwargs)List existing resources in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.query">query</a>
(name, query, **kwargs)Query a resource in the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.release_resource">release_resource</a>
(name)Release a loaded resource from the memory. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.retrieve_by_keys">retrieve_by_keys</a>
(name, keys, **kwargs)Retrieve the inserted vectors using keys from the resource. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.similarity_search">similarity_search</a>
(name, **kwargs)Perform a similarity search within the vector database. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.transform">transform</a>
(data, **kwargs)Transform data according to the specific vector database implementation. <a href="#morpheus.service.vdb.vector_db_service.VectorDBService.update">update</a>
(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
- **kwargs
Name of the resource.
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
- overwrite
- **kwargs
Name of the resource.
Whether to overwrite the resource if it already exists.
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
- df
- overwrite
- **kwargs
Name of the resource.
The dataframe to create the resource from.
Whether to overwrite the resource if it already exists. Default is False.
Extra keyword arguments specific to the vector database implementation.
- abstract delete(name, expr, **kwargs)[source]
Delete data in the vector database.
- Parameters
- name
- expr
- **kwargs
Name of the resource.
Delete expression.
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
- keys
- **kwargs
Name of the resource.
Primary keys to delete vectors.
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
- **kwargs
Name of the resource.
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
- **kwargs
Name of the resource.
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
- data
- **kwargs
Name of the resource.
Data to be inserted into the resource.
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
- df
- **kwargs
Name of the resource to be inserted.
Dataframe to be inserted.
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
- query
- **kwargs
Name of the resource.
Query to execute on the given resource.
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
- keys
- **kwargs
Name of the resource.
Primary keys to get vectors.
Extra keyword arguments specific to the vector database implementation.
- Returns
- list[typing.Any]
Returns rows of the given keys that exists in the resource.
- abstract async similarity_search(name, **kwargs)[source]
Perform a similarity search within the vector database.
- Parameters
- name
- **kwargs
Name of the resource.
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
- **kwargs
Data to be updated in the resource.
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
- data
- **kwargs
Name of the resource.
Data to be updated in the resource.
Extra keyword arguments specific to the vector database implementation.
- Returns
- dict[str, typing.Any]
Returns result of the updated operation stats.