lionagi 0.0.316__py3-none-any.whl → 0.1.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- lionagi/core/__init__.py +19 -8
- lionagi/core/agent/__init__.py +0 -3
- lionagi/core/agent/base_agent.py +25 -30
- lionagi/core/branch/__init__.py +0 -4
- lionagi/core/branch/{base_branch.py → base.py} +12 -13
- lionagi/core/branch/branch.py +22 -19
- lionagi/core/branch/executable_branch.py +0 -347
- lionagi/core/branch/{branch_flow_mixin.py → flow_mixin.py} +5 -5
- lionagi/core/direct/__init__.py +10 -1
- lionagi/core/direct/cot.py +61 -26
- lionagi/core/direct/plan.py +10 -8
- lionagi/core/direct/predict.py +5 -5
- lionagi/core/direct/react.py +8 -8
- lionagi/core/direct/score.py +4 -4
- lionagi/core/direct/select.py +4 -4
- lionagi/core/direct/utils.py +7 -4
- lionagi/core/direct/vote.py +2 -2
- lionagi/core/execute/base_executor.py +47 -0
- lionagi/core/execute/branch_executor.py +296 -0
- lionagi/core/execute/instruction_map_executor.py +179 -0
- lionagi/core/execute/neo4j_executor.py +381 -0
- lionagi/core/execute/structure_executor.py +314 -0
- lionagi/core/flow/monoflow/ReAct.py +20 -20
- lionagi/core/flow/monoflow/chat.py +6 -6
- lionagi/core/flow/monoflow/chat_mixin.py +23 -33
- lionagi/core/flow/monoflow/followup.py +14 -15
- lionagi/core/flow/polyflow/chat.py +15 -12
- lionagi/core/{prompt/action_template.py → form/action_form.py} +2 -2
- lionagi/core/{prompt → form}/field_validator.py +40 -31
- lionagi/core/form/form.py +302 -0
- lionagi/core/form/mixin.py +214 -0
- lionagi/core/{prompt/scored_template.py → form/scored_form.py} +2 -2
- lionagi/core/generic/__init__.py +37 -0
- lionagi/core/generic/action.py +26 -0
- lionagi/core/generic/component.py +455 -0
- lionagi/core/generic/condition.py +44 -0
- lionagi/core/generic/data_logger.py +305 -0
- lionagi/core/generic/edge.py +162 -0
- lionagi/core/generic/mail.py +90 -0
- lionagi/core/generic/mailbox.py +36 -0
- lionagi/core/generic/node.py +285 -0
- lionagi/core/generic/relation.py +70 -0
- lionagi/core/generic/signal.py +22 -0
- lionagi/core/generic/structure.py +362 -0
- lionagi/core/generic/transfer.py +20 -0
- lionagi/core/generic/work.py +40 -0
- lionagi/core/graph/graph.py +126 -0
- lionagi/core/graph/tree.py +190 -0
- lionagi/core/mail/__init__.py +0 -8
- lionagi/core/mail/mail_manager.py +15 -12
- lionagi/core/mail/schema.py +9 -2
- lionagi/core/messages/__init__.py +0 -3
- lionagi/core/messages/schema.py +17 -225
- lionagi/core/session/__init__.py +0 -3
- lionagi/core/session/session.py +24 -22
- lionagi/core/tool/__init__.py +3 -1
- lionagi/core/tool/tool.py +28 -0
- lionagi/core/tool/tool_manager.py +75 -75
- lionagi/experimental/directive/evaluator/__init__.py +0 -0
- lionagi/experimental/directive/evaluator/ast_evaluator.py +115 -0
- lionagi/experimental/directive/evaluator/base_evaluator.py +202 -0
- lionagi/experimental/directive/evaluator/sandbox_.py +14 -0
- lionagi/experimental/directive/evaluator/script_engine.py +83 -0
- lionagi/experimental/directive/parser/__init__.py +0 -0
- lionagi/experimental/directive/parser/base_parser.py +215 -0
- lionagi/experimental/directive/schema.py +36 -0
- lionagi/experimental/directive/template_/__init__.py +0 -0
- lionagi/experimental/directive/template_/base_template.py +63 -0
- lionagi/experimental/tool/__init__.py +0 -0
- lionagi/experimental/tool/function_calling.py +43 -0
- lionagi/experimental/tool/manual.py +66 -0
- lionagi/experimental/tool/schema.py +59 -0
- lionagi/experimental/tool/tool_manager.py +138 -0
- lionagi/experimental/tool/util.py +16 -0
- lionagi/experimental/work/__init__.py +0 -0
- lionagi/experimental/work/_logger.py +25 -0
- lionagi/experimental/work/exchange.py +0 -0
- lionagi/experimental/work/schema.py +30 -0
- lionagi/experimental/work/tests.py +72 -0
- lionagi/experimental/work/util.py +0 -0
- lionagi/experimental/work/work_function.py +89 -0
- lionagi/experimental/work/worker.py +12 -0
- lionagi/integrations/bridge/autogen_/__init__.py +0 -0
- lionagi/integrations/bridge/autogen_/autogen_.py +124 -0
- lionagi/integrations/bridge/llamaindex_/get_index.py +294 -0
- lionagi/integrations/bridge/llamaindex_/llama_pack.py +227 -0
- lionagi/integrations/bridge/transformers_/__init__.py +0 -0
- lionagi/integrations/bridge/transformers_/install_.py +36 -0
- lionagi/integrations/chunker/chunk.py +7 -7
- lionagi/integrations/config/oai_configs.py +5 -5
- lionagi/integrations/config/ollama_configs.py +1 -1
- lionagi/integrations/config/openrouter_configs.py +1 -1
- lionagi/integrations/loader/load.py +6 -6
- lionagi/integrations/loader/load_util.py +8 -8
- lionagi/integrations/storage/__init__.py +3 -0
- lionagi/integrations/storage/neo4j.py +673 -0
- lionagi/integrations/storage/storage_util.py +289 -0
- lionagi/integrations/storage/to_csv.py +63 -0
- lionagi/integrations/storage/to_excel.py +67 -0
- lionagi/libs/ln_api.py +3 -3
- lionagi/libs/ln_knowledge_graph.py +405 -0
- lionagi/libs/ln_parse.py +43 -6
- lionagi/libs/ln_queue.py +101 -0
- lionagi/libs/ln_tokenizer.py +57 -0
- lionagi/libs/ln_validate.py +288 -0
- lionagi/libs/sys_util.py +29 -7
- lionagi/lions/__init__.py +0 -0
- lionagi/lions/coder/__init__.py +0 -0
- lionagi/lions/coder/add_feature.py +20 -0
- lionagi/lions/coder/base_prompts.py +22 -0
- lionagi/lions/coder/coder.py +121 -0
- lionagi/lions/coder/util.py +91 -0
- lionagi/lions/researcher/__init__.py +0 -0
- lionagi/lions/researcher/data_source/__init__.py +0 -0
- lionagi/lions/researcher/data_source/finhub_.py +191 -0
- lionagi/lions/researcher/data_source/google_.py +199 -0
- lionagi/lions/researcher/data_source/wiki_.py +96 -0
- lionagi/lions/researcher/data_source/yfinance_.py +21 -0
- lionagi/tests/integrations/__init__.py +0 -0
- lionagi/tests/libs/__init__.py +0 -0
- lionagi/tests/libs/test_async.py +0 -0
- lionagi/tests/libs/test_field_validators.py +353 -0
- lionagi/tests/libs/test_queue.py +67 -0
- lionagi/tests/test_core/test_base_branch.py +0 -1
- lionagi/tests/test_core/test_branch.py +2 -0
- lionagi/tests/test_core/test_session_base_util.py +1 -0
- lionagi/version.py +1 -1
- {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/METADATA +1 -1
- lionagi-0.1.1.dist-info/RECORD +190 -0
- lionagi/core/prompt/prompt_template.py +0 -312
- lionagi/core/schema/__init__.py +0 -22
- lionagi/core/schema/action_node.py +0 -29
- lionagi/core/schema/base_mixin.py +0 -296
- lionagi/core/schema/base_node.py +0 -199
- lionagi/core/schema/condition.py +0 -24
- lionagi/core/schema/data_logger.py +0 -354
- lionagi/core/schema/data_node.py +0 -93
- lionagi/core/schema/prompt_template.py +0 -67
- lionagi/core/schema/structure.py +0 -912
- lionagi/core/tool/manual.py +0 -1
- lionagi-0.0.316.dist-info/RECORD +0 -121
- /lionagi/core/{branch/base → execute}/__init__.py +0 -0
- /lionagi/core/flow/{base/baseflow.py → baseflow.py} +0 -0
- /lionagi/core/flow/{base/__init__.py → mono_chat_mixin.py} +0 -0
- /lionagi/core/{prompt → form}/__init__.py +0 -0
- /lionagi/{tests/test_integrations → core/graph}/__init__.py +0 -0
- /lionagi/{tests/test_libs → experimental}/__init__.py +0 -0
- /lionagi/{tests/test_libs/test_async.py → experimental/directive/__init__.py} +0 -0
- /lionagi/tests/{test_libs → libs}/test_api.py +0 -0
- /lionagi/tests/{test_libs → libs}/test_convert.py +0 -0
- /lionagi/tests/{test_libs → libs}/test_func_call.py +0 -0
- /lionagi/tests/{test_libs → libs}/test_nested.py +0 -0
- /lionagi/tests/{test_libs → libs}/test_parse.py +0 -0
- /lionagi/tests/{test_libs → libs}/test_sys_util.py +0 -0
- {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/LICENSE +0 -0
- {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/WHEEL +0 -0
- {lionagi-0.0.316.dist-info → lionagi-0.1.1.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Callable
|
2
2
|
|
3
|
-
from lionagi.core.
|
3
|
+
from lionagi.core.generic import Node
|
4
4
|
from ..bridge.langchain_.langchain_bridge import LangchainBridge
|
5
5
|
from ..bridge.llamaindex_.llama_index_bridge import LlamaIndexBridge
|
6
6
|
|
@@ -9,14 +9,14 @@ from .load_util import dir_to_nodes, ReaderType, _datanode_parser
|
|
9
9
|
|
10
10
|
def text_reader(args, kwargs):
|
11
11
|
"""
|
12
|
-
Reads text files from a directory and converts them to
|
12
|
+
Reads text files from a directory and converts them to Node instances.
|
13
13
|
|
14
14
|
Args:
|
15
15
|
args: Positional arguments for the dir_to_nodes function.
|
16
16
|
kwargs: Keyword arguments for the dir_to_nodes function.
|
17
17
|
|
18
18
|
Returns:
|
19
|
-
A list of
|
19
|
+
A list of Node instances.
|
20
20
|
|
21
21
|
Example usage:
|
22
22
|
>>> args = ['path/to/text/files']
|
@@ -96,7 +96,7 @@ def _plain_reader(reader, reader_args, reader_kwargs):
|
|
96
96
|
def _langchain_reader(reader, reader_args, reader_kwargs, to_datanode: bool | Callable):
|
97
97
|
nodes = LangchainBridge.langchain_loader(reader, reader_args, reader_kwargs)
|
98
98
|
if isinstance(to_datanode, bool) and to_datanode is True:
|
99
|
-
nodes = [
|
99
|
+
nodes = [Node.from_langchain(i) for i in nodes]
|
100
100
|
|
101
101
|
elif isinstance(to_datanode, Callable):
|
102
102
|
nodes = _datanode_parser(nodes, to_datanode)
|
@@ -115,7 +115,7 @@ def _llama_index_reader(
|
|
115
115
|
reader, reader_args, reader_kwargs, load_args, load_kwargs
|
116
116
|
)
|
117
117
|
if isinstance(to_datanode, bool) and to_datanode is True:
|
118
|
-
nodes = [
|
118
|
+
nodes = [Node.from_llama_index(i) for i in nodes]
|
119
119
|
elif isinstance(to_datanode, Callable):
|
120
120
|
nodes = _datanode_parser(nodes, to_datanode)
|
121
121
|
return nodes
|
@@ -138,7 +138,7 @@ def _self_defined_reader(
|
|
138
138
|
) from e
|
139
139
|
|
140
140
|
if isinstance(to_datanode, bool) and to_datanode is True:
|
141
|
-
raise ValueError("Please define a valid parser to
|
141
|
+
raise ValueError("Please define a valid parser to Node.")
|
142
142
|
elif isinstance(to_datanode, Callable):
|
143
143
|
nodes = _datanode_parser(nodes, to_datanode)
|
144
144
|
return nodes
|
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
5
5
|
from typing import List, Union, Dict, Any, Tuple
|
6
6
|
|
7
7
|
from lionagi.libs import convert, func_call
|
8
|
-
from lionagi.core.
|
8
|
+
from lionagi.core.generic import Node
|
9
9
|
|
10
10
|
|
11
11
|
class ReaderType(str, Enum):
|
@@ -62,11 +62,11 @@ def dir_to_nodes(
|
|
62
62
|
recursive: bool = False,
|
63
63
|
flatten: bool = True,
|
64
64
|
clean_text: bool = True,
|
65
|
-
) -> List[
|
65
|
+
) -> List[Node]:
|
66
66
|
"""
|
67
|
-
Converts directory contents into
|
67
|
+
Converts directory contents into Node objects based on specified file extensions.
|
68
68
|
|
69
|
-
This function first retrieves a list of file paths from the specified directory, matching the given file extension. It then reads the content of these files, optionally cleaning the text, and converts each file's content into a
|
69
|
+
This function first retrieves a list of file paths from the specified directory, matching the given file extension. It then reads the content of these files, optionally cleaning the text, and converts each file's content into a Node object.
|
70
70
|
|
71
71
|
Parameters:
|
72
72
|
dir (str): The directory path from which to read files.
|
@@ -76,17 +76,17 @@ def dir_to_nodes(
|
|
76
76
|
clean_text (bool, optional): If True, cleans the text read from files. Defaults to True.
|
77
77
|
|
78
78
|
Returns:
|
79
|
-
list: A list of
|
79
|
+
list: A list of Node objects created from the files in the specified directory.
|
80
80
|
|
81
81
|
Example:
|
82
82
|
nodes = dir_to_nodes("/path/to/dir", ".txt", recursive=True)
|
83
83
|
# This would read all .txt files in /path/to/dir and its subdirectories,
|
84
|
-
# converting them into
|
84
|
+
# converting them into Node objects.
|
85
85
|
"""
|
86
86
|
|
87
87
|
path_list = dir_to_path(dir, ext, recursive, flatten)
|
88
88
|
files_info = func_call.lcall(path_list, read_text, clean=clean_text)
|
89
|
-
return func_call.lcall(files_info, lambda x:
|
89
|
+
return func_call.lcall(files_info, lambda x: Node(content=x[0], metadata=x[1]))
|
90
90
|
|
91
91
|
|
92
92
|
def chunk_text(
|
@@ -263,4 +263,4 @@ def _datanode_parser(nodes, parser):
|
|
263
263
|
try:
|
264
264
|
return parser(nodes)
|
265
265
|
except Exception as e:
|
266
|
-
raise ValueError(f"
|
266
|
+
raise ValueError(f"Node parser {parser} failed. Error:{e}") from e
|