cocoindex 0.1.39__cp312-cp312-macosx_11_0_arm64.whl → 0.1.41__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 +6 -5
- cocoindex/_engine.cpython-312-darwin.so +0 -0
- cocoindex/flow.py +33 -14
- cocoindex/utils.py +9 -0
- {cocoindex-0.1.39.dist-info → cocoindex-0.1.41.dist-info}/METADATA +2 -2
- {cocoindex-0.1.39.dist-info → cocoindex-0.1.41.dist-info}/RECORD +8 -7
- {cocoindex-0.1.39.dist-info → cocoindex-0.1.41.dist-info}/WHEEL +0 -0
- {cocoindex-0.1.39.dist-info → cocoindex-0.1.41.dist-info}/licenses/LICENSE +0 -0
cocoindex/__init__.py
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
"""
|
2
2
|
Cocoindex is a framework for building and running indexing pipelines.
|
3
3
|
"""
|
4
|
-
from . import functions, query, sources, storages, cli
|
5
|
-
|
4
|
+
from . import functions, query, sources, storages, cli, utils
|
5
|
+
|
6
|
+
from .auth_registry import AuthEntryReference, add_auth_entry, ref_auth_entry
|
7
|
+
from .flow import FlowBuilder, DataScope, DataSlice, Flow, transform_flow
|
8
|
+
from .flow import flow_def, flow_def as flow
|
6
9
|
from .flow import EvaluateAndDumpOptions, GeneratedField
|
7
10
|
from .flow import update_all_flows_async, FlowLiveUpdater, FlowLiveUpdaterOptions
|
11
|
+
from .lib import init, start_server, stop, main_fn
|
8
12
|
from .llm import LlmSpec, LlmApiType
|
9
13
|
from .index import VectorSimilarityMetric, VectorIndexDef, IndexOptions
|
10
|
-
from .auth_registry import AuthEntryReference, add_auth_entry, ref_auth_entry
|
11
|
-
from .lib import *
|
12
14
|
from .setting import DatabaseConnectionSpec, Settings, ServerSettings
|
13
15
|
from .setting import get_app_namespace
|
14
|
-
from ._engine import OpArgSchema
|
15
16
|
from .typing import Float32, Float64, LocalDateTime, OffsetDateTime, Range, Vector, Json
|
Binary file
|
cocoindex/flow.py
CHANGED
@@ -310,9 +310,8 @@ class _FlowBuilderState:
|
|
310
310
|
engine_flow_builder: _engine.FlowBuilder
|
311
311
|
field_name_builder: _NameBuilder
|
312
312
|
|
313
|
-
def __init__(self,
|
314
|
-
|
315
|
-
self.engine_flow_builder = _engine.FlowBuilder(get_full_flow_name(flow_name))
|
313
|
+
def __init__(self, full_name: str):
|
314
|
+
self.engine_flow_builder = _engine.FlowBuilder(full_name)
|
316
315
|
self.field_name_builder = _NameBuilder()
|
317
316
|
|
318
317
|
def get_data_slice(self, v: Any) -> _engine.DataSlice:
|
@@ -464,9 +463,13 @@ class Flow:
|
|
464
463
|
"""
|
465
464
|
A flow describes an indexing pipeline.
|
466
465
|
"""
|
466
|
+
_name: str
|
467
|
+
_full_name: str
|
467
468
|
_lazy_engine_flow: Callable[[], _engine.Flow]
|
468
469
|
|
469
|
-
def __init__(self, engine_flow_creator: Callable[[], _engine.Flow]):
|
470
|
+
def __init__(self, name: str, full_name: str, engine_flow_creator: Callable[[], _engine.Flow]):
|
471
|
+
self._name = name
|
472
|
+
self._full_name = full_name
|
470
473
|
engine_flow = None
|
471
474
|
lock = Lock()
|
472
475
|
def _lazy_engine_flow() -> _engine.Flow:
|
@@ -497,7 +500,7 @@ class Flow:
|
|
497
500
|
tree.children.append(section_node)
|
498
501
|
return tree
|
499
502
|
|
500
|
-
def _get_spec(self, verbose: bool = False) ->
|
503
|
+
def _get_spec(self, verbose: bool = False) -> _engine.RenderedSpec:
|
501
504
|
return self._lazy_engine_flow().get_spec(output_mode="verbose" if verbose else "concise")
|
502
505
|
|
503
506
|
def _get_schema(self) -> list[tuple[str, str, str]]:
|
@@ -509,12 +512,19 @@ class Flow:
|
|
509
512
|
def __repr__(self):
|
510
513
|
return repr(self._lazy_engine_flow())
|
511
514
|
|
515
|
+
@property
|
516
|
+
def name(self) -> str:
|
517
|
+
"""
|
518
|
+
Get the name of the flow.
|
519
|
+
"""
|
520
|
+
return self._name
|
521
|
+
|
512
522
|
@property
|
513
523
|
def full_name(self) -> str:
|
514
524
|
"""
|
515
525
|
Get the full name of the flow.
|
516
526
|
"""
|
517
|
-
return self.
|
527
|
+
return self._full_name
|
518
528
|
|
519
529
|
def update(self) -> _engine.IndexUpdateInfo:
|
520
530
|
"""
|
@@ -555,14 +565,16 @@ def _create_lazy_flow(name: str | None, fl_def: Callable[[FlowBuilder, DataScope
|
|
555
565
|
Create a flow without really building it yet.
|
556
566
|
The flow will be built the first time when it's really needed.
|
557
567
|
"""
|
568
|
+
flow_name = _flow_name_builder.build_name(name, prefix="_flow_")
|
569
|
+
flow_full_name = get_full_flow_name(flow_name)
|
558
570
|
def _create_engine_flow() -> _engine.Flow:
|
559
|
-
flow_builder_state = _FlowBuilderState(
|
571
|
+
flow_builder_state = _FlowBuilderState(flow_full_name)
|
560
572
|
root_scope = DataScope(
|
561
573
|
flow_builder_state, flow_builder_state.engine_flow_builder.root_scope())
|
562
574
|
fl_def(FlowBuilder(flow_builder_state), root_scope)
|
563
575
|
return flow_builder_state.engine_flow_builder.build_flow(execution_context.event_loop)
|
564
576
|
|
565
|
-
return Flow(_create_engine_flow)
|
577
|
+
return Flow(flow_name, flow_full_name, _create_engine_flow)
|
566
578
|
|
567
579
|
|
568
580
|
_flows_lock = Lock()
|
@@ -695,7 +707,7 @@ class TransformFlow(Generic[T]):
|
|
695
707
|
return self._lazy_flow_info
|
696
708
|
|
697
709
|
async def _build_flow_info_async(self) -> TransformFlowInfo:
|
698
|
-
flow_builder_state = _FlowBuilderState(
|
710
|
+
flow_builder_state = _FlowBuilderState(self._flow_name)
|
699
711
|
sig = inspect.signature(self._flow_fn)
|
700
712
|
if len(sig.parameters) != len(self._flow_arg_types):
|
701
713
|
raise ValueError(
|
@@ -706,9 +718,11 @@ class TransformFlow(Generic[T]):
|
|
706
718
|
for (param_name, param), param_type in zip(sig.parameters.items(), self._flow_arg_types):
|
707
719
|
if param.kind not in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
708
720
|
inspect.Parameter.KEYWORD_ONLY):
|
709
|
-
raise ValueError(f"Parameter {param_name} is not a parameter can be passed by name")
|
710
|
-
|
711
|
-
|
721
|
+
raise ValueError(f"Parameter `{param_name}` is not a parameter can be passed by name")
|
722
|
+
encoded_type = encode_enriched_type(param_type)
|
723
|
+
if encoded_type is None:
|
724
|
+
raise ValueError(f"Parameter `{param_name}` has no type annotation")
|
725
|
+
engine_ds = flow_builder_state.engine_flow_builder.add_direct_input(param_name, encoded_type)
|
712
726
|
kwargs[param_name] = DataSlice(_DataSliceState(flow_builder_state, engine_ds))
|
713
727
|
|
714
728
|
output = self._flow_fn(**kwargs)
|
@@ -768,8 +782,13 @@ def transform_flow() -> Callable[[Callable[..., DataSlice[T]]], TransformFlow[T]
|
|
768
782
|
for (param_name, param) in sig.parameters.items():
|
769
783
|
if param.kind not in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
770
784
|
inspect.Parameter.KEYWORD_ONLY):
|
771
|
-
raise ValueError(f"Parameter {param_name} is not a parameter can be passed by name")
|
772
|
-
|
785
|
+
raise ValueError(f"Parameter `{param_name}` is not a parameter can be passed by name")
|
786
|
+
value_type_annotation = _get_data_slice_annotation_type(param.annotation)
|
787
|
+
if value_type_annotation is None:
|
788
|
+
raise ValueError(
|
789
|
+
f"Parameter `{param_name}` for {fn} has no value type annotation. "
|
790
|
+
"Please use `cocoindex.DataSlice[T]` where T is the type of the value.")
|
791
|
+
arg_types.append(value_type_annotation)
|
773
792
|
|
774
793
|
_transform_flow = TransformFlow(fn, arg_types)
|
775
794
|
functools.update_wrapper(_transform_flow, fn)
|
cocoindex/utils.py
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
from .flow import Flow
|
2
|
+
from .setting import get_app_namespace
|
3
|
+
|
4
|
+
def get_target_storage_default_name(flow: Flow, target_name: str, delimiter: str = "__") -> str:
|
5
|
+
"""
|
6
|
+
Get the default name for a target.
|
7
|
+
It's used as the underlying storage name (e.g. a table, a collection, etc.) followed by most storage backends, if not explicitly specified.
|
8
|
+
"""
|
9
|
+
return get_app_namespace(trailing_delimiter=delimiter) + flow.name + delimiter + target_name
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: cocoindex
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.41
|
4
4
|
Requires-Dist: sentence-transformers>=3.3.1
|
5
5
|
Requires-Dist: click>=8.1.8
|
6
6
|
Requires-Dist: rich>=14.0.0
|
@@ -153,7 +153,7 @@ It defines an index flow like this:
|
|
153
153
|
| [Docs to Knowledge Graph](examples/docs_to_knowledge_graph) | Extract relationships from Markdown documents and build a knowledge graph |
|
154
154
|
| [Embeddings to Qdrant](examples/text_embedding_qdrant) | Index documents in a Qdrant collection for semantic search |
|
155
155
|
| [FastAPI Server with Docker](examples/fastapi_server_docker) | Run the semantic search server in a Dockerized FastAPI setup |
|
156
|
-
| [
|
156
|
+
| [Product Recommendation](examples/product_recommendation) | Build real-time product recommendations with LLM and graph database|
|
157
157
|
| [Image Search with Vision API](examples/image_search_example) | Generates detailed captions for images using a vision model, embeds them, enables live-updating semantic search via FastAPI and served on a React frontend|
|
158
158
|
|
159
159
|
More coming and stay tuned 👀!
|
@@ -1,12 +1,12 @@
|
|
1
|
-
cocoindex-0.1.
|
2
|
-
cocoindex-0.1.
|
3
|
-
cocoindex-0.1.
|
4
|
-
cocoindex/__init__.py,sha256=
|
5
|
-
cocoindex/_engine.cpython-312-darwin.so,sha256=
|
1
|
+
cocoindex-0.1.41.dist-info/METADATA,sha256=_wnwGo7A-7PLOp6HuG18kFtC-ld4QEP4RtKwVEWdpQ4,9790
|
2
|
+
cocoindex-0.1.41.dist-info/WHEEL,sha256=ryp1uXCltaq3TPfjxhSWoam4EHMC40-Yabw-yvEW9gU,104
|
3
|
+
cocoindex-0.1.41.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
|
+
cocoindex/__init__.py,sha256=0iO3lM8w35zhVDPsvCGBAXwUQZsCWRRqjt2wFdtJhME,834
|
5
|
+
cocoindex/_engine.cpython-312-darwin.so,sha256=TgrpClutvTXWvlJ4Mr3VU0ifRutOlh6yOrsSjZrPlj4,56853136
|
6
6
|
cocoindex/auth_registry.py,sha256=NsALZ3SKsDG9cPdrlTlalIqUvgbgFOaFGAbWJNedtJE,692
|
7
7
|
cocoindex/cli.py,sha256=Ac3ybnQW-HGVGJeUwIOHd1qhjs0KC5wCsemWuyouEfU,8999
|
8
8
|
cocoindex/convert.py,sha256=75HSBie7DokM0RJyUBqeveZRl5y_Fl8lzByoRF0yb2M,6915
|
9
|
-
cocoindex/flow.py,sha256=
|
9
|
+
cocoindex/flow.py,sha256=FJGuw71q8EPd37DUbveiMV-LTpqRG2ckQ7jM5bVMJcw,28356
|
10
10
|
cocoindex/functions.py,sha256=F79dNmGE127LaU67kF5Oqtf_tIzebFQH7MkyceMX4-s,1830
|
11
11
|
cocoindex/index.py,sha256=LssEOuZi6AqhwKtZM3QFeQpa9T-0ELi8G5DsrYKECvc,534
|
12
12
|
cocoindex/lib.py,sha256=OqTMuOHicdyX9PRA7fmTzznK8HZMrzxpUDbqxAEF--Q,2383
|
@@ -22,4 +22,5 @@ cocoindex/storages.py,sha256=MFMsfyOCYMggTWeWrOi82miqOXQmiUuqq828x5htBr0,2207
|
|
22
22
|
cocoindex/tests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
23
23
|
cocoindex/tests/test_convert.py,sha256=7jc--I3frrg7DB5MPr4JFzE7DSCznJuWyHdlDLQJ_fM,15516
|
24
24
|
cocoindex/typing.py,sha256=369ABRtnpbaVSQVIBc2ZDutXW8jUmncvNJd9CHEWT3Q,8962
|
25
|
-
cocoindex
|
25
|
+
cocoindex/utils.py,sha256=eClhMdjBjcXaDkah-rPUmE7Y5Ncd7S1goUe2qTETR08,456
|
26
|
+
cocoindex-0.1.41.dist-info/RECORD,,
|
File without changes
|
File without changes
|