record_definition Package
Modules
| vector_store_model_decorator | |
| vector_store_model_definition | |
| vector_store_model_protocols | |
| vector_store_record_fields | |
| vector_store_record_utils |
Classes
| VectorStoreRecordDataField |
Memory record data field. Note: This class is marked as 'experimental' and may change in the future. |
| VectorStoreRecordDefinition |
Memory record definition. Args: fields: The fields of the record. container_mode: Whether the record is in container mode. to_dict: The to_dict function, should take a record and return a list of dicts. from_dict: The from_dict function, should take a list of dicts and return a record. serialize: The serialize function, should take a record and return the type specific to a datastore. deserialize: The deserialize function, should take a type specific to a datastore and return a record. Note: This class is marked as 'experimental' and may change in the future. |
| VectorStoreRecordKeyField |
Memory record key field. Note: This class is marked as 'experimental' and may change in the future. |
| VectorStoreRecordUtils |
Helper class to easily add embeddings to a (set of) vector store record. Note: This class is marked as 'experimental' and may change in the future. Initializes the VectorStoreRecordUtils with a kernel. |
| VectorStoreRecordVectorField |
Memory record vector field. Most vectors stores use a list[float] as the data type for vectors. This is the default and all vector stores in SK use this internally. But in your class you may want to use a numpy array or some other optimized type, in order to support that, you can set the deserialize_function to a function that takes a list of floats and returns the optimized type, and then also supply a serialize_function that takes the optimized type and returns a list of floats. For instance for numpy, that would be serialize_function=np.ndarray.tolist and deserialize_function=np.array, (with import numpy as np at the top of your file). if you want to set it up with more specific options, use a lambda, a custom function or a partial. Args: property_type (str, optional): Property type. For vectors this should be the inner type of the vector. By default the vector will be a list of numbers. If you want to use a numpy array or some other optimized format, set the cast_function with a function that takes a list of floats and returns a numpy array.
Note: This class is marked as 'experimental' and may change in the future. |
Functions
vectorstoremodel
Returns the class as a vector store model.
This decorator makes a class a vector store model. There are three things being checked:
The class must have at least one field with a annotation,
of type VectorStoreRecordKeyField, VectorStoreRecordDataField or VectorStoreRecordVectorField.
The class must have exactly one field with the VectorStoreRecordKeyField annotation.
A field with multiple VectorStoreRecordKeyField annotations will be set to the first one found.
Optionally, when there are VectorStoreRecordDataFields that specify a embedding property name, there must be a corresponding VectorStoreRecordVectorField with the same name.
Args: cls: The class to be decorated.
Raises: VectorStoreModelException: If the class does not implement the serialize and deserialize methods. VectorStoreModelException: If there are no fields with a VectorStoreRecordField annotation. VectorStoreModelException: If there are fields with no name. VectorStoreModelException: If there is no key field. VectorStoreModelException: If there is a field with an embedding property name but no corresponding field. VectorStoreModelException: If there is a ndarray field without a serialize or deserialize function.
Note: This function is marked as 'experimental' and may change in the future.
vectorstoremodel(cls: Any | None = None)
Parameters
| Name | Description |
|---|---|
|
cls
|
Default value: None
|