AstraClient Class
AstraClient.
Note: This class is marked as 'experimental' and may change in the future.
Initializes a new instance of the AstraClient class.
Constructor
AstraClient(astra_id: str, astra_region: str, astra_application_token: str, keyspace_name: str, embedding_dim: int, similarity_function: str, session: ClientSession | None = None)
Parameters
| Name | Description |
|---|---|
|
astra_id
Required
|
|
|
astra_region
Required
|
|
|
astra_application_token
Required
|
|
|
keyspace_name
Required
|
|
|
embedding_dim
Required
|
|
|
similarity_function
Required
|
|
|
session
|
Default value: None
|
Methods
| create_collection |
Creates a new collection in the keyspace. |
| delete_collection |
Deletes a collection from the keyspace. |
| delete_documents |
Deletes documents from the collection. |
| find_collection |
Finds a collection in the keyspace. |
| find_collections |
Finds all collections in the keyspace. |
| find_documents |
Finds all documents in the collection. |
| insert_document |
Inserts a document into the collection. |
| insert_documents |
Inserts multiple documents into the collection. |
| update_document |
Updates a document in the collection. |
| update_documents |
Updates multiple documents in the collection. |
create_collection
Creates a new collection in the keyspace.
async create_collection(collection_name: str, embedding_dim: int | None = None, similarity_function: str | None = None)
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
embedding_dim
|
Default value: None
|
|
similarity_function
|
Default value: None
|
delete_collection
Deletes a collection from the keyspace.
async delete_collection(collection_name: str)
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
delete_documents
Deletes documents from the collection.
async delete_documents(collection_name: str, filter: dict) -> int
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
filter
Required
|
|
find_collection
Finds a collection in the keyspace.
async find_collection(collection_name: str)
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
find_collections
Finds all collections in the keyspace.
async find_collections(include_detail: bool = True)
Parameters
| Name | Description |
|---|---|
|
include_detail
|
Default value: True
|
find_documents
Finds all documents in the collection.
async find_documents(collection_name: str, filter: dict | None = None, vector: list[float] | None = None, limit: int | None = None, include_vector: bool | None = None, include_similarity: bool | None = None) -> list[dict]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
filter
|
Default value: None
|
|
vector
|
Default value: None
|
|
limit
|
Default value: None
|
|
include_vector
|
Default value: None
|
|
include_similarity
|
Default value: None
|
insert_document
Inserts a document into the collection.
async insert_document(collection_name: str, document: dict) -> str
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
document
Required
|
|
insert_documents
Inserts multiple documents into the collection.
async insert_documents(collection_name: str, documents: list[dict]) -> list[str]
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
documents
Required
|
|
update_document
Updates a document in the collection.
async update_document(collection_name: str, filter: dict, update: dict, upsert: bool = True) -> dict
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
filter
Required
|
|
|
update
Required
|
|
|
upsert
|
Default value: True
|
update_documents
Updates multiple documents in the collection.
async update_documents(collection_name: str, filter: dict, update: dict)
Parameters
| Name | Description |
|---|---|
|
collection_name
Required
|
|
|
filter
Required
|
|
|
update
Required
|
|
Attributes
is_experimental
is_experimental = True
stage_status
stage_status = 'experimental'