diff --git a/integration/test_collection.py b/integration/test_collection.py index 30fb6d634..86d9fb3fb 100644 --- a/integration/test_collection.py +++ b/integration/test_collection.py @@ -604,16 +604,15 @@ def test_search_hybrid(collection_factory: CollectionFactory, fusion_type: Hybri ) collection.data.insert({"Name": "some name"}, uuid=uuid.uuid4()) collection.data.insert({"Name": "other word"}, uuid=uuid.uuid4()) - objs = collection.query.hybrid( + objs1 = collection.query.hybrid( alpha=0, query="name", fusion_type=fusion_type, include_vector=True ).objects - assert len(objs) == 1 + assert len(objs1) == 1 - assert objs[0].vector is not None - objs = collection.query.hybrid( - alpha=1, query="name", fusion_type=fusion_type, vector=objs[0].vector["default"] + objs2 = collection.query.hybrid( + alpha=1, query="name", fusion_type=fusion_type, vector=objs1[0].vector["default"] ).objects - assert len(objs) == 2 + assert len(objs2) == 2 @pytest.mark.skip(reason="currently bugged in weaviate") @@ -1723,11 +1722,11 @@ class DataModel4(TypedDict): pass objects: Union[ - List[Object[DataModel0, None]], - List[Object[DataModel1, None]], - List[Object[DataModel2, None]], - List[Object[DataModel3, None]], - List[Object[DataModel4, None]], + List[Object[DataModel0, None, None]], + List[Object[DataModel1, None, None]], + List[Object[DataModel2, None, None]], + List[Object[DataModel3, None, None]], + List[Object[DataModel4, None, None]], ] if which_case == 0: objects = collection.query.fetch_objects(return_properties=DataModel0).objects diff --git a/integration/test_collection_references.py b/integration/test_collection_references.py index 1e2be81aa..8db4bf2a7 100644 --- a/integration/test_collection_references.py +++ b/integration/test_collection_references.py @@ -367,7 +367,7 @@ class CRefs(TypedDict): ) elif level == "col-query": c_objs = ( - collection_factory_get(C.name, CProps) + collection_factory_get(C.name, CProps) # type: ignore .query.bm25( query="find", include_vector=True, @@ -387,7 +387,7 @@ class CRefs(TypedDict): ) else: c_objs = ( - collection_factory_get(C.name) + collection_factory_get(C.name) # type: ignore .query.bm25( query="find", include_vector=True, @@ -405,6 +405,7 @@ class CRefs(TypedDict): assert ( c_objs[0].properties.get("not_specified") is None ) # type is str but instance is None (in type but not in return_properties) + assert c_objs[0].references is not None assert c_objs[0].references["b"].objects[0].collection == B.name assert c_objs[0].references["b"].objects[0].properties["name"] == "B" assert c_objs[0].references["b"].objects[0].uuid == uuid_B diff --git a/integration/test_iterator.py b/integration/test_iterator.py index f7fc9fc55..faf1eab74 100644 --- a/integration/test_iterator.py +++ b/integration/test_iterator.py @@ -69,7 +69,9 @@ def test_iterator_arguments( ) iter_ = collection.iterator( - include_vector, return_metadata=return_metadata, return_properties=return_properties + include_vector=include_vector, + return_metadata=return_metadata, + return_properties=return_properties, ) # Expect everything back diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tools/stubs.py b/tools/stubs.py new file mode 100644 index 000000000..5374628ec --- /dev/null +++ b/tools/stubs.py @@ -0,0 +1,75 @@ +import yaml +from typing import List + + +def parse_yaml(file_path): + with open(file_path, "r") as file: + return yaml.safe_load(file) + + +class Function: + def __init__(self, name: str, args: List[str], return_type: str) -> None: + self.name = name + self.args = args + self.return_type = return_type + + def __str__(self) -> str: + return f"def {self.name}({', '.join(self.args)}) -> {self.return_type}: ..." + + +def generate_pyi(data: dict): + for function in data["functions"]: + functions: List[Function] = [] + required: List[str] = [] + for arg in function["required"]: + if arg["name"] == "self": + required.append("self") + else: + required.append(f"{arg['name']}: {arg['type']}") + + optional: List[str] = [] + if function.get("optional") is not None: + for arg in function["optional"]: + optional.append(f"{arg['name']}: {arg['type']}") + + args = required + ["*"] + optional + + for i_v in function["include_vector"]: + for r_p in function["return_properties"]: + for r_r in function["return_references"]: + if function.get("group_by") is not None: + for group in function["group_by"]: + argss = args.copy() + argss.append(f"group_by: {group['type']}") + argss.append(f"include_vector: {i_v['type']}") + argss.append(f"return_properties: {r_p['type']}") + argss.append(f"return_references: {r_r['type']}") + if i_v["generic"] == "None,Vectors": + return_ = f"Union[{group['return']}[{r_p['generic']}, {r_r['generic']}, None], {group['return']}[{r_p['generic']}, {r_r['generic']}, Vectors]]" + else: + return_ = f"{group['return']}[{r_p['generic']}, {r_r['generic']}, {i_v['generic']}]" + functions.append( + Function(name=function["name"], args=argss, return_type=return_) + ) + else: + argss = args.copy() + argss.append(f"include_vector: {i_v['type']}") + argss.append(f"return_properties: {r_p['type']}") + argss.append(f"return_references: {r_r['type']}") + if i_v["generic"] == "None,Vectors": + return_ = f"Union[{function['return']}[{r_p['generic']}, {r_r['generic']}, None], {function['return']}[{r_p['generic']}, {r_r['generic']}, Vectors]]" + else: + return_ = f"{function['return']}[{r_p['generic']}, {r_r['generic']}, {i_v['generic']}]" + functions.append( + Function(name=function["name"], args=argss, return_type=return_) + ) + + with open(function["target_file"], "w") as file: + file.write("\n".join(function["header"])) + for func in functions: + file.write(f"\n @overload\n {func}\n") + + +# Example usage +yaml_data = parse_yaml("./tools/stubs.yaml") +generate_pyi(yaml_data) diff --git a/tools/stubs.yaml b/tools/stubs.yaml new file mode 100644 index 000000000..a2a43a126 --- /dev/null +++ b/tools/stubs.yaml @@ -0,0 +1,994 @@ +functions: + - name: bm25 + required: + - name: self + - name: query + type: str + optional: + - name: query_properties + type: Optional[List[str]] = None + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: GenerativeReturn + target_file: weaviate/collections/queries/bm25/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters,) + - from weaviate.collections.classes.grpc import Rerank, METADATA, PROPERTIES, REFERENCES + - from weaviate.collections.classes.internal import (GenerativeReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _BM25Generate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: bm25 + required: + - name: self + - name: query + type: str + optional: + - name: query_properties + type: Optional[List[str]] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: QueryReturn + target_file: weaviate/collections/queries/bm25/query.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters,) + - from weaviate.collections.classes.grpc import Rerank, METADATA, PROPERTIES, REFERENCES + - from weaviate.collections.classes.internal import (QueryReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: fetch_object_by_id + required: + - name: self + - name: uuid + type: UUID + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: ObjectSingleReturn + target_file: weaviate/collections/queries/fetch_object_by_id/query.pyi + header: + - from typing import (Generic,Literal,Optional,Type,Union,overload) + - from weaviate.collections.classes.grpc import PROPERTIES, REFERENCES + - from weaviate.collections.classes.internal import (ObjectSingleReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _FetchObjectByIDQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: fetch_objects + required: + - name: self + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: after + type: Optional[UUID] = None + - name: filters + type: Optional[_Filters] = None + - name: sort + type: Optional[_Sorting] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: GenerativeReturn + target_file: weaviate/collections/queries/fetch_objects/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Union, Type, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import (METADATA,PROPERTIES,REFERENCES,_Sorting,) + - from weaviate.collections.classes.internal import (GenerativeReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: fetch_objects + required: + - name: self + optional: + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: after + type: Optional[UUID] = None + - name: filters + type: Optional[_Filters] = None + - name: sort + type: Optional[_Sorting] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: QueryReturn + target_file: weaviate/collections/queries/fetch_objects/query.pyi + header: + - from typing import Generic, Literal, Optional, Union, Type, overload + - from weaviate.collections.classes.filters import (_Filters,) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, _Sorting + - from weaviate.collections.classes.internal import (QueryReturn,CrossReferences,ReturnProperties,ReturnReferences,QueryReturnType) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: hybrid + required: + - name: self + - name: query + type: str + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: alpha + type: NUMBER = 0.5 + - name: vector + type: Optional[List[float]] = None + - name: query_properties + type: Optional[List[str]] = None + - name: fusion_type + type: Optional[HybridFusion] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: GenerativeReturn + target_file: weaviate/collections/queries/hybrid/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters,) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, HybridFusion, Rerank + - from weaviate.collections.classes.internal import (GenerativeReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import NUMBER + - "class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: hybrid + required: + - name: self + - name: query + type: str + optional: + - name: alpha + type: NUMBER = 0.5 + - name: vector + type: Optional[List[float]] = None + - name: query_properties + type: Optional[List[str]] = None + - name: fusion_type + type: Optional[HybridFusion] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: QueryReturn + target_file: weaviate/collections/queries/hybrid/query.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters,) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, HybridFusion, Rerank + - from weaviate.collections.classes.internal import (QueryReturn,CrossReferences,) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import NUMBER + - "class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_image + required: + - name: self + - name: near_image + type: Union[str, Path, BufferedReader] + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: GenerativeReturn + - type: GroupBy + return: GenerativeGroupByReturn + target_file: weaviate/collections/queries/near_image/generate.pyi + header: + - from io import BufferedReader + - from pathlib import Path + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (GenerativeReturn,GenerativeGroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_image + required: + - name: self + - name: near_image + type: Union[str, Path, BufferedReader] + optional: + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: QueryReturn + - type: GroupBy + return: GroupByReturn + target_file: weaviate/collections/queries/near_image/query.pyi + header: + - from io import BufferedReader + - from pathlib import Path + - from typing import Generic, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (QueryReturn,GroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearImageQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_media + required: + - name: self + - name: media + type: Union[str, Path, BufferedReader] + - name: media_type + type: NearMediaType + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: GenerativeReturn + - type: GroupBy + return: GenerativeGroupByReturn + target_file: weaviate/collections/queries/near_media/generate.pyi + header: + - from io import BufferedReader + - from pathlib import Path + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank, NearMediaType + - from weaviate.collections.classes.internal import (GenerativeReturn,GenerativeGroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_media + required: + - name: self + - name: media + type: Union[str, Path, BufferedReader] + - name: media_type + type: NearMediaType + optional: + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: QueryReturn + - type: GroupBy + return: GroupByReturn + target_file: weaviate/collections/queries/near_media/query.pyi + header: + - from io import BufferedReader + - from pathlib import Path + - from typing import Generic, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank, NearMediaType + - from weaviate.collections.classes.internal import (QueryReturn,GroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearMediaQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_object + required: + - name: self + - name: near_object + type: UUID + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: GenerativeReturn + - type: GroupBy + return: GenerativeGroupByReturn + target_file: weaviate/collections/queries/near_object/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (GenerativeReturn,GenerativeGroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_object + required: + - name: self + - name: near_object + type: UUID + optional: + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: QueryReturn + - type: GroupBy + return: GroupByReturn + target_file: weaviate/collections/queries/near_object/query.pyi + header: + - from typing import Generic, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (QueryReturn,GroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _NearObjectQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_text + required: + - name: self + - name: query + type: Union[str, List[str]] + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: move_to + type: Optional[Move] = None + - name: move_away + type: Optional[Move] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: GenerativeReturn + - type: GroupBy + return: GenerativeGroupByReturn + target_file: weaviate/collections/queries/near_text/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Move, Rerank + - from weaviate.collections.classes.internal import (GenerativeReturn,GenerativeGroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _NearTextGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_text + required: + - name: self + - name: query + type: Union[str, List[str]] + optional: + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: move_to + type: Optional[Move] = None + - name: move_away + type: Optional[Move] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: QueryReturn + - type: GroupBy + return: GroupByReturn + target_file: weaviate/collections/queries/near_text/query.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Move, Rerank + - from weaviate.collections.classes.internal import (QueryReturn,GroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - from weaviate.types import UUID + - "class _NearTextQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_vector + required: + - name: self + - name: near_vector + type: List[float] + optional: + - name: single_prompt + type: Optional[str] = None + - name: grouped_task + type: Optional[str] = None + - name: grouped_properties + type: Optional[List[str]] = None + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: GenerativeReturn + - type: GroupBy + return: GenerativeGroupByReturn + target_file: weaviate/collections/queries/near_vector/generate.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (GenerativeReturn,GenerativeGroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: near_vector + required: + - name: self + - name: near_vector + type: List[float] + optional: + - name: certainty + type: Optional[float] = None + - name: distance + type: Optional[float] = None + - name: limit + type: Optional[int] = None + - name: offset + type: Optional[int] = None + - name: auto_limit + type: Optional[int] = None + - name: filters + type: Optional[_Filters] = None + - name: rerank + type: Optional[Rerank] = None + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + group_by: + - type: Literal[None] = None + return: QueryReturn + - type: GroupBy + return: GroupByReturn + target_file: weaviate/collections/queries/near_vector/query.pyi + header: + - from typing import Generic, List, Literal, Optional, Type, Union, overload + - from weaviate.collections.classes.filters import (_Filters) + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank + - from weaviate.collections.classes.internal import (QueryReturn,GroupByReturn,CrossReferences) + - from weaviate.collections.classes.types import Properties, TProperties, References, TReferences, Vectors + - from weaviate.collections.queries.base import _BaseQuery + - "class _NearVectorQuery(Generic[Properties, References], _BaseQuery[Properties, References]):" + - name: iterator + required: + - name: self + optional: + - name: return_metadata + type: Optional[METADATA] = None + include_vector: + - type: Literal[False] = False + generic: None + - type: Literal[True] + generic: Vectors + - type: bool = False + generic: None,Vectors + return_properties: + - type: Optional[PROPERTIES] = None + generic: Properties + - type: Type[TProperties] + generic: TProperties + return_references: + - type: Literal[None] = None + generic: None + - type: REFERENCES + generic: CrossReferences + - type: Type[TReferences] + generic: TReferences + return: _ObjectIterator + target_file: weaviate/collections/collection.pyi + header: + - from typing import Generic, Literal, Optional, Type, Union, overload + - from weaviate.collections.base import _CollectionBase + - from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES + - from weaviate.collections.classes.internal import CrossReferences + - from weaviate.collections.classes.types import References, TReferences, Properties, TProperties, Vectors + - from weaviate.collections.iterator import _ObjectIterator + - "class Collection(_CollectionBase, Generic[Properties, References]):" \ No newline at end of file diff --git a/weaviate/collections/__init__.py b/weaviate/collections/__init__.py index 45bd9cc89..e43a1ea88 100644 --- a/weaviate/collections/__init__.py +++ b/weaviate/collections/__init__.py @@ -1,3 +1,3 @@ __all__ = ["Collection"] -from weaviate.collections.collections import Collection +from weaviate.collections.collection import Collection diff --git a/weaviate/collections/classes/internal.py b/weaviate/collections/classes/internal.py index 8025f1c4f..0671d7096 100644 --- a/weaviate/collections/classes/internal.py +++ b/weaviate/collections/classes/internal.py @@ -42,7 +42,9 @@ M, P, R, + V, TProperties, + Vectors, WeaviateProperties, _WeaviateInput, ) @@ -88,17 +90,17 @@ class GroupByMetadataReturn: @dataclass -class _Object(Generic[P, R, M]): +class _Object(Generic[P, R, M, V]): uuid: uuid_package.UUID metadata: M properties: P references: R - vector: Optional[Dict[str, List[float]]] + vector: V collection: str @dataclass -class Object(Generic[P, R], _Object[P, R, MetadataReturn]): +class Object(Generic[P, R, V], _Object[P, R, MetadataReturn, V]): """A single Weaviate object returned by a query within the `.query` namespace of a collection.""" pass @@ -114,82 +116,82 @@ class MetadataSingleObjectReturn: @dataclass -class ObjectSingleReturn(Generic[P, R], _Object[P, R, MetadataSingleObjectReturn]): +class ObjectSingleReturn(Generic[P, R, V], _Object[P, R, MetadataSingleObjectReturn, V]): """A single Weaviate object returned by the `fetch_object_by_id` query.""" pass @dataclass -class GroupByObject(Generic[P, R], _Object[P, R, GroupByMetadataReturn]): +class GroupByObject(Generic[P, R, V], _Object[P, R, GroupByMetadataReturn, V]): """A single Weaviate object returned by a query with the `group_by` argument specified.""" belongs_to_group: str @dataclass -class GroupedObject(Generic[P, R], _Object[P, R, GroupByMetadataReturn]): +class GroupedObject(Generic[P, R, V], _Object[P, R, GroupByMetadataReturn, V]): """A single Weaviate object returned by a query with the `group_by` argument specified.""" pass @dataclass -class GenerativeObject(Generic[P, R], Object[P, R]): +class GenerativeObject(Generic[P, R, V], Object[P, R, V]): """A single Weaviate object returned by a query within the `generate` namespace of a collection.""" generated: Optional[str] @dataclass -class GenerativeReturn(Generic[P, R]): +class GenerativeReturn(Generic[P, R, V]): """The return type of a query within the `generate` namespace of a collection.""" - objects: List[GenerativeObject[P, R]] + objects: List[GenerativeObject[P, R, V]] generated: Optional[str] @dataclass -class Group(Generic[P, R]): +class Group(Generic[P, R, V]): """A group of objects returned in a group by query.""" name: str min_distance: float max_distance: float number_of_objects: int - objects: List[GroupedObject[P, R]] + objects: List[GroupedObject[P, R, V]] rerank_score: Optional[float] @dataclass -class GenerativeGroup(Generic[P, R], Group[P, R]): +class GenerativeGroup(Generic[P, R, V], Group[P, R, V]): """A group of objects returned in a generative group by query.""" generated: Optional[str] @dataclass -class GenerativeGroupByReturn(Generic[P, R]): +class GenerativeGroupByReturn(Generic[P, R, V]): """The return type of a query within the `.generate` namespace of a collection with the `group_by` argument specified.""" - objects: List[GroupByObject[P, R]] - groups: Dict[str, GenerativeGroup[P, R]] + objects: List[GroupByObject[P, R, V]] + groups: Dict[str, GenerativeGroup[P, R, V]] generated: Optional[str] @dataclass -class GroupByReturn(Generic[P, R]): +class GroupByReturn(Generic[P, R, V]): """The return type of a query within the `.query` namespace of a collection with the `group_by` argument specified.""" - objects: List[GroupByObject[P, R]] - groups: Dict[str, Group[P, R]] + objects: List[GroupByObject[P, R, V]] + groups: Dict[str, Group[P, R, V]] @dataclass -class QueryReturn(Generic[P, R]): +class QueryReturn(Generic[P, R, V]): """The return type of a query within the `.query` namespace of a collection.""" - objects: List[Object[P, R]] + objects: List[Object[P, R, V]] _GQLEntryReturnType: TypeAlias = Dict[str, List[Dict[str, Any]]] @@ -318,18 +320,18 @@ def uuids_str(self) -> List[str]: class _CrossReference(Generic[Properties, IReferences]): def __init__( self, - objects: Optional[List[Object[Properties, IReferences]]], + objects: Optional[List[Object[Properties, IReferences, Optional[Vectors]]]], ): self.__objects = objects @classmethod def _from( - cls, objects: List[Object[Properties, IReferences]] + cls, objects: List[Object[Properties, IReferences, Optional[Vectors]]] ) -> "_CrossReference[Properties, IReferences]": return cls(objects) @property - def objects(self) -> List[Object[Properties, IReferences]]: + def objects(self) -> List[Object[Properties, IReferences, Optional[Vectors]]]: """Returns the objects of the cross reference.""" return self.__objects or [] @@ -526,30 +528,48 @@ def from_input( QuerySingleReturn = Union[ - ObjectSingleReturn[Properties, References], - ObjectSingleReturn[TProperties, TReferences], - ObjectSingleReturn[Properties, CrossReferences], - ObjectSingleReturn[Properties, TReferences], - ObjectSingleReturn[TProperties, References], - ObjectSingleReturn[TProperties, CrossReferences], + ObjectSingleReturn[Properties, References, None], + ObjectSingleReturn[Properties, References, Vectors], + ObjectSingleReturn[TProperties, TReferences, None], + ObjectSingleReturn[TProperties, TReferences, Vectors], + ObjectSingleReturn[Properties, CrossReferences, None], + ObjectSingleReturn[Properties, CrossReferences, Vectors], + ObjectSingleReturn[Properties, TReferences, None], + ObjectSingleReturn[Properties, TReferences, Vectors], + ObjectSingleReturn[TProperties, References, None], + ObjectSingleReturn[TProperties, References, Vectors], + ObjectSingleReturn[TProperties, CrossReferences, None], + ObjectSingleReturn[TProperties, CrossReferences, Vectors], ] GenerativeGroupByReturnType = Union[ - GenerativeGroupByReturn[Properties, References], - GenerativeGroupByReturn[TProperties, TReferences], - GenerativeGroupByReturn[Properties, CrossReferences], - GenerativeGroupByReturn[Properties, TReferences], - GenerativeGroupByReturn[TProperties, References], - GenerativeGroupByReturn[TProperties, CrossReferences], + GenerativeGroupByReturn[Properties, References, None], + GenerativeGroupByReturn[Properties, References, Vectors], + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + GenerativeGroupByReturn[TProperties, References, None], + GenerativeGroupByReturn[TProperties, References, Vectors], + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], ] GenerativeReturnType = Union[ - GenerativeReturn[Properties, References], - GenerativeReturn[TProperties, TReferences], - GenerativeReturn[Properties, CrossReferences], - GenerativeReturn[Properties, TReferences], - GenerativeReturn[TProperties, References], - GenerativeReturn[TProperties, CrossReferences], + GenerativeReturn[Properties, References, None], + GenerativeReturn[Properties, References, Vectors], + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + GenerativeReturn[TProperties, References, None], + GenerativeReturn[TProperties, References, Vectors], + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], ] # The way in which generic type aliases work requires that all the generic arguments @@ -562,21 +582,33 @@ def from_input( ] QueryReturnType = Union[ - QueryReturn[Properties, References], - QueryReturn[TProperties, TReferences], - QueryReturn[Properties, CrossReferences], - QueryReturn[Properties, TReferences], - QueryReturn[TProperties, References], - QueryReturn[TProperties, CrossReferences], + QueryReturn[Properties, References, None], + QueryReturn[TProperties, TReferences, None], + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, TReferences, None], + QueryReturn[TProperties, References, None], + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[Properties, References, Vectors], + QueryReturn[TProperties, TReferences, Vectors], + QueryReturn[Properties, CrossReferences, Vectors], + QueryReturn[Properties, TReferences, Vectors], + QueryReturn[TProperties, References, Vectors], + QueryReturn[TProperties, CrossReferences, Vectors], ] GroupByReturnType = Union[ - GroupByReturn[Properties, References], - GroupByReturn[TProperties, TReferences], - GroupByReturn[Properties, CrossReferences], - GroupByReturn[Properties, TReferences], - GroupByReturn[TProperties, References], - GroupByReturn[TProperties, CrossReferences], + GroupByReturn[Properties, References, None], + GroupByReturn[Properties, References, Vectors], + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + GroupByReturn[TProperties, References, None], + GroupByReturn[TProperties, References, Vectors], + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], ] QueryNearMediaReturnType = Union[ diff --git a/weaviate/collections/classes/types.py b/weaviate/collections/classes/types.py index d2d955900..253b961c7 100644 --- a/weaviate/collections/classes/types.py +++ b/weaviate/collections/classes/types.py @@ -1,7 +1,7 @@ import datetime import uuid as uuid_package -from typing import Any, Dict, Mapping, Optional, Sequence, Type, Union, get_origin +from typing import Any, Dict, List, Mapping, Optional, Sequence, Type, Union, get_origin from typing_extensions import TypeAlias, TypeVar, is_typeddict from pydantic import BaseModel, ConfigDict, Field @@ -102,7 +102,10 @@ class _PhoneNumber(_PhoneNumberBase): M = TypeVar("M") """`M` is a completely general type that is used wherever generic metadata objects are defined that can be used""" -P = TypeVar("P") +V = TypeVar("V", covariant=True) +"""`V` is a completely general type that is used wherever generic vector objects are defined that can be used""" + +P = TypeVar("P", covariant=True) """`P` is a completely general type that is used wherever generic properties objects are defined that can be used within the non-ORM and ORM APIs interchangeably""" @@ -110,7 +113,7 @@ class _PhoneNumber(_PhoneNumberBase): """`QP` is a completely general type that is used wherever generic properties objects are defined that can be used within the non-ORM and ORM APIs interchangeably""" -R = TypeVar("R") +R = TypeVar("R", covariant=True) """`R` is a completely general type that is used wherever generic reference objects are defined that can be used within the non-ORM and ORM APIs interchangeably""" @@ -131,6 +134,9 @@ class _PhoneNumber(_PhoneNumberBase): """`TReferences` is used alongside `References` wherever there are two generic types needed""" +Vectors = Dict[str, List[float]] + + def _check_properties_generic(properties: Optional[Type[Properties]]) -> None: if ( properties is not None diff --git a/weaviate/collections/collection.py b/weaviate/collections/collection.py index cf8273df4..c8fa25033 100644 --- a/weaviate/collections/collection.py +++ b/weaviate/collections/collection.py @@ -11,17 +11,21 @@ ) from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES from weaviate.collections.classes.internal import ( - References, - TReferences, ReturnProperties, ReturnReferences, CrossReferences, ) from weaviate.collections.classes.tenants import Tenant -from weaviate.collections.classes.types import Properties, TProperties +from weaviate.collections.classes.types import ( + References, + TReferences, + Properties, + TProperties, + Vectors, +) from weaviate.collections.config import _ConfigCollection from weaviate.collections.data import _DataCollection -from weaviate.collections.iterator import _ObjectIterator +from weaviate.collections.iterator import _ObjectIterator, ObjectIterator from weaviate.collections.query import _GenerateCollection, _QueryCollection from weaviate.collections.tenants import _Tenants from weaviate.validator import _validate_input, _ValidateArgument @@ -171,83 +175,223 @@ def __str__(self) -> str: @overload def iterator( self, - include_vector: bool = False, - return_metadata: Optional[METADATA] = None, *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, return_references: Literal[None] = None, - ) -> _ObjectIterator[Properties, References]: + ) -> _ObjectIterator[Properties, None, None]: ... @overload def iterator( self, - include_vector: bool = False, + *, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES, + ) -> _ObjectIterator[Properties, CrossReferences, None]: + ... + + @overload + def iterator( + self, *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences], + ) -> _ObjectIterator[Properties, TReferences, None]: + ... + + @overload + def iterator( + self, + *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None, + ) -> _ObjectIterator[TProperties, None, None]: + ... + + @overload + def iterator( + self, + *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], return_references: REFERENCES, - ) -> _ObjectIterator[Properties, CrossReferences]: + ) -> _ObjectIterator[TProperties, CrossReferences, None]: ... @overload def iterator( self, - include_vector: bool = False, + *, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences], + ) -> _ObjectIterator[TProperties, TReferences, None]: + ... + + @overload + def iterator( + self, *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> _ObjectIterator[Properties, TReferences]: + return_references: Literal[None] = None, + ) -> _ObjectIterator[Properties, None, Vectors]: ... @overload def iterator( self, - include_vector: bool = False, + *, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES, + ) -> _ObjectIterator[Properties, CrossReferences, Vectors]: + ... + + @overload + def iterator( + self, *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences], + ) -> _ObjectIterator[Properties, TReferences, Vectors]: + ... + + @overload + def iterator( + self, + *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], return_references: Literal[None] = None, - ) -> _ObjectIterator[TProperties, References]: + ) -> _ObjectIterator[TProperties, None, Vectors]: ... @overload def iterator( self, - include_vector: bool = False, + *, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES, + ) -> _ObjectIterator[TProperties, CrossReferences, Vectors]: + ... + + @overload + def iterator( + self, *, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], + return_references: Type[TReferences], + ) -> _ObjectIterator[TProperties, TReferences, Vectors]: + ... + + @overload + def iterator( + self, + *, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None, + ) -> Union[_ObjectIterator[Properties, None, None], _ObjectIterator[Properties, None, Vectors]]: + ... + + @overload + def iterator( + self, + *, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, return_references: REFERENCES, - ) -> _ObjectIterator[TProperties, CrossReferences]: + ) -> Union[ + _ObjectIterator[Properties, CrossReferences, None], + _ObjectIterator[Properties, CrossReferences, Vectors], + ]: ... @overload def iterator( self, + *, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences], + ) -> Union[ + _ObjectIterator[Properties, TReferences, None], + _ObjectIterator[Properties, TReferences, Vectors], + ]: + ... + + @overload + def iterator( + self, + *, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None, + ) -> Union[ + _ObjectIterator[TProperties, None, None], _ObjectIterator[TProperties, None, Vectors] + ]: + ... + + @overload + def iterator( + self, *, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> _ObjectIterator[TProperties, TReferences]: + return_references: REFERENCES, + ) -> Union[ + _ObjectIterator[TProperties, CrossReferences, None], + _ObjectIterator[TProperties, CrossReferences, Vectors], + ]: ... + @overload def iterator( self, + *, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences], + ) -> Union[ + _ObjectIterator[TProperties, TReferences, None], + _ObjectIterator[TProperties, TReferences, Vectors], + ]: + ... + + def iterator( + self, + *, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Optional[ReturnProperties[TProperties]] = None, return_references: Optional[ReturnReferences[TReferences]] = None, - ) -> Union[ - _ObjectIterator[Properties, References], - _ObjectIterator[Properties, CrossReferences], - _ObjectIterator[Properties, TReferences], - _ObjectIterator[TProperties, References], - _ObjectIterator[TProperties, CrossReferences], - _ObjectIterator[TProperties, TReferences], - ]: + ) -> ObjectIterator[Properties, References, TProperties, TReferences]: """Use this method to return an iterator over the objects in the collection. This iterator keeps a record of the last object that it returned to be used in each subsequent call to @@ -278,7 +422,7 @@ def iterator( after=after, include_vector=include_vector, return_metadata=return_metadata, - return_properties=return_properties, - return_references=return_references, + return_properties=return_properties, # type: ignore + return_references=return_references, # type: ignore ).objects ) diff --git a/weaviate/collections/iterator.py b/weaviate/collections/iterator.py index 9106e3ebc..1d030a3b9 100644 --- a/weaviate/collections/iterator.py +++ b/weaviate/collections/iterator.py @@ -1,28 +1,37 @@ -from typing import Callable, Generic, Iterable, Iterator, List, Optional +from typing import Callable, Generic, Iterable, Iterator, List, Optional, Union from uuid import UUID -from weaviate.collections.classes.internal import Object -from weaviate.collections.classes.types import P, R +from weaviate.collections.classes.internal import CrossReferences, Object +from weaviate.collections.classes.types import ( + P, + R, + V, + Properties, + TProperties, + References, + TReferences, + Vectors, +) ITERATOR_CACHE_SIZE = 100 -class _ObjectIterator(Generic[P, R], Iterable[Object[P, R]]): +class _ObjectIterator(Generic[P, R, V], Iterable[Object[P, R, V]]): def __init__( - self, fetch_objects_query: Callable[[int, Optional[UUID]], List[Object[P, R]]] + self, fetch_objects_query: Callable[[int, Optional[UUID]], List[Object[P, R, V]]] ) -> None: self.__query = fetch_objects_query - self.__iter_object_cache: List[Object[P, R]] = [] + self.__iter_object_cache: List[Object[P, R, V]] = [] self.__iter_object_last_uuid: Optional[UUID] = None - def __iter__(self) -> Iterator[Object[P, R]]: + def __iter__(self) -> Iterator[Object[P, R, V]]: self.__iter_object_cache = [] self.__iter_object_last_uuid = None return self - def __next__(self) -> Object[P, R]: + def __next__(self) -> Object[P, R, V]: if len(self.__iter_object_cache) == 0: objects = self.__query( ITERATOR_CACHE_SIZE, @@ -38,3 +47,19 @@ def __next__(self) -> Object[P, R]: self.__iter_object_last_uuid is not None ) # if this is None the iterator will never stop return ret_object + + +ObjectIterator = Union[ + _ObjectIterator[Properties, References, None], + _ObjectIterator[Properties, References, Vectors], + _ObjectIterator[TProperties, References, None], + _ObjectIterator[TProperties, References, Vectors], + _ObjectIterator[Properties, CrossReferences, None], + _ObjectIterator[Properties, CrossReferences, Vectors], + _ObjectIterator[Properties, TReferences, None], + _ObjectIterator[Properties, TReferences, Vectors], + _ObjectIterator[TProperties, CrossReferences, None], + _ObjectIterator[TProperties, CrossReferences, Vectors], + _ObjectIterator[TProperties, TReferences, None], + _ObjectIterator[TProperties, TReferences, Vectors], +] diff --git a/weaviate/collections/queries/base.py b/weaviate/collections/queries/base.py index ac6ae362b..3f3dfcb0b 100644 --- a/weaviate/collections/queries/base.py +++ b/weaviate/collections/queries/base.py @@ -4,7 +4,7 @@ import pathlib import struct import uuid as uuid_lib -from typing import Any, Dict, Generic, List, Optional, Sequence, Type, Union, cast +from typing import Any, Generic, List, Optional, Sequence, Type, Union, cast from typing_extensions import is_typeddict @@ -29,17 +29,19 @@ _extract_references_from_data_model, GenerativeNearMediaReturnType, GenerativeReturn, + GenerativeReturnType, GenerativeGroupByReturn, + GenerativeGroupByReturnType, GroupByReturn, GroupByReturnType, Group, GenerativeGroup, QueryReturn, + QueryReturnType, QueryNearMediaReturnType, _QueryOptions, ReturnProperties, ReturnReferences, - CrossReferences, _CrossReference, ) from weaviate.collections.classes.types import ( @@ -49,6 +51,7 @@ TProperties, References, TReferences, + Vectors, ) from weaviate.collections.grpc.query import _QueryGRPC from weaviate.validator import _validate_input, _ValidateArgument @@ -150,7 +153,7 @@ def __extract_id_for_object( def __extract_vector_for_object( self, add_props: "search_get_pb2.MetadataResult", - ) -> Optional[Dict[str, List[float]]]: + ) -> Optional[Vectors]: if len(add_props.vector_bytes) == 0 and len(add_props.vector) == 0: return None @@ -230,7 +233,7 @@ def __result_to_query_object( props: search_get_pb2.PropertiesResult, meta: search_get_pb2.MetadataResult, options: _QueryOptions, - ) -> Object[Any, Any]: + ) -> Object[Any, Any, Optional[Vectors]]: return Object( collection=props.target_collection, properties=( @@ -255,7 +258,7 @@ def __result_to_generative_object( props: search_get_pb2.PropertiesResult, meta: search_get_pb2.MetadataResult, options: _QueryOptions, - ) -> GenerativeObject[Any, Any]: + ) -> GenerativeObject[Any, Any, Any]: return GenerativeObject( collection=props.target_collection, properties=( @@ -280,7 +283,7 @@ def __result_to_group( self, res: search_get_pb2.GroupByResult, options: _QueryOptions, - ) -> Group[Any, Any]: + ) -> Group[Any, Any, Any]: return Group( objects=[ self.__result_to_group_by_object(obj.properties, obj.metadata, options) @@ -297,7 +300,7 @@ def __result_to_generative_group( self, res: search_get_pb2.GroupByResult, options: _QueryOptions, - ) -> GenerativeGroup[Any, Any]: + ) -> GenerativeGroup[Any, Any, Any]: return GenerativeGroup( objects=[ self.__result_to_group_by_object(obj.properties, obj.metadata, options) @@ -316,7 +319,7 @@ def __result_to_group_by_object( props: search_get_pb2.PropertiesResult, meta: search_get_pb2.MetadataResult, options: _QueryOptions, - ) -> GroupedObject[Any, Any]: + ) -> GroupedObject[Any, Any, Any]: return GroupedObject( collection=props.target_collection, properties=( @@ -346,15 +349,8 @@ def _result_to_query_return( references: Optional[ ReturnReferences[TReferences] ], # required until 3.12 is minimum supported version to use new generics syntax - ) -> Union[ - QueryReturn[Properties, References], - QueryReturn[Properties, CrossReferences], - QueryReturn[Properties, TReferences], - QueryReturn[TProperties, References], - QueryReturn[TProperties, CrossReferences], - QueryReturn[TProperties, TReferences], - ]: - return QueryReturn( + ) -> QueryReturnType[Properties, References, TProperties, TReferences]: + return QueryReturn( # type: ignore objects=[ self.__result_to_query_object(obj.properties, obj.metadata, options) for obj in res.results @@ -371,14 +367,7 @@ def _result_to_generative_query_return( references: Optional[ ReturnReferences[TReferences] ], # required until 3.12 is minimum supported version to use new generics syntax - ) -> Union[ - GenerativeReturn[Properties, References], - GenerativeReturn[Properties, CrossReferences], - GenerativeReturn[Properties, TReferences], - GenerativeReturn[TProperties, References], - GenerativeReturn[TProperties, CrossReferences], - GenerativeReturn[TProperties, TReferences], - ]: + ) -> GenerativeReturnType[Properties, References, TProperties, TReferences]: return GenerativeReturn( objects=[ self.__result_to_generative_object(obj.properties, obj.metadata, options) @@ -445,14 +434,7 @@ def _result_to_generative_groupby_return( references: Optional[ ReturnReferences[TReferences] ], # required until 3.12 is minimum supported version to use new generics syntax - ) -> Union[ - GenerativeGroupByReturn[Properties, References], - GenerativeGroupByReturn[Properties, CrossReferences], - GenerativeGroupByReturn[Properties, TReferences], - GenerativeGroupByReturn[TProperties, References], - GenerativeGroupByReturn[TProperties, CrossReferences], - GenerativeGroupByReturn[TProperties, TReferences], - ]: + ) -> GenerativeGroupByReturnType[Properties, References, TProperties, TReferences]: groups = { group.name: self.__result_to_generative_group(group, options) for group in res.group_by_results diff --git a/weaviate/collections/queries/bm25/generate.py b/weaviate/collections/queries/bm25/generate.py index 6e6c609c0..7e87842e9 100644 --- a/weaviate/collections/queries/bm25/generate.py +++ b/weaviate/collections/queries/bm25/generate.py @@ -20,10 +20,10 @@ def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - query_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, @@ -41,14 +41,14 @@ def bm25( Arguments: `query` The keyword-based query to search for, REQUIRED. + `query_properties` + The properties to search in. If not specified, all properties are searched. `single_prompt` The prompt to use for RaG on each object individually. `grouped_task` The prompt to use for RaG on the entire result set. `grouped_properties` The properties to use in the RaG on the entire result set. - `query_properties` - The properties to search in. If not specified, all properties are searched. `limit` The maximum number of results to return. If not specified, the default limit specified by the server is returned. `offset` diff --git a/weaviate/collections/queries/bm25/generate.pyi b/weaviate/collections/queries/bm25/generate.pyi index cd3939c09..61a324d8a 100644 --- a/weaviate/collections/queries/bm25/generate.pyi +++ b/weaviate/collections/queries/bm25/generate.pyi @@ -1,5 +1,4 @@ -from typing import Generic, List, Literal, Optional, Type, overload - +from typing import Generic, List, Literal, Optional, Type, Union, overload from weaviate.collections.classes.filters import ( _Filters, ) @@ -8,7 +7,13 @@ from weaviate.collections.classes.internal import ( GenerativeReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery class _BM25Generate(Generic[Properties, References], _BaseQuery[Properties, References]): @@ -17,112 +22,356 @@ class _BM25Generate(Generic[Properties, References], _BaseQuery[Properties, Refe self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def bm25( + self, + query: str, + *, query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... @overload def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... @overload def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... @overload def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def bm25( + self, + query: str, + *, query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def bm25( self, query: str, *, + query_properties: Optional[List[str]] = None, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - query_properties: Optional[List[str]] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/bm25/query.pyi b/weaviate/collections/queries/bm25/query.pyi index 6cc4a880c..e154e64d1 100644 --- a/weaviate/collections/queries/bm25/query.pyi +++ b/weaviate/collections/queries/bm25/query.pyi @@ -1,5 +1,4 @@ -from typing import Generic, List, Literal, Optional, Type, overload - +from typing import Generic, List, Literal, Optional, Type, Union, overload from weaviate.collections.classes.filters import ( _Filters, ) @@ -8,7 +7,13 @@ from weaviate.collections.classes.internal import ( QueryReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, References]): @@ -23,11 +28,11 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... @overload def bm25( self, @@ -39,11 +44,11 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... @overload def bm25( self, @@ -55,11 +60,139 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... @overload def bm25( self, @@ -71,11 +204,11 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... @overload def bm25( self, @@ -87,11 +220,64 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def bm25( self, @@ -103,8 +289,29 @@ class _BM25Query(Generic[Properties, References], _BaseQuery[Properties, Referen auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def bm25( + self, + query: str, + *, + query_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... diff --git a/weaviate/collections/queries/fetch_object_by_id/query.py b/weaviate/collections/queries/fetch_object_by_id/query.py index 07263e081..b5e641487 100644 --- a/weaviate/collections/queries/fetch_object_by_id/query.py +++ b/weaviate/collections/queries/fetch_object_by_id/query.py @@ -25,8 +25,8 @@ class _FetchObjectByIDQuery(Generic[Properties, References], _BaseQuery[Properti def fetch_object_by_id( self, uuid: UUID, - include_vector: bool = False, *, + include_vector: bool = False, return_properties: Optional[ReturnProperties[TProperties]] = None, return_references: Optional[ReturnReferences[TReferences]] = None, ) -> Optional[QuerySingleReturn[Properties, References, TProperties, TReferences]]: diff --git a/weaviate/collections/queries/fetch_object_by_id/query.pyi b/weaviate/collections/queries/fetch_object_by_id/query.pyi index 697fe1ef6..f7859630f 100644 --- a/weaviate/collections/queries/fetch_object_by_id/query.pyi +++ b/weaviate/collections/queries/fetch_object_by_id/query.pyi @@ -1,17 +1,16 @@ -from typing import ( - Generic, - Literal, - Optional, - Type, - overload, -) - +from typing import Generic, Literal, Optional, Type, Union, overload from weaviate.collections.classes.grpc import PROPERTIES, REFERENCES from weaviate.collections.classes.internal import ( ObjectSingleReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery from weaviate.types import UUID @@ -20,53 +19,177 @@ class _FetchObjectByIDQuery(Generic[Properties, References], _BaseQuery[Properti def fetch_object_by_id( self, uuid: UUID, - include_vector: bool = False, *, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> ObjectSingleReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> ObjectSingleReturn[Properties, None, None]: ... @overload def fetch_object_by_id( self, uuid: UUID, - include_vector: bool = False, *, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> ObjectSingleReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> ObjectSingleReturn[Properties, CrossReferences, None]: ... @overload def fetch_object_by_id( self, uuid: UUID, - include_vector: bool = False, *, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> ObjectSingleReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> ObjectSingleReturn[Properties, TReferences, None]: ... @overload def fetch_object_by_id( self, uuid: UUID, - include_vector: bool = False, *, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> ObjectSingleReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> ObjectSingleReturn[TProperties, None, None]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> ObjectSingleReturn[TProperties, CrossReferences, None]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> ObjectSingleReturn[TProperties, TReferences, None]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> ObjectSingleReturn[Properties, None, Vectors]: ... @overload def fetch_object_by_id( self, uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> ObjectSingleReturn[Properties, CrossReferences, Vectors]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> ObjectSingleReturn[Properties, TReferences, Vectors]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> ObjectSingleReturn[TProperties, None, Vectors]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> ObjectSingleReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> ObjectSingleReturn[TProperties, TReferences, Vectors]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + ObjectSingleReturn[Properties, None, None], ObjectSingleReturn[Properties, None, Vectors] + ]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, *, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + ObjectSingleReturn[Properties, CrossReferences, None], + ObjectSingleReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + ObjectSingleReturn[Properties, TReferences, None], + ObjectSingleReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, + *, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> ObjectSingleReturn[TProperties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> Union[ + ObjectSingleReturn[TProperties, None, None], ObjectSingleReturn[TProperties, None, Vectors] + ]: ... @overload def fetch_object_by_id( self, uuid: UUID, + *, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + ObjectSingleReturn[TProperties, CrossReferences, None], + ObjectSingleReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def fetch_object_by_id( + self, + uuid: UUID, *, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> ObjectSingleReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + ObjectSingleReturn[TProperties, TReferences, None], + ObjectSingleReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/fetch_objects/generate.pyi b/weaviate/collections/queries/fetch_objects/generate.pyi index 483633ba6..f5bdeb55a 100644 --- a/weaviate/collections/queries/fetch_objects/generate.pyi +++ b/weaviate/collections/queries/fetch_objects/generate.pyi @@ -1,19 +1,22 @@ from typing import Generic, List, Literal, Optional, Union, Type, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import ( METADATA, PROPERTIES, REFERENCES, - Sort, + _Sorting, ) from weaviate.collections.classes.internal import ( GenerativeReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery from weaviate.types import UUID @@ -29,15 +32,16 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, - include_vector: bool = False, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, return_references: Literal[None] = None - ) -> GenerativeReturn[Properties, References]: ... + ) -> GenerativeReturn[Properties, None, None]: ... @overload def fetch_objects( self, + *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, @@ -45,13 +49,63 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, - include_vector: bool = False, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def fetch_objects( + self, *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], return_references: REFERENCES - ) -> GenerativeReturn[Properties, CrossReferences]: ... + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... @overload def fetch_objects( self, @@ -63,12 +117,63 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, - include_vector: bool = False, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, return_references: Type[TReferences] - ) -> GenerativeReturn[Properties, TReferences]: ... + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... @overload def fetch_objects( self, @@ -80,12 +185,12 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, - include_vector: bool = False, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], return_references: Literal[None] = None - ) -> GenerativeReturn[TProperties, References]: ... + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def fetch_objects( self, @@ -97,12 +202,68 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, - include_vector: bool = False, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], return_references: REFERENCES - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def fetch_objects( self, @@ -114,9 +275,71 @@ class _FetchObjectsGenerate(Generic[Properties, References], _BaseQuery[Properti offset: Optional[int] = None, after: Optional[UUID] = None, filters: Optional[_Filters] = None, - sort: Optional[Union[Sort, List[Sort]]] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def fetch_objects( + self, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], return_references: Type[TReferences] - ) -> GenerativeReturn[TProperties, TReferences]: ... + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/fetch_objects/query.pyi b/weaviate/collections/queries/fetch_objects/query.pyi index 799c07adc..6ab0f8113 100644 --- a/weaviate/collections/queries/fetch_objects/query.pyi +++ b/weaviate/collections/queries/fetch_objects/query.pyi @@ -1,9 +1,8 @@ -from typing import Generic, List, Literal, Optional, Union, Type, overload - +from typing import Generic, Literal, Optional, Union, Type, overload from weaviate.collections.classes.filters import ( _Filters, ) -from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, _Sort, _Sorting +from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, _Sorting from weaviate.collections.classes.internal import ( QueryReturn, CrossReferences, @@ -11,7 +10,13 @@ from weaviate.collections.classes.internal import ( ReturnReferences, QueryReturnType, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery from weaviate.types import UUID @@ -25,11 +30,11 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, return_references: Literal[None] = None - ) -> QueryReturn[Properties, References]: ... + ) -> QueryReturn[Properties, None, None]: ... @overload def fetch_objects( self, @@ -39,11 +44,11 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, return_references: REFERENCES - ) -> QueryReturn[Properties, CrossReferences]: ... + ) -> QueryReturn[Properties, CrossReferences, None]: ... @overload def fetch_objects( self, @@ -53,11 +58,11 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, return_references: Type[TReferences] - ) -> QueryReturn[Properties, TReferences]: ... + ) -> QueryReturn[Properties, TReferences, None]: ... @overload def fetch_objects( self, @@ -67,11 +72,11 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Type[TProperties], return_references: Literal[None] = None - ) -> QueryReturn[TProperties, References]: ... + ) -> QueryReturn[TProperties, None, None]: ... @overload def fetch_objects( self, @@ -81,11 +86,11 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Type[TProperties], return_references: REFERENCES - ) -> QueryReturn[TProperties, CrossReferences]: ... + ) -> QueryReturn[TProperties, CrossReferences, None]: ... @overload def fetch_objects( self, @@ -95,11 +100,67 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Type[TProperties], return_references: Type[TReferences] - ) -> QueryReturn[TProperties, TReferences]: ... + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... @overload def fetch_objects( self, @@ -109,8 +170,116 @@ class _FetchObjectsQuery(Generic[Properties, References], _BaseQuery[Properties, after: Optional[UUID] = None, filters: Optional[_Filters] = None, sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, return_metadata: Optional[METADATA] = None, - return_properties: Optional[ReturnProperties[TProperties]] = None, - return_references: Optional[ReturnReferences[TReferences]] = None - ) -> QueryReturnType[Properties, References, TProperties, TReferences]: ... + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def fetch_objects( + self, + *, + limit: Optional[int] = None, + offset: Optional[int] = None, + after: Optional[UUID] = None, + filters: Optional[_Filters] = None, + sort: Optional[_Sorting] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... diff --git a/weaviate/collections/queries/hybrid/generate.pyi b/weaviate/collections/queries/hybrid/generate.pyi index 6e142ff03..d28bdf52f 100644 --- a/weaviate/collections/queries/hybrid/generate.pyi +++ b/weaviate/collections/queries/hybrid/generate.pyi @@ -1,5 +1,4 @@ -from typing import Generic, List, Literal, Optional, Type, overload - +from typing import Generic, List, Literal, Optional, Type, Union, overload from weaviate.collections.classes.filters import ( _Filters, ) @@ -8,7 +7,13 @@ from weaviate.collections.classes.internal import ( GenerativeReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery from weaviate.types import NUMBER @@ -30,11 +35,11 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... @overload def hybrid( self, @@ -52,11 +57,11 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... @overload def hybrid( self, @@ -74,11 +79,187 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... @overload def hybrid( self, @@ -96,11 +277,11 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... @overload def hybrid( self, @@ -118,11 +299,87 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def hybrid( self, @@ -140,8 +397,36 @@ class _HybridGenerate(Generic[Properties, References], _BaseQuery[Properties, Re auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def hybrid( + self, + query: str, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/hybrid/query.pyi b/weaviate/collections/queries/hybrid/query.pyi index 0b6475b07..32562025a 100644 --- a/weaviate/collections/queries/hybrid/query.pyi +++ b/weaviate/collections/queries/hybrid/query.pyi @@ -1,5 +1,4 @@ -from typing import Generic, List, Literal, Optional, Type, overload - +from typing import Generic, List, Literal, Optional, Type, Union, overload from weaviate.collections.classes.filters import ( _Filters, ) @@ -8,7 +7,13 @@ from weaviate.collections.classes.internal import ( QueryReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery from weaviate.types import NUMBER @@ -27,11 +32,11 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... @overload def hybrid( self, @@ -46,11 +51,11 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... @overload def hybrid( self, @@ -65,11 +70,144 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... @overload def hybrid( self, @@ -84,11 +222,11 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... @overload def hybrid( self, @@ -103,11 +241,92 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def hybrid( self, @@ -122,8 +341,32 @@ class _HybridQuery(Generic[Properties, References], _BaseQuery[Properties, Refer auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def hybrid( + self, + query: str, + *, + alpha: NUMBER = 0.5, + vector: Optional[List[float]] = None, + query_properties: Optional[List[str]] = None, + fusion_type: Optional[HybridFusion] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... diff --git a/weaviate/collections/queries/near_image/generate.pyi b/weaviate/collections/queries/near_image/generate.pyi index 207f4cb98..05c804e25 100644 --- a/weaviate/collections/queries/near_image/generate.pyi +++ b/weaviate/collections/queries/near_image/generate.pyi @@ -1,19 +1,21 @@ from io import BufferedReader from pathlib import Path from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank from weaviate.collections.classes.internal import ( GenerativeReturn, GenerativeGroupByReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -24,19 +26,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, None]: ... @overload def near_image( self, @@ -45,19 +68,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, None]: ... @overload def near_image( self, @@ -66,19 +110,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, None]: ... @overload def near_image( self, @@ -87,19 +152,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, None]: ... @overload def near_image( self, @@ -108,19 +194,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_image( self, @@ -129,20 +236,61 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... - ### GroupBy ### + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... @overload def near_image( self, @@ -151,19 +299,40 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... @overload def near_image( self, @@ -172,19 +341,82 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def near_image( self, @@ -193,19 +425,174 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[Properties, None, None], + GenerativeGroupByReturn[Properties, None, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_image( self, @@ -214,19 +601,93 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def near_image( self, @@ -235,19 +696,46 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[TProperties, None, None], + GenerativeGroupByReturn[TProperties, None, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_image( self, @@ -256,16 +744,67 @@ class _NearImageGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_image/query.pyi b/weaviate/collections/queries/near_image/query.pyi index 0d5818582..4ea31cafa 100644 --- a/weaviate/collections/queries/near_image/query.pyi +++ b/weaviate/collections/queries/near_image/query.pyi @@ -1,19 +1,17 @@ from io import BufferedReader from pathlib import Path from typing import Generic, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank -from weaviate.collections.classes.internal import ( - GroupByReturn, - QueryReturn, - CrossReferences, +from weaviate.collections.classes.internal import QueryReturn, GroupByReturn, CrossReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearImageQuery(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -21,217 +19,670 @@ class _NearImageQuery(Generic[Properties, References], _BaseQuery[Properties, Re self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... - - ### GroupBy ### - + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, None]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, Vectors]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[GroupByReturn[Properties, None, None], GroupByReturn[Properties, None, Vectors]]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GroupByReturn[TProperties, None, None], GroupByReturn[TProperties, None, Vectors] + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_image( self, near_image: Union[str, Path, BufferedReader], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... + @overload + def near_image( + self, + near_image: Union[str, Path, BufferedReader], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_media/generate.pyi b/weaviate/collections/queries/near_media/generate.pyi index fb78571a8..e25fc5005 100644 --- a/weaviate/collections/queries/near_media/generate.pyi +++ b/weaviate/collections/queries/near_media/generate.pyi @@ -1,26 +1,28 @@ from io import BufferedReader from pathlib import Path from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import ( METADATA, PROPERTIES, REFERENCES, GroupBy, - NearMediaType, Rerank, + NearMediaType, ) from weaviate.collections.classes.internal import ( GenerativeReturn, GenerativeGroupByReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -32,19 +34,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, None]: ... @overload def near_media( self, @@ -54,19 +78,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, None]: ... @overload def near_media( self, @@ -76,19 +122,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, None]: ... @overload def near_media( self, @@ -98,19 +166,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, None]: ... @overload def near_media( self, @@ -120,19 +210,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_media( self, @@ -142,20 +254,41 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... - ### GroupBy ### + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, None]: ... @overload def near_media( self, @@ -165,19 +298,63 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... @overload def near_media( self, @@ -187,19 +364,85 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def near_media( self, @@ -209,19 +452,181 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[Properties, None, None], + GenerativeGroupByReturn[Properties, None, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_media( self, @@ -231,19 +636,96 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def near_media( self, @@ -253,19 +735,47 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[TProperties, None, None], + GenerativeGroupByReturn[TProperties, None, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_media( self, @@ -275,16 +785,69 @@ class _NearMediaGenerate(Generic[Properties, References], _BaseQuery[Properties, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_media/query.pyi b/weaviate/collections/queries/near_media/query.pyi index d424628f1..5222da64f 100644 --- a/weaviate/collections/queries/near_media/query.pyi +++ b/weaviate/collections/queries/near_media/query.pyi @@ -1,26 +1,24 @@ from io import BufferedReader from pathlib import Path from typing import Generic, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import ( - GroupBy, METADATA, PROPERTIES, REFERENCES, - NearMediaType, + GroupBy, Rerank, + NearMediaType, ) -from weaviate.collections.classes.internal import ( - GroupByReturn, - QueryReturn, - CrossReferences, +from weaviate.collections.classes.internal import QueryReturn, GroupByReturn, CrossReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearMediaQuery(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -29,228 +27,705 @@ class _NearMediaQuery(Generic[Properties, References], _BaseQuery[Properties, Re media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... - - ### GroupBy ### - + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, None]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, Vectors]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[GroupByReturn[Properties, None, None], GroupByReturn[Properties, None, Vectors]]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GroupByReturn[TProperties, None, None], GroupByReturn[TProperties, None, Vectors] + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_media( self, media: Union[str, Path, BufferedReader], media_type: NearMediaType, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... + @overload + def near_media( + self, + media: Union[str, Path, BufferedReader], + media_type: NearMediaType, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_object/generate.pyi b/weaviate/collections/queries/near_object/generate.pyi index f3899c8db..53693e78b 100644 --- a/weaviate/collections/queries/near_object/generate.pyi +++ b/weaviate/collections/queries/near_object/generate.pyi @@ -1,17 +1,20 @@ from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank from weaviate.collections.classes.internal import ( GenerativeReturn, GenerativeGroupByReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER, UUID +from weaviate.types import UUID class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -22,19 +25,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, None]: ... @overload def near_object( self, @@ -43,19 +67,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, None]: ... @overload def near_object( self, @@ -64,19 +109,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, None]: ... @overload def near_object( self, @@ -85,19 +151,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, None]: ... @overload def near_object( self, @@ -106,19 +193,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_object( self, @@ -127,20 +235,61 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... - ### GroupBy ### + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... @overload def near_object( self, @@ -149,19 +298,40 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... @overload def near_object( self, @@ -170,19 +340,82 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def near_object( self, @@ -191,19 +424,174 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[Properties, None, None], + GenerativeGroupByReturn[Properties, None, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_object( self, @@ -212,19 +600,93 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def near_object( self, @@ -233,19 +695,46 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[TProperties, None, None], + GenerativeGroupByReturn[TProperties, None, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_object( self, @@ -254,16 +743,67 @@ class _NearObjectGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_object/query.pyi b/weaviate/collections/queries/near_object/query.pyi index 91d2230ac..ccbceb58c 100644 --- a/weaviate/collections/queries/near_object/query.pyi +++ b/weaviate/collections/queries/near_object/query.pyi @@ -1,17 +1,16 @@ from typing import Generic, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank -from weaviate.collections.classes.internal import ( - GroupByReturn, - QueryReturn, - CrossReferences, +from weaviate.collections.classes.internal import QueryReturn, GroupByReturn, CrossReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER, UUID +from weaviate.types import UUID class _NearObjectQuery(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -19,217 +18,670 @@ class _NearObjectQuery(Generic[Properties, References], _BaseQuery[Properties, R self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... - - ### GroupBy ### - + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, None]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, Vectors]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[GroupByReturn[Properties, None, None], GroupByReturn[Properties, None, Vectors]]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GroupByReturn[TProperties, None, None], GroupByReturn[TProperties, None, Vectors] + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_object( self, near_object: UUID, *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... + @overload + def near_object( + self, + near_object: UUID, + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_text/generate.pyi b/weaviate/collections/queries/near_text/generate.pyi index 878e09ee3..297d07e14 100644 --- a/weaviate/collections/queries/near_text/generate.pyi +++ b/weaviate/collections/queries/near_text/generate.pyi @@ -1,8 +1,5 @@ from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import ( METADATA, PROPERTIES, @@ -16,285 +13,876 @@ from weaviate.collections.classes.internal import ( GenerativeGroupByReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER +from weaviate.types import UUID class _NearTextGenerate(Generic[Properties, References], _BaseQuery[Properties, References]): @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... - ### GroupBy ### + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[Properties, None, None], + GenerativeGroupByReturn[Properties, None, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[TProperties, None, None], + GenerativeGroupByReturn[TProperties, None, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_text/query.pyi b/weaviate/collections/queries/near_text/query.pyi index 1da131bc9..79f6ed3ef 100644 --- a/weaviate/collections/queries/near_text/query.pyi +++ b/weaviate/collections/queries/near_text/query.pyi @@ -1,8 +1,5 @@ from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import ( METADATA, PROPERTIES, @@ -11,256 +8,759 @@ from weaviate.collections.classes.grpc import ( Move, Rerank, ) -from weaviate.collections.classes.internal import ( - GroupByReturn, - QueryReturn, - CrossReferences, +from weaviate.collections.classes.internal import QueryReturn, GroupByReturn, CrossReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER +from weaviate.types import UUID class _NearTextQuery(Generic[Properties, References], _BaseQuery[Properties, References]): @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... - - ### GroupBy ### - + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, None]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, Vectors]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[GroupByReturn[Properties, None, None], GroupByReturn[Properties, None, Vectors]]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GroupByReturn[TProperties, None, None], GroupByReturn[TProperties, None, Vectors] + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_text( self, - query: Union[List[str], str], + query: Union[str, List[str]], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, move_to: Optional[Move] = None, move_away: Optional[Move] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... + @overload + def near_text( + self, + query: Union[str, List[str]], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + move_to: Optional[Move] = None, + move_away: Optional[Move] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_vector/generate.pyi b/weaviate/collections/queries/near_vector/generate.pyi index b2d222d12..54876c74f 100644 --- a/weaviate/collections/queries/near_vector/generate.pyi +++ b/weaviate/collections/queries/near_vector/generate.pyi @@ -1,17 +1,19 @@ from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank from weaviate.collections.classes.internal import ( GenerativeReturn, GenerativeGroupByReturn, CrossReferences, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, +) from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -22,19 +24,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, None]: ... @overload def near_vector( self, @@ -43,19 +66,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, None]: ... @overload def near_vector( self, @@ -64,19 +108,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, None]: ... @overload def near_vector( self, @@ -85,19 +150,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, None]: ... @overload def near_vector( self, @@ -106,19 +192,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_vector( self, @@ -127,20 +234,61 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeReturn[TProperties, TReferences]: ... - ### GroupBy ### + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeReturn[Properties, None, Vectors]: ... @overload def near_vector( self, @@ -149,19 +297,40 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[Properties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> GenerativeReturn[Properties, CrossReferences, Vectors]: ... @overload def near_vector( self, @@ -170,19 +339,82 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GenerativeGroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> GenerativeReturn[Properties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeReturn[TProperties, None, Vectors]: ... @overload def near_vector( self, @@ -191,19 +423,174 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GenerativeGroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GenerativeGroupByReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GenerativeGroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[Properties, None, None], GenerativeReturn[Properties, None, Vectors] + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[Properties, None, None], + GenerativeGroupByReturn[Properties, None, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[Properties, CrossReferences, None], + GenerativeReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_vector( self, @@ -212,19 +599,93 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[Properties, CrossReferences, None], + GenerativeGroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[Properties, TReferences, None], + GenerativeReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[Properties, TReferences, None], + GenerativeGroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GenerativeGroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[ + GenerativeReturn[TProperties, None, None], GenerativeReturn[TProperties, None, Vectors] + ]: ... @overload def near_vector( self, @@ -233,19 +694,46 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GenerativeGroupByReturn[TProperties, None, None], + GenerativeGroupByReturn[TProperties, None, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GenerativeGroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + GenerativeReturn[TProperties, CrossReferences, None], + GenerativeReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_vector( self, @@ -254,16 +742,67 @@ class _NearVectorGenerate(Generic[Properties, References], _BaseQuery[Properties single_prompt: Optional[str] = None, grouped_task: Optional[str] = None, grouped_properties: Optional[List[str]] = None, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GenerativeGroupByReturn[TProperties, CrossReferences, None], + GenerativeGroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + GenerativeReturn[TProperties, TReferences, None], + GenerativeReturn[TProperties, TReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + single_prompt: Optional[str] = None, + grouped_task: Optional[str] = None, + grouped_properties: Optional[List[str]] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GenerativeGroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GenerativeGroupByReturn[TProperties, TReferences, None], + GenerativeGroupByReturn[TProperties, TReferences, Vectors], + ]: ... diff --git a/weaviate/collections/queries/near_vector/query.pyi b/weaviate/collections/queries/near_vector/query.pyi index 328f07f47..9d6aa582d 100644 --- a/weaviate/collections/queries/near_vector/query.pyi +++ b/weaviate/collections/queries/near_vector/query.pyi @@ -1,17 +1,15 @@ from typing import Generic, List, Literal, Optional, Type, Union, overload - -from weaviate.collections.classes.filters import ( - _Filters, -) +from weaviate.collections.classes.filters import _Filters from weaviate.collections.classes.grpc import METADATA, PROPERTIES, REFERENCES, GroupBy, Rerank -from weaviate.collections.classes.internal import ( - GroupByReturn, - QueryReturn, - CrossReferences, +from weaviate.collections.classes.internal import QueryReturn, GroupByReturn, CrossReferences +from weaviate.collections.classes.types import ( + Properties, + TProperties, + References, + TReferences, + Vectors, ) -from weaviate.collections.classes.types import Properties, TProperties, References, TReferences from weaviate.collections.queries.base import _BaseQuery -from weaviate.types import NUMBER class _NearVectorQuery(Generic[Properties, References], _BaseQuery[Properties, References]): @overload @@ -19,217 +17,670 @@ class _NearVectorQuery(Generic[Properties, References], _BaseQuery[Properties, R self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> QueryReturn[Properties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> QueryReturn[Properties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> QueryReturn[Properties, TReferences]: ... + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> QueryReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> QueryReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: Literal[None] = None, + include_vector: Literal[False] = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, None]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[False] = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> QueryReturn[TProperties, TReferences]: ... - - ### GroupBy ### - + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, None]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> QueryReturn[Properties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> GroupByReturn[Properties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: Literal[None] = None, - ) -> GroupByReturn[Properties, References]: ... + return_references: REFERENCES + ) -> QueryReturn[Properties, CrossReferences, Vectors]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> GroupByReturn[Properties, CrossReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, - include_vector: bool = False, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], return_properties: Optional[PROPERTIES] = None, - return_references: REFERENCES, - ) -> GroupByReturn[Properties, CrossReferences]: ... + return_references: Type[TReferences] + ) -> QueryReturn[Properties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> GroupByReturn[Properties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> QueryReturn[TProperties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> GroupByReturn[TProperties, None, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> QueryReturn[TProperties, CrossReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> GroupByReturn[TProperties, CrossReferences, Vectors]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> QueryReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: Literal[True], + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> GroupByReturn[TProperties, TReferences, Vectors]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[QueryReturn[Properties, None, None], QueryReturn[Properties, None, Vectors]]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Literal[None] = None + ) -> Union[GroupByReturn[Properties, None, None], GroupByReturn[Properties, None, Vectors]]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Optional[PROPERTIES] = None, - return_references: Type[TReferences], - ) -> GroupByReturn[Properties, TReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[Properties, CrossReferences, None], + QueryReturn[Properties, CrossReferences, Vectors], + ]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: REFERENCES + ) -> Union[ + GroupByReturn[Properties, CrossReferences, None], + GroupByReturn[Properties, CrossReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[Properties, TReferences, None], QueryReturn[Properties, TReferences, Vectors] + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Optional[PROPERTIES] = None, + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[Properties, TReferences, None], + GroupByReturn[Properties, TReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Literal[None] = None, - ) -> GroupByReturn[TProperties, References]: ... + return_references: Literal[None] = None + ) -> Union[QueryReturn[TProperties, None, None], QueryReturn[TProperties, None, Vectors]]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, - group_by: GroupBy, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: GroupBy, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Literal[None] = None + ) -> Union[ + GroupByReturn[TProperties, None, None], GroupByReturn[TProperties, None, Vectors] + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: REFERENCES, - ) -> GroupByReturn[TProperties, CrossReferences]: ... + return_references: REFERENCES + ) -> Union[ + QueryReturn[TProperties, CrossReferences, None], + QueryReturn[TProperties, CrossReferences, Vectors], + ]: ... @overload def near_vector( self, near_vector: List[float], *, - certainty: Optional[NUMBER] = None, - distance: Optional[NUMBER] = None, + certainty: Optional[float] = None, + distance: Optional[float] = None, limit: Optional[int] = None, offset: Optional[int] = None, auto_limit: Optional[int] = None, filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, group_by: GroupBy, + include_vector: bool = False, + return_properties: Type[TProperties], + return_references: REFERENCES + ) -> Union[ + GroupByReturn[TProperties, CrossReferences, None], + GroupByReturn[TProperties, CrossReferences, Vectors], + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, rerank: Optional[Rerank] = None, + return_metadata: Optional[METADATA] = None, + group_by: Literal[None] = None, include_vector: bool = False, + return_properties: Type[TProperties], + return_references: Type[TReferences] + ) -> Union[ + QueryReturn[TProperties, TReferences, None], QueryReturn[TProperties, TReferences, Vectors] + ]: ... + @overload + def near_vector( + self, + near_vector: List[float], + *, + certainty: Optional[float] = None, + distance: Optional[float] = None, + limit: Optional[int] = None, + offset: Optional[int] = None, + auto_limit: Optional[int] = None, + filters: Optional[_Filters] = None, + rerank: Optional[Rerank] = None, return_metadata: Optional[METADATA] = None, + group_by: GroupBy, + include_vector: bool = False, return_properties: Type[TProperties], - return_references: Type[TReferences], - ) -> GroupByReturn[TProperties, TReferences]: ... + return_references: Type[TReferences] + ) -> Union[ + GroupByReturn[TProperties, TReferences, None], + GroupByReturn[TProperties, TReferences, Vectors], + ]: ...