zvec 0.8.0__cp313-cp313-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. zvec/__init__.py +205 -0
  2. zvec/__init__.pyi +242 -0
  3. zvec/_zvec.cp313-win_arm64.pyd +0 -0
  4. zvec/common/__init__.py +18 -0
  5. zvec/common/constants.py +33 -0
  6. zvec/executor/__init__.py +24 -0
  7. zvec/executor/query_executor.py +269 -0
  8. zvec/extension/__init__.py +58 -0
  9. zvec/extension/bm25_embedding_function.py +375 -0
  10. zvec/extension/embedding_function.py +147 -0
  11. zvec/extension/http_embedding_function.py +162 -0
  12. zvec/extension/jina_embedding_function.py +240 -0
  13. zvec/extension/jina_function.py +182 -0
  14. zvec/extension/multi_vector_reranker.py +197 -0
  15. zvec/extension/openai_embedding_function.py +238 -0
  16. zvec/extension/openai_function.py +149 -0
  17. zvec/extension/qwen_embedding_function.py +537 -0
  18. zvec/extension/qwen_function.py +186 -0
  19. zvec/extension/qwen_rerank_function.py +177 -0
  20. zvec/extension/rerank_function.py +56 -0
  21. zvec/extension/sentence_transformer_embedding_function.py +839 -0
  22. zvec/extension/sentence_transformer_function.py +150 -0
  23. zvec/extension/sentence_transformer_rerank_function.py +396 -0
  24. zvec/model/__init__.py +31 -0
  25. zvec/model/_validation.py +31 -0
  26. zvec/model/collection.py +714 -0
  27. zvec/model/convert.py +59 -0
  28. zvec/model/doc.py +201 -0
  29. zvec/model/param/__init__.py +64 -0
  30. zvec/model/param/__init__.pyi +1490 -0
  31. zvec/model/param/query.py +177 -0
  32. zvec/model/schema/__init__.py +21 -0
  33. zvec/model/schema/__init__.pyi +109 -0
  34. zvec/model/schema/collection_schema.py +220 -0
  35. zvec/model/schema/field_schema.py +333 -0
  36. zvec/py.typed +0 -0
  37. zvec/tool/__init__.py +18 -0
  38. zvec/tool/util.py +63 -0
  39. zvec/typing/__init__.py +34 -0
  40. zvec/typing/__init__.pyi +492 -0
  41. zvec/typing/enum.py +62 -0
  42. zvec/zvec.py +236 -0
  43. zvec-0.8.0.dist-info/METADATA +204 -0
  44. zvec-0.8.0.dist-info/RECORD +47 -0
  45. zvec-0.8.0.dist-info/WHEEL +5 -0
  46. zvec-0.8.0.dist-info/licenses/LICENSE +201 -0
  47. zvec-0.8.0.dist-info/licenses/NOTICE +96 -0
