lionagi 0.16.1__py3-none-any.whl → 0.16.3__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/adapters/_utils.py +0 -14
- lionagi/libs/file/save.py +8 -1
- lionagi/ln/__init__.py +10 -0
- lionagi/ln/_json_dump.py +322 -49
- lionagi/ln/fuzzy/__init__.py +4 -1
- lionagi/ln/fuzzy/_fuzzy_validate.py +109 -0
- lionagi/ln/fuzzy/_to_dict.py +388 -0
- lionagi/models/__init__.py +0 -2
- lionagi/operations/brainstorm/brainstorm.py +10 -10
- lionagi/operations/communicate/communicate.py +1 -1
- lionagi/operations/parse/parse.py +1 -1
- lionagi/protocols/generic/element.py +5 -14
- lionagi/protocols/generic/log.py +2 -2
- lionagi/protocols/generic/pile.py +1 -1
- lionagi/protocols/messages/message.py +8 -1
- lionagi/protocols/operatives/operative.py +2 -2
- lionagi/service/connections/endpoint.py +7 -0
- lionagi/service/connections/match_endpoint.py +2 -10
- lionagi/service/connections/providers/types.py +1 -3
- lionagi/service/hooks/hook_event.py +1 -1
- lionagi/service/hooks/hook_registry.py +1 -1
- lionagi/service/rate_limited_processor.py +1 -1
- lionagi/session/branch.py +1 -101
- lionagi/session/session.py +9 -14
- lionagi/utils.py +3 -334
- lionagi/version.py +1 -1
- {lionagi-0.16.1.dist-info → lionagi-0.16.3.dist-info}/METADATA +3 -13
- {lionagi-0.16.1.dist-info → lionagi-0.16.3.dist-info}/RECORD +30 -78
- lionagi/adapters/postgres_model_adapter.py +0 -131
- lionagi/libs/concurrency.py +0 -1
- lionagi/libs/file/params.py +0 -175
- lionagi/libs/nested/__init__.py +0 -3
- lionagi/libs/nested/flatten.py +0 -172
- lionagi/libs/nested/nfilter.py +0 -59
- lionagi/libs/nested/nget.py +0 -45
- lionagi/libs/nested/ninsert.py +0 -104
- lionagi/libs/nested/nmerge.py +0 -158
- lionagi/libs/nested/npop.py +0 -69
- lionagi/libs/nested/nset.py +0 -94
- lionagi/libs/nested/unflatten.py +0 -83
- lionagi/libs/nested/utils.py +0 -189
- lionagi/libs/parse.py +0 -31
- lionagi/libs/schema/json_schema.py +0 -231
- lionagi/libs/token_transform/__init__.py +0 -0
- lionagi/libs/token_transform/base.py +0 -54
- lionagi/libs/token_transform/llmlingua.py +0 -1
- lionagi/libs/token_transform/perplexity.py +0 -450
- lionagi/libs/token_transform/symbolic_compress_context.py +0 -152
- lionagi/libs/token_transform/synthlang.py +0 -9
- lionagi/libs/token_transform/synthlang_/base.py +0 -128
- lionagi/libs/token_transform/synthlang_/resources/frameworks/abstract_algebra.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/category_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/complex_analysis.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/framework_options.json +0 -52
- lionagi/libs/token_transform/synthlang_/resources/frameworks/group_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/math_logic.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/reflective_patterns.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/set_theory.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/frameworks/topology_fundamentals.toml +0 -11
- lionagi/libs/token_transform/synthlang_/resources/mapping/lion_emoji_mapping.toml +0 -61
- lionagi/libs/token_transform/synthlang_/resources/mapping/python_math_mapping.toml +0 -41
- lionagi/libs/token_transform/synthlang_/resources/mapping/rust_chinese_mapping.toml +0 -60
- lionagi/libs/token_transform/synthlang_/resources/utility/base_synthlang_system_prompt.toml +0 -11
- lionagi/libs/token_transform/synthlang_/translate_to_synthlang.py +0 -140
- lionagi/libs/token_transform/types.py +0 -15
- lionagi/libs/unstructured/__init__.py +0 -0
- lionagi/libs/unstructured/pdf_to_image.py +0 -45
- lionagi/libs/unstructured/read_image_to_base64.py +0 -33
- lionagi/libs/validate/fuzzy_match_keys.py +0 -7
- lionagi/libs/validate/fuzzy_validate_mapping.py +0 -144
- lionagi/libs/validate/string_similarity.py +0 -7
- lionagi/libs/validate/xml_parser.py +0 -203
- lionagi/models/note.py +0 -383
- lionagi/operations/translate/__init__.py +0 -0
- lionagi/operations/translate/translate.py +0 -47
- lionagi/service/connections/providers/claude_code_.py +0 -294
- lionagi/tools/memory/tools.py +0 -495
- {lionagi-0.16.1.dist-info → lionagi-0.16.3.dist-info}/WHEEL +0 -0
- {lionagi-0.16.1.dist-info → lionagi-0.16.3.dist-info}/licenses/LICENSE +0 -0
lionagi/session/branch.py
CHANGED
@@ -50,7 +50,7 @@ from lionagi.settings import Settings
|
|
50
50
|
from lionagi.tools.base import LionTool
|
51
51
|
from lionagi.utils import UNDEFINED
|
52
52
|
from lionagi.utils import alcall as alcall_legacy
|
53
|
-
from lionagi.utils import copy
|
53
|
+
from lionagi.utils import copy
|
54
54
|
|
55
55
|
from .prompts import LION_SYSTEM_MESSAGE
|
56
56
|
|
@@ -1307,68 +1307,6 @@ class Branch(Element, Communicatable, Relational):
|
|
1307
1307
|
)
|
1308
1308
|
return results
|
1309
1309
|
|
1310
|
-
async def translate(
|
1311
|
-
self,
|
1312
|
-
text: str,
|
1313
|
-
technique: Literal["SynthLang"] = "SynthLang",
|
1314
|
-
technique_kwargs: dict = None,
|
1315
|
-
compress: bool = False,
|
1316
|
-
chat_model: iModel = None,
|
1317
|
-
compress_model: iModel = None,
|
1318
|
-
compression_ratio: float = 0.2,
|
1319
|
-
compress_kwargs=None,
|
1320
|
-
verbose: bool = True,
|
1321
|
-
new_branch: bool = True,
|
1322
|
-
**kwargs,
|
1323
|
-
) -> str:
|
1324
|
-
"""
|
1325
|
-
An example "translate" operation that transforms text using a chosen technique
|
1326
|
-
(e.g., "SynthLang"). Optionally compresses text with a custom `compress_model`.
|
1327
|
-
|
1328
|
-
Args:
|
1329
|
-
text (str):
|
1330
|
-
The text to be translated or transformed.
|
1331
|
-
technique (Literal["SynthLang"]):
|
1332
|
-
The translation/transform technique (currently only "SynthLang").
|
1333
|
-
technique_kwargs (dict, optional):
|
1334
|
-
Additional parameters for the chosen technique.
|
1335
|
-
compress (bool):
|
1336
|
-
Whether to compress the resulting text further.
|
1337
|
-
chat_model (iModel, optional):
|
1338
|
-
A custom model for the translation step (defaults to self.chat_model).
|
1339
|
-
compress_model (iModel, optional):
|
1340
|
-
A separate model for compression (if `compress=True`).
|
1341
|
-
compression_ratio (float):
|
1342
|
-
Desired compression ratio if compressing text (0.0 - 1.0).
|
1343
|
-
compress_kwargs (dict, optional):
|
1344
|
-
Additional arguments for the compression step.
|
1345
|
-
verbose (bool):
|
1346
|
-
If True, prints debug/logging info.
|
1347
|
-
new_branch (bool):
|
1348
|
-
If True, performs the translation in a new branch context.
|
1349
|
-
**kwargs:
|
1350
|
-
Additional parameters passed through to the technique function.
|
1351
|
-
|
1352
|
-
Returns:
|
1353
|
-
str: The transformed (and optionally compressed) text.
|
1354
|
-
"""
|
1355
|
-
from lionagi.operations.translate.translate import translate
|
1356
|
-
|
1357
|
-
return await translate(
|
1358
|
-
branch=self,
|
1359
|
-
text=text,
|
1360
|
-
technique=technique,
|
1361
|
-
technique_kwargs=technique_kwargs,
|
1362
|
-
compress=compress,
|
1363
|
-
chat_model=chat_model,
|
1364
|
-
compress_model=compress_model,
|
1365
|
-
compression_ratio=compression_ratio,
|
1366
|
-
compress_kwargs=compress_kwargs,
|
1367
|
-
verbose=verbose,
|
1368
|
-
new_branch=new_branch,
|
1369
|
-
**kwargs,
|
1370
|
-
)
|
1371
|
-
|
1372
1310
|
async def select(
|
1373
1311
|
self,
|
1374
1312
|
instruct: Instruct | dict[str, Any],
|
@@ -1411,44 +1349,6 @@ class Branch(Element, Communicatable, Relational):
|
|
1411
1349
|
**kwargs,
|
1412
1350
|
)
|
1413
1351
|
|
1414
|
-
async def compress(
|
1415
|
-
self,
|
1416
|
-
text: str,
|
1417
|
-
system: str = None,
|
1418
|
-
compression_ratio: float = 0.2,
|
1419
|
-
n_samples: int = 5,
|
1420
|
-
max_tokens_per_sample=80,
|
1421
|
-
verbose=True,
|
1422
|
-
) -> str:
|
1423
|
-
"""
|
1424
|
-
Uses the `chat_model`'s built-in compression routine to shorten text.
|
1425
|
-
|
1426
|
-
Args:
|
1427
|
-
text (str):
|
1428
|
-
The text to compress.
|
1429
|
-
system (str, optional):
|
1430
|
-
System-level instructions, appended to the prompt.
|
1431
|
-
compression_ratio (float):
|
1432
|
-
Desired compression ratio (0.0-1.0).
|
1433
|
-
n_samples (int):
|
1434
|
-
How many compression attempts to combine or evaluate.
|
1435
|
-
max_tokens_per_sample (int):
|
1436
|
-
Max token count per sample chunk.
|
1437
|
-
verbose (bool):
|
1438
|
-
If True, logs or prints progress.
|
1439
|
-
|
1440
|
-
Returns:
|
1441
|
-
str: The compressed text.
|
1442
|
-
"""
|
1443
|
-
return await self.chat_model.compress_text(
|
1444
|
-
text=text,
|
1445
|
-
system=system,
|
1446
|
-
compression_ratio=compression_ratio,
|
1447
|
-
n_samples=n_samples,
|
1448
|
-
max_tokens_per_sample=max_tokens_per_sample,
|
1449
|
-
verbose=verbose,
|
1450
|
-
)
|
1451
|
-
|
1452
1352
|
async def interpret(
|
1453
1353
|
self,
|
1454
1354
|
text: str,
|
lionagi/session/session.py
CHANGED
@@ -79,7 +79,7 @@ class Session(Node, Communicatable, Relational):
|
|
79
79
|
|
80
80
|
def include_branches(self, branches: ID[Branch].ItemSeq):
|
81
81
|
def _take_in_branch(branch: Branch):
|
82
|
-
if not
|
82
|
+
if branch not in self.branches:
|
83
83
|
self.branches.include(branch)
|
84
84
|
self.mail_manager.add_sources(branch)
|
85
85
|
|
@@ -171,19 +171,14 @@ class Session(Node, Communicatable, Relational):
|
|
171
171
|
as_default_branch: bool = False,
|
172
172
|
**kwargs,
|
173
173
|
) -> Branch:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
kwargs["tool_manager"] = tool_manager
|
183
|
-
kwargs["tools"] = tools
|
184
|
-
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
185
|
-
|
186
|
-
branch = Branch(**kwargs) # type: ignore
|
174
|
+
"""Create and include a new branch in the session."""
|
175
|
+
params = {
|
176
|
+
k: v
|
177
|
+
for k, v in locals().items()
|
178
|
+
if k not in ("self", "as_default_branch", "kwargs")
|
179
|
+
and v is not None
|
180
|
+
}
|
181
|
+
branch = Branch(**params, **kwargs) # type: ignore
|
187
182
|
self.include_branches(branch)
|
188
183
|
if as_default_branch:
|
189
184
|
self.default_branch = branch
|
lionagi/utils.py
CHANGED
@@ -2,23 +2,12 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
5
|
-
import contextlib
|
6
5
|
import copy as _copy
|
7
|
-
import dataclasses
|
8
|
-
import json
|
9
6
|
import logging
|
10
7
|
import types
|
11
8
|
import uuid
|
12
|
-
from collections.abc import
|
13
|
-
AsyncGenerator,
|
14
|
-
Callable,
|
15
|
-
Iterable,
|
16
|
-
Mapping,
|
17
|
-
Sequence,
|
18
|
-
)
|
9
|
+
from collections.abc import AsyncGenerator, Callable, Iterable, Mapping
|
19
10
|
from datetime import datetime, timezone
|
20
|
-
from enum import Enum as _Enum
|
21
|
-
from functools import partial
|
22
11
|
from inspect import isclass
|
23
12
|
from pathlib import Path
|
24
13
|
from typing import (
|
@@ -32,10 +21,8 @@ from typing import (
|
|
32
21
|
)
|
33
22
|
|
34
23
|
from pydantic import BaseModel
|
35
|
-
from pydantic_core import PydanticUndefinedType
|
36
24
|
from typing_extensions import deprecated
|
37
25
|
|
38
|
-
from .libs.validate.xml_parser import xml_to_dict
|
39
26
|
from .ln import (
|
40
27
|
extract_json,
|
41
28
|
fuzzy_json,
|
@@ -44,6 +31,7 @@ from .ln import (
|
|
44
31
|
import_module,
|
45
32
|
is_coro_func,
|
46
33
|
is_import_installed,
|
34
|
+
to_dict,
|
47
35
|
to_list,
|
48
36
|
)
|
49
37
|
from .ln.types import (
|
@@ -114,6 +102,7 @@ __all__ = (
|
|
114
102
|
"MaybeUnset",
|
115
103
|
"is_import_installed",
|
116
104
|
"import_module",
|
105
|
+
"to_dict",
|
117
106
|
)
|
118
107
|
|
119
108
|
|
@@ -532,326 +521,6 @@ def create_path(
|
|
532
521
|
return full_path
|
533
522
|
|
534
523
|
|
535
|
-
def to_dict(
|
536
|
-
input_: Any,
|
537
|
-
/,
|
538
|
-
*,
|
539
|
-
use_model_dump: bool = True,
|
540
|
-
fuzzy_parse: bool = False,
|
541
|
-
suppress: bool = False,
|
542
|
-
str_type: Literal["json", "xml"] | None = "json",
|
543
|
-
parser: Callable[[str], Any] | None = None,
|
544
|
-
recursive: bool = False,
|
545
|
-
max_recursive_depth: int = None,
|
546
|
-
recursive_python_only: bool = True,
|
547
|
-
use_enum_values: bool = False,
|
548
|
-
**kwargs: Any,
|
549
|
-
) -> dict[str, Any]:
|
550
|
-
"""
|
551
|
-
Convert various input types to a dictionary, with optional recursive processing.
|
552
|
-
|
553
|
-
Args:
|
554
|
-
input_: The input to convert.
|
555
|
-
use_model_dump: Use model_dump() for Pydantic models if available.
|
556
|
-
fuzzy_parse: Use fuzzy parsing for string inputs.
|
557
|
-
suppress: Return empty dict on errors if True.
|
558
|
-
str_type: Input string type ("json" or "xml").
|
559
|
-
parser: Custom parser function for string inputs.
|
560
|
-
recursive: Enable recursive conversion of nested structures.
|
561
|
-
max_recursive_depth: Maximum recursion depth (default 5, max 10).
|
562
|
-
recursive_python_only: If False, attempts to convert custom types recursively.
|
563
|
-
use_enum_values: Use enum values instead of names.
|
564
|
-
**kwargs: Additional arguments for parsing functions.
|
565
|
-
|
566
|
-
Returns:
|
567
|
-
dict[str, Any]: A dictionary derived from the input.
|
568
|
-
|
569
|
-
Raises:
|
570
|
-
ValueError: If parsing fails and suppress is False.
|
571
|
-
|
572
|
-
Examples:
|
573
|
-
>>> to_dict({"a": 1, "b": [2, 3]})
|
574
|
-
{'a': 1, 'b': [2, 3]}
|
575
|
-
>>> to_dict('{"x": 10}', str_type="json")
|
576
|
-
{'x': 10}
|
577
|
-
>>> to_dict({"a": {"b": {"c": 1}}}, recursive=True, max_recursive_depth=2)
|
578
|
-
{'a': {'b': {'c': 1}}}
|
579
|
-
"""
|
580
|
-
|
581
|
-
try:
|
582
|
-
if recursive:
|
583
|
-
input_ = recursive_to_dict(
|
584
|
-
input_,
|
585
|
-
use_model_dump=use_model_dump,
|
586
|
-
fuzzy_parse=fuzzy_parse,
|
587
|
-
str_type=str_type,
|
588
|
-
parser=parser,
|
589
|
-
max_recursive_depth=max_recursive_depth,
|
590
|
-
recursive_custom_types=not recursive_python_only,
|
591
|
-
use_enum_values=use_enum_values,
|
592
|
-
**kwargs,
|
593
|
-
)
|
594
|
-
|
595
|
-
return _to_dict(
|
596
|
-
input_,
|
597
|
-
fuzzy_parse=fuzzy_parse,
|
598
|
-
parser=parser,
|
599
|
-
str_type=str_type,
|
600
|
-
use_model_dump=use_model_dump,
|
601
|
-
use_enum_values=use_enum_values,
|
602
|
-
**kwargs,
|
603
|
-
)
|
604
|
-
except Exception as e:
|
605
|
-
if suppress or input_ == "":
|
606
|
-
return {}
|
607
|
-
raise e
|
608
|
-
|
609
|
-
|
610
|
-
def recursive_to_dict(
|
611
|
-
input_: Any,
|
612
|
-
/,
|
613
|
-
*,
|
614
|
-
max_recursive_depth: int = None,
|
615
|
-
recursive_custom_types: bool = False,
|
616
|
-
**kwargs: Any,
|
617
|
-
) -> Any:
|
618
|
-
if not isinstance(max_recursive_depth, int):
|
619
|
-
max_recursive_depth = 5
|
620
|
-
else:
|
621
|
-
if max_recursive_depth < 0:
|
622
|
-
raise ValueError(
|
623
|
-
"max_recursive_depth must be a non-negative integer"
|
624
|
-
)
|
625
|
-
if max_recursive_depth == 0:
|
626
|
-
return input_
|
627
|
-
if max_recursive_depth > 10:
|
628
|
-
raise ValueError(
|
629
|
-
"max_recursive_depth must be less than or equal to 10"
|
630
|
-
)
|
631
|
-
|
632
|
-
return _recur_to_dict(
|
633
|
-
input_,
|
634
|
-
max_recursive_depth=max_recursive_depth,
|
635
|
-
current_depth=0,
|
636
|
-
recursive_custom_types=recursive_custom_types,
|
637
|
-
**kwargs,
|
638
|
-
)
|
639
|
-
|
640
|
-
|
641
|
-
def _recur_to_dict(
|
642
|
-
input_: Any,
|
643
|
-
/,
|
644
|
-
*,
|
645
|
-
max_recursive_depth: int,
|
646
|
-
current_depth: int = 0,
|
647
|
-
recursive_custom_types: bool = False,
|
648
|
-
**kwargs: Any,
|
649
|
-
) -> Any:
|
650
|
-
if current_depth >= max_recursive_depth:
|
651
|
-
return input_
|
652
|
-
|
653
|
-
if isinstance(input_, str):
|
654
|
-
try:
|
655
|
-
# Attempt to parse the string
|
656
|
-
parsed = _to_dict(input_, **kwargs)
|
657
|
-
# Recursively process the parsed result
|
658
|
-
return _recur_to_dict(
|
659
|
-
parsed,
|
660
|
-
max_recursive_depth=max_recursive_depth,
|
661
|
-
current_depth=current_depth + 1,
|
662
|
-
recursive_custom_types=recursive_custom_types,
|
663
|
-
**kwargs,
|
664
|
-
)
|
665
|
-
except Exception:
|
666
|
-
# Return the original string if parsing fails
|
667
|
-
return input_
|
668
|
-
|
669
|
-
elif isinstance(input_, dict):
|
670
|
-
# Recursively process dictionary values
|
671
|
-
return {
|
672
|
-
key: _recur_to_dict(
|
673
|
-
value,
|
674
|
-
max_recursive_depth=max_recursive_depth,
|
675
|
-
current_depth=current_depth + 1,
|
676
|
-
recursive_custom_types=recursive_custom_types,
|
677
|
-
**kwargs,
|
678
|
-
)
|
679
|
-
for key, value in input_.items()
|
680
|
-
}
|
681
|
-
|
682
|
-
elif isinstance(input_, (list, tuple, set)):
|
683
|
-
# Recursively process list or tuple elements
|
684
|
-
processed = [
|
685
|
-
_recur_to_dict(
|
686
|
-
element,
|
687
|
-
max_recursive_depth=max_recursive_depth,
|
688
|
-
current_depth=current_depth + 1,
|
689
|
-
recursive_custom_types=recursive_custom_types,
|
690
|
-
**kwargs,
|
691
|
-
)
|
692
|
-
for element in input_
|
693
|
-
]
|
694
|
-
return type(input_)(processed)
|
695
|
-
|
696
|
-
elif isinstance(input_, type) and issubclass(input_, _Enum):
|
697
|
-
try:
|
698
|
-
obj_dict = _to_dict(input_, **kwargs)
|
699
|
-
return _recur_to_dict(
|
700
|
-
obj_dict,
|
701
|
-
max_recursive_depth=max_recursive_depth,
|
702
|
-
current_depth=current_depth + 1,
|
703
|
-
**kwargs,
|
704
|
-
)
|
705
|
-
except Exception:
|
706
|
-
return input_
|
707
|
-
|
708
|
-
elif recursive_custom_types:
|
709
|
-
# Process custom classes if enabled
|
710
|
-
try:
|
711
|
-
obj_dict = _to_dict(input_, **kwargs)
|
712
|
-
return _recur_to_dict(
|
713
|
-
obj_dict,
|
714
|
-
max_recursive_depth=max_recursive_depth,
|
715
|
-
current_depth=current_depth + 1,
|
716
|
-
recursive_custom_types=recursive_custom_types,
|
717
|
-
**kwargs,
|
718
|
-
)
|
719
|
-
except Exception:
|
720
|
-
return input_
|
721
|
-
|
722
|
-
else:
|
723
|
-
# Return the input as is for other data types
|
724
|
-
return input_
|
725
|
-
|
726
|
-
|
727
|
-
def _enum_to_dict(input_, /, use_enum_values: bool = True):
|
728
|
-
dict_ = dict(input_.__members__).copy()
|
729
|
-
if use_enum_values:
|
730
|
-
return {key: value.value for key, value in dict_.items()}
|
731
|
-
return dict_
|
732
|
-
|
733
|
-
|
734
|
-
def _str_to_dict(
|
735
|
-
input_: str,
|
736
|
-
/,
|
737
|
-
fuzzy_parse: bool = False,
|
738
|
-
str_type: Literal["json", "xml"] | None = "json",
|
739
|
-
parser: Callable[[str], Any] | None = None,
|
740
|
-
remove_root: bool = False,
|
741
|
-
root_tag: str = "root",
|
742
|
-
**kwargs: Any,
|
743
|
-
):
|
744
|
-
"""
|
745
|
-
kwargs for parser
|
746
|
-
"""
|
747
|
-
if not parser:
|
748
|
-
if str_type == "xml" and not parser:
|
749
|
-
parser = partial(
|
750
|
-
xml_to_dict, remove_root=remove_root, root_tag=root_tag
|
751
|
-
)
|
752
|
-
|
753
|
-
elif fuzzy_parse:
|
754
|
-
parser = fuzzy_parse_json
|
755
|
-
else:
|
756
|
-
parser = json.loads
|
757
|
-
|
758
|
-
return parser(input_, **kwargs)
|
759
|
-
|
760
|
-
|
761
|
-
def _na_to_dict(input_: type[None] | UndefinedType | PydanticUndefinedType, /):
|
762
|
-
return {}
|
763
|
-
|
764
|
-
|
765
|
-
def _model_to_dict(input_: Any, /, use_model_dump=True, **kwargs):
|
766
|
-
"""
|
767
|
-
kwargs: built-in serialization methods kwargs
|
768
|
-
accepted built-in serialization methods:
|
769
|
-
- mdoel_dump
|
770
|
-
- to_dict
|
771
|
-
- to_json
|
772
|
-
- dict
|
773
|
-
- json
|
774
|
-
"""
|
775
|
-
|
776
|
-
if use_model_dump and hasattr(input_, "model_dump"):
|
777
|
-
return input_.model_dump(**kwargs)
|
778
|
-
|
779
|
-
methods = (
|
780
|
-
"to_dict",
|
781
|
-
"to_json",
|
782
|
-
"json",
|
783
|
-
"dict",
|
784
|
-
)
|
785
|
-
for method in methods:
|
786
|
-
if hasattr(input_, method):
|
787
|
-
result = getattr(input_, method)(**kwargs)
|
788
|
-
return json.loads(result) if isinstance(result, str) else result
|
789
|
-
|
790
|
-
if hasattr(input_, "__dict__"):
|
791
|
-
return input_.__dict__
|
792
|
-
|
793
|
-
try:
|
794
|
-
return dict(input_)
|
795
|
-
except Exception as e:
|
796
|
-
raise ValueError(f"Unable to convert input to dictionary: {e}")
|
797
|
-
|
798
|
-
|
799
|
-
def _set_to_dict(input_: set, /) -> dict:
|
800
|
-
return {v: v for v in input_}
|
801
|
-
|
802
|
-
|
803
|
-
def _iterable_to_dict(input_: Iterable, /) -> dict:
|
804
|
-
return {idx: v for idx, v in enumerate(input_)}
|
805
|
-
|
806
|
-
|
807
|
-
def _to_dict(
|
808
|
-
input_: Any,
|
809
|
-
/,
|
810
|
-
*,
|
811
|
-
fuzzy_parse: bool = False,
|
812
|
-
str_type: Literal["json", "xml"] | None = "json",
|
813
|
-
parser: Callable[[str], Any] | None = None,
|
814
|
-
remove_root: bool = False,
|
815
|
-
root_tag: str = "root",
|
816
|
-
use_model_dump: bool = True,
|
817
|
-
use_enum_values: bool = True,
|
818
|
-
**kwargs: Any,
|
819
|
-
) -> dict[str, Any]:
|
820
|
-
if isinstance(input_, set):
|
821
|
-
return _set_to_dict(input_)
|
822
|
-
|
823
|
-
if isinstance(input_, type) and issubclass(input_, _Enum):
|
824
|
-
return _enum_to_dict(input_, use_enum_values=use_enum_values)
|
825
|
-
|
826
|
-
if isinstance(input_, Mapping):
|
827
|
-
return dict(input_)
|
828
|
-
|
829
|
-
if isinstance(input_, type(None) | UndefinedType | PydanticUndefinedType):
|
830
|
-
return _na_to_dict(input_)
|
831
|
-
|
832
|
-
if isinstance(input_, str):
|
833
|
-
return _str_to_dict(
|
834
|
-
input_,
|
835
|
-
fuzzy_parse=fuzzy_parse,
|
836
|
-
str_type=str_type,
|
837
|
-
parser=parser,
|
838
|
-
remove_root=remove_root,
|
839
|
-
root_tag=root_tag,
|
840
|
-
**kwargs,
|
841
|
-
)
|
842
|
-
|
843
|
-
if isinstance(input_, BaseModel) or not isinstance(input_, Sequence):
|
844
|
-
return _model_to_dict(input_, use_model_dump=use_model_dump, **kwargs)
|
845
|
-
|
846
|
-
if isinstance(input_, Iterable):
|
847
|
-
return _iterable_to_dict(input_)
|
848
|
-
|
849
|
-
with contextlib.suppress(Exception):
|
850
|
-
return dataclasses.asdict(input_)
|
851
|
-
|
852
|
-
return dict(input_)
|
853
|
-
|
854
|
-
|
855
524
|
def get_bins(input_: list[str], upper: int) -> list[list[int]]:
|
856
525
|
"""Organizes indices of strings into bins based on a cumulative upper limit.
|
857
526
|
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.16.
|
1
|
+
__version__ = "0.16.3"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.16.
|
3
|
+
Version: 0.16.3
|
4
4
|
Summary: An Intelligence Operating System.
|
5
5
|
Author-email: HaiyangLi <quantocean.li@gmail.com>
|
6
6
|
License: Apache License
|
@@ -226,17 +226,13 @@ Requires-Dist: backoff>=2.0.0
|
|
226
226
|
Requires-Dist: jinja2>=3.0.0
|
227
227
|
Requires-Dist: json-repair>=0.40.0
|
228
228
|
Requires-Dist: msgspec>=0.18.0
|
229
|
-
Requires-Dist: pillow>=10.0.0
|
230
|
-
Requires-Dist: psutil>=6.0.0
|
231
229
|
Requires-Dist: pydantic-settings>=2.8.0
|
232
230
|
Requires-Dist: pydantic>=2.8.0
|
233
231
|
Requires-Dist: pydapter[pandas]>=1.1.1
|
234
232
|
Requires-Dist: python-dotenv>=1.1.0
|
235
233
|
Requires-Dist: tiktoken>=0.9.0
|
236
|
-
Requires-Dist: toml>=0.8.0
|
237
234
|
Provides-Extra: all
|
238
235
|
Requires-Dist: aiosqlite>=0.21.0; extra == 'all'
|
239
|
-
Requires-Dist: claude-code-sdk>=0.0.15; extra == 'all'
|
240
236
|
Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'all'
|
241
237
|
Requires-Dist: docling>=2.15.0; extra == 'all'
|
242
238
|
Requires-Dist: fastmcp>=2.10.5; extra == 'all'
|
@@ -245,8 +241,6 @@ Requires-Dist: networkx>=3.0.0; extra == 'all'
|
|
245
241
|
Requires-Dist: ollama>=0.4.0; extra == 'all'
|
246
242
|
Requires-Dist: pydapter[postgres]; extra == 'all'
|
247
243
|
Requires-Dist: rich>=13.0.0; extra == 'all'
|
248
|
-
Provides-Extra: claude-code
|
249
|
-
Requires-Dist: claude-code-sdk>=0.0.15; extra == 'claude-code'
|
250
244
|
Provides-Extra: graph
|
251
245
|
Requires-Dist: matplotlib>=3.7.0; extra == 'graph'
|
252
246
|
Requires-Dist: networkx>=3.0.0; extra == 'graph'
|
@@ -264,10 +258,6 @@ Provides-Extra: schema
|
|
264
258
|
Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'schema'
|
265
259
|
Provides-Extra: sqlite
|
266
260
|
Requires-Dist: aiosqlite>=0.21.0; extra == 'sqlite'
|
267
|
-
Provides-Extra: tools
|
268
|
-
Requires-Dist: docling>=2.15.0; extra == 'tools'
|
269
|
-
Provides-Extra: unstructured
|
270
|
-
Requires-Dist: opencv-python>=4.2.0.34; extra == 'unstructured'
|
271
261
|
Provides-Extra: xml
|
272
262
|
Requires-Dist: xmltodict>=0.12.0; extra == 'xml'
|
273
263
|
Description-Content-Type: text/markdown
|
@@ -275,6 +265,7 @@ Description-Content-Type: text/markdown
|
|
275
265
|

|
276
266
|

|
277
267
|

|
268
|
+
[](https://codecov.io/github/khive-ai/lionagi)
|
278
269
|
|
279
270
|
[Documentation](https://khive-ai.github.io/lionagi/) |
|
280
271
|
[Discord](https://discord.gg/JDj9ENhUE8) |
|
@@ -417,7 +408,7 @@ Seamlessly route to different models in the same workflow.
|
|
417
408
|
|
418
409
|
### Claude Code Integration
|
419
410
|
|
420
|
-
LionAGI now supports Anthropic's Claude Code [
|
411
|
+
LionAGI now supports Anthropic's Claude Code [CLI SDK](https://docs.anthropic.com/en/docs/claude-code/sdk) enabling autonomous coding capabilities with persistent session management. The CLI endpoint
|
421
412
|
directly connects to claude code, and is recommended, you can either use it via a [proxy server](https://github.com/khive-ai/lionagi/tree/main/cookbooks/claude_proxy) or directly with `query_cli` endpoint, provided you have already logged onto claude code cli in your terminal.
|
422
413
|
|
423
414
|
```python
|
@@ -485,7 +476,6 @@ Key features:
|
|
485
476
|
```
|
486
477
|
"lionagi[reader]" - Reader tool for any unstructured data and web pages
|
487
478
|
"lionagi[ollama]" - Ollama model support for local inference
|
488
|
-
"lionagi[claude-code]" - Claude code python SDK integration (cli endpoint does not require this)
|
489
479
|
"lionagi[rich]" - Rich output formatting for better console display
|
490
480
|
"lionagi[schema]" - Convert pydantic schema to make the Model class persistent
|
491
481
|
"lionagi[postgres]" - Postgres database support for storing and retrieving structured data
|