MetadataSchema
MetadataSchema Objects
class MetadataSchema()
A class to manage the metadata schema for an organization.
Methods:
save() -> None Saves the metadata schema to the backend if it has been modified.
save
def save() -> None
Saves the metadata schema to the backend if changes have been made.
add_embedding
def add_embedding(k: str, *, size: int) -> None
Adds a new embedding to the metadata schema.
Arguments:
k : str The key under which the embedding will be stored in the schema. size : int The size of the embedding.
Raises:
MetadataSchemaError
If the key k
is already defined in the schema.
add_enum
def add_enum(k: str, *, values: Sequence[str]) -> None
Adds a new enum to the metadata schema.
Arguments:
k : str The key under which the embedding will be stored in the schema. values : Sequence[str] The set of values for the enum (min 1, max 256).
Raises:
MetadataSchemaError
If the key k
is already defined in the schema.
add_enum_options
def add_enum_options(k: str, *, values: Sequence[str]) -> None
Adds extra valid enum values to an existing enum schema.
Arguments:
k : str The key referencing the enum. values : Sequence[str] The set of new values to add to the enum (min 1, max 256).
Raises:
MetadataSchemaError
If the key k
is not defined in the schema or is not an enum.
add_scalar
def add_scalar(
k: str, *, data_type: Literal["boolean", "datetime", "number", "uuid",
"text", "varchar", "string", "long_string"]
) -> None
Sets a simple metadata type for a given key in the schema.
Arguments:
k : str The key for which the metadata type is being set. schema : Literal[ “boolean”, “datetime”, “number”, “uuid”, “text”, “varchar”, “string”, “long_string” ] The type of metadata to be associated with the key. Must be a valid identifier. “string” is an alias of “varchar” “long_string” is an alias of “text”
Raises:
MetadataSchemaError
If the key k
is already defined in the schema with a conflicting type.
delete_key
def delete_key(k: str) -> None
Delete a metadata key from the schema, this cannot be undone.
Arguments:
k : str The key for which the metadata type is being deleted.
Raises:
MetadataSchemaError
If the key k
is already deleted or not present in the schema
keys
def keys() -> Sequence[str]
Returns a sequence of all keys defined in the metadata schema.
Returns:
Sequence[str] A list of keys present in the metadata schema.
has_key
def has_key(k: str) -> bool
Check if any definition exists for a key.
Arguments:
k : str The key for which the metadata type is to be retrieved.
is_key_deleted
def is_key_deleted(k: str) -> bool
Check if the key is defined as deleted. (Tombstone type)
Arguments:
k : str The key for which the metadata type is to be retrieved.
get_key_type
def get_key_type(
k: str
) -> Union[Literal["boolean", "datetime", "uuid", "number", "varchar", "text",
"embedding", "enum"], None]
Retrieves the metadata type associated with a given key.
Arguments:
k : str The key for which the metadata type is to be retrieved.
Returns:
Literal[“boolean”, “datetime”, “uuid”, “number”, “varchar”, “text”, “embedding”, “enum”]
The metadata type associated with the key k
.
Raises:
MetadataSchemaError
If the key k
is not supported by the current SDK.
get_embedding_size
def get_embedding_size(k: str) -> int
Retrieves size associated with a given embedding.
Arguments:
k : str The key for which the metadata type is to be retrieved.
Returns:
int The size of the embedding
Raises:
MetadataSchemaError
If the key k
is not defined in the schema or is not an embedding
get_enum_options
def get_enum_options(k: str) -> Sequence[str]
Retrieves all values associated with a given enum.
Arguments:
k : str The key for which the metadata type is to be retrieved.
Returns:
Sequence[str] The list of all values associated with an enum type
Raises:
MetadataSchemaError
If the key k
is not defined in the schema or is not an enum
Was this page helpful?