zvec/__init__.py ADDED
@@ -0,0 +1,205 @@
1
+ # Copyright 2025-present the zvec project
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ import sys
18
+ from typing import TYPE_CHECKING
19
+
20
+ if TYPE_CHECKING:
21
+ from importlib.metadata import PackageNotFoundError
22
+
23
+ # zvec ships a native C++ extension that is only built and tested for 64-bit
24
+ # CPython. A 32-bit interpreter would fail to load the extension with an
25
+ # obscure error, so fail fast here with an actionable message.
26
+ if sys.maxsize <= 2**32:
27
+ raise ImportError(
28
+ "zvec requires a 64-bit Python interpreter; "
29
+ "the current interpreter is 32-bit and is not supported."
30
+ )
31
+
32
+
33
+ from zvec._zvec import io_backend_description, io_backend_type
34
+
35
+ # ==============================
36
+ # Public API — grouped by category
37
+ # ==============================
38
+ from . import model as model
39
+
40
+ # —— Extensions ——
41
+ from .extension import (
42
+ BM25EmbeddingFunction,
43
+ DefaultLocalDenseEmbedding,
44
+ DefaultLocalReRanker,
45
+ DefaultLocalSparseEmbedding,
46
+ DenseEmbeddingFunction,
47
+ OpenAIDenseEmbedding,
48
+ OpenAIFunctionBase,
49
+ QwenDenseEmbedding,
50
+ QwenFunctionBase,
51
+ QwenReRanker,
52
+ QwenSparseEmbedding,
53
+ ReRanker,
54
+ RrfReRanker,
55
+ SentenceTransformerFunctionBase,
56
+ SparseEmbeddingFunction,
57
+ WeightedReRanker,
58
+ )
59
+
60
+ # —— Typing ——
61
+ from .model import param as param
62
+ from .model import schema as schema
63
+
64
+ # —— Core data structures ——
65
+ from .model.collection import Collection
66
+ from .model.doc import Doc, DocList, GroupResult
67
+
68
+ # —— Query & index parameters ——
69
+ # —— FTS params (C++ binding) ——
70
+ from .model.param import (
71
+ AddColumnOption,
72
+ AlterColumnOption,
73
+ CollectionOption,
74
+ DiskAnnIndexParam,
75
+ DiskAnnQueryParam,
76
+ FlatIndexParam,
77
+ FtsIndexParam,
78
+ FtsQueryParam,
79
+ HnswIndexParam,
80
+ HnswQueryParam,
81
+ HnswRabitqIndexParam,
82
+ HnswRabitqQueryParam,
83
+ IndexOption,
84
+ InvertIndexParam,
85
+ IVFIndexParam,
86
+ IVFQueryParam,
87
+ IvfRabitqIndexParam,
88
+ IvfRabitqQueryParam,
89
+ OptimizeOption,
90
+ QuantizerParam,
91
+ VamanaIndexParam,
92
+ VamanaQueryParam,
93
+ )
94
+ from .model.param.query import Fts, Query, VectorQuery
95
+
96
+ # —— Schema & field definitions ——
97
+ from .model.schema import CollectionSchema, CollectionStats, FieldSchema, VectorSchema
98
+
99
+ # —— tools ——
100
+ from .tool import require_module
101
+ from .typing import (
102
+ DataType,
103
+ IndexType,
104
+ IOBackendType,
105
+ MetricType,
106
+ QuantizeType,
107
+ Status,
108
+ StatusCode,
109
+ )
110
+ from .typing.enum import LogLevel, LogType
111
+
112
+ # —— lifecycle ——
113
+ from .zvec import create_and_open, init, open
114
+
115
+ # ==============================
116
+ # Public interface declaration
117
+ # ==============================
118
+ __all__ = [
119
+ # Zvec functions
120
+ "create_and_open",
121
+ "init",
122
+ "open",
123
+ "io_backend_type",
124
+ "io_backend_description",
125
+ # Core classes
126
+ "Collection",
127
+ "Doc",
128
+ "DocList",
129
+ # Schema
130
+ "CollectionSchema",
131
+ "FieldSchema",
132
+ "VectorSchema",
133
+ "CollectionStats",
134
+ # Parameters
135
+ "GroupResult",
136
+ "Query",
137
+ "VectorQuery",
138
+ "Fts",
139
+ "FtsIndexParam",
140
+ "FtsQueryParam",
141
+ "InvertIndexParam",
142
+ "HnswIndexParam",
143
+ "HnswRabitqIndexParam",
144
+ "IvfRabitqIndexParam",
145
+ "FlatIndexParam",
146
+ "IVFIndexParam",
147
+ "DiskAnnIndexParam",
148
+ "DiskAnnQueryParam",
149
+ "CollectionOption",
150
+ "IndexOption",
151
+ "OptimizeOption",
152
+ "AddColumnOption",
153
+ "AlterColumnOption",
154
+ "HnswQueryParam",
155
+ "HnswRabitqQueryParam",
156
+ "IvfRabitqQueryParam",
157
+ "IVFQueryParam",
158
+ "QuantizerParam",
159
+ "VamanaIndexParam",
160
+ "VamanaQueryParam",
161
+ # Extensions
162
+ "DenseEmbeddingFunction",
163
+ "SparseEmbeddingFunction",
164
+ "QwenFunctionBase",
165
+ "OpenAIFunctionBase",
166
+ "SentenceTransformerFunctionBase",
167
+ "ReRanker",
168
+ "DefaultLocalDenseEmbedding",
169
+ "DefaultLocalSparseEmbedding",
170
+ "BM25EmbeddingFunction",
171
+ "OpenAIDenseEmbedding",
172
+ "QwenDenseEmbedding",
173
+ "QwenSparseEmbedding",
174
+ "RrfReRanker",
175
+ "WeightedReRanker",
176
+ "DefaultLocalReRanker",
177
+ "QwenReRanker",
178
+ # Typing
179
+ "DataType",
180
+ "IOBackendType",
181
+ "MetricType",
182
+ "QuantizeType",
183
+ "IndexType",
184
+ "LogLevel",
185
+ "LogType",
186
+ "Status",
187
+ "StatusCode",
188
+ # Tools
189
+ "require_module",
190
+ ]
191
+
192
+ # ==============================
193
+ # Version handling
194
+ # ==============================
195
+ __version__: str
196
+
197
+ try:
198
+ from importlib.metadata import version
199
+ except ImportError:
200
+ from importlib_metadata import version # Python < 3.8
201
+
202
+ try:
203
+ __version__ = version("zvec")
204
+ except Exception:
205
+ __version__ = "unknown"
zvec/__init__.pyi ADDED
@@ -0,0 +1,242 @@
1
+ """
2
+ Zvec core module
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import collections
8
+
9
+ from . import typing
10
+ from .extension import ReRanker, RrfReRanker, WeightedReRanker
11
+ from .extension.embedding import DenseEmbeddingFunction
12
+ from .model import param, schema
13
+ from .model.collection import Collection
14
+ from .model.doc import Doc, DocList, GroupResult
15
+ from .model.param import (
16
+ AddColumnOption,
17
+ AlterColumnOption,
18
+ CollectionOption,
19
+ DiskAnnIndexParam,
20
+ DiskAnnQueryParam,
21
+ FlatIndexParam,
22
+ FtsIndexParam,
23
+ FtsQueryParam,
24
+ HnswIndexParam,
25
+ HnswQueryParam,
26
+ HnswRabitqIndexParam,
27
+ HnswRabitqQueryParam,
28
+ IndexOption,
29
+ InvertIndexParam,
30
+ IVFIndexParam,
31
+ IVFQueryParam,
32
+ IvfRabitqIndexParam,
33
+ IvfRabitqQueryParam,
34
+ OptimizeOption,
35
+ QuantizerParam,
36
+ VamanaIndexParam,
37
+ VamanaQueryParam,
38
+ )
39
+ from .model.param.query import Fts, Query, VectorQuery
40
+ from .model.schema import CollectionSchema, CollectionStats, FieldSchema, VectorSchema
41
+ from .tool import require_module
42
+ from .typing import (
43
+ DataType,
44
+ IndexType,
45
+ IOBackendType,
46
+ MetricType,
47
+ QuantizeType,
48
+ Status,
49
+ StatusCode,
50
+ )
51
+ from .typing.enum import LogLevel, LogType
52
+ from .zvec import create_and_open, init, open
53
+
54
+ def io_backend_type() -> IOBackendType:
55
+ """Returns the current I/O backend type for DiskAnn disk reads.
56
+
57
+ Linux selects IOBackendType.IO_URING, IOBackendType.LIBAIO, or
58
+ IOBackendType.PREAD in that order. macOS ARM64 uses IOBackendType.PREAD.
59
+ Windows uses IOBackendType.WINDOWS_OVERLAPPED.
60
+ """
61
+
62
+ def io_backend_description() -> str:
63
+ """Returns a human-readable description of the current I/O backend.
64
+
65
+ The description identifies io_uring, libaio, or pread. On Linux, the
66
+ pread description includes guidance for enabling io_uring or installing
67
+ libaio. Windows reports its overlapped-I/O backend.
68
+ """
69
+
70
+ __all__: list = [
71
+ "AddColumnOption",
72
+ "AlterColumnOption",
73
+ "Collection",
74
+ "CollectionOption",
75
+ "CollectionSchema",
76
+ "CollectionStats",
77
+ "DataType",
78
+ "DenseEmbeddingFunction",
79
+ "DiskAnnIndexParam",
80
+ "DiskAnnQueryParam",
81
+ "Doc",
82
+ "DocList",
83
+ "FieldSchema",
84
+ "FlatIndexParam",
85
+ "Fts",
86
+ "FtsIndexParam",
87
+ "FtsQueryParam",
88
+ "GroupResult",
89
+ "HnswIndexParam",
90
+ "HnswQueryParam",
91
+ "HnswRabitqIndexParam",
92
+ "HnswRabitqQueryParam",
93
+ "IOBackendType",
94
+ "IVFIndexParam",
95
+ "IVFQueryParam",
96
+ "IndexOption",
97
+ "IndexType",
98
+ "InvertIndexParam",
99
+ "IvfRabitqIndexParam",
100
+ "IvfRabitqQueryParam",
101
+ "LogLevel",
102
+ "LogType",
103
+ "MetricType",
104
+ "OptimizeOption",
105
+ "QuantizeType",
106
+ "QuantizerParam",
107
+ "Query",
108
+ "ReRanker",
109
+ "RrfReRanker",
110
+ "Status",
111
+ "StatusCode",
112
+ "VamanaIndexParam",
113
+ "VamanaQueryParam",
114
+ "VectorQuery",
115
+ "VectorSchema",
116
+ "WeightedReRanker",
117
+ "create_and_open",
118
+ "init",
119
+ "io_backend_description",
120
+ "io_backend_type",
121
+ "open",
122
+ "require_module",
123
+ ]
124
+
125
+ class _Collection:
126
+ @staticmethod
127
+ def CreateAndOpen(
128
+ arg0: str, arg1: schema._CollectionSchema, arg2: param.CollectionOption
129
+ ) -> _Collection: ...
130
+ @staticmethod
131
+ def Open(arg0: str, arg1: param.CollectionOption) -> _Collection: ...
132
+ def AddColumn(
133
+ self,
134
+ arg0: schema._FieldSchema,
135
+ arg1: str,
136
+ arg2: param.AddColumnOption,
137
+ ) -> None: ...
138
+ def AlterColumn(
139
+ self,
140
+ arg0: str,
141
+ arg1: str,
142
+ arg2: schema._FieldSchema,
143
+ arg3: param.AlterColumnOption,
144
+ ) -> None: ...
145
+ def Close(self) -> None: ...
146
+ def CreateIndex(
147
+ self, arg0: str, arg1: param.IndexParam, arg2: param.IndexOption
148
+ ) -> None: ...
149
+ def Delete(self, arg0: collections.abc.Sequence[str]) -> list[typing.Status]: ...
150
+ def DeleteByFilter(self, arg0: str) -> None: ...
151
+ def Destroy(self) -> None: ...
152
+ def DropColumn(self, arg0: str) -> None: ...
153
+ def DropIndex(self, arg0: str) -> None: ...
154
+ def Fetch(
155
+ self,
156
+ pks: collections.abc.Sequence[str],
157
+ output_fields: list[str] | None = None,
158
+ include_vector: bool = True,
159
+ ) -> dict[str, _Doc]: ...
160
+ def Flush(self) -> None: ...
161
+ def GroupByQuery(self, arg0: param._GroupByVectorQuery) -> list[_GroupResult]: ...
162
+ def Insert(self, arg0: collections.abc.Sequence[_Doc]) -> list[typing.Status]: ...
163
+ def Optimize(self, arg0: param.OptimizeOption) -> None: ...
164
+ def Options(self) -> param.CollectionOption: ...
165
+ def Path(self) -> str: ...
166
+ def Query(
167
+ self, arg0: param._SearchQuery
168
+ ) -> list[tuple[str, float, dict | None, dict | None] | None]: ...
169
+ def QueryInternalIds(
170
+ self, query: param._SearchQuery, return_scores: bool = False
171
+ ) -> typing.Any: ...
172
+ def ResolveInternalIds(
173
+ self, ids: collections.abc.Sequence[int]
174
+ ) -> list[str | None]: ...
175
+ def Schema(self) -> schema._CollectionSchema: ...
176
+ def Stats(self) -> schema.CollectionStats: ...
177
+ def Update(self, arg0: collections.abc.Sequence[_Doc]) -> list[typing.Status]: ...
178
+ def Upsert(self, arg0: collections.abc.Sequence[_Doc]) -> list[typing.Status]: ...
179
+ def _debug_hnsw_storage_mode(self, column_name: str) -> str:
180
+ """Debug-only: returns the storage mode of the HNSW entity on the
181
+ given vector column. One of 'mmap', 'buffer_pool', 'contiguous'.
182
+ Raises KeyError if no HNSW index exists on the column, or
183
+ ValueError if the column's index is not an HNSW index. Intended
184
+ for introspection and testing only; not part of the stable API."""
185
+
186
+ def __getstate__(self) -> tuple: ...
187
+ def __setstate__(self, arg0: tuple) -> None: ...
188
+
189
+ class _Doc:
190
+ def __getstate__(self) -> bytes: ...
191
+ def __init__(self) -> None: ...
192
+ def __setstate__(self, arg0: bytes) -> None: ...
193
+ def field_names(self) -> list[str]: ...
194
+ def get_any(self, arg0: str, arg1: typing.DataType) -> typing.Any: ...
195
+ def has_field(self, arg0: str) -> bool: ...
196
+ def pk(self) -> str: ...
197
+ def score(self) -> float: ...
198
+ def set_any(self, arg0: str, arg1: typing.DataType, arg2: typing.Any) -> bool: ...
199
+ def set_pk(self, arg0: str) -> None: ...
200
+ def set_score(self, arg0: typing.SupportsFloat) -> None: ...
201
+
202
+ class _GroupResult:
203
+ @property
204
+ def docs(self) -> list[_Doc]: ...
205
+ @property
206
+ def group_by_value(self) -> str: ...
207
+
208
+ class _DocOp:
209
+ """
210
+ Members:
211
+
212
+ INSERT
213
+
214
+ UPDATE
215
+
216
+ DELETE
217
+
218
+ UPSERT
219
+ """
220
+
221
+ DELETE: typing.ClassVar[_DocOp] # value = <_DocOp.DELETE: 3>
222
+ INSERT: typing.ClassVar[_DocOp] # value = <_DocOp.INSERT: 0>
223
+ UPDATE: typing.ClassVar[_DocOp] # value = <_DocOp.UPDATE: 2>
224
+ UPSERT: typing.ClassVar[_DocOp] # value = <_DocOp.UPSERT: 1>
225
+ __members__: typing.ClassVar[
226
+ dict[str, _DocOp]
227
+ ] # value = {'INSERT': <_DocOp.INSERT: 0>, 'UPDATE': <_DocOp.UPDATE: 2>, 'DELETE': <_DocOp.DELETE: 3>, 'UPSERT': <_DocOp.UPSERT: 1>}
228
+
229
+ def __eq__(self, other: typing.Any) -> bool: ...
230
+ def __getstate__(self) -> int: ...
231
+ def __hash__(self) -> int: ...
232
+ def __index__(self) -> int: ...
233
+ def __init__(self, value: typing.SupportsInt) -> None: ...
234
+ def __int__(self) -> int: ...
235
+ def __ne__(self, other: typing.Any) -> bool: ...
236
+ def __repr__(self) -> str: ...
237
+ def __setstate__(self, state: typing.SupportsInt) -> None: ...
238
+ def __str__(self) -> str: ...
239
+ @property
240
+ def name(self) -> str: ...
241
+ @property
242
+ def value(self) -> int: ...
Binary file
@@ -0,0 +1,18 @@
1
+ # Copyright 2025-present the zvec project
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ from __future__ import annotations
15
+
16
+ from .constants import DenseVectorType, SparseVectorType, VectorType
17
+
18
+ __all__ = ["DenseVectorType", "SparseVectorType", "VectorType"]
@@ -0,0 +1,33 @@
1
+ # Copyright 2025-present the zvec project
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ from __future__ import annotations
15
+
16
+ from typing import Optional, TypeVar, Union
17
+
18
+ import numpy as np
19
+
20
+ # VectorType: DenseVectorType | SparseVectorType
21
+ DenseVectorType = Union[list[float], list[int], np.ndarray]
22
+ SparseVectorType = dict[int, float]
23
+ VectorType = Optional[Union[DenseVectorType, SparseVectorType]]
24
+
25
+ # Embeddable: Text | Image | Audio
26
+ TEXT = str
27
+ IMAGE = Union[str, bytes, np.ndarray] # file path, raw bytes, or numpy array
28
+ AUDIO = Union[str, bytes, np.ndarray] # file path, raw bytes, or numpy array
29
+
30
+ Embeddable = Optional[Union[TEXT, IMAGE, AUDIO]]
31
+
32
+ # Multimodal Embeddable
33
+ MD = TypeVar("MD", bound=Embeddable, contravariant=True)
@@ -0,0 +1,24 @@
1
+ # Copyright 2025-present the zvec project
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ from __future__ import annotations
15
+
16
+ from .query_executor import (
17
+ QueryContext,
18
+ QueryExecutor,
19
+ )
20
+
21
+ __all__ = [
22
+ "QueryContext",
23
+ "QueryExecutor",
24
+ ]