lionagi 0.10.4__py3-none-any.whl → 0.10.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/fields/research.py +4 -4
- lionagi/libs/file/concat.py +121 -0
- lionagi/libs/file/process.py +1 -1
- lionagi/libs/token_transform/symbolic_compress_context.py +1 -1
- lionagi/version.py +1 -1
- {lionagi-0.10.4.dist-info → lionagi-0.10.6.dist-info}/METADATA +2 -2
- {lionagi-0.10.4.dist-info → lionagi-0.10.6.dist-info}/RECORD +9 -8
- {lionagi-0.10.4.dist-info → lionagi-0.10.6.dist-info}/WHEEL +0 -0
- {lionagi-0.10.4.dist-info → lionagi-0.10.6.dist-info}/licenses/LICENSE +0 -0
lionagi/fields/research.py
CHANGED
@@ -16,8 +16,8 @@ class ResearchFinding(HashableModel):
|
|
16
16
|
A single piece of information or insight from the research phase.
|
17
17
|
"""
|
18
18
|
|
19
|
-
summary: str = Field(
|
20
|
-
|
19
|
+
summary: str | None = Field(
|
20
|
+
None,
|
21
21
|
description="Concise text describing the discovered fact, concept, or best practice.",
|
22
22
|
)
|
23
23
|
snippets: list[TextSnippet | CodeSnippet] = Field(
|
@@ -35,8 +35,8 @@ class PotentialRisk(HashableModel):
|
|
35
35
|
Identifies a risk or challenge discovered during research.
|
36
36
|
"""
|
37
37
|
|
38
|
-
description: str = Field(
|
39
|
-
|
38
|
+
description: str | None = Field(
|
39
|
+
None,
|
40
40
|
description="Short text describing the risk. E.g., 'Scalability concerns with chosen DB'.",
|
41
41
|
)
|
42
42
|
impact: str | None = Field(
|
@@ -0,0 +1,121 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from lionagi.utils import create_path, lcall
|
5
|
+
|
6
|
+
from .process import dir_to_files
|
7
|
+
|
8
|
+
|
9
|
+
def concat(
|
10
|
+
data_path: str | Path | list,
|
11
|
+
file_types: list[str],
|
12
|
+
output_dir: str | Path = None,
|
13
|
+
output_filename: str = None,
|
14
|
+
file_exist_ok: bool = True,
|
15
|
+
recursive: bool = True,
|
16
|
+
verbose: bool = True,
|
17
|
+
threshold: int = 0,
|
18
|
+
return_fps: bool = False,
|
19
|
+
return_files: bool = False,
|
20
|
+
exclude_patterns: list[str] = None,
|
21
|
+
**kwargs,
|
22
|
+
) -> dict[str, Any]:
|
23
|
+
"""
|
24
|
+
data_path: str or Path or list of str or Path, the directory or file paths to concatenate.
|
25
|
+
file_types: list of str, the file types to concatenate. [e.g. ['.txt', '.md']]
|
26
|
+
output_dir: str or Path, the directory to save the concatenated file. If provided, will save the file.
|
27
|
+
output_filename: str, the filename to save the concatenated file.
|
28
|
+
file_exist_ok: bool, if True, overwrite the existing file. Default is True.
|
29
|
+
recursive: bool, if True, search files recursively. Default is True.
|
30
|
+
verbose: bool, if True, print the output path. Default is True.
|
31
|
+
threshold: int, the minimum number of chars for the file to be considered valid to concatenate.
|
32
|
+
exclude_patterns: list of str, patterns to exclude files from concatenation (e.g. ['log', 'temp', '.venv']).
|
33
|
+
kwargs: additional keyword arguments to pass to create_path.
|
34
|
+
"""
|
35
|
+
persist_path = None
|
36
|
+
if output_dir:
|
37
|
+
if not output_filename:
|
38
|
+
output_filename = "concatenated_text.txt"
|
39
|
+
kwargs["timestamp"] = kwargs.get("timestamp", True)
|
40
|
+
kwargs["random_hash_digits"] = kwargs.get("random_hash_digits", 6)
|
41
|
+
output_filename = output_filename or "concatenated_text.txt"
|
42
|
+
persist_path = create_path(
|
43
|
+
output_dir, output_filename, file_exist_ok=file_exist_ok, **kwargs
|
44
|
+
)
|
45
|
+
|
46
|
+
texts = []
|
47
|
+
|
48
|
+
def _check_existence(_p: str) -> Path | list[Path] | None:
|
49
|
+
if exclude_patterns:
|
50
|
+
_str_p = str(_p)
|
51
|
+
for pattern in exclude_patterns:
|
52
|
+
if pattern in _str_p:
|
53
|
+
return None
|
54
|
+
|
55
|
+
if not Path(_p).exists():
|
56
|
+
# if the path doesn't exist, return None
|
57
|
+
if verbose:
|
58
|
+
print(f"Path {_p} does not exist, skipping...")
|
59
|
+
return None
|
60
|
+
|
61
|
+
p = Path(_p)
|
62
|
+
if p.is_dir():
|
63
|
+
return dir_to_files(
|
64
|
+
p,
|
65
|
+
recursive=recursive,
|
66
|
+
file_types=file_types,
|
67
|
+
ignore_errors=True,
|
68
|
+
max_workers=5,
|
69
|
+
)
|
70
|
+
if p.is_file():
|
71
|
+
return p
|
72
|
+
|
73
|
+
data_path: list[Path] = lcall(
|
74
|
+
data_path,
|
75
|
+
_check_existence,
|
76
|
+
sanitize_input=True,
|
77
|
+
unique_input=True,
|
78
|
+
flatten=True,
|
79
|
+
dropna=True,
|
80
|
+
unique_output=True,
|
81
|
+
flatten_tuple_set=True,
|
82
|
+
)
|
83
|
+
|
84
|
+
contents = {}
|
85
|
+
fps = []
|
86
|
+
for dp in data_path:
|
87
|
+
try:
|
88
|
+
text = dp.read_text(encoding="utf-8")
|
89
|
+
|
90
|
+
except Exception:
|
91
|
+
# if we cannot read the file, skip it
|
92
|
+
print(f"Could not read file: {dp}. Skipping...")
|
93
|
+
continue
|
94
|
+
|
95
|
+
if threshold > 0 and len(text) < threshold:
|
96
|
+
continue
|
97
|
+
|
98
|
+
fps.append(dp)
|
99
|
+
contents[str(dp)] = text
|
100
|
+
|
101
|
+
for k, text in sorted(contents.items(), key=lambda x: x[0]):
|
102
|
+
texts.extend(["---", k, "---\n", text])
|
103
|
+
|
104
|
+
text = "\n".join(texts)
|
105
|
+
if persist_path:
|
106
|
+
persist_path.write_text(text, encoding="utf-8")
|
107
|
+
if verbose:
|
108
|
+
print(
|
109
|
+
f"Concatenated {len(fps)} files to {persist_path}."
|
110
|
+
f" The file contains {len(text)} characters."
|
111
|
+
)
|
112
|
+
|
113
|
+
out = {"text": text} # default output
|
114
|
+
if persist_path:
|
115
|
+
out["persist_path"] = persist_path
|
116
|
+
if return_files:
|
117
|
+
out["texts"] = texts
|
118
|
+
if return_fps:
|
119
|
+
out["fps"] = fps
|
120
|
+
|
121
|
+
return out
|
lionagi/libs/file/process.py
CHANGED
@@ -203,7 +203,7 @@ def chunk(
|
|
203
203
|
)
|
204
204
|
|
205
205
|
if reader_tool is None:
|
206
|
-
reader_tool = lambda x: x.read_text(encoding="utf-8")
|
206
|
+
reader_tool = lambda x: Path(x).read_text(encoding="utf-8")
|
207
207
|
|
208
208
|
if reader_tool == "docling":
|
209
209
|
from lionagi.libs.package.imports import check_import
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.10.
|
1
|
+
__version__ = "0.10.6"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.6
|
4
4
|
Summary: An Intelligence Operating System.
|
5
5
|
Author-email: HaiyangLi <quantocean.li@gmail.com>
|
6
6
|
License: Apache License
|
@@ -220,7 +220,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
220
220
|
Classifier: Programming Language :: Python :: 3.13
|
221
221
|
Requires-Python: >=3.10
|
222
222
|
Requires-Dist: aiocache>=0.12.0
|
223
|
-
Requires-Dist: aiohttp>=3.11.
|
223
|
+
Requires-Dist: aiohttp>=3.11.14
|
224
224
|
Requires-Dist: jinja2>=3.0.0
|
225
225
|
Requires-Dist: pandas>=2.0.0
|
226
226
|
Requires-Dist: pillow>=10.0.0
|
@@ -4,7 +4,7 @@ lionagi/_errors.py,sha256=JlBTFJnRWtVYcRxKb7fWFiJHLbykl1E19mSJ8sXYVxg,455
|
|
4
4
|
lionagi/_types.py,sha256=iDdYewsP9rDrM7QY19_NDTcWUk7swp8vnGCrloHMtUM,53
|
5
5
|
lionagi/settings.py,sha256=W52mM34E6jXF3GyqCFzVREKZrmnUqtZm_BVDsUiDI_s,1627
|
6
6
|
lionagi/utils.py,sha256=uLTJKl7aTnFXV6ehA6zwiwEB7G2nQYKsO2pZ6mqFzUk,78908
|
7
|
-
lionagi/version.py,sha256=
|
7
|
+
lionagi/version.py,sha256=7qmFu9Qmzy5OxKJPN-LQOkzV_2T4cJYrUSLTfq7F3kE,23
|
8
8
|
lionagi/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
lionagi/adapters/adapter.py,sha256=aW7s1OKAdxHd8HBv2UcThn-r2Q08EyArssNyFobMLuA,3357
|
10
10
|
lionagi/adapters/json_adapter.py,sha256=EJj0Jev46ZhU3ZMnlYwyzN2rLxjLCVrMDpHkEuggBvk,4561
|
@@ -22,15 +22,16 @@ lionagi/fields/code.py,sha256=TFym51obzaSfCmeRoHZJyBtjfDI4tvl9F-1sjFc9rMw,7713
|
|
22
22
|
lionagi/fields/file.py,sha256=DhQ_HE0RvTNzkvBGQHRgbMYSokDkzE8GEu814i6jw5Q,7297
|
23
23
|
lionagi/fields/instruct.py,sha256=sMbCxEv0HQLa31JkJDmdrWWEzIfeKbcmN2hYOehz3Q0,4773
|
24
24
|
lionagi/fields/reason.py,sha256=3Ksz9_40dI-oQ9VtmpnYAmJdeDDIO-TwLDrf1ijbXGM,1438
|
25
|
-
lionagi/fields/research.py,sha256=
|
25
|
+
lionagi/fields/research.py,sha256=eEPKocx8eQy2E9FExRWVIo6MK_xvmwBAoRZciBY3RG0,1421
|
26
26
|
lionagi/libs/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
27
27
|
lionagi/libs/parse.py,sha256=JRS3bql0InHJqATnAatl-hQv4N--XXw4P77JHhTFnrc,1011
|
28
28
|
lionagi/libs/file/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
29
29
|
lionagi/libs/file/chunk.py,sha256=XeVMwM33JF0X1W6udz_nhlb3DCevA_EK6A50Hn_e5SY,9300
|
30
|
+
lionagi/libs/file/concat.py,sha256=YSauXVBL3WWx5Mvpn208Cj7q9TLt_aq-0M9J1fm-ins,3864
|
30
31
|
lionagi/libs/file/concat_files.py,sha256=FoI983oWFzp9VfFDP7kmbRb3t1CPe5F5LCtsux0ASAs,3089
|
31
32
|
lionagi/libs/file/file_ops.py,sha256=HBiIh1EljIJ5VTIXuyvJM0ppSs0YYOPUWmgDMJT634U,3430
|
32
33
|
lionagi/libs/file/params.py,sha256=SZ5DkoffWfxWudOAYCfCxpL8UIm-1UjeyTtploo-Lqs,5824
|
33
|
-
lionagi/libs/file/process.py,sha256=
|
34
|
+
lionagi/libs/file/process.py,sha256=EsnEJcQUm4ReP7qkCeMvL4Qe6fLRcENVWZndh9TSUsc,8692
|
34
35
|
lionagi/libs/file/save.py,sha256=TCxVlKxFFnr3xZ-HAXPpTomQoyiVrp6nKRoj-bcQt4k,2863
|
35
36
|
lionagi/libs/nested/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
36
37
|
lionagi/libs/nested/flatten.py,sha256=sB4jxZRoaUbjak9RbIWVWNKz2hzkhQJPFffV_Ws1GA0,5479
|
@@ -57,7 +58,7 @@ lionagi/libs/token_transform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
57
58
|
lionagi/libs/token_transform/base.py,sha256=LBnaDgi4HNgaJJGwIzWcQjVMdu49i_93rRvOvMU22Rw,1545
|
58
59
|
lionagi/libs/token_transform/llmlingua.py,sha256=DkeLUlrb7rGx3nZ04aADU9HXXu5mZTf_DBwT0xhzIv4,7
|
59
60
|
lionagi/libs/token_transform/perplexity.py,sha256=tcVRjPBX3nuVqsoTkowCf6RBXuybO--owH1lf2Ywj1s,14470
|
60
|
-
lionagi/libs/token_transform/symbolic_compress_context.py,sha256=
|
61
|
+
lionagi/libs/token_transform/symbolic_compress_context.py,sha256=J8UleoCRDBvbFvmss2JjOvJfuBT7LXUW7AsRB-oQq7c,4598
|
61
62
|
lionagi/libs/token_transform/synthlang.py,sha256=W6e-_265UXqVosM9X0TLKW53rNHvWCKhsWbVAop49Ac,259
|
62
63
|
lionagi/libs/token_transform/types.py,sha256=4HgAfNDlJ_Hu18kLt59GHr_76eF3xLpNCTbOXlAYVlA,491
|
63
64
|
lionagi/libs/token_transform/synthlang_/base.py,sha256=GDle72c8EjFz_3hg_k-y0YmksBsn5TSRVTw5_cwfWTo,4109
|
@@ -222,7 +223,7 @@ lionagi/tools/file/writer.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,
|
|
222
223
|
lionagi/tools/file/providers/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
223
224
|
lionagi/tools/file/providers/docling_.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
224
225
|
lionagi/tools/query/__init__.py,sha256=5y5joOZzfFWERl75auAcNcKC3lImVJ5ZZGvvHZUFCJM,112
|
225
|
-
lionagi-0.10.
|
226
|
-
lionagi-0.10.
|
227
|
-
lionagi-0.10.
|
228
|
-
lionagi-0.10.
|
226
|
+
lionagi-0.10.6.dist-info/METADATA,sha256=5vxUHPlRrLHQDEKg7Ke_NT5wDxl1hj3Llx3coh2-yro,18465
|
227
|
+
lionagi-0.10.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
228
|
+
lionagi-0.10.6.dist-info/licenses/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
|
229
|
+
lionagi-0.10.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|