Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
main
====
CollectionDefinition fluent interface: renamed all `set_*` methods to `with_*` (e.g., `set_vector_dimension` → `with_vector_dimension`):
- This better conveys the immutable builder pattern (methods return new objects rather than mutating in place)
- Old `set_*` methods remain as deprecated aliases (deprecated in 2.1.0, will be removed in 3.0.0)
- Affected methods: `with_indexing`, `with_default_id`, `with_vector_dimension`, `with_vector_metric`, `with_vector_source_model`, `with_vector_service`, `with_rerank`, `with_lexical`
Supported Python versions are now 3.9 to 3.14:
- extend to 3.13 and 3.14
- removal of Python 3.8 [Breaking change w.r.t. 2.1]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ my_collection = my_database.create_collection(
"dreams_collection",
definition=(
CollectionDefinition.builder()
.set_vector_dimension(3)
.set_vector_metric(VectorMetric.COSINE)
.with_vector_dimension(3)
.with_vector_metric(VectorMetric.COSINE)
.build()
)
)
Expand Down Expand Up @@ -104,7 +104,7 @@ my_collection = database.create_collection(
"my_vectorize_collection",
definition=(
CollectionDefinition.builder()
.set_vector_service(
.with_vector_service(
provider="example_vendor",
model_name="embedding_model_name",
authentication={"providerKey": "<STORED_API_KEY_NAME>"} # if needed
Expand Down Expand Up @@ -651,7 +651,7 @@ my_database = my_client.get_database(

my_collection = my_database.create_collection(
"ecommerce",
definition=CollectionDefinition.builder().set_default_id(
definition=CollectionDefinition.builder().with_default_id(
DefaultIdType.UUIDV6
).build(),
)
Expand Down
6 changes: 3 additions & 3 deletions astrapy/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def create_database(
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... )
... )
Expand Down Expand Up @@ -1794,7 +1794,7 @@ def get_database(
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... )
... )
Expand Down Expand Up @@ -1920,7 +1920,7 @@ def get_async_database(
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... )
... )
Expand Down
6 changes: 3 additions & 3 deletions astrapy/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class EmbeddingAPIKeyHeaderProvider(EmbeddingHeadersProvider):
... "vectorize_aws_collection",
... definition=(
... CollectionDefinition.builder()
... .set_vector_service(service_options)
... .with_vector_service(service_options)
... .build()
... ),
... embedding_api_key=my_emb_api_key,
Expand Down Expand Up @@ -393,7 +393,7 @@ class AWSEmbeddingHeadersProvider(EmbeddingHeadersProvider):
... "vectorize_aws_collection",
... definition=(
... CollectionDefinition.builder()
... .set_vector_service(service_options)
... .with_vector_service(service_options)
... .build()
... ),
... embedding_api_key=my_aws_emb_api_key,
Expand Down Expand Up @@ -465,7 +465,7 @@ class RerankingAPIKeyHeaderProvider(RerankingHeadersProvider):
... "my_reranking_collection",
... definition=(
... CollectionDefinition.builder()
... .set_rerank(CollectionRerankOptions(service=service_options))
... .with_rerank(CollectionRerankOptions(service=service_options))
... .build()
... ),
... reranking_api_key=my_rrk_api_key,
Expand Down
6 changes: 3 additions & 3 deletions astrapy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class DataAPIClient:
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... ),
... )
Expand Down Expand Up @@ -244,7 +244,7 @@ def get_database(
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... ),
... )
Expand Down Expand Up @@ -340,7 +340,7 @@ def get_async_database(
... "movies",
... definition=(
... CollectionDefinition.builder()
... .set_vector_dimension(2)
... .with_vector_dimension(2)
... .build()
... )
... )
Expand Down
20 changes: 10 additions & 10 deletions astrapy/data/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ class Collection(Generic[DOC]):
>>>
>>> collection_definition = (
... CollectionDefinition.builder()
... .set_vector_dimension(3)
... .set_vector_metric(VectorMetric.DOT_PRODUCT)
... .set_indexing("deny", ["annotations", "logs"])
... .with_vector_dimension(3)
... .with_vector_metric(VectorMetric.DOT_PRODUCT)
... .with_indexing("deny", ["annotations", "logs"])
... .build()
... )
>>> my_collection = database.create_collection(
Expand Down Expand Up @@ -212,7 +212,7 @@ class Collection(Generic[DOC]):
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
>>> collection_definition_vz1 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... )
Expand All @@ -228,7 +228,7 @@ class Collection(Generic[DOC]):
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
>>> collection_definition_vz2 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... authentication={
Expand Down Expand Up @@ -3132,9 +3132,9 @@ class AsyncCollection(Generic[DOC]):
>>>
>>> collection_definition = (
... CollectionDefinition.builder()
... .set_vector_dimension(3)
... .set_vector_metric(VectorMetric.DOT_PRODUCT)
... .set_indexing("deny", ["annotations", "logs"])
... .with_vector_dimension(3)
... .with_vector_metric(VectorMetric.DOT_PRODUCT)
... .with_indexing("deny", ["annotations", "logs"])
... .build()
... )
>>> my_collection = await async_database.create_collection(
Expand Down Expand Up @@ -3183,7 +3183,7 @@ class AsyncCollection(Generic[DOC]):
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
>>> collection_definition_vz1 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... )
Expand All @@ -3199,7 +3199,7 @@ class AsyncCollection(Generic[DOC]):
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
>>> collection_definition_vz2 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... authentication={
Expand Down
20 changes: 10 additions & 10 deletions astrapy/data/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,9 @@ def create_collection(
>>>
>>> collection_definition = (
... CollectionDefinition.builder()
... .set_vector_dimension(3)
... .set_vector_metric(VectorMetric.DOT_PRODUCT)
... .set_indexing("deny", ["annotations", "logs"])
... .with_vector_dimension(3)
... .with_vector_metric(VectorMetric.DOT_PRODUCT)
... .with_indexing("deny", ["annotations", "logs"])
... .build()
... )
>>> my_collection = database.create_collection(
Expand Down Expand Up @@ -769,7 +769,7 @@ def create_collection(
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
>>> collection_definition_vz1 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... )
Expand All @@ -785,7 +785,7 @@ def create_collection(
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
>>> collection_definition_vz2 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... authentication={
Expand Down Expand Up @@ -2973,9 +2973,9 @@ async def create_collection(
>>>
>>> collection_definition = (
... CollectionDefinition.builder()
... .set_vector_dimension(3)
... .set_vector_metric(VectorMetric.DOT_PRODUCT)
... .set_indexing("deny", ["annotations", "logs"])
... .with_vector_dimension(3)
... .with_vector_metric(VectorMetric.DOT_PRODUCT)
... .with_indexing("deny", ["annotations", "logs"])
... .build()
... )
>>> my_collection = asyncio.run(async_database.create_collection(
Expand Down Expand Up @@ -3019,7 +3019,7 @@ async def create_collection(
>>> # Create a collection with 'vectorize' and on-the-fly authentication (by headers)
>>> collection_definition_vz1 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... )
Expand All @@ -3035,7 +3035,7 @@ async def create_collection(
>>> # Create a 'vectorize' collection, its secret pre-stored on DB as 'EMB_AUTH_KEY'
>>> collection_definition_vz2 = (
... CollectionDefinition.builder()
... .set_vector_service(
... .with_vector_service(
... "openai",
... "text-embedding-3-small",
... authentication={
Expand Down
Loading
Loading