lionagi 0.15.14__py3-none-any.whl → 0.16.0__py3-none-any.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 (39) hide show
  1. lionagi/libs/validate/fuzzy_match_keys.py +5 -182
  2. lionagi/libs/validate/string_similarity.py +6 -331
  3. lionagi/ln/__init__.py +56 -66
  4. lionagi/ln/_async_call.py +13 -10
  5. lionagi/ln/_hash.py +33 -8
  6. lionagi/ln/_list_call.py +2 -35
  7. lionagi/ln/_to_list.py +51 -28
  8. lionagi/ln/_utils.py +156 -0
  9. lionagi/ln/concurrency/__init__.py +39 -31
  10. lionagi/ln/concurrency/_compat.py +65 -0
  11. lionagi/ln/concurrency/cancel.py +92 -109
  12. lionagi/ln/concurrency/errors.py +17 -17
  13. lionagi/ln/concurrency/patterns.py +249 -206
  14. lionagi/ln/concurrency/primitives.py +257 -216
  15. lionagi/ln/concurrency/resource_tracker.py +42 -155
  16. lionagi/ln/concurrency/task.py +55 -73
  17. lionagi/ln/concurrency/throttle.py +3 -0
  18. lionagi/ln/concurrency/utils.py +1 -0
  19. lionagi/ln/fuzzy/__init__.py +15 -0
  20. lionagi/ln/{_extract_json.py → fuzzy/_extract_json.py} +22 -9
  21. lionagi/ln/{_fuzzy_json.py → fuzzy/_fuzzy_json.py} +14 -8
  22. lionagi/ln/fuzzy/_fuzzy_match.py +172 -0
  23. lionagi/ln/fuzzy/_fuzzy_validate.py +46 -0
  24. lionagi/ln/fuzzy/_string_similarity.py +332 -0
  25. lionagi/ln/{_models.py → types.py} +153 -4
  26. lionagi/operations/flow.py +2 -1
  27. lionagi/operations/operate/operate.py +26 -16
  28. lionagi/protocols/contracts.py +46 -0
  29. lionagi/protocols/generic/event.py +6 -6
  30. lionagi/protocols/generic/processor.py +9 -5
  31. lionagi/protocols/ids.py +82 -0
  32. lionagi/protocols/types.py +10 -12
  33. lionagi/utils.py +34 -64
  34. lionagi/version.py +1 -1
  35. {lionagi-0.15.14.dist-info → lionagi-0.16.0.dist-info}/METADATA +4 -2
  36. {lionagi-0.15.14.dist-info → lionagi-0.16.0.dist-info}/RECORD +38 -31
  37. lionagi/ln/_types.py +0 -146
  38. {lionagi-0.15.14.dist-info → lionagi-0.16.0.dist-info}/WHEEL +0 -0
  39. {lionagi-0.15.14.dist-info → lionagi-0.16.0.dist-info}/licenses/LICENSE +0 -0
lionagi/ln/_types.py DELETED
@@ -1,146 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from enum import Enum as _Enum
4
- from typing import Any, Final, Literal, TypeVar, Union
5
-
6
- from typing_extensions import TypedDict
7
-
8
- __all__ = (
9
- "Undefined",
10
- "Unset",
11
- "MaybeUndefined",
12
- "MaybeUnset",
13
- "MaybeSentinel",
14
- "SingletonType",
15
- "UndefinedType",
16
- "UnsetType",
17
- "KeysDict",
18
- "T",
19
- "Enum",
20
- "is_sentinel",
21
- "not_sentinel",
22
- )
23
-
24
- T = TypeVar("T")
25
-
26
-
27
- class _SingletonMeta(type):
28
- """Metaclass that guarantees exactly one instance per subclass.
29
-
30
- This ensures that sentinel values maintain identity across the entire application,
31
- allowing safe identity checks with 'is' operator.
32
- """
33
-
34
- _cache: dict[type, SingletonType] = {}
35
-
36
- def __call__(cls, *a, **kw):
37
- if cls not in cls._cache:
38
- cls._cache[cls] = super().__call__(*a, **kw)
39
- return cls._cache[cls]
40
-
41
-
42
- class SingletonType(metaclass=_SingletonMeta):
43
- """Base class for singleton sentinel types.
44
-
45
- Provides consistent interface for sentinel values with:
46
- - Identity preservation across deepcopy
47
- - Falsy boolean evaluation
48
- - Clear string representation
49
- """
50
-
51
- __slots__: tuple[str, ...] = ()
52
-
53
- def __deepcopy__(self, memo): # copy & deepcopy both noop
54
- return self
55
-
56
- def __copy__(self):
57
- return self
58
-
59
- # concrete classes *must* override the two methods below
60
- def __bool__(self) -> bool: ...
61
- def __repr__(self) -> str: ...
62
-
63
-
64
- class UndefinedType(SingletonType):
65
- """Sentinel for a key or field entirely missing from a namespace.
66
-
67
- Use this when:
68
- - A field has never been set
69
- - A key doesn't exist in a mapping
70
- - A value is conceptually undefined (not just unset)
71
-
72
- Example:
73
- >>> d = {"a": 1}
74
- >>> d.get("b", Undefined) is Undefined
75
- True
76
- """
77
-
78
- __slots__ = ()
79
-
80
- def __bool__(self) -> Literal[False]:
81
- return False
82
-
83
- def __repr__(self) -> Literal["Undefined"]:
84
- return "Undefined"
85
-
86
- def __str__(self) -> Literal["Undefined"]:
87
- return "Undefined"
88
-
89
-
90
- class UnsetType(SingletonType):
91
- """Sentinel for a key present but value not yet provided.
92
-
93
- Use this when:
94
- - A parameter exists but hasn't been given a value
95
- - Distinguishing between None and "not provided"
96
- - API parameters that are optional but need explicit handling
97
-
98
- Example:
99
- >>> def func(param=Unset):
100
- ... if param is not Unset:
101
- ... # param was explicitly provided
102
- ... process(param)
103
- """
104
-
105
- __slots__ = ()
106
-
107
- def __bool__(self) -> Literal[False]:
108
- return False
109
-
110
- def __repr__(self) -> Literal["Unset"]:
111
- return "Unset"
112
-
113
- def __str__(self) -> Literal["Unset"]:
114
- return "Unset"
115
-
116
-
117
- Undefined: Final = UndefinedType()
118
- """A key or field entirely missing from a namespace"""
119
- Unset: Final = UnsetType()
120
- """A key present but value not yet provided."""
121
-
122
- MaybeUndefined = Union[T, UndefinedType]
123
- MaybeUnset = Union[T, UnsetType]
124
- MaybeSentinel = Union[T, UndefinedType, UnsetType]
125
-
126
-
127
- def is_sentinel(value: Any) -> bool:
128
- """Check if a value is any sentinel (Undefined or Unset)."""
129
- return value is Undefined or value is Unset
130
-
131
-
132
- def not_sentinel(value: Any) -> bool:
133
- """Check if a value is NOT a sentinel. Useful for filtering operations."""
134
- return value is not Undefined and value is not Unset
135
-
136
-
137
- class Enum(_Enum):
138
- @classmethod
139
- def allowed(cls) -> tuple[str, ...]:
140
- return tuple(e.value for e in cls)
141
-
142
-
143
- class KeysDict(TypedDict, total=False):
144
- """TypedDict for keys dictionary."""
145
-
146
- key: Any # Represents any key-type pair