astradb_vector_store_driver
AstraDbVectorStoreDriver
Bases: BaseVectorStoreDriver
A Vector Store Driver for Astra DB.
Attributes:
Name | Type | Description |
---|---|---|
embedding_driver |
a |
|
api_endpoint |
str
|
the "API Endpoint" for the Astra DB instance. |
token |
Optional[str | TokenProvider]
|
a Database Token ("AstraCS:...") secret to access Astra DB. An instance of |
collection_name |
str
|
the name of the collection on Astra DB. The collection must have been created beforehand, and support vectors with a vector dimension matching the embeddings being used by this driver. |
environment |
Optional[str]
|
the environment ("prod", "hcd", ...) hosting the target Data API.
It can be omitted for production Astra DB targets. See |
astra_db_namespace |
Optional[str]
|
optional specification of the namespace (in the Astra database) for the data. Note: not to be confused with the "namespace" mentioned elsewhere, which is a grouping within this vector store. |
caller_name |
str
|
the name of the caller for the Astra DB client. Defaults to "griptape". |
client |
DataAPIClient
|
an instance of |
collection |
Collection
|
an instance of |
Source code in griptape/drivers/vector/astradb_vector_store_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
api_endpoint: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
astra_db_namespace: Optional[str] = field(default=None, kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
caller_name: str = field(default='griptape', kw_only=True, metadata={'serializable': False})
class-attribute
instance-attribute
collection_name: str = field(kw_only=True, metadata={'serializable': True})
class-attribute
instance-attribute
environment: Optional[str] = field(kw_only=True, default=None, metadata={'serializable': True})
class-attribute
instance-attribute
token: Optional[str | astrapy.authentication.TokenProvider] = field(kw_only=True, default=None, metadata={'serializable': False})
class-attribute
instance-attribute
client()
collection()
delete_vector(vector_id)
Delete a vector from Astra DB store.
The method succeeds regardless of whether a vector with the provided ID was actually stored or not in the first place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id |
str
|
ID of the vector to delete. |
required |
Source code in griptape/drivers/vector/astradb_vector_store_driver.py
load_entries(*, namespace=None)
Load entries from the Astra DB store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
namespace |
Optional[str]
|
a namespace, within the vector store, to constrain the search. |
None
|
Returns:
Type | Description |
---|---|
list[Entry]
|
A list of vector ( |
Source code in griptape/drivers/vector/astradb_vector_store_driver.py
load_entry(vector_id, *, namespace=None)
Load a single vector entry from the Astra DB store given its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id |
str
|
the ID of the required vector. |
required |
namespace |
Optional[str]
|
a namespace, within the vector store, to constrain the search. |
None
|
Returns:
Type | Description |
---|---|
Optional[Entry]
|
The vector entry (a |
Source code in griptape/drivers/vector/astradb_vector_store_driver.py
query(query, *, count=None, namespace=None, include_vectors=False, **kwargs)
Run a similarity search on the Astra DB store, based on a query string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
the query string. |
required |
count |
Optional[int]
|
the maximum number of results to return. If omitted, defaults will apply. |
None
|
namespace |
Optional[str]
|
the namespace to filter results by. |
None
|
include_vectors |
bool
|
whether to include vector data in the results. |
False
|
kwargs |
Any
|
additional keyword arguments. Currently only the free-form dict |
{}
|
Returns:
Type | Description |
---|---|
list[Entry]
|
A list of vector ( |
list[Entry]
|
with their |
Source code in griptape/drivers/vector/astradb_vector_store_driver.py
upsert_vector(vector, *, vector_id=None, namespace=None, meta=None, **kwargs)
Write a vector to the Astra DB store.
In case the provided ID exists already, an overwrite will take place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector |
list[float]
|
the vector to be upserted. |
required |
vector_id |
Optional[str]
|
the ID for the vector to store. If omitted, a server-provided new ID will be employed. |
None
|
namespace |
Optional[str]
|
a namespace (a grouping within the vector store) to assign the vector to. |
None
|
meta |
Optional[dict]
|
a metadata dictionary associated to the vector. |
None
|
kwargs |
Any
|
additional keyword arguments. Currently none is used: if they are passed, they will be ignored with a warning. |
{}
|
Returns:
Type | Description |
---|---|
str
|
the ID of the written vector (str). |