cocoindex 0.2.3__cp311-abi3-macosx_10_12_x86_64.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 ADDED
@@ -0,0 +1,92 @@
1
+ """
2
+ Cocoindex is a framework for building and running indexing pipelines.
3
+ """
4
+
5
+ from . import functions, sources, targets, cli, utils
6
+
7
+ from . import targets as storages # Deprecated: Use targets instead
8
+
9
+ from .auth_registry import AuthEntryReference, add_auth_entry, add_transient_auth_entry
10
+ from .flow import FlowBuilder, DataScope, DataSlice, Flow, transform_flow
11
+ from .flow import flow_def
12
+ from .flow import EvaluateAndDumpOptions, GeneratedField
13
+ from .flow import FlowLiveUpdater, FlowLiveUpdaterOptions, FlowUpdaterStatusUpdates
14
+ from .flow import open_flow
15
+ from .flow import add_flow_def, remove_flow # DEPRECATED
16
+ from .flow import update_all_flows_async, setup_all_flows, drop_all_flows
17
+ from .lib import init, start_server, stop
18
+ from .llm import LlmSpec, LlmApiType
19
+ from .index import VectorSimilarityMetric, VectorIndexDef, IndexOptions
20
+ from .setting import DatabaseConnectionSpec, Settings, ServerSettings
21
+ from .setting import get_app_namespace
22
+ from .typing import (
23
+ Int64,
24
+ Float32,
25
+ Float64,
26
+ LocalDateTime,
27
+ OffsetDateTime,
28
+ Range,
29
+ Vector,
30
+ Json,
31
+ )
32
+
33
+ __all__ = [
34
+ # Submodules
35
+ "_engine",
36
+ "functions",
37
+ "llm",
38
+ "sources",
39
+ "targets",
40
+ "storages",
41
+ "cli",
42
+ "op",
43
+ "utils",
44
+ # Auth registry
45
+ "AuthEntryReference",
46
+ "add_auth_entry",
47
+ "add_transient_auth_entry",
48
+ "ref_auth_entry",
49
+ # Flow
50
+ "FlowBuilder",
51
+ "DataScope",
52
+ "DataSlice",
53
+ "Flow",
54
+ "transform_flow",
55
+ "flow_def",
56
+ "EvaluateAndDumpOptions",
57
+ "GeneratedField",
58
+ "FlowLiveUpdater",
59
+ "FlowLiveUpdaterOptions",
60
+ "FlowUpdaterStatusUpdates",
61
+ "open_flow",
62
+ "add_flow_def", # DEPRECATED
63
+ "remove_flow", # DEPRECATED
64
+ "update_all_flows_async",
65
+ "setup_all_flows",
66
+ "drop_all_flows",
67
+ # Lib
68
+ "init",
69
+ "start_server",
70
+ "stop",
71
+ # LLM
72
+ "LlmSpec",
73
+ "LlmApiType",
74
+ # Index
75
+ "VectorSimilarityMetric",
76
+ "VectorIndexDef",
77
+ "IndexOptions",
78
+ # Settings
79
+ "DatabaseConnectionSpec",
80
+ "Settings",
81
+ "ServerSettings",
82
+ "get_app_namespace",
83
+ # Typing
84
+ "Int64",
85
+ "Float32",
86
+ "Float64",
87
+ "LocalDateTime",
88
+ "OffsetDateTime",
89
+ "Range",
90
+ "Vector",
91
+ "Json",
92
+ ]
Binary file
@@ -0,0 +1,51 @@
1
+ """
2
+ Auth registry is used to register and reference auth entries.
3
+ """
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Generic, TypeVar
7
+ import threading
8
+
9
+ from . import _engine # type: ignore
10
+ from .convert import dump_engine_object
11
+
12
+ T = TypeVar("T")
13
+
14
+ # Global atomic counter for generating unique auth entry keys
15
+ _counter_lock = threading.Lock()
16
+ _auth_key_counter = 0
17
+
18
+
19
+ def _generate_auth_key() -> str:
20
+ """Generate a unique auth entry key using a global atomic counter."""
21
+ global _auth_key_counter # pylint: disable=global-statement
22
+ with _counter_lock:
23
+ _auth_key_counter += 1
24
+ return f"__auth_{_auth_key_counter}"
25
+
26
+
27
+ @dataclass
28
+ class TransientAuthEntryReference(Generic[T]):
29
+ """Reference an auth entry, may or may not have a stable key."""
30
+
31
+ key: str
32
+
33
+
34
+ class AuthEntryReference(TransientAuthEntryReference[T]):
35
+ """Reference an auth entry, with a key stable across ."""
36
+
37
+
38
+ def add_transient_auth_entry(value: T) -> TransientAuthEntryReference[T]:
39
+ """Add an auth entry to the registry. Returns its reference."""
40
+ return add_auth_entry(_generate_auth_key(), value)
41
+
42
+
43
+ def add_auth_entry(key: str, value: T) -> AuthEntryReference[T]:
44
+ """Add an auth entry to the registry. Returns its reference."""
45
+ _engine.add_auth_entry(key, dump_engine_object(value))
46
+ return AuthEntryReference(key)
47
+
48
+
49
+ def ref_auth_entry(key: str) -> AuthEntryReference[T]:
50
+ """Reference an auth entry by its key."""
51
+ return AuthEntryReference(key)