lionagi 0.13.5__py3-none-any.whl → 0.13.6__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.
- lionagi/libs/schema/load_pydantic_model_from_schema.py +4 -6
- lionagi/operations/flow.py +7 -21
- lionagi/operations/utils.py +3 -1
- lionagi/service/connections/endpoint_config.py +12 -1
- lionagi/version.py +1 -1
- {lionagi-0.13.5.dist-info → lionagi-0.13.6.dist-info}/METADATA +4 -1
- {lionagi-0.13.5.dist-info → lionagi-0.13.6.dist-info}/RECORD +9 -9
- {lionagi-0.13.5.dist-info → lionagi-0.13.6.dist-info}/WHEEL +0 -0
- {lionagi-0.13.5.dist-info → lionagi-0.13.6.dist-info}/licenses/LICENSE +0 -0
@@ -13,18 +13,16 @@ from pydantic import BaseModel, PydanticUserError
|
|
13
13
|
|
14
14
|
from lionagi.utils import is_import_installed
|
15
15
|
|
16
|
-
_HAS_DATAMODEL_CODE_GENERATOR = is_import_installed("
|
16
|
+
_HAS_DATAMODEL_CODE_GENERATOR = is_import_installed("datamodel_code_generator")
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
from datamodel_code_generator import (
|
18
|
+
try:
|
19
|
+
from datamodel_code_generator import ( # type: ignore[import]
|
21
20
|
DataModelType,
|
22
21
|
InputFileType,
|
23
22
|
PythonVersion,
|
24
23
|
generate,
|
25
24
|
)
|
26
|
-
|
27
|
-
# Create dummy objects for when package is not installed
|
25
|
+
except ImportError:
|
28
26
|
DataModelType = None
|
29
27
|
InputFileType = None
|
30
28
|
PythonVersion = None
|
lionagi/operations/flow.py
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
5
5
|
import asyncio
|
6
|
+
import contextlib
|
6
7
|
from typing import Any
|
7
8
|
|
8
9
|
from lionagi.operations.node import Operation
|
9
|
-
from lionagi.
|
10
|
+
from lionagi.operations.utils import prepare_session
|
11
|
+
from lionagi.protocols.types import ID, Edge, Graph, Node
|
10
12
|
from lionagi.session.branch import Branch
|
11
13
|
from lionagi.session.session import Session
|
12
14
|
from lionagi.utils import to_dict
|
@@ -44,19 +46,10 @@ async def flow(
|
|
44
46
|
if not graph.is_acyclic():
|
45
47
|
raise ValueError("Graph must be acyclic for flow execution")
|
46
48
|
|
47
|
-
|
49
|
+
session, branch = prepare_session(session, branch)
|
48
50
|
if not parallel or max_concurrent == 1:
|
49
51
|
return await _execute_sequential(branch, graph, context, verbose)
|
50
52
|
|
51
|
-
# Parallel execution using session
|
52
|
-
if session is None:
|
53
|
-
# Create temporary session for this flow
|
54
|
-
from lionagi.session.session import Session
|
55
|
-
|
56
|
-
session = Session()
|
57
|
-
session.branches.include(branch)
|
58
|
-
session.default_branch = branch
|
59
|
-
|
60
53
|
return await _execute_parallel(
|
61
54
|
session, graph, context, max_concurrent, verbose
|
62
55
|
)
|
@@ -167,7 +160,7 @@ async def _execute_parallel(
|
|
167
160
|
|
168
161
|
# Process nodes in dependency order
|
169
162
|
remaining_nodes = {node.id for node in operation_nodes}
|
170
|
-
executing_tasks = {}
|
163
|
+
executing_tasks: dict[ID[Operation], asyncio.Task] = {}
|
171
164
|
blocked_nodes = set() # Nodes that have been checked and found blocked
|
172
165
|
|
173
166
|
max_iterations = 1000 # Prevent infinite loops
|
@@ -392,7 +385,7 @@ async def _dependencies_satisfied_async(
|
|
392
385
|
) -> bool:
|
393
386
|
"""Check if node dependencies are satisfied and edge conditions pass."""
|
394
387
|
# Get all incoming edges to this node
|
395
|
-
incoming_edges = []
|
388
|
+
incoming_edges: list[Edge] = []
|
396
389
|
for edge in graph.internal_edges:
|
397
390
|
if edge.tail == node.id:
|
398
391
|
incoming_edges.append(edge)
|
@@ -406,10 +399,6 @@ async def _dependencies_satisfied_async(
|
|
406
399
|
for edge in incoming_edges:
|
407
400
|
# Check if predecessor is completed
|
408
401
|
if edge.head not in completed:
|
409
|
-
# If edge has no condition, we need to wait for predecessor
|
410
|
-
if not edge.condition:
|
411
|
-
continue
|
412
|
-
# If edge has condition but predecessor not complete, skip
|
413
402
|
continue
|
414
403
|
|
415
404
|
# Predecessor is completed
|
@@ -423,12 +412,9 @@ async def _dependencies_satisfied_async(
|
|
423
412
|
result_value = to_dict(result_value, recursive=True)
|
424
413
|
|
425
414
|
ctx = {"result": result_value, "context": execution_context or {}}
|
426
|
-
|
415
|
+
with contextlib.suppress(Exception):
|
427
416
|
if await edge.condition.apply(ctx):
|
428
417
|
at_least_one_satisfied = True
|
429
|
-
except Exception as e:
|
430
|
-
# Condition evaluation failed
|
431
|
-
continue
|
432
418
|
else:
|
433
419
|
# No condition, edge is satisfied
|
434
420
|
at_least_one_satisfied = True
|
lionagi/operations/utils.py
CHANGED
@@ -7,7 +7,9 @@ from lionagi.session.session import Branch, Session
|
|
7
7
|
|
8
8
|
|
9
9
|
def prepare_session(
|
10
|
-
session
|
10
|
+
session: Session | None = None,
|
11
|
+
branch: Branch | None = None,
|
12
|
+
branch_kwargs=None,
|
11
13
|
) -> tuple[Session, Branch]:
|
12
14
|
if session is not None:
|
13
15
|
if branch is not None:
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
5
|
+
import logging
|
5
6
|
import os
|
6
7
|
from typing import Any, TypeVar
|
7
8
|
|
@@ -17,6 +18,9 @@ from pydantic import (
|
|
17
18
|
|
18
19
|
from .header_factory import AUTH_TYPES
|
19
20
|
|
21
|
+
logger = logging.getLogger(__name__)
|
22
|
+
|
23
|
+
|
20
24
|
B = TypeVar("B", bound=type[BaseModel])
|
21
25
|
|
22
26
|
|
@@ -32,7 +36,7 @@ class EndpointConfig(BaseModel):
|
|
32
36
|
auth_type: AUTH_TYPES = "bearer"
|
33
37
|
default_headers: dict = {}
|
34
38
|
request_options: B | None = None
|
35
|
-
api_key: str | SecretStr | None = None
|
39
|
+
api_key: str | SecretStr | None = Field(None, exclude=True)
|
36
40
|
timeout: int = 300
|
37
41
|
max_retries: int = 3
|
38
42
|
openai_compatible: bool = False
|
@@ -98,9 +102,16 @@ class EndpointConfig(BaseModel):
|
|
98
102
|
return v.__class__
|
99
103
|
if isinstance(v, dict | str):
|
100
104
|
from lionagi.libs.schema.load_pydantic_model_from_schema import (
|
105
|
+
_HAS_DATAMODEL_CODE_GENERATOR,
|
101
106
|
load_pydantic_model_from_schema,
|
102
107
|
)
|
103
108
|
|
109
|
+
if not _HAS_DATAMODEL_CODE_GENERATOR:
|
110
|
+
logger.warning(
|
111
|
+
"datamodel-code-generator is not installed, "
|
112
|
+
"request_options will not be validated"
|
113
|
+
)
|
114
|
+
return None
|
104
115
|
return load_pydantic_model_from_schema(v)
|
105
116
|
except Exception as e:
|
106
117
|
raise ValueError("Invalid request options") from e
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.13.
|
1
|
+
__version__ = "0.13.6"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.13.
|
3
|
+
Version: 0.13.6
|
4
4
|
Summary: An Intelligence Operating System.
|
5
5
|
Author-email: HaiyangLi <quantocean.li@gmail.com>, Liangbingyan Luo <llby_luo@outlook.com>
|
6
6
|
License: Apache License
|
@@ -235,6 +235,7 @@ Requires-Dist: tiktoken>=0.8.0
|
|
235
235
|
Requires-Dist: toml>=0.9.0
|
236
236
|
Provides-Extra: all
|
237
237
|
Requires-Dist: claude-code-sdk>=0.0.14; extra == 'all'
|
238
|
+
Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'all'
|
238
239
|
Requires-Dist: docling>=2.15.1; extra == 'all'
|
239
240
|
Requires-Dist: fastmcp>=2.10.5; extra == 'all'
|
240
241
|
Requires-Dist: ollama>=0.4.0; extra == 'all'
|
@@ -257,6 +258,8 @@ Provides-Extra: reader
|
|
257
258
|
Requires-Dist: docling>=2.15.1; extra == 'reader'
|
258
259
|
Provides-Extra: rich
|
259
260
|
Requires-Dist: rich>=13.0.0; extra == 'rich'
|
261
|
+
Provides-Extra: schema
|
262
|
+
Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'schema'
|
260
263
|
Provides-Extra: test
|
261
264
|
Requires-Dist: pytest-asyncio>=1.0.0; extra == 'test'
|
262
265
|
Requires-Dist: pytest>=8.3.4; extra == 'test'
|
@@ -6,7 +6,7 @@ lionagi/config.py,sha256=Dxs5FA9UCv1YX5H54qOJcPsDrIF9wFokWEPZ212eH-k,3715
|
|
6
6
|
lionagi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
lionagi/settings.py,sha256=HDuKCEJCpc4HudKodBnhoQUGuTGhRHdlIFhbtf3VBtY,1633
|
8
8
|
lionagi/utils.py,sha256=8zCdJHKbDJv2WSzAAiFnMSpvfyZb9RnmfSNaMEqdTJE,79003
|
9
|
-
lionagi/version.py,sha256=
|
9
|
+
lionagi/version.py,sha256=riz4KLyxI3rKxqm-AbvFFuR22uDgmXnMIjs0NxKBiIE,23
|
10
10
|
lionagi/fields/__init__.py,sha256=yrn9NDAM6_v73kK7aJeb-Pvqigeu8WASaV-My-6CDsc,939
|
11
11
|
lionagi/fields/action.py,sha256=OziEpbaUeEVo34KdtbzDxXJBgkf3QLxlcKIQAfHe4O0,5791
|
12
12
|
lionagi/fields/base.py,sha256=5CJc7j8kTTWzXwpYzkSAFzx4BglABfx3AElIATKB7bg,3857
|
@@ -46,7 +46,7 @@ lionagi/libs/schema/extract_code_block.py,sha256=PuJbJj1JnqR5fSZudowPcVPpEoKISLr
|
|
46
46
|
lionagi/libs/schema/extract_docstring.py,sha256=uWyUevXS4JSN60tfouoBBAyE4_jyE-fz45CiS-fvKeI,5714
|
47
47
|
lionagi/libs/schema/function_to_schema.py,sha256=XAB031WbYu3a7eFJyYjXVMAjmtWYSYr5kC_DYgjiuyM,5604
|
48
48
|
lionagi/libs/schema/json_schema.py,sha256=cuHcaMr748O9g6suNGmRx4tRXcidd5-c7AMGjTIZyHM,7670
|
49
|
-
lionagi/libs/schema/load_pydantic_model_from_schema.py,sha256=
|
49
|
+
lionagi/libs/schema/load_pydantic_model_from_schema.py,sha256=p4UTgGcb2Tmxc9tLznHPSOWXnHeztJLpl6XTSDcIZ90,10078
|
50
50
|
lionagi/libs/token_transform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
51
|
lionagi/libs/token_transform/base.py,sha256=LBnaDgi4HNgaJJGwIzWcQjVMdu49i_93rRvOvMU22Rw,1545
|
52
52
|
lionagi/libs/token_transform/llmlingua.py,sha256=DkeLUlrb7rGx3nZ04aADU9HXXu5mZTf_DBwT0xhzIv4,7
|
@@ -84,11 +84,11 @@ lionagi/models/operable_model.py,sha256=fXbcpBjO-SoaeF8fn-F1_KIcYw9_L73VIUM1BDg5
|
|
84
84
|
lionagi/models/schema_model.py,sha256=ghRIM8aBNaToAknwNlhQKpuKXcwzyCw5pDE31bVKxs0,667
|
85
85
|
lionagi/operations/__init__.py,sha256=L22n8rRls9oVdzHoDlznHFGiKJMNw3ZhbwVQbm1Fn6M,584
|
86
86
|
lionagi/operations/builder.py,sha256=6OEPQuONlJuC7bkrmaxOrurMdygjSsvwEX_Zsqf1EmM,20300
|
87
|
-
lionagi/operations/flow.py,sha256=
|
87
|
+
lionagi/operations/flow.py,sha256=o_o_UTXvW1MRvsCwbIXG5pbJPEvLA0d3Qb7Fk3wRHF4,14627
|
88
88
|
lionagi/operations/manager.py,sha256=7KD6NMWqYJHCPI2LumDRwGinF8WYKFjrr3bsNUi9xzI,564
|
89
89
|
lionagi/operations/node.py,sha256=JNJpn_LUP_46F7C8DcvwAg6rzlaRKzs9RcVGQakARyU,3066
|
90
90
|
lionagi/operations/types.py,sha256=fM8HphnbBifMzhoKKvdl3JxGCBHlEGPJEYkLWj9b7vE,704
|
91
|
-
lionagi/operations/utils.py,sha256=
|
91
|
+
lionagi/operations/utils.py,sha256=b8HmpF5vRgmf6PTzg3_fZCIKMnhoGa0HCyOlX6JCz7g,1263
|
92
92
|
lionagi/operations/ReAct/ReAct.py,sha256=uoJnFMoPP1kzzmgLDFNBwEbWdfGNfG37IT22N1AM-hE,13504
|
93
93
|
lionagi/operations/ReAct/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
94
94
|
lionagi/operations/ReAct/utils.py,sha256=FKb0v-1tboN17imxef9jLKWhet0Iz049eqvZCcJKNX8,4436
|
@@ -175,7 +175,7 @@ lionagi/service/types.py,sha256=6zavqBxK1Fj0nB9eZgJn3JICxmdT-n0nn8YWZFzM5LU,508
|
|
175
175
|
lionagi/service/connections/__init__.py,sha256=yHQZ7OJpCftd6CStYR8inbxjJydYdmv9kCvbUBhJ2zU,362
|
176
176
|
lionagi/service/connections/api_calling.py,sha256=XetCrjMhOHNKGGv-NzHhBhVS7XjKPalrS_iExzU-4S4,8005
|
177
177
|
lionagi/service/connections/endpoint.py,sha256=yNIjq9wETMnytynGbq3qY_dkyaMlaHrcfiZjS-tnmLg,14756
|
178
|
-
lionagi/service/connections/endpoint_config.py,sha256=
|
178
|
+
lionagi/service/connections/endpoint_config.py,sha256=7u5HDWe-4nttG2cDXtx_OxPzAI4DAA0bPtjJ6BA4gk8,5162
|
179
179
|
lionagi/service/connections/header_factory.py,sha256=22sG4ian3MiNklF6SdQqkEYgtWKOZik_yDE0Lna6BiE,1754
|
180
180
|
lionagi/service/connections/match_endpoint.py,sha256=K3I4vU6GH6utlEArlyDFUmNdnp94CEPxqKrehAx29J4,2410
|
181
181
|
lionagi/service/connections/providers/__init__.py,sha256=3lzOakDoBWmMaNnT2g-YwktPKa_Wme4lnPRSmOQfayY,105
|
@@ -202,7 +202,7 @@ lionagi/tools/types.py,sha256=XtJLY0m-Yi_ZLWhm0KycayvqMCZd--HxfQ0x9vFUYDE,230
|
|
202
202
|
lionagi/tools/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
203
203
|
lionagi/tools/file/reader.py,sha256=0TdnfVGVCKuM58MmGM-NyVjhU9BFoitkNYEepdc0z_Y,9529
|
204
204
|
lionagi/tools/memory/tools.py,sha256=zTGBenVsF8Wuh303kWntmQSGlAFKonHNdh5ePuQ26KE,15948
|
205
|
-
lionagi-0.13.
|
206
|
-
lionagi-0.13.
|
207
|
-
lionagi-0.13.
|
208
|
-
lionagi-0.13.
|
205
|
+
lionagi-0.13.6.dist-info/METADATA,sha256=ENE6dEOAAy0IbJkdVVgryZ8v-ySobfMqzgdsZguQsJE,20818
|
206
|
+
lionagi-0.13.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
207
|
+
lionagi-0.13.6.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
|
208
|
+
lionagi-0.13.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|