cocoindex 0.1.49__cp312-cp312-macosx_11_0_arm64.whl → 0.1.51__cp312-cp312-macosx_11_0_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.
- cocoindex/__init__.py +52 -1
- cocoindex/_engine.cpython-312-darwin.so +0 -0
- cocoindex/cli.py +22 -4
- cocoindex/convert.py +41 -1
- cocoindex/functions.py +6 -4
- cocoindex/lib.py +1 -2
- cocoindex/setting.py +10 -6
- cocoindex/tests/test_convert.py +359 -84
- cocoindex/tests/test_optional_database.py +249 -0
- cocoindex/tests/test_typing.py +505 -0
- cocoindex/typing.py +92 -17
- {cocoindex-0.1.49.dist-info → cocoindex-0.1.51.dist-info}/METADATA +1 -1
- cocoindex-0.1.51.dist-info/RECORD +28 -0
- {cocoindex-0.1.49.dist-info → cocoindex-0.1.51.dist-info}/WHEEL +1 -1
- cocoindex/query.py +0 -115
- cocoindex-0.1.49.dist-info/RECORD +0 -27
- {cocoindex-0.1.49.dist-info → cocoindex-0.1.51.dist-info}/entry_points.txt +0 -0
- {cocoindex-0.1.49.dist-info → cocoindex-0.1.51.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
cocoindex-0.1.51.dist-info/METADATA,sha256=A88vlfjkMZq9o0uB23j60uueJrzBs7RPf38zSHP6MuY,9875
|
2
|
+
cocoindex-0.1.51.dist-info/WHEEL,sha256=vahFoO0M6DZmYz1cr_3GC_BJXbjcSJJ4jR_JC04LGJc,104
|
3
|
+
cocoindex-0.1.51.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
|
4
|
+
cocoindex-0.1.51.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
|
+
cocoindex/__init__.py,sha256=H0YmqZaLBNLtY4PWYM1w9lM_HbiGGh2xEwo1_NMDOOE,1698
|
6
|
+
cocoindex/_engine.cpython-312-darwin.so,sha256=yj1dAXaCGAJ9uMaZZsp8d1guRVkrV483q6psHWLcTDI,57344608
|
7
|
+
cocoindex/auth_registry.py,sha256=1XqO7ibjmBBd8i11XSJTvTgdz8p1ptW-ZpuSgo_5zzk,716
|
8
|
+
cocoindex/cli.py,sha256=mlHIgH8vgf4PuTYifAOtn2ywcbVCOT452pIg376uPLs,18224
|
9
|
+
cocoindex/convert.py,sha256=s5T2IQ1tMBT9JKTzqQtQ-I0sUrfjBGKAnMjDjY6LdrI,8785
|
10
|
+
cocoindex/flow.py,sha256=sC7eg0L9MkZuo7MlvGA4eYe-mEReIyPjKIILFtkWm-Y,30017
|
11
|
+
cocoindex/functions.py,sha256=9A61Jj5a3vQoI2MIAhjXvJrDxSzDhe6VncQWbiVtwcg,2393
|
12
|
+
cocoindex/index.py,sha256=j93B9jEvvLXHtpzKWL88SY6wCGEoPgpsQhEGHlyYGFg,540
|
13
|
+
cocoindex/lib.py,sha256=BeRUn3RqE_wSsVtsgCzbFFKe1LXgRyRmMOcmwWBuEXo,2940
|
14
|
+
cocoindex/llm.py,sha256=KO-R4mrAWtxXD82-Yv5ixpkKMVfkwpbdWwqPVZygLu4,352
|
15
|
+
cocoindex/op.py,sha256=hOJoHC8elhLHMNVRTGTBWNSK5uYrQb-FfRV-qt08j8g,11815
|
16
|
+
cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
+
cocoindex/runtime.py,sha256=bAdHYaXFWiiUWyAgzmKTeaAaRR0D_AmaqVCIdPO-v00,1056
|
18
|
+
cocoindex/setting.py,sha256=Zl8K86r8RVvG9c3pCsH0Ot8BHhDAQAQCjoBp7TnXMLQ,3590
|
19
|
+
cocoindex/setup.py,sha256=u5dYZFKfz4yZLiGHD0guNaR0s4zY9JAoZWrWHpAHw_0,773
|
20
|
+
cocoindex/sources.py,sha256=JCnOhv1w4o28e03i7yvo4ESicWYAhckkBg5bQlxNH4U,1330
|
21
|
+
cocoindex/storages.py,sha256=i9cPzj5LbLJVHjskEWyltUXF9kqCyc6ftMEqll6FDwI,2804
|
22
|
+
cocoindex/tests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
23
|
+
cocoindex/tests/test_convert.py,sha256=mlCJ1U_T7sPDk1Dw78V1BKaYbfqjDjGAaOZT0zMYOwg,28960
|
24
|
+
cocoindex/tests/test_optional_database.py,sha256=snAmkNa6wtOSaxoZE1HgjvL5v_ylitt3Jt_9df4Cgdc,8506
|
25
|
+
cocoindex/tests/test_typing.py,sha256=4cy_6kPyGxsM6qX-O8K-jXhsgDr_FXePplERgky22qI,12313
|
26
|
+
cocoindex/typing.py,sha256=PEV_ds7AGHAHkZmX_fWg-2mFiEXDx-V-Rlhv11_8rtk,12387
|
27
|
+
cocoindex/utils.py,sha256=5a3ubVzDowJUJyUl8ecd75Th_OzON3G-MV2vXf0dQSk,503
|
28
|
+
cocoindex-0.1.51.dist-info/RECORD,,
|
cocoindex/query.py
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
from typing import Callable, Any
|
2
|
-
from dataclasses import dataclass
|
3
|
-
from threading import Lock
|
4
|
-
|
5
|
-
from . import flow as fl
|
6
|
-
from . import index
|
7
|
-
from . import _engine # type: ignore
|
8
|
-
|
9
|
-
_handlers_lock = Lock()
|
10
|
-
_handlers: dict[str, _engine.SimpleSemanticsQueryHandler] = {}
|
11
|
-
|
12
|
-
|
13
|
-
@dataclass
|
14
|
-
class SimpleSemanticsQueryInfo:
|
15
|
-
"""
|
16
|
-
Additional information about the query.
|
17
|
-
"""
|
18
|
-
|
19
|
-
similarity_metric: index.VectorSimilarityMetric
|
20
|
-
query_vector: list[float]
|
21
|
-
vector_field_name: str
|
22
|
-
|
23
|
-
|
24
|
-
@dataclass
|
25
|
-
class QueryResult:
|
26
|
-
"""
|
27
|
-
A single result from the query.
|
28
|
-
"""
|
29
|
-
|
30
|
-
data: dict[str, Any]
|
31
|
-
score: float
|
32
|
-
|
33
|
-
|
34
|
-
class SimpleSemanticsQueryHandler:
|
35
|
-
"""
|
36
|
-
A query handler that uses simple semantics to query the index.
|
37
|
-
"""
|
38
|
-
|
39
|
-
_lazy_query_handler: Callable[[], _engine.SimpleSemanticsQueryHandler]
|
40
|
-
|
41
|
-
def __init__(
|
42
|
-
self,
|
43
|
-
name: str,
|
44
|
-
flow: fl.Flow,
|
45
|
-
target_name: str,
|
46
|
-
query_transform_flow: Callable[..., fl.DataSlice[Any]],
|
47
|
-
default_similarity_metric: index.VectorSimilarityMetric = index.VectorSimilarityMetric.COSINE_SIMILARITY,
|
48
|
-
) -> None:
|
49
|
-
engine_handler = None
|
50
|
-
lock = Lock()
|
51
|
-
|
52
|
-
def _lazy_handler() -> _engine.SimpleSemanticsQueryHandler:
|
53
|
-
nonlocal engine_handler, lock
|
54
|
-
if engine_handler is None:
|
55
|
-
with lock:
|
56
|
-
if engine_handler is None:
|
57
|
-
engine_handler = _engine.SimpleSemanticsQueryHandler(
|
58
|
-
flow.internal_flow(),
|
59
|
-
target_name,
|
60
|
-
fl.TransformFlow(
|
61
|
-
query_transform_flow, [str]
|
62
|
-
).internal_flow(),
|
63
|
-
default_similarity_metric.value,
|
64
|
-
)
|
65
|
-
engine_handler.register_query_handler(name)
|
66
|
-
return engine_handler
|
67
|
-
|
68
|
-
self._lazy_query_handler = _lazy_handler
|
69
|
-
|
70
|
-
with _handlers_lock:
|
71
|
-
_handlers[name] = self
|
72
|
-
|
73
|
-
def internal_handler(self) -> _engine.SimpleSemanticsQueryHandler:
|
74
|
-
"""
|
75
|
-
Get the internal query handler.
|
76
|
-
"""
|
77
|
-
return self._lazy_query_handler()
|
78
|
-
|
79
|
-
def search(
|
80
|
-
self,
|
81
|
-
query: str,
|
82
|
-
limit: int,
|
83
|
-
vector_field_name: str | None = None,
|
84
|
-
similarity_metric: index.VectorSimilarityMetric | None = None,
|
85
|
-
) -> tuple[list[QueryResult], SimpleSemanticsQueryInfo]:
|
86
|
-
"""
|
87
|
-
Search the index with the given query, limit, vector field name, and similarity metric.
|
88
|
-
"""
|
89
|
-
internal_results, internal_info = self.internal_handler().search(
|
90
|
-
query,
|
91
|
-
limit,
|
92
|
-
vector_field_name,
|
93
|
-
similarity_metric.value if similarity_metric is not None else None,
|
94
|
-
)
|
95
|
-
results = [
|
96
|
-
QueryResult(data=result["data"], score=result["score"])
|
97
|
-
for result in internal_results
|
98
|
-
]
|
99
|
-
info = SimpleSemanticsQueryInfo(
|
100
|
-
similarity_metric=index.VectorSimilarityMetric(
|
101
|
-
internal_info["similarity_metric"]
|
102
|
-
),
|
103
|
-
query_vector=internal_info["query_vector"],
|
104
|
-
vector_field_name=internal_info["vector_field_name"],
|
105
|
-
)
|
106
|
-
return results, info
|
107
|
-
|
108
|
-
|
109
|
-
def ensure_all_handlers_built() -> None:
|
110
|
-
"""
|
111
|
-
Ensure all handlers are built.
|
112
|
-
"""
|
113
|
-
with _handlers_lock:
|
114
|
-
for handler in _handlers.values():
|
115
|
-
handler.internal_handler()
|
@@ -1,27 +0,0 @@
|
|
1
|
-
cocoindex-0.1.49.dist-info/METADATA,sha256=8Fow__E5M04be_uy0-Gz-ojEaokr4scBR4lQdRMEVGo,9875
|
2
|
-
cocoindex-0.1.49.dist-info/WHEEL,sha256=ryp1uXCltaq3TPfjxhSWoam4EHMC40-Yabw-yvEW9gU,104
|
3
|
-
cocoindex-0.1.49.dist-info/entry_points.txt,sha256=_NretjYVzBdNTn7dK-zgwr7YfG2afz1u1uSE-5bZXF8,46
|
4
|
-
cocoindex-0.1.49.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
5
|
-
cocoindex/__init__.py,sha256=TkfOR-7upXpzETEvBQUhcnYVuI_A3sqjOdXYeTPAwO0,818
|
6
|
-
cocoindex/_engine.cpython-312-darwin.so,sha256=ONPsIFmeqp4ez7FTgDuSJWSIrMc1FVxNTqaDSAqA_jI,57406784
|
7
|
-
cocoindex/auth_registry.py,sha256=1XqO7ibjmBBd8i11XSJTvTgdz8p1ptW-ZpuSgo_5zzk,716
|
8
|
-
cocoindex/cli.py,sha256=p92s-Ya6VpT4EY5xfbl-R0yyIJv8ySK-2eyxnwC8KqA,17853
|
9
|
-
cocoindex/convert.py,sha256=CfsZDRs1kwMeNCeJ3-gifHQm_9GzyqySpUmZyCyWXMo,7316
|
10
|
-
cocoindex/flow.py,sha256=sC7eg0L9MkZuo7MlvGA4eYe-mEReIyPjKIILFtkWm-Y,30017
|
11
|
-
cocoindex/functions.py,sha256=RnrYJFJCfj263wow3rEx89UBtff44ldQ_torgwArPEw,2294
|
12
|
-
cocoindex/index.py,sha256=j93B9jEvvLXHtpzKWL88SY6wCGEoPgpsQhEGHlyYGFg,540
|
13
|
-
cocoindex/lib.py,sha256=W3hPh0QQIjLRRe2tpyLCvL_6ajzXhGGSNJubikkS27s,2985
|
14
|
-
cocoindex/llm.py,sha256=KO-R4mrAWtxXD82-Yv5ixpkKMVfkwpbdWwqPVZygLu4,352
|
15
|
-
cocoindex/op.py,sha256=hOJoHC8elhLHMNVRTGTBWNSK5uYrQb-FfRV-qt08j8g,11815
|
16
|
-
cocoindex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
|
-
cocoindex/query.py,sha256=UswtEp0wZwwNPeR9x9lRokFpNNZOHkyt5tYfCmGIWWU,3450
|
18
|
-
cocoindex/runtime.py,sha256=bAdHYaXFWiiUWyAgzmKTeaAaRR0D_AmaqVCIdPO-v00,1056
|
19
|
-
cocoindex/setting.py,sha256=ePqHw1i95rVtqYYRVqzVwtBifRO4SfH1rlMW_AG3Zek,3418
|
20
|
-
cocoindex/setup.py,sha256=u5dYZFKfz4yZLiGHD0guNaR0s4zY9JAoZWrWHpAHw_0,773
|
21
|
-
cocoindex/sources.py,sha256=JCnOhv1w4o28e03i7yvo4ESicWYAhckkBg5bQlxNH4U,1330
|
22
|
-
cocoindex/storages.py,sha256=i9cPzj5LbLJVHjskEWyltUXF9kqCyc6ftMEqll6FDwI,2804
|
23
|
-
cocoindex/tests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
24
|
-
cocoindex/tests/test_convert.py,sha256=tTsDveMCgflhcYmDq-fQq3MRGAmN2xlbtFIEDYlRpGw,17095
|
25
|
-
cocoindex/typing.py,sha256=0WQ4F04kFhXwHphv9AHJqc1cThYmLe27eqqGEuGWHAU,9462
|
26
|
-
cocoindex/utils.py,sha256=5a3ubVzDowJUJyUl8ecd75Th_OzON3G-MV2vXf0dQSk,503
|
27
|
-
cocoindex-0.1.49.dist-info/RECORD,,
|
File without changes
|
File without changes
|