@@ -245,9 +245,9 @@ def _decide_hybrid_search_setting(
245245
246246
247247def _make_hybrid_limits (
248- hlf : None | float | dict [str , float ],
248+ hlf : float | dict [str , float ] | None ,
249249 k : int ,
250- ) -> None | int | dict [str , int ]:
250+ ) -> int | dict [str , int ] | None :
251251 if hlf is None :
252252 return None
253253 if isinstance (hlf , float ):
@@ -258,9 +258,9 @@ def _make_hybrid_limits(
258258
259259def _normalize_hybrid_limit_factor (
260260 hybrid_limit_factor : float
261- | None
262261 | dict [str , float ]
263- | HybridLimitFactorPrescription ,
262+ | HybridLimitFactorPrescription
263+ | None ,
264264) -> float | dict [str , float ] | None :
265265 """Bring `hybrid_limit_factor` to a normal form."""
266266 if hybrid_limit_factor is None :
@@ -740,9 +740,9 @@ def __init__(
740740 | None = None ,
741741 hybrid_search : HybridSearchMode | None = None ,
742742 hybrid_limit_factor : float
743- | None
744743 | dict [str , float ]
745- | HybridLimitFactorPrescription = None ,
744+ | HybridLimitFactorPrescription
745+ | None = None ,
746746 ) -> None :
747747 """A vector store which uses DataStax Astra DB as backend.
748748
@@ -891,6 +891,9 @@ def __init__(
891891 and the lexical subsearches. Alternatively, a simple dictionary
892892 with keys "$lexical" and "$vector" achieves the same effect.
893893
894+ Raises:
895+ ValueError: if the parameters are inconsistent or invalid.
896+
894897 Note:
895898 For concurrency in synchronous :meth:`~add_texts`:, as a rule of thumb,
896899 on a typical client machine it is suggested to keep the quantity
@@ -941,7 +944,7 @@ def __init__(
941944 self .has_lexical : bool
942945 self .has_hybrid : bool
943946 self .hybrid_search : bool # affecting the actual behaviour when running searches
944- self .hybrid_limit_factor : None | float | dict [str , float ]
947+ self .hybrid_limit_factor : float | dict [str , float ] | None
945948 self .collection_reranking_api_key = collection_reranking_api_key
946949
947950 if not self .autodetect_collection :
@@ -1178,7 +1181,7 @@ def copy(
11781181 In those cases, one should create a new instance of ``AstraDBVectorStore``
11791182 from scratch.
11801183
1181- Attributes :
1184+ Args :
11821185 token: API token for Astra DB usage, either in the form of a string
11831186 or a subclass of ``astrapy.authentication.TokenProvider``.
11841187 In order to suppress token usage in the copy, explicitly pass
@@ -1200,6 +1203,10 @@ def copy(
12001203 This is useful when the service is configured for the collection,
12011204 but no corresponding secret is stored within
12021205 Astra's key management system.
1206+
1207+ Returns:
1208+ a shallow copy of this vector store, possibly with some changed
1209+ attributes.
12031210 """
12041211 copy = AstraDBVectorStore (
12051212 collection_name = "moot" ,
@@ -1310,6 +1317,9 @@ def delete(
13101317
13111318 Returns:
13121319 True if deletion is (entirely) successful, False otherwise.
1320+
1321+ Raises:
1322+ ValueError: if no ids are provided.
13131323 """
13141324 if kwargs :
13151325 warnings .warn (
@@ -1350,6 +1360,9 @@ async def adelete(
13501360
13511361 Returns:
13521362 True if deletion is (entirely) successful, False otherwise.
1363+
1364+ Raises:
1365+ ValueError: if no ids are provided.
13531366 """
13541367 if kwargs :
13551368 warnings .warn (
@@ -1383,6 +1396,9 @@ def delete_by_metadata_filter(
13831396
13841397 Returns:
13851398 A number expressing the amount of deleted documents.
1399+
1400+ Raises:
1401+ ValueError: if the provided filter is empty.
13861402 """
13871403 if not filter :
13881404 msg = (
@@ -1412,6 +1428,9 @@ async def adelete_by_metadata_filter(
14121428
14131429 Returns:
14141430 A number expressing the amount of deleted documents.
1431+
1432+ Raises:
1433+ ValueError: if the provided filter is empty.
14151434 """
14161435 if not filter :
14171436 msg = (
@@ -1524,6 +1543,9 @@ def add_texts(
15241543
15251544 Returns:
15261545 The list of ids of the added texts.
1546+
1547+ Raises:
1548+ AstraDBVectorStoreError: if not all documents could be inserted.
15271549 """
15281550 if kwargs :
15291551 warnings .warn (
@@ -1665,6 +1687,9 @@ async def aadd_texts(
16651687
16661688 Returns:
16671689 The list of ids of the added texts.
1690+
1691+ Raises:
1692+ AstraDBVectorStoreError: if not all documents could be inserted.
16681693 """
16691694 if kwargs :
16701695 warnings .warn (
@@ -2473,6 +2498,9 @@ def metadata_search(
24732498 Args:
24742499 filter: the metadata to query for.
24752500 n: the maximum number of documents to return.
2501+
2502+ Returns:
2503+ The documents found.
24762504 """
24772505 docs_ite = self .run_query (n = n , filter = filter )
24782506 return [doc for doc , _ , _ , _ in docs_ite ]
@@ -2487,6 +2515,9 @@ async def ametadata_search(
24872515 Args:
24882516 filter: the metadata to query for.
24892517 n: the maximum number of documents to return.
2518+
2519+ Returns:
2520+ The documents found.
24902521 """
24912522 docs_ite = await self .arun_query (n = n , filter = filter )
24922523 return [doc async for doc , _ , _ , _ in docs_ite ]
@@ -2933,6 +2964,9 @@ def similarity_search_with_score_id_by_vector(
29332964
29342965 Returns:
29352966 The list of (Document, score, id), the most similar to the query vector.
2967+
2968+ Raises:
2969+ ValueError: if the vector store uses server-side embeddings.
29362970 """
29372971 if self .document_codec .server_side_embeddings :
29382972 msg = (
@@ -3232,6 +3266,9 @@ async def asimilarity_search_with_score_id_by_vector(
32323266
32333267 Returns:
32343268 The list of (Document, score, id), the most similar to the query vector.
3269+
3270+ Raises:
3271+ ValueError: If the vector store uses server-side embeddings.
32353272 """
32363273 if self .document_codec .server_side_embeddings :
32373274 msg = (
@@ -3559,8 +3596,8 @@ async def _arun_mmr_find_by_sort(
35593596 prefetch_hit_pairs = prefetch_hit_pairs ,
35603597 )
35613598
3599+ @staticmethod
35623600 def _get_mmr_hits (
3563- self ,
35643601 embedding : list [float ],
35653602 k : int ,
35663603 lambda_mult : float ,
0 commit comments