lionagi 0.14.0__py3-none-any.whl → 0.14.2__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/protocols/generic/pile.py +41 -156
- lionagi/protocols/graph/node.py +30 -54
- lionagi/protocols/types.py +1 -2
- lionagi/service/connections/providers/claude_code_.py +31 -8
- lionagi/service/connections/providers/claude_code_cli.py +2 -3
- lionagi/session/session.py +6 -6
- lionagi/version.py +1 -1
- {lionagi-0.14.0.dist-info → lionagi-0.14.2.dist-info}/METADATA +2 -2
- {lionagi-0.14.0.dist-info → lionagi-0.14.2.dist-info}/RECORD +11 -11
- {lionagi-0.14.0.dist-info → lionagi-0.14.2.dist-info}/WHEEL +0 -0
- {lionagi-0.14.0.dist-info → lionagi-0.14.2.dist-info}/licenses/LICENSE +0 -0
@@ -5,7 +5,6 @@
|
|
5
5
|
from __future__ import annotations
|
6
6
|
|
7
7
|
import asyncio
|
8
|
-
import json
|
9
8
|
import threading
|
10
9
|
from collections import deque
|
11
10
|
from collections.abc import (
|
@@ -17,15 +16,12 @@ from collections.abc import (
|
|
17
16
|
)
|
18
17
|
from functools import wraps
|
19
18
|
from pathlib import Path
|
20
|
-
from typing import Any,
|
19
|
+
from typing import Any, Generic, TypeVar
|
21
20
|
|
22
21
|
import pandas as pd
|
23
22
|
from pydantic import Field
|
24
23
|
from pydantic.fields import FieldInfo
|
25
|
-
from pydapter import
|
26
|
-
from pydapter.adapters import CsvAdapter, JsonAdapter
|
27
|
-
from pydapter.extras.excel_ import ExcelAdapter
|
28
|
-
from pydapter.extras.pandas_ import DataFrameAdapter
|
24
|
+
from pydapter import Adaptable, AsyncAdaptable
|
29
25
|
from typing_extensions import Self, override
|
30
26
|
|
31
27
|
from lionagi._errors import ItemExistsError, ItemNotFoundError
|
@@ -39,27 +35,7 @@ D = TypeVar("D")
|
|
39
35
|
T = TypeVar("T", bound=E)
|
40
36
|
|
41
37
|
|
42
|
-
|
43
|
-
JsonAdapter,
|
44
|
-
CsvAdapter,
|
45
|
-
ExcelAdapter,
|
46
|
-
DataFrameAdapter,
|
47
|
-
)
|
48
|
-
|
49
|
-
|
50
|
-
class PileAdapterRegistry(AdapterRegistry):
|
51
|
-
pass
|
52
|
-
|
53
|
-
|
54
|
-
pile_adapter_registry = PileAdapterRegistry()
|
55
|
-
for i in PILE_DEFAULT_ADAPTERS:
|
56
|
-
pile_adapter_registry.register(i)
|
57
|
-
|
58
|
-
|
59
|
-
__all__ = (
|
60
|
-
"Pile",
|
61
|
-
"pile",
|
62
|
-
)
|
38
|
+
__all__ = ("Pile",)
|
63
39
|
|
64
40
|
|
65
41
|
def synchronized(func: Callable):
|
@@ -80,7 +56,7 @@ def async_synchronized(func: Callable):
|
|
80
56
|
return wrapper
|
81
57
|
|
82
58
|
|
83
|
-
class Pile(Element, Collective[E], Generic[E]):
|
59
|
+
class Pile(Element, Collective[E], Generic[E], Adaptable, AsyncAdaptable):
|
84
60
|
"""Thread-safe async-compatible, ordered collection of elements.
|
85
61
|
|
86
62
|
The Pile class provides a thread-safe, async-compatible collection with:
|
@@ -113,8 +89,6 @@ class Pile(Element, Collective[E], Generic[E]):
|
|
113
89
|
frozen=True,
|
114
90
|
)
|
115
91
|
|
116
|
-
_adapter_registry: ClassVar[AdapterRegistry] = pile_adapter_registry
|
117
|
-
|
118
92
|
def __pydantic_extra__(self) -> dict[str, FieldInfo]:
|
119
93
|
return {
|
120
94
|
"_lock": Field(default_factory=threading.Lock),
|
@@ -959,48 +933,30 @@ class Pile(Element, Collective[E], Generic[E]):
|
|
959
933
|
is_same_dtype(self.collections.values())
|
960
934
|
)
|
961
935
|
|
962
|
-
def adapt_to(self, obj_key: str,
|
963
|
-
""
|
964
|
-
|
965
|
-
if obj_key in ["json", "csv", "toml"]:
|
966
|
-
data = self.to_dict()
|
967
|
-
|
968
|
-
# Create a simple object that has model_dump method
|
969
|
-
class _Wrapper:
|
970
|
-
def __init__(self, data):
|
971
|
-
self._data = data
|
972
|
-
|
973
|
-
def model_dump(self):
|
974
|
-
return self._data
|
975
|
-
|
976
|
-
wrapper = _Wrapper(data)
|
977
|
-
return self._get_adapter_registry().adapt_to(
|
978
|
-
wrapper, obj_key=obj_key, **kwargs
|
979
|
-
)
|
980
|
-
return self._get_adapter_registry().adapt_to(
|
981
|
-
self, obj_key=obj_key, **kwargs
|
982
|
-
)
|
936
|
+
def adapt_to(self, obj_key: str, many=False, **kwargs: Any) -> Any:
|
937
|
+
kwargs["adapt_meth"] = "to_dict"
|
938
|
+
return super().adapt_to(obj_key, many=many, **kwargs)
|
983
939
|
|
984
940
|
@classmethod
|
985
|
-
def
|
986
|
-
"""
|
987
|
-
|
941
|
+
def adapt_from(cls, obj: Any, obj_key: str, many=False, **kwargs: Any):
|
942
|
+
"""Create from another format."""
|
943
|
+
kwargs["adapt_meth"] = "from_dict"
|
944
|
+
return super().adapt_from(obj, obj_key, many=many, **kwargs)
|
988
945
|
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
return
|
946
|
+
async def adapt_to_async(
|
947
|
+
self, obj_key: str, many=False, **kwargs: Any
|
948
|
+
) -> Any:
|
949
|
+
kwargs["adapt_meth"] = "to_dict"
|
950
|
+
return await super().adapt_to_async(obj_key, many=many, **kwargs)
|
994
951
|
|
995
952
|
@classmethod
|
996
|
-
def
|
997
|
-
|
998
|
-
|
999
|
-
|
953
|
+
async def adapt_from_async(
|
954
|
+
cls, obj: Any, obj_key: str, many=False, **kwargs: Any
|
955
|
+
):
|
956
|
+
kwargs["adapt_meth"] = "from_dict"
|
957
|
+
return await super().adapt_from_async(
|
958
|
+
obj, obj_key, many=many, **kwargs
|
1000
959
|
)
|
1001
|
-
if isinstance(dict_, list):
|
1002
|
-
dict_ = {"collections": dict_}
|
1003
|
-
return cls.from_dict(dict_)
|
1004
960
|
|
1005
961
|
def to_df(
|
1006
962
|
self,
|
@@ -1008,116 +964,45 @@ class Pile(Element, Collective[E], Generic[E]):
|
|
1008
964
|
**kwargs: Any,
|
1009
965
|
) -> pd.DataFrame:
|
1010
966
|
"""Convert to DataFrame."""
|
1011
|
-
|
1012
|
-
data = [item.to_dict() for item in self.collections.values()]
|
967
|
+
from pydapter.extras.pandas_ import DataFrameAdapter
|
1013
968
|
|
1014
|
-
|
1015
|
-
|
1016
|
-
def __init__(self, data):
|
1017
|
-
self._data = data
|
1018
|
-
|
1019
|
-
def model_dump(self):
|
1020
|
-
return self._data
|
1021
|
-
|
1022
|
-
wrappers = [_ItemWrapper(d) for d in data]
|
1023
|
-
df = self._get_adapter_registry().adapt_to(
|
1024
|
-
wrappers, obj_key="pd.DataFrame", many=True, **kwargs
|
969
|
+
df = DataFrameAdapter.to_obj(
|
970
|
+
list(self.collections.values()), adapt_meth="to_dict", **kwargs
|
1025
971
|
)
|
1026
|
-
|
1027
972
|
if columns:
|
1028
973
|
return df[columns]
|
1029
974
|
return df
|
1030
975
|
|
1031
976
|
def to_csv_file(self, fp: str | Path, **kwargs: Any) -> None:
|
1032
977
|
"""Save to CSV file."""
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
978
|
+
from pydapter.adapters import CsvAdapter
|
979
|
+
|
980
|
+
csv_str = CsvAdapter.to_obj(
|
981
|
+
list(self.collections.values()), adapt_meth="to_dict", **kwargs
|
982
|
+
)
|
983
|
+
with open(fp, "w") as f:
|
984
|
+
f.write(csv_str)
|
1036
985
|
|
1037
986
|
def to_json_file(
|
1038
|
-
self,
|
1039
|
-
path_or_buf,
|
1040
|
-
*,
|
1041
|
-
use_pd: bool = False,
|
1042
|
-
many: bool = False,
|
1043
|
-
mode="w",
|
1044
|
-
**kwargs,
|
987
|
+
self, fp: str | Path, mode: str = "w", many: bool = False, **kwargs
|
1045
988
|
):
|
1046
989
|
"""Export collection to JSON file.
|
1047
990
|
|
1048
991
|
Args:
|
1049
|
-
|
1050
|
-
|
1051
|
-
mode: File
|
1052
|
-
verbose: Print confirmation message.
|
992
|
+
fp: File path or buffer to write to.
|
993
|
+
many: If True, export as a list of items.
|
994
|
+
mode: File mode ('w' for write, 'a' for append).
|
1053
995
|
**kwargs: Additional arguments for json.dump() or DataFrame.to_json().
|
1054
996
|
"""
|
1055
|
-
|
1056
|
-
return self.to_df().to_json(path_or_buf, mode=mode, **kwargs)
|
997
|
+
from pydapter.adapters import JsonAdapter
|
1057
998
|
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
with open(path_or_buf, mode, encoding="utf-8") as f:
|
999
|
+
json_str = JsonAdapter.to_obj(
|
1000
|
+
self, many=many, adapt_meth="to_dict", **kwargs
|
1001
|
+
)
|
1002
|
+
with open(fp, mode) as f:
|
1063
1003
|
f.write(json_str)
|
1064
1004
|
|
1065
1005
|
|
1066
|
-
def pile(
|
1067
|
-
collections: Any = None,
|
1068
|
-
/,
|
1069
|
-
item_type: type[T] | set[type[T]] | None = None,
|
1070
|
-
progression: list[str] | None = None,
|
1071
|
-
strict_type: bool = False,
|
1072
|
-
df: pd.DataFrame | None = None, # priority 1
|
1073
|
-
fp: str | Path | None = None, # priority 2
|
1074
|
-
**kwargs,
|
1075
|
-
) -> Pile:
|
1076
|
-
"""Create a new Pile instance.
|
1077
|
-
|
1078
|
-
Args:
|
1079
|
-
items: Initial items for the pile.
|
1080
|
-
item_type: Allowed types for items in the pile.
|
1081
|
-
order: Initial order of items.
|
1082
|
-
strict: If True, enforce strict type checking.
|
1083
|
-
|
1084
|
-
Returns:
|
1085
|
-
Pile: A new Pile instance.
|
1086
|
-
"""
|
1087
|
-
|
1088
|
-
if df:
|
1089
|
-
return Pile.adapt_from(df, "pd.DataFrame", **kwargs)
|
1090
|
-
|
1091
|
-
if fp:
|
1092
|
-
fp = Path(fp)
|
1093
|
-
if fp.suffix == ".csv":
|
1094
|
-
# Read CSV to DataFrame first
|
1095
|
-
df = pd.read_csv(fp, **kwargs)
|
1096
|
-
return Pile.adapt_from(df, "pd.DataFrame")
|
1097
|
-
if fp.suffix == ".xlsx":
|
1098
|
-
# Read Excel to DataFrame first
|
1099
|
-
df = pd.read_excel(fp, **kwargs)
|
1100
|
-
return Pile.adapt_from(df, "pd.DataFrame")
|
1101
|
-
if fp.suffix in [".json", ".jsonl"]:
|
1102
|
-
# Read JSON file
|
1103
|
-
with open(fp, encoding="utf-8") as f:
|
1104
|
-
data = json.load(f)
|
1105
|
-
if isinstance(data, dict):
|
1106
|
-
return Pile.from_dict(data)
|
1107
|
-
elif isinstance(data, list):
|
1108
|
-
return Pile.from_dict({"collections": data})
|
1109
|
-
else:
|
1110
|
-
raise ValueError(f"Invalid JSON data structure in {fp}")
|
1111
|
-
|
1112
|
-
return Pile(
|
1113
|
-
collections,
|
1114
|
-
item_type=item_type,
|
1115
|
-
order=progression,
|
1116
|
-
strict=strict_type,
|
1117
|
-
**kwargs,
|
1118
|
-
)
|
1119
|
-
|
1120
|
-
|
1121
1006
|
def to_list_type(value: Any, /) -> list[Any]:
|
1122
1007
|
"""Convert input to a list format"""
|
1123
1008
|
if value is None:
|
lionagi/protocols/graph/node.py
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
5
|
+
from __future__ import annotations
|
6
|
+
|
5
7
|
import json
|
6
|
-
from typing import Any
|
8
|
+
from typing import Any
|
7
9
|
|
8
10
|
from pydantic import field_validator
|
9
|
-
from pydapter import
|
11
|
+
from pydapter import Adaptable, AsyncAdaptable
|
10
12
|
from pydapter.adapters import JsonAdapter, TomlAdapter
|
11
13
|
from pydapter.extras.pandas_ import SeriesAdapter
|
12
14
|
|
@@ -22,18 +24,10 @@ NODE_DEFAULT_ADAPTERS = (
|
|
22
24
|
)
|
23
25
|
|
24
26
|
|
25
|
-
class NodeAdapterRegistry(AdapterRegistry):
|
26
|
-
pass
|
27
|
-
|
28
|
-
|
29
|
-
node_adapter_registry = NodeAdapterRegistry()
|
30
|
-
for i in NODE_DEFAULT_ADAPTERS:
|
31
|
-
node_adapter_registry.register(i)
|
32
|
-
|
33
27
|
__all__ = ("Node",)
|
34
28
|
|
35
29
|
|
36
|
-
class Node(Element, Relational):
|
30
|
+
class Node(Element, Relational, AsyncAdaptable, Adaptable):
|
37
31
|
"""
|
38
32
|
A base class for all Nodes in a graph, storing:
|
39
33
|
- Arbitrary content
|
@@ -42,8 +36,6 @@ class Node(Element, Relational):
|
|
42
36
|
- Automatic subclass registration
|
43
37
|
"""
|
44
38
|
|
45
|
-
_adapter_registry: ClassVar[AdapterRegistry] = node_adapter_registry
|
46
|
-
|
47
39
|
content: Any = None
|
48
40
|
embedding: list[float] | None = None
|
49
41
|
|
@@ -76,63 +68,47 @@ class Node(Element, Relational):
|
|
76
68
|
"Invalid embedding type; must be list or JSON-encoded string."
|
77
69
|
)
|
78
70
|
|
79
|
-
def
|
80
|
-
self, obj_key: str,
|
71
|
+
async def adapt_to_async(
|
72
|
+
self, obj_key: str, many=False, **kwargs: Any
|
81
73
|
) -> Any:
|
74
|
+
kwargs["adapt_meth"] = "to_dict"
|
75
|
+
return super().adapt_to_async(obj_key, many=many, **kwargs)
|
76
|
+
|
77
|
+
@classmethod
|
78
|
+
def adapt_from_async(
|
79
|
+
cls,
|
80
|
+
obj: Any,
|
81
|
+
obj_key: str,
|
82
|
+
many=False,
|
83
|
+
**kwargs: Any,
|
84
|
+
) -> Node:
|
85
|
+
kwargs["adapt_meth"] = "from_dict"
|
86
|
+
return super().adapt_from_async(
|
87
|
+
obj, obj_key=obj_key, many=many, **kwargs
|
88
|
+
)
|
89
|
+
|
90
|
+
def adapt_to(self, obj_key: str, many=False, **kwargs: Any) -> Any:
|
82
91
|
"""
|
83
92
|
Convert this Node to another format using a registered adapter.
|
84
93
|
"""
|
85
|
-
|
86
|
-
|
87
|
-
data = self.to_dict()
|
88
|
-
|
89
|
-
# Create a simple object that has model_dump method
|
90
|
-
class _Wrapper:
|
91
|
-
def __init__(self, data):
|
92
|
-
self._data = data
|
93
|
-
|
94
|
-
def model_dump(self):
|
95
|
-
return self._data
|
96
|
-
|
97
|
-
wrapper = _Wrapper(data)
|
98
|
-
return self._get_adapter_registry().adapt_to(
|
99
|
-
wrapper, obj_key=obj_key, many=many, **kwargs
|
100
|
-
)
|
101
|
-
return self._get_adapter_registry().adapt_to(
|
102
|
-
self, obj_key=obj_key, many=many, **kwargs
|
103
|
-
)
|
94
|
+
kwargs["adapt_meth"] = "to_dict"
|
95
|
+
return super().adapt_to(obj_key, many=many, **kwargs)
|
104
96
|
|
105
97
|
@classmethod
|
106
98
|
def adapt_from(
|
107
99
|
cls,
|
108
100
|
obj: Any,
|
109
101
|
obj_key: str,
|
110
|
-
|
111
|
-
many: bool = False,
|
102
|
+
many=False,
|
112
103
|
**kwargs: Any,
|
113
|
-
) ->
|
104
|
+
) -> Node:
|
114
105
|
"""
|
115
106
|
Construct a Node from an external format using a registered adapter.
|
116
107
|
If the adapter returns a dictionary with 'lion_class', we can
|
117
108
|
auto-delegate to the correct subclass via from_dict.
|
118
109
|
"""
|
119
|
-
|
120
|
-
|
121
|
-
)
|
122
|
-
# If adapter returned multiple items, choose the first or handle as needed.
|
123
|
-
if isinstance(result, list):
|
124
|
-
result = result[0]
|
125
|
-
return cls.from_dict(result)
|
126
|
-
|
127
|
-
@classmethod
|
128
|
-
def _get_adapter_registry(cls) -> AdapterRegistry:
|
129
|
-
if isinstance(cls._adapter_registry, type):
|
130
|
-
cls._adapter_registry = cls._adapter_registry()
|
131
|
-
return cls._adapter_registry
|
132
|
-
|
133
|
-
@classmethod
|
134
|
-
def register_adapter(cls, adapter: Any) -> None:
|
135
|
-
cls._get_adapter_registry().register(adapter)
|
110
|
+
kwargs["adapt_meth"] = "from_dict"
|
111
|
+
return super().adapt_from(obj, obj_key=obj_key, many=many, **kwargs)
|
136
112
|
|
137
113
|
|
138
114
|
# File: lionagi/protocols/graph/node.py
|
lionagi/protocols/types.py
CHANGED
@@ -19,7 +19,7 @@ from .forms.report import BaseForm, Form, Report
|
|
19
19
|
from .generic.element import ID, Element, IDError, IDType, validate_order
|
20
20
|
from .generic.event import Event, EventStatus, Execution
|
21
21
|
from .generic.log import Log, LogManager, LogManagerConfig
|
22
|
-
from .generic.pile import Pile,
|
22
|
+
from .generic.pile import Pile, to_list_type
|
23
23
|
from .generic.processor import Executor, Processor
|
24
24
|
from .generic.progression import Progression, prog
|
25
25
|
from .graph.edge import EdgeCondition
|
@@ -67,7 +67,6 @@ __all__ = (
|
|
67
67
|
"LogManager",
|
68
68
|
"LogManagerConfig",
|
69
69
|
"Pile",
|
70
|
-
"pile",
|
71
70
|
"to_list_type",
|
72
71
|
"Executor",
|
73
72
|
"Processor",
|
@@ -5,18 +5,18 @@
|
|
5
5
|
from __future__ import annotations
|
6
6
|
|
7
7
|
import json
|
8
|
+
import warnings
|
8
9
|
from pathlib import Path
|
9
10
|
from typing import Any, Literal
|
10
11
|
|
11
|
-
from claude_code_sdk import ClaudeCodeOptions
|
12
|
-
from claude_code_sdk import query as sdk_query
|
13
|
-
from claude_code_sdk import types as cc_types
|
14
12
|
from pydantic import BaseModel, Field, field_validator, model_validator
|
15
13
|
|
16
14
|
from lionagi.libs.schema.as_readable import as_readable
|
17
15
|
from lionagi.service.connections.endpoint import Endpoint
|
18
16
|
from lionagi.service.connections.endpoint_config import EndpointConfig
|
19
|
-
from lionagi.utils import to_dict, to_list
|
17
|
+
from lionagi.utils import is_import_installed, to_dict, to_list
|
18
|
+
|
19
|
+
HAS_CLAUDE_CODE_SDK = is_import_installed("claude_code_sdk")
|
20
20
|
|
21
21
|
# --------------------------------------------------------------------------- constants
|
22
22
|
ClaudePermission = Literal[
|
@@ -172,7 +172,9 @@ class ClaudeCodeRequest(BaseModel):
|
|
172
172
|
return args
|
173
173
|
|
174
174
|
# ------------------------ SDK helpers -----------------------------------
|
175
|
-
def as_claude_options(self)
|
175
|
+
def as_claude_options(self):
|
176
|
+
from claude_code_sdk import ClaudeCodeOptions
|
177
|
+
|
176
178
|
data = {
|
177
179
|
k: v
|
178
180
|
for k, v in self.model_dump(exclude_none=True).items()
|
@@ -253,6 +255,17 @@ class ClaudeCodeEndpoint(Endpoint):
|
|
253
255
|
"""Direct Python-SDK (non-CLI) endpoint - unchanged except for bug-fixes."""
|
254
256
|
|
255
257
|
def __init__(self, config: EndpointConfig = ENDPOINT_CONFIG, **kwargs):
|
258
|
+
if not HAS_CLAUDE_CODE_SDK:
|
259
|
+
raise ImportError(
|
260
|
+
"claude_code_sdk is not installed. "
|
261
|
+
"Please install it with `uv pip install lionagi[claude_code_sdk]`."
|
262
|
+
)
|
263
|
+
warnings.warn(
|
264
|
+
"The claude_code `query` endpoint is deprecated. "
|
265
|
+
"Use `query_cli` endpoint instead.",
|
266
|
+
DeprecationWarning,
|
267
|
+
)
|
268
|
+
|
256
269
|
super().__init__(config=config, **kwargs)
|
257
270
|
|
258
271
|
def create_payload(self, request: dict | BaseModel, **kwargs):
|
@@ -262,13 +275,15 @@ class ClaudeCodeEndpoint(Endpoint):
|
|
262
275
|
return {"request": req_obj}, {}
|
263
276
|
|
264
277
|
def _stream_claude_code(self, request: ClaudeCodeRequest):
|
278
|
+
from claude_code_sdk import query as sdk_query
|
279
|
+
|
265
280
|
return sdk_query(
|
266
281
|
prompt=request.prompt, options=request.as_claude_options()
|
267
282
|
)
|
268
283
|
|
269
284
|
async def stream(self, request: dict | BaseModel, **kwargs):
|
270
|
-
payload, _ = self.create_payload(request, **kwargs)
|
271
|
-
async for chunk in self._stream_claude_code(payload):
|
285
|
+
payload, _ = self.create_payload(request, **kwargs)
|
286
|
+
async for chunk in self._stream_claude_code(payload["request"]):
|
272
287
|
yield chunk
|
273
288
|
|
274
289
|
def _parse_claude_code_response(self, responses: list) -> dict:
|
@@ -298,6 +313,7 @@ class ClaudeCodeEndpoint(Endpoint):
|
|
298
313
|
"total_tokens": 0,
|
299
314
|
},
|
300
315
|
}
|
316
|
+
from claude_code_sdk import types as cc_types
|
301
317
|
|
302
318
|
for response in responses:
|
303
319
|
if isinstance(response, cc_types.SystemMessage):
|
@@ -350,6 +366,9 @@ class ClaudeCodeEndpoint(Endpoint):
|
|
350
366
|
headers: dict,
|
351
367
|
**kwargs,
|
352
368
|
):
|
369
|
+
from claude_code_sdk import query as sdk_query
|
370
|
+
from claude_code_sdk import types as cc_types
|
371
|
+
|
353
372
|
responses = []
|
354
373
|
request: ClaudeCodeRequest = payload["request"]
|
355
374
|
system: cc_types.SystemMessage = None
|
@@ -400,6 +419,8 @@ class ClaudeCodeEndpoint(Endpoint):
|
|
400
419
|
|
401
420
|
|
402
421
|
def _display_message(chunk, theme):
|
422
|
+
from claude_code_sdk import types as cc_types
|
423
|
+
|
403
424
|
if isinstance(
|
404
425
|
chunk,
|
405
426
|
cc_types.SystemMessage
|
@@ -437,7 +458,9 @@ def _display_message(chunk, theme):
|
|
437
458
|
)
|
438
459
|
|
439
460
|
|
440
|
-
def _verbose_output(res
|
461
|
+
def _verbose_output(res) -> str:
|
462
|
+
from claude_code_sdk import types as cc_types
|
463
|
+
|
441
464
|
str_ = ""
|
442
465
|
if isinstance(res, cc_types.SystemMessage):
|
443
466
|
str_ = f"Claude Code Session Started: {res.data.get('session_id', 'unknown')}"
|
@@ -355,7 +355,7 @@ ENDPOINT_CONFIG = EndpointConfig(
|
|
355
355
|
endpoint="query_cli",
|
356
356
|
api_key="dummy",
|
357
357
|
request_options=ClaudeCodeRequest,
|
358
|
-
timeout=
|
358
|
+
timeout=18000, # 30 mins
|
359
359
|
)
|
360
360
|
|
361
361
|
|
@@ -404,8 +404,7 @@ class ClaudeCodeCLIEndpoint(Endpoint):
|
|
404
404
|
responses.append(chunk)
|
405
405
|
if isinstance(chunk, ClaudeSession):
|
406
406
|
break
|
407
|
-
|
407
|
+
log.info(
|
408
408
|
f"Session {session.session_id} finished with {len(responses)} chunks"
|
409
409
|
)
|
410
|
-
|
411
410
|
return to_dict(session, recursive=True)
|
lionagi/session/session.py
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
5
5
|
from collections.abc import Callable
|
6
|
-
from functools import partial
|
7
6
|
from typing import Any
|
8
7
|
|
9
8
|
import pandas as pd
|
@@ -28,7 +27,6 @@ from lionagi.protocols.types import (
|
|
28
27
|
SenderRecipient,
|
29
28
|
System,
|
30
29
|
Tool,
|
31
|
-
pile,
|
32
30
|
)
|
33
31
|
|
34
32
|
from .._errors import ItemNotFoundError
|
@@ -36,8 +34,6 @@ from ..service.imodel import iModel
|
|
36
34
|
from ..utils import lcall
|
37
35
|
from .branch import Branch
|
38
36
|
|
39
|
-
msg_pile = partial(pile, item_type={RoledMessage}, strict_type=False)
|
40
|
-
|
41
37
|
|
42
38
|
class Session(Node, Communicatable, Relational):
|
43
39
|
"""
|
@@ -50,7 +46,9 @@ class Session(Node, Communicatable, Relational):
|
|
50
46
|
mail_manager (MailManager | None): Manages mail operations.
|
51
47
|
"""
|
52
48
|
|
53
|
-
branches: Pile[Any] = Field(
|
49
|
+
branches: Pile[Any] = Field(
|
50
|
+
default_factory=lambda: Pile(item_type={Branch}, strict_type=False)
|
51
|
+
)
|
54
52
|
default_branch: Any = Field(default=None, exclude=True)
|
55
53
|
mail_transfer: Exchange = Field(default_factory=Exchange)
|
56
54
|
mail_manager: MailManager = Field(
|
@@ -219,7 +217,9 @@ class Session(Node, Communicatable, Relational):
|
|
219
217
|
unique_input=True,
|
220
218
|
unique_output=True,
|
221
219
|
)
|
222
|
-
return
|
220
|
+
return Pile(
|
221
|
+
collections=messages, item_type={RoledMessage}, strict_type=False
|
222
|
+
)
|
223
223
|
|
224
224
|
def to_df(
|
225
225
|
self,
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.14.
|
1
|
+
__version__ = "0.14.2"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.14.
|
3
|
+
Version: 0.14.2
|
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
|
@@ -229,7 +229,7 @@ Requires-Dist: matplotlib>=3.9.0
|
|
229
229
|
Requires-Dist: pillow>=11.0.0
|
230
230
|
Requires-Dist: psutil>=7.0.0
|
231
231
|
Requires-Dist: pydantic-settings>=2.8.0
|
232
|
-
Requires-Dist: pydapter[pandas]>=0.
|
232
|
+
Requires-Dist: pydapter[pandas]>=1.0.0
|
233
233
|
Requires-Dist: python-dotenv>=1.1.0
|
234
234
|
Requires-Dist: tiktoken>=0.8.0
|
235
235
|
Requires-Dist: toml>=0.9.0
|
@@ -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=hR3o7j_Ti5BahUZJjIeDkTEL09cseYBFJTIE0WEh8nw,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=mvgqxLonCROszMjnG8QWt00l-MvIr_mnGvCtaH-SQ_k,3814
|
@@ -125,7 +125,7 @@ lionagi/operations/translate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
125
125
|
lionagi/operations/translate/translate.py,sha256=6eBVoQRarGEJ8Tfcl6Z__PLHQTTIbM5MaPVYNeKHRIs,1397
|
126
126
|
lionagi/protocols/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
127
127
|
lionagi/protocols/_concepts.py,sha256=ZBN5OYpLMWLrl9uZqSg9GD4uwf60V4VHcxRnBTRWIRc,1555
|
128
|
-
lionagi/protocols/types.py,sha256=
|
128
|
+
lionagi/protocols/types.py,sha256=qhAGExKJFa0uL1TfdJk-gNx3Z6b5zWu17s5HyYnI7Ps,2436
|
129
129
|
lionagi/protocols/action/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
130
130
|
lionagi/protocols/action/function_calling.py,sha256=rfuzIowjJpyqO5Ynfs5fGnxsDIU5aKinTj1NI6bGlEU,5106
|
131
131
|
lionagi/protocols/action/manager.py,sha256=XmdQIaVgSpmFBFW9kbW_rdwdQmlBteP4VRanxh_f918,8549
|
@@ -139,13 +139,13 @@ lionagi/protocols/generic/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGv
|
|
139
139
|
lionagi/protocols/generic/element.py,sha256=Eaij2YpTWsGk28Tqjazmjmc_tOnalH7_iGFZrL6QJb4,14420
|
140
140
|
lionagi/protocols/generic/event.py,sha256=InjBd2K9aSYxgai1c20d4jaJOkEx5VGFfb7iZbiMiNA,5200
|
141
141
|
lionagi/protocols/generic/log.py,sha256=vepclOaY3fdR1QgFDj9usOffsx9T-9PbgwXjTvm6twQ,7441
|
142
|
-
lionagi/protocols/generic/pile.py,sha256=
|
142
|
+
lionagi/protocols/generic/pile.py,sha256=sSj999xPf9pAKxa3TgB6Wc7xGrY4sMYNYtIk-k9TDhw,30362
|
143
143
|
lionagi/protocols/generic/processor.py,sha256=GQ_j_5f4UE-jJeqIJ9L2NdicpZnu50DSP1mvxlc7O_4,10381
|
144
144
|
lionagi/protocols/generic/progression.py,sha256=qlITq1qzV119iR5qR__fBAzV489S7d4t20E8uDRicEw,15189
|
145
145
|
lionagi/protocols/graph/__init__.py,sha256=UPu3OmUpjSgX2aBuBJUdG2fppGlfqAH96hU0qIMBMp0,253
|
146
146
|
lionagi/protocols/graph/edge.py,sha256=YxSGj4w_fG7khm-zpKduuK5fJzhJDx23JhU1dZp29d8,5241
|
147
147
|
lionagi/protocols/graph/graph.py,sha256=fhPc_ogXkxbBrM0_En9QTDVM7fHA_LzURCdmDRuBlHE,10217
|
148
|
-
lionagi/protocols/graph/node.py,sha256=
|
148
|
+
lionagi/protocols/graph/node.py,sha256=seQobwaQ32sA7rsxwcGAZERIomzkoAsADTJuQa3qY0w,3404
|
149
149
|
lionagi/protocols/mail/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
150
150
|
lionagi/protocols/mail/exchange.py,sha256=P1PcrFylIBeiQa8kox9H1qyJ4kjhUlbLiTUT8rs1OXg,7041
|
151
151
|
lionagi/protocols/mail/mail.py,sha256=RB5CUft_4J85H9nM9g6aRXomTaqKwF5xVjJacPAhoa8,1356
|
@@ -186,8 +186,8 @@ lionagi/service/connections/header_factory.py,sha256=22sG4ian3MiNklF6SdQqkEYgtWK
|
|
186
186
|
lionagi/service/connections/match_endpoint.py,sha256=K3I4vU6GH6utlEArlyDFUmNdnp94CEPxqKrehAx29J4,2410
|
187
187
|
lionagi/service/connections/providers/__init__.py,sha256=3lzOakDoBWmMaNnT2g-YwktPKa_Wme4lnPRSmOQfayY,105
|
188
188
|
lionagi/service/connections/providers/anthropic_.py,sha256=SUPnw2UqjY5wuHXLHas6snMTzhQ-UuixvPYbkVnXn34,3083
|
189
|
-
lionagi/service/connections/providers/claude_code_.py,sha256=
|
190
|
-
lionagi/service/connections/providers/claude_code_cli.py,sha256=
|
189
|
+
lionagi/service/connections/providers/claude_code_.py,sha256=79f6ibcOI6z2v5m_aBcsWK0LdX6r2gnx8CapzHdHQWI,18131
|
190
|
+
lionagi/service/connections/providers/claude_code_cli.py,sha256=Wj-wOLJ7-wwOnbX_BH26P1EMg6vBdNGsX9MXLfalgGY,14584
|
191
191
|
lionagi/service/connections/providers/exa_.py,sha256=GGWaD9jd5gKM257OfUaIBBKIqR1NrNcBE67p_7JbK7g,938
|
192
192
|
lionagi/service/connections/providers/oai_.py,sha256=FmQMEmOY7H7dZd4og-_cdd1Unzy4lkIzMsTtEsm-yVE,4782
|
193
193
|
lionagi/service/connections/providers/ollama_.py,sha256=jdx6dGeChwVk5TFfFRbpnrpKzj8YQZw6D5iWJ6zYmfk,4096
|
@@ -201,14 +201,14 @@ lionagi/service/third_party/pplx_models.py,sha256=Nkm1ftESBa_NwP9ITBUNqLmAZ3Jh92
|
|
201
201
|
lionagi/session/__init__.py,sha256=kDypY6L3kGPnatAw7YNQAykgg-9MlIBnlhHExaXvt-c,202
|
202
202
|
lionagi/session/branch.py,sha256=bMNZQhCB7s_vWCOqQ3X1w2gZ9mhkDUMf21OvJGMWOyM,69713
|
203
203
|
lionagi/session/prompts.py,sha256=GPr0jibyAAqS3awDzGC8SoCL6aWJLLCCbXY0JUuxOC0,3170
|
204
|
-
lionagi/session/session.py,sha256=
|
204
|
+
lionagi/session/session.py,sha256=4zPB2E2yn7JcdlAkh757pmG6tjobvlryvvVRCO7uCW0,10795
|
205
205
|
lionagi/tools/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
206
206
|
lionagi/tools/base.py,sha256=cld32pyjaTUdyiqZ8hNyJjWKAhcJ8RQNhgImI7R8b-E,1940
|
207
207
|
lionagi/tools/types.py,sha256=XtJLY0m-Yi_ZLWhm0KycayvqMCZd--HxfQ0x9vFUYDE,230
|
208
208
|
lionagi/tools/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
209
209
|
lionagi/tools/file/reader.py,sha256=0TdnfVGVCKuM58MmGM-NyVjhU9BFoitkNYEepdc0z_Y,9529
|
210
210
|
lionagi/tools/memory/tools.py,sha256=zTGBenVsF8Wuh303kWntmQSGlAFKonHNdh5ePuQ26KE,15948
|
211
|
-
lionagi-0.14.
|
212
|
-
lionagi-0.14.
|
213
|
-
lionagi-0.14.
|
214
|
-
lionagi-0.14.
|
211
|
+
lionagi-0.14.2.dist-info/METADATA,sha256=UxE50bjUj-bnK5BHGMiyjmSzme6g9B87v19EjyBU940,20818
|
212
|
+
lionagi-0.14.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
213
|
+
lionagi-0.14.2.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
|
214
|
+
lionagi-0.14.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|