@ -59,6 +59,7 @@ class Cassandra(VectorStore):
* ,
body_index_options : Optional [ List [ Tuple [ str , Any ] ] ] = None ,
setup_mode : SetupMode = SetupMode . SYNC ,
metadata_indexing : Union [ Tuple [ str , Iterable [ str ] ] , str ] = " all " ,
) - > None :
""" Apache Cassandra(R) for vector-store workloads.
@ -83,13 +84,24 @@ class Cassandra(VectorStore):
embedding : Embedding function to use .
session : Cassandra driver session . If not provided , it is resolved from
cassio .
keyspace : Cassandra key space. If not provided , it is resolved from cassio .
keyspace : Cassandra key space. If not provided , it is resolved from cassio .
table_name : Cassandra table ( required ) .
ttl_seconds : Optional time - to - live for the added texts .
body_index_options : Optional options used to create the body index .
Eg . body_index_options = [ cassio . table . cql . STANDARD_ANALYZER ]
setup_mode : mode used to create the Cassandra table ( SYNC ,
ASYNC or OFF ) .
metadata_indexing : Optional specification of a metadata indexing policy ,
i . e . to fine - tune which of the metadata fields are indexed .
It can be a string ( " all " or " none " ) , or a 2 - tuple . The following
means that all fields except ' f1 ' , ' f2 ' . . . are NOT indexed :
metadata_indexing = ( " allowlist " , [ " f1 " , " f2 " , . . . ] )
The following means all fields EXCEPT ' g1 ' , ' g2 ' , . . . are indexed :
metadata_indexing ( " denylist " , [ " g1 " , " g2 " , . . . ] )
The default is to index every metadata field .
Note : if you plan to have massive unique text metadata entries ,
consider not indexing them for performance
( and to overcome max - length limitations ) .
"""
try :
from cassio . table import MetadataVectorCassandraTable
@ -125,7 +137,7 @@ class Cassandra(VectorStore):
keyspace = keyspace ,
table = table_name ,
vector_dimension = embedding_dimension ,
metadata_indexing = " all " ,
metadata_indexing = metadata_indexing ,
primary_key_type = " TEXT " ,
skip_provisioning = setup_mode == SetupMode . OFF ,
* * kwargs ,
@ -885,6 +897,7 @@ class Cassandra(VectorStore):
batch_size : int = 16 ,
ttl_seconds : Optional [ int ] = None ,
body_index_options : Optional [ List [ Tuple [ str , Any ] ] ] = None ,
metadata_indexing : Union [ Tuple [ str , Iterable [ str ] ] , str ] = " all " ,
* * kwargs : Any ,
) - > CVST :
""" Create a Cassandra vectorstore from raw texts.
@ -915,6 +928,7 @@ class Cassandra(VectorStore):
table_name = table_name ,
ttl_seconds = ttl_seconds ,
body_index_options = body_index_options ,
metadata_indexing = metadata_indexing ,
)
store . add_texts (
texts = texts , metadatas = metadatas , ids = ids , batch_size = batch_size
@ -935,6 +949,7 @@ class Cassandra(VectorStore):
concurrency : int = 16 ,
ttl_seconds : Optional [ int ] = None ,
body_index_options : Optional [ List [ Tuple [ str , Any ] ] ] = None ,
metadata_indexing : Union [ Tuple [ str , Iterable [ str ] ] , str ] = " all " ,
* * kwargs : Any ,
) - > CVST :
""" Create a Cassandra vectorstore from raw texts.
@ -966,6 +981,7 @@ class Cassandra(VectorStore):
ttl_seconds = ttl_seconds ,
setup_mode = SetupMode . ASYNC ,
body_index_options = body_index_options ,
metadata_indexing = metadata_indexing ,
)
await store . aadd_texts (
texts = texts , metadatas = metadatas , ids = ids , concurrency = concurrency
@ -985,6 +1001,7 @@ class Cassandra(VectorStore):
batch_size : int = 16 ,
ttl_seconds : Optional [ int ] = None ,
body_index_options : Optional [ List [ Tuple [ str , Any ] ] ] = None ,
metadata_indexing : Union [ Tuple [ str , Iterable [ str ] ] , str ] = " all " ,
* * kwargs : Any ,
) - > CVST :
""" Create a Cassandra vectorstore from a document list.
@ -1020,6 +1037,7 @@ class Cassandra(VectorStore):
batch_size = batch_size ,
ttl_seconds = ttl_seconds ,
body_index_options = body_index_options ,
metadata_indexing = metadata_indexing ,
* * kwargs ,
)
@ -1036,6 +1054,7 @@ class Cassandra(VectorStore):
concurrency : int = 16 ,
ttl_seconds : Optional [ int ] = None ,
body_index_options : Optional [ List [ Tuple [ str , Any ] ] ] = None ,
metadata_indexing : Union [ Tuple [ str , Iterable [ str ] ] , str ] = " all " ,
* * kwargs : Any ,
) - > CVST :
""" Create a Cassandra vectorstore from a document list.
@ -1071,6 +1090,7 @@ class Cassandra(VectorStore):
concurrency = concurrency ,
ttl_seconds = ttl_seconds ,
body_index_options = body_index_options ,
metadata_indexing = metadata_indexing ,
* * kwargs ,
)