morpheus_llm.service.vdb.kinetica_vector_db_service.KineticaVectorDBResourceService#
- class KineticaVectorDBResourceService(name, schema, client)[source]#
Bases:
VectorDBResourceServiceRepresents a service for managing resources in a Kinetica Vector Database.
- Parameters:
- namestr
Name of the Kinetica table. Must be an existing table
- schemastr
Name of the Kinetica schema. Must be an existing schema
- clientGPUdb instance
An instance of the GPUdb class for interaction with the Kinetica Vector Database.
Methods
count(**kwargs)Returns number of rows/entities.
delete(expr, **kwargs)Delete vectors from the Kinetica table using expressions.
delete_by_keys(keys, **kwargs)Not supported by Kinetica.
describe(**kwargs)Provides a description of the Kinetica table.
drop(**kwargs)Drop a Kinetica table.
insert(data, **kwargs)Insert data into the vector database.
insert_dataframe(df, **kwargs)Insert a dataframe entires into the vector database.
query(query, **kwargs)Query data in a table in the Kinetica database.
retrieve_by_keys(keys, **kwargs)Retrieve the inserted vectors using their primary keys.
similarity_search(embeddings[, k])Perform a similarity search within the Kinetica table.
similarity_search_by_vector(embedding, ...)Return docs most similar to embedding vector.
update(data, **kwargs)Update data in the Kinetica table.
similarity_search_with_score_by_vector
- count(**kwargs)[source]#
Returns number of rows/entities.
- Parameters:
- **kwargsdict[str, typing.Any]
Not used.
- Returns:
- int
Returns number of records in the Kinetica table.
- delete(expr, **kwargs)[source]#
Delete vectors from the Kinetica table using expressions.
- Parameters:
- exprstr
Delete expression.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict[str, typing.Any]
Returns result of the given keys that are deleted from the Kinetica table.
- delete_by_keys(keys, **kwargs)[source]#
Not supported by Kinetica.
- 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.
- describe(**kwargs)[source]#
Provides a description of the Kinetica table.
- Parameters:
- **kwargsdict[str, typing.Any]
Not used by Kinetica.
- Returns:
- dict
Returns response content as a dictionary.
- drop(**kwargs)[source]#
Drop a Kinetica table.
This function allows you to delete/drop a Kinetica table.
- Parameters:
- **kwargsdict
Options as accepted by
/clear/tableAPI of Kinetica.
- insert(data, **kwargs)[source]#
Insert data into the vector database.
- Parameters:
- datalist[list] | list[dict]
Data to be inserted into the Kinetica table.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to the vector database implementation.
- Returns:
- dict
Returns response content as a dictionary.
- insert_dataframe(df, **kwargs)[source]#
Insert a dataframe entires into the vector database.
- Parameters:
- dfDataFrameType
Dataframe to be inserted into the Kinetica table.
- **kwargsdict[str, typing.Any]
Not used by Kinetica.
- Returns:
- dict
Returns response content as a dictionary.
- query(query, **kwargs)[source]#
Query data in a table in the Kinetica database.
This method performs a search operation in the specified table in the Kinetica database.
- Parameters:
- querystr, optional
The search query, which is an SQL query.
- **kwargsdict
Additional keyword arguments for the search operation.
- Returns:
- typing.Any
The search result (a GPUdbSqlIterator object)
- Raises:
- GPUdbException
If an error occurs during the search operation.
- retrieve_by_keys(keys, **kwargs)[source]#
Retrieve the inserted vectors using their primary keys.
- Parameters:
- keysint | str | list
Primary keys to get vectors for. Depending on pk_field type it can be int or str or a list of either.
- **kwargsdict[str, typing.Any]
Additional keyword arguments for the retrieval operation.
Only valid keyword arguments are:
expression: [str] - The Kinetica expression to pass on to
get/records/by/keyoptions: dict - The
optionsdict accepted byget/records/by/key
- Returns:
- list[typing.Any]
Returns result rows of the given keys from the Kinetica table.
- async similarity_search(
- embeddings,
- k=4,
- **kwargs,
Perform a similarity search within the Kinetica table.
- 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 ‘list of dictionaries’ representing the results of the similarity search.
- similarity_search_by_vector(
- embedding,
- output_fields,
- k=4,
- kinetica_filter=None,
Return docs most similar to embedding vector.
- Args:
embedding: Embedding to look up documents similar to. output_fields: The fields to return in the query output k: Number of Documents to return. Defaults to 4. kinetica_filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
- Returns:
List of records most similar to the query vector.
- update(data, **kwargs)[source]#
Update data in the Kinetica table.
- Parameters:
- datalist[typing.Any]
Data to be updated in the Kinetica table. This is npt used by Kinetica. The required parameters are all passed in a keyword arguments.
- **kwargsdict[str, typing.Any]
Extra keyword arguments specific to Kinetica. The full explanation of each of these keyword arguments is available in the documentation of the API
/update/records.- Allowed keyword arguments:
options: dict[str, str] - options
expressions: [list] - expression used to filter records for update
new_value_maps: [list[dict]] | [dict] -
records_to_insert: list[] -
records_to_insert_str: list[] -
- Returns:
- dict[str, typing.Any]
Returns result of the updated operation stats.