lionagi 0.2.7__py3-none-any.whl → 0.2.9__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- lionagi/__init__.py +11 -25
- lionagi/core/action/README.md +20 -0
- lionagi/core/action/__init__.py +1 -2
- lionagi/core/action/function_calling.py +2 -27
- lionagi/core/action/node.py +1 -16
- lionagi/core/action/tool.py +4 -17
- lionagi/core/action/tool_manager.py +8 -31
- lionagi/core/agent/README.md +1 -0
- lionagi/core/agent/base_agent.py +3 -27
- lionagi/core/agent/eval/README.md +1 -0
- lionagi/core/collections/README.md +23 -0
- lionagi/core/collections/__init__.py +2 -3
- lionagi/core/collections/_logger.py +0 -17
- lionagi/core/collections/abc/README.md +63 -0
- lionagi/core/collections/abc/__init__.py +18 -18
- lionagi/core/collections/abc/component.py +5 -21
- lionagi/core/collections/abc/concepts.py +1 -17
- lionagi/core/collections/abc/exceptions.py +0 -16
- lionagi/core/collections/exchange.py +1 -16
- lionagi/core/collections/flow.py +5 -25
- lionagi/core/collections/model.py +6 -21
- lionagi/core/collections/pile.py +317 -35
- lionagi/core/collections/progression.py +4 -17
- lionagi/core/collections/util.py +2 -2
- lionagi/core/director/README.md +1 -0
- lionagi/core/director/direct.py +1 -17
- lionagi/core/engine/branch_engine.py +6 -6
- lionagi/core/engine/instruction_map_engine.py +4 -4
- lionagi/core/engine/script_engine.py +2 -16
- lionagi/core/executor/base_executor.py +1 -1
- lionagi/core/executor/graph_executor.py +6 -9
- lionagi/core/executor/neo4j_executor.py +7 -9
- lionagi/core/generic/README.md +0 -0
- lionagi/core/generic/__init__.py +1 -2
- lionagi/core/generic/edge.py +7 -3
- lionagi/core/generic/edge_condition.py +3 -2
- lionagi/core/generic/graph.py +5 -6
- lionagi/core/generic/node.py +4 -4
- lionagi/core/generic/tree.py +2 -1
- lionagi/core/generic/tree_node.py +2 -0
- lionagi/core/mail/__init__.py +0 -1
- lionagi/core/mail/mail.py +2 -1
- lionagi/core/mail/mail_manager.py +8 -6
- lionagi/core/mail/package.py +2 -0
- lionagi/core/mail/start_mail.py +2 -2
- lionagi/core/message/__init__.py +4 -5
- lionagi/core/message/action_request.py +5 -31
- lionagi/core/message/action_response.py +3 -23
- lionagi/core/message/assistant_response.py +2 -17
- lionagi/core/message/instruction.py +2 -48
- lionagi/core/message/message.py +2 -17
- lionagi/core/message/system.py +2 -17
- lionagi/core/message/util.py +7 -26
- lionagi/core/report/base.py +4 -26
- lionagi/core/report/form.py +6 -28
- lionagi/core/report/report.py +3 -26
- lionagi/core/report/util.py +2 -17
- lionagi/core/rule/_default.py +3 -2
- lionagi/core/rule/action.py +4 -19
- lionagi/core/rule/base.py +4 -19
- lionagi/core/rule/boolean.py +2 -2
- lionagi/core/rule/choice.py +3 -2
- lionagi/core/rule/mapping.py +7 -21
- lionagi/core/rule/number.py +3 -1
- lionagi/core/rule/rulebook.py +2 -70
- lionagi/core/rule/string.py +2 -13
- lionagi/core/rule/util.py +0 -35
- lionagi/core/session/branch.py +11 -27
- lionagi/core/session/directive_mixin.py +1 -16
- lionagi/core/session/session.py +8 -24
- lionagi/core/unit/__init__.py +1 -2
- lionagi/core/unit/parallel_unit.py +4 -21
- lionagi/core/unit/template/action.py +0 -16
- lionagi/core/unit/template/base.py +0 -16
- lionagi/core/unit/template/plan.py +1 -16
- lionagi/core/unit/template/predict.py +0 -16
- lionagi/core/unit/template/score.py +1 -17
- lionagi/core/unit/template/select.py +1 -16
- lionagi/core/unit/unit.py +6 -21
- lionagi/core/unit/unit_form.py +6 -19
- lionagi/core/unit/unit_mixin.py +11 -29
- lionagi/core/unit/util.py +1 -0
- lionagi/core/validator/validator.py +8 -22
- lionagi/core/work/work.py +2 -19
- lionagi/core/work/work_edge.py +3 -3
- lionagi/core/work/work_function.py +1 -18
- lionagi/core/work/work_function_node.py +0 -5
- lionagi/core/work/work_queue.py +1 -16
- lionagi/core/work/work_task.py +4 -4
- lionagi/core/work/worker.py +5 -20
- lionagi/core/work/worker_engine.py +5 -5
- lionagi/core/work/worklog.py +1 -17
- lionagi/experimental/compressor/base.py +1 -0
- lionagi/experimental/compressor/llm_compressor.py +7 -4
- lionagi/experimental/directive/README.md +1 -0
- lionagi/experimental/directive/parser/base_parser.py +2 -17
- lionagi/experimental/directive/parser/base_syntax.txt +200 -0
- lionagi/experimental/directive/template/base_template.py +1 -17
- lionagi/experimental/directive/tokenizer.py +0 -16
- lionagi/experimental/evaluator/README.md +1 -0
- lionagi/experimental/evaluator/ast_evaluator.py +0 -16
- lionagi/experimental/evaluator/base_evaluator.py +1 -17
- lionagi/experimental/knowledge/base.py +1 -1
- lionagi/integrations/bridge/__init__.py +1 -1
- lionagi/integrations/bridge/langchain_/documents.py +1 -1
- lionagi/integrations/bridge/llamaindex_/node_parser.py +2 -1
- lionagi/integrations/bridge/llamaindex_/textnode.py +2 -1
- lionagi/integrations/bridge/pydantic_/pydantic_bridge.py +1 -1
- lionagi/integrations/bridge/transformers_/install_.py +1 -0
- lionagi/integrations/chunker/chunk.py +5 -6
- lionagi/integrations/loader/load.py +3 -3
- lionagi/integrations/loader/load_util.py +2 -2
- lionagi/integrations/provider/__init__.py +0 -1
- lionagi/integrations/provider/_mapping.py +6 -5
- lionagi/integrations/provider/mlx_service.py +4 -3
- lionagi/integrations/provider/oai.py +1 -17
- lionagi/integrations/provider/ollama.py +1 -1
- lionagi/integrations/provider/openrouter.py +1 -0
- lionagi/integrations/provider/transformers.py +2 -2
- lionagi/integrations/storage/neo4j.py +1 -1
- lionagi/integrations/storage/storage_util.py +3 -4
- lionagi/integrations/storage/structure_excel.py +5 -4
- lionagi/integrations/storage/to_csv.py +3 -2
- lionagi/integrations/storage/to_excel.py +2 -2
- lionagi/libs/__init__.py +15 -19
- lionagi/libs/ln_api.py +9 -26
- lionagi/libs/ln_async.py +3 -2
- lionagi/libs/ln_convert.py +1 -18
- lionagi/libs/ln_func_call.py +3 -20
- lionagi/libs/ln_image.py +4 -1
- lionagi/libs/ln_knowledge_graph.py +5 -2
- lionagi/libs/ln_nested.py +2 -18
- lionagi/libs/ln_parse.py +4 -19
- lionagi/libs/ln_queue.py +2 -17
- lionagi/libs/ln_tokenize.py +3 -1
- lionagi/libs/ln_validate.py +2 -18
- lionagi/libs/sys_util.py +0 -16
- lionagi/lions/coder/code_form.py +3 -1
- lionagi/lions/coder/coder.py +1 -1
- lionagi/lions/coder/util.py +3 -2
- lionagi/lions/researcher/data_source/finhub_.py +1 -0
- lionagi/lions/researcher/data_source/google_.py +2 -2
- lionagi/lions/researcher/data_source/wiki_.py +1 -1
- lionagi/tests/libs/test_api.py +2 -1
- lionagi/tests/libs/test_convert.py +2 -1
- lionagi/tests/libs/test_field_validators.py +9 -8
- lionagi/tests/libs/test_func_call.py +2 -2
- lionagi/tests/libs/test_nested.py +1 -0
- lionagi/tests/libs/test_queue.py +1 -0
- lionagi/tests/libs/test_sys_util.py +4 -4
- lionagi/tests/test_core/collections/test_component.py +6 -4
- lionagi/tests/test_core/collections/test_exchange.py +2 -1
- lionagi/tests/test_core/collections/test_flow.py +2 -1
- lionagi/tests/test_core/collections/test_pile.py +3 -2
- lionagi/tests/test_core/collections/test_progression.py +3 -2
- lionagi/tests/test_core/generic/test_edge.py +4 -2
- lionagi/tests/test_core/generic/test_graph.py +3 -2
- lionagi/tests/test_core/generic/test_node.py +2 -1
- lionagi/tests/test_core/generic/test_tree_node.py +2 -1
- lionagi/tests/test_core/mail/test_mail.py +2 -1
- lionagi/tests/test_core/test_branch.py +3 -2
- lionagi/tests/test_core/test_form.py +1 -0
- lionagi/tests/test_core/test_report.py +1 -0
- lionagi/tests/test_core/test_validator.py +4 -3
- lionagi/version.py +1 -1
- lionagi-0.2.9.dist-info/METADATA +68 -0
- lionagi-0.2.9.dist-info/RECORD +267 -0
- {lionagi-0.2.7.dist-info → lionagi-0.2.9.dist-info}/WHEEL +1 -2
- lionagi-0.2.7.dist-info/METADATA +0 -277
- lionagi-0.2.7.dist-info/RECORD +0 -258
- lionagi-0.2.7.dist-info/top_level.txt +0 -1
- {lionagi-0.2.7.dist-info → lionagi-0.2.9.dist-info}/LICENSE +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Any
|
2
|
+
|
2
3
|
from lionagi.libs.sys_util import SysUtil
|
3
4
|
|
4
5
|
|
@@ -25,8 +26,8 @@ def get_llama_index_node_parser(node_parser: Any):
|
|
25
26
|
"""
|
26
27
|
|
27
28
|
SysUtil.check_import("llama_index", pip_name="llama-index")
|
28
|
-
from llama_index.core.node_parser.interface import NodeParser
|
29
29
|
import llama_index.core.node_parser
|
30
|
+
from llama_index.core.node_parser.interface import NodeParser
|
30
31
|
|
31
32
|
if not isinstance(node_parser, str) and not issubclass(node_parser, NodeParser):
|
32
33
|
raise TypeError("node_parser must be a string or NodeParser.")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from typing import Any, TypeVar
|
2
|
+
|
2
3
|
from lionagi.libs.sys_util import SysUtil
|
3
4
|
|
4
5
|
|
@@ -24,8 +25,8 @@ def to_llama_index_node(lion_node, node_type: Any = None, **kwargs: Any) -> Any:
|
|
24
25
|
"""
|
25
26
|
|
26
27
|
SysUtil.check_import("llama_index", pip_name="llama-index")
|
27
|
-
from llama_index.core.schema import BaseNode
|
28
28
|
import llama_index.core.schema
|
29
|
+
from llama_index.core.schema import BaseNode
|
29
30
|
|
30
31
|
node_type = node_type or "TextNode"
|
31
32
|
|
@@ -1 +1 @@
|
|
1
|
-
from pydantic import BaseModel, Field, ValidationError,
|
1
|
+
from pydantic import AliasChoices, BaseModel, Field, ValidationError, field_serializer
|
@@ -1,14 +1,13 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Callable, Union
|
2
2
|
|
3
|
-
from lionagi.libs import func_call
|
4
|
-
from lionagi.libs.ln_convert import to_list
|
5
3
|
from lionagi.core.collections import pile
|
6
4
|
from lionagi.core.generic import Node
|
5
|
+
from lionagi.libs import func_call
|
6
|
+
from lionagi.libs.ln_convert import to_list
|
7
|
+
|
7
8
|
from ..bridge.langchain_.langchain_bridge import LangchainBridge
|
8
9
|
from ..bridge.llamaindex_.llama_index_bridge import LlamaIndexBridge
|
9
|
-
|
10
|
-
|
11
|
-
from ..loader.load_util import ChunkerType, file_to_chunks, _datanode_parser
|
10
|
+
from ..loader.load_util import ChunkerType, _datanode_parser, file_to_chunks
|
12
11
|
|
13
12
|
|
14
13
|
def datanodes_convert(documents, chunker_type):
|
@@ -1,11 +1,11 @@
|
|
1
1
|
from typing import Callable
|
2
2
|
|
3
|
-
from lionagi.core.generic import Node
|
4
3
|
from lionagi.core.collections import pile
|
4
|
+
from lionagi.core.generic import Node
|
5
|
+
|
5
6
|
from ..bridge.langchain_.langchain_bridge import LangchainBridge
|
6
7
|
from ..bridge.llamaindex_.llama_index_bridge import LlamaIndexBridge
|
7
|
-
|
8
|
-
from .load_util import dir_to_nodes, ReaderType, _datanode_parser
|
8
|
+
from .load_util import ReaderType, _datanode_parser, dir_to_nodes
|
9
9
|
|
10
10
|
|
11
11
|
def text_reader(args, kwargs):
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# use utils and schema
|
2
2
|
from enum import Enum
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import
|
4
|
+
from typing import Any, Dict, List, Tuple, Union
|
5
5
|
|
6
|
+
from lionagi.core.generic import Node
|
6
7
|
from lionagi.libs import convert, func_call
|
7
8
|
from lionagi.libs.ln_tokenize import TokenizeUtil
|
8
|
-
from lionagi.core.generic import Node
|
9
9
|
|
10
10
|
|
11
11
|
class ReaderType(str, Enum):
|
@@ -1,11 +1,12 @@
|
|
1
|
+
from lionagi.integrations.config.oai_configs import oai_schema
|
2
|
+
from lionagi.integrations.config.openrouter_configs import openrouter_schema
|
3
|
+
|
4
|
+
from .litellm import LiteLLMService
|
5
|
+
from .mlx_service import MLXService
|
1
6
|
from .oai import OpenAIService
|
2
|
-
from .openrouter import OpenRouterService
|
3
7
|
from .ollama import OllamaService
|
8
|
+
from .openrouter import OpenRouterService
|
4
9
|
from .transformers import TransformersService
|
5
|
-
from .litellm import LiteLLMService
|
6
|
-
from .mlx_service import MLXService
|
7
|
-
from lionagi.integrations.config.oai_configs import oai_schema
|
8
|
-
from lionagi.integrations.config.openrouter_configs import openrouter_schema
|
9
10
|
|
10
11
|
SERVICE_PROVIDERS_MAPPING = {
|
11
12
|
"openai": {
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import re
|
2
|
-
|
2
|
+
|
3
3
|
import lionagi.libs.ln_convert as convert
|
4
|
-
from lionagi.libs.ln_api import BaseService
|
5
4
|
from lionagi.integrations.config.mlx_configs import model
|
5
|
+
from lionagi.libs.ln_api import BaseService
|
6
|
+
from lionagi.libs.sys_util import SysUtil
|
6
7
|
|
7
8
|
|
8
9
|
class MLXService(BaseService):
|
@@ -14,7 +15,7 @@ class MLXService(BaseService):
|
|
14
15
|
if model is not None and "olmo" in str(model).lower():
|
15
16
|
SysUtil.check_import("olmo", pip_name="ai2-olmo")
|
16
17
|
|
17
|
-
from mlx_lm import
|
18
|
+
from mlx_lm import generate, load
|
18
19
|
|
19
20
|
super().__init__()
|
20
21
|
|
@@ -1,24 +1,8 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
from os import getenv
|
2
|
+
|
18
3
|
from lionagi.integrations.config.oai_configs import oai_schema
|
19
4
|
from lionagi.libs.ln_api import BaseService, PayloadPackage
|
20
5
|
|
21
|
-
|
22
6
|
allowed_kwargs = [
|
23
7
|
"model",
|
24
8
|
"frequency_penalty",
|
@@ -1,8 +1,8 @@
|
|
1
|
-
from typing import Union, Dict, Any
|
2
1
|
import subprocess
|
2
|
+
from typing import Any, Dict, Union
|
3
3
|
|
4
|
-
from lionagi.libs.sys_util import SysUtil
|
5
4
|
from lionagi.libs.ln_api import BaseService
|
5
|
+
from lionagi.libs.sys_util import SysUtil
|
6
6
|
|
7
7
|
allowed_kwargs = [
|
8
8
|
# "model",
|
@@ -1,12 +1,11 @@
|
|
1
|
-
import json
|
2
1
|
import inspect
|
2
|
+
import json
|
3
3
|
import re
|
4
4
|
|
5
|
-
from lionagi.core.
|
6
|
-
from lionagi.core.action import Tool, DirectiveSelection, func_to_tool
|
7
|
-
from lionagi.core.action import DirectiveSelection
|
5
|
+
from lionagi.core.action import DirectiveSelection, Tool, func_to_tool
|
8
6
|
from lionagi.core.agent.base_agent import BaseAgent
|
9
7
|
from lionagi.core.generic.edge_condition import EdgeCondition
|
8
|
+
from lionagi.core.message import Instruction, RoledMessage, System
|
10
9
|
|
11
10
|
|
12
11
|
def output_node_list(structure):
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import pandas as pd
|
2
1
|
import json
|
3
2
|
from pathlib import Path
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
import pandas as pd
|
5
|
+
|
7
6
|
from lionagi.core.agent.base_agent import BaseAgent
|
8
|
-
from lionagi.core.executor.base_executor import BaseExecutor
|
9
7
|
from lionagi.core.engine.instruction_map_engine import InstructionMapEngine
|
8
|
+
from lionagi.core.executor.base_executor import BaseExecutor
|
9
|
+
from lionagi.core.executor.graph_executor import GraphExecutor
|
10
|
+
from lionagi.integrations.storage.storage_util import ParseNode
|
10
11
|
|
11
12
|
|
12
13
|
def excel_reload(structure_name=None, structure_id=None, dir="structure_storage"):
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import zipfile
|
2
|
-
import pandas as pd
|
3
2
|
from pathlib import Path
|
4
3
|
|
5
|
-
|
4
|
+
import pandas as pd
|
5
|
+
|
6
|
+
from lionagi.integrations.storage.storage_util import output_edge_list, output_node_list
|
6
7
|
|
7
8
|
|
8
9
|
def _output_csv(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import pandas as pd
|
2
|
-
from lionagi.libs import SysUtil
|
3
2
|
|
4
|
-
from lionagi.integrations.storage.storage_util import
|
3
|
+
from lionagi.integrations.storage.storage_util import output_edge_list, output_node_list
|
4
|
+
from lionagi.libs import SysUtil
|
5
5
|
|
6
6
|
|
7
7
|
def _output_excel(
|
lionagi/libs/__init__.py
CHANGED
@@ -1,33 +1,29 @@
|
|
1
|
-
from lionagi.libs.sys_util import SysUtil
|
2
|
-
from lionagi.libs.ln_async import AsyncUtil
|
3
|
-
|
4
1
|
import lionagi.libs.ln_convert as convert
|
5
|
-
from lionagi.libs.ln_convert import (
|
6
|
-
to_str,
|
7
|
-
to_list,
|
8
|
-
to_dict,
|
9
|
-
to_df,
|
10
|
-
to_readable_dict,
|
11
|
-
to_num,
|
12
|
-
)
|
13
2
|
import lionagi.libs.ln_dataframe as dataframe
|
14
3
|
import lionagi.libs.ln_func_call as func_call
|
15
|
-
from lionagi.libs.ln_func_call import lcall, CallDecorator
|
16
4
|
import lionagi.libs.ln_nested as nested
|
17
|
-
from lionagi.libs.ln_nested import nget, nset, ninsert
|
18
|
-
from lionagi.libs.ln_parse import ParseUtil, StringMatch
|
19
|
-
|
20
5
|
from lionagi.libs.ln_api import (
|
21
6
|
APIUtil,
|
22
|
-
SimpleRateLimiter,
|
23
|
-
StatusTracker,
|
24
7
|
BaseService,
|
25
8
|
PayloadPackage,
|
9
|
+
SimpleRateLimiter,
|
10
|
+
StatusTracker,
|
26
11
|
)
|
27
|
-
|
12
|
+
from lionagi.libs.ln_async import AsyncUtil
|
13
|
+
from lionagi.libs.ln_convert import (
|
14
|
+
to_df,
|
15
|
+
to_dict,
|
16
|
+
to_list,
|
17
|
+
to_num,
|
18
|
+
to_readable_dict,
|
19
|
+
to_str,
|
20
|
+
)
|
21
|
+
from lionagi.libs.ln_func_call import CallDecorator, lcall
|
28
22
|
from lionagi.libs.ln_image import ImageUtil
|
23
|
+
from lionagi.libs.ln_nested import nget, ninsert, nset
|
24
|
+
from lionagi.libs.ln_parse import ParseUtil, StringMatch
|
29
25
|
from lionagi.libs.ln_validate import validation_funcs
|
30
|
-
|
26
|
+
from lionagi.libs.sys_util import SysUtil
|
31
27
|
|
32
28
|
__all__ = [
|
33
29
|
"SysUtil",
|
lionagi/libs/ln_api.py
CHANGED
@@ -1,35 +1,17 @@
|
|
1
|
-
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
|
-
from collections.abc import Sequence, Mapping
|
18
|
-
|
19
|
-
from abc import ABC
|
20
|
-
from dataclasses import dataclass
|
21
|
-
|
1
|
+
import asyncio
|
22
2
|
import contextlib
|
23
3
|
import logging
|
24
4
|
import re
|
25
|
-
import
|
26
|
-
import
|
5
|
+
from abc import ABC
|
6
|
+
from collections.abc import Mapping, Sequence
|
7
|
+
from dataclasses import dataclass
|
8
|
+
from typing import Any, Callable, NoReturn, Type
|
27
9
|
|
28
|
-
|
10
|
+
import aiohttp
|
29
11
|
|
30
|
-
from lionagi.libs.ln_async import AsyncUtil
|
31
|
-
from lionagi.libs.ln_convert import to_dict, strip_lower, to_str
|
32
12
|
import lionagi.libs.ln_func_call as func_call
|
13
|
+
from lionagi.libs.ln_async import AsyncUtil
|
14
|
+
from lionagi.libs.ln_convert import strip_lower, to_dict, to_str
|
33
15
|
from lionagi.libs.ln_nested import nget
|
34
16
|
|
35
17
|
|
@@ -372,6 +354,7 @@ class APIUtil:
|
|
372
354
|
# Expected token calculation for the given payload and endpoint.
|
373
355
|
"""
|
374
356
|
import tiktoken
|
357
|
+
|
375
358
|
from .ln_image import ImageUtil
|
376
359
|
|
377
360
|
token_encoding_name = token_encoding_name or "cl100k_base"
|
lionagi/libs/ln_async.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import asyncio
|
4
|
-
|
4
|
+
import logging
|
5
|
+
from collections.abc import Callable, Coroutine, Mapping
|
5
6
|
from functools import lru_cache
|
6
7
|
from typing import Any
|
7
|
-
|
8
|
+
|
8
9
|
import aiocache
|
9
10
|
import aiohttp
|
10
11
|
|
lionagi/libs/ln_convert.py
CHANGED
@@ -1,24 +1,7 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
import json
|
18
2
|
import re
|
19
3
|
from functools import singledispatch
|
20
|
-
|
21
|
-
from typing import Any, Type, Iterable, Generator
|
4
|
+
from typing import Any, Generator, Iterable, Type
|
22
5
|
|
23
6
|
import pandas as pd
|
24
7
|
from pydantic import BaseModel
|
lionagi/libs/ln_func_call.py
CHANGED
@@ -1,31 +1,14 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
from __future__ import annotations
|
18
2
|
|
19
|
-
import functools
|
20
3
|
import asyncio
|
4
|
+
import functools
|
21
5
|
import logging
|
22
6
|
from concurrent.futures import ThreadPoolExecutor
|
23
|
-
|
24
7
|
from typing import Any, Callable, Coroutine
|
25
8
|
|
26
|
-
from lionagi.libs.sys_util import SysUtil
|
27
|
-
from lionagi.libs.ln_convert import to_list
|
28
9
|
from lionagi.libs.ln_async import AsyncUtil
|
10
|
+
from lionagi.libs.ln_convert import to_list
|
11
|
+
from lionagi.libs.sys_util import SysUtil
|
29
12
|
|
30
13
|
|
31
14
|
def lru_cache(*args, **kwargs):
|
lionagi/libs/ln_image.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import base64
|
2
|
-
import numpy as np
|
3
2
|
from typing import Optional
|
3
|
+
|
4
|
+
import numpy as np
|
5
|
+
|
4
6
|
from .sys_util import SysUtil
|
5
7
|
|
6
8
|
|
@@ -70,6 +72,7 @@ class ImageUtil:
|
|
70
72
|
"""
|
71
73
|
import base64
|
72
74
|
from io import BytesIO
|
75
|
+
|
73
76
|
from PIL import Image
|
74
77
|
|
75
78
|
# Decode the base64 string to get image data
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import math
|
2
|
+
|
2
3
|
from lionagi.libs import CallDecorator as cd
|
3
4
|
|
4
5
|
|
@@ -282,11 +283,13 @@ class KGTripletExtractor:
|
|
282
283
|
)
|
283
284
|
|
284
285
|
try:
|
285
|
-
from transformers import AutoModelForSeq2SeqLM
|
286
|
+
from transformers import AutoModelForSeq2SeqLM # type: ignore
|
287
|
+
from transformers import AutoTokenizer
|
286
288
|
except ImportError:
|
287
289
|
install_transformers()
|
288
|
-
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer # type: ignore
|
289
290
|
import torch # type: ignore
|
291
|
+
from transformers import AutoModelForSeq2SeqLM # type: ignore
|
292
|
+
from transformers import AutoTokenizer
|
290
293
|
|
291
294
|
"""
|
292
295
|
Extract knowledge graph triplets from text and create a KnowledgeBase (KB) containing entities and relations.
|
lionagi/libs/ln_nested.py
CHANGED
@@ -1,25 +1,9 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
from collections import defaultdict
|
18
2
|
from itertools import chain
|
19
|
-
from typing import Any,
|
3
|
+
from typing import Any, Callable, Generator
|
20
4
|
|
21
|
-
from lionagi.libs.sys_util import SysUtil
|
22
5
|
import lionagi.libs.ln_convert as convert
|
6
|
+
from lionagi.libs.sys_util import SysUtil
|
23
7
|
|
24
8
|
|
25
9
|
def nset(nested_structure: dict | list, indices: list[int | str], value: Any) -> None:
|
lionagi/libs/ln_parse.py
CHANGED
@@ -1,27 +1,12 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
|
-
from collections.abc import Callable
|
18
|
-
import re
|
19
1
|
import inspect
|
20
2
|
import itertools
|
3
|
+
import re
|
4
|
+
from collections.abc import Callable
|
21
5
|
from typing import Any
|
6
|
+
|
22
7
|
import numpy as np
|
23
|
-
import lionagi.libs.ln_convert as convert
|
24
8
|
|
9
|
+
import lionagi.libs.ln_convert as convert
|
25
10
|
|
26
11
|
md_json_char_map = {"\n": "\\n", "\r": "\\r", "\t": "\\t", '"': '\\"'}
|
27
12
|
|
lionagi/libs/ln_queue.py
CHANGED
@@ -1,25 +1,10 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
"""
|
18
2
|
A class that manages asynchronous task processing with controlled concurrency.
|
19
3
|
"""
|
20
4
|
|
21
|
-
from typing import Any, Callable
|
22
5
|
import asyncio
|
6
|
+
from typing import Any, Callable
|
7
|
+
|
23
8
|
from lionagi.libs import func_call
|
24
9
|
|
25
10
|
|
lionagi/libs/ln_tokenize.py
CHANGED
lionagi/libs/ln_validate.py
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
"""
|
18
2
|
This module provides functions for validating and fixing field values based on their data types.
|
19
3
|
|
@@ -22,8 +6,8 @@ including numeric, boolean, string, and enum. It also provides a dictionary `val
|
|
22
6
|
maps data types to their corresponding validation functions.
|
23
7
|
"""
|
24
8
|
|
25
|
-
from .ln_convert import
|
26
|
-
from .ln_parse import
|
9
|
+
from .ln_convert import is_same_dtype, strip_lower, to_dict, to_list, to_num, to_str
|
10
|
+
from .ln_parse import ParseUtil, StringMatch
|
27
11
|
|
28
12
|
|
29
13
|
def check_dict_field(x, keys: list[str] | dict, fix_=True, **kwargs):
|
lionagi/libs/sys_util.py
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
"""
|
2
|
-
Copyright 2024 HaiyangLi
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
"""
|
16
|
-
|
17
1
|
import copy
|
18
2
|
import importlib
|
19
3
|
import logging
|
lionagi/lions/coder/code_form.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
from typing import Any
|
2
|
+
|
2
3
|
from pydantic import Field
|
3
|
-
|
4
|
+
|
4
5
|
from lionagi.core import Session
|
5
6
|
from lionagi.core.form.action_form import ActionForm
|
7
|
+
from lionagi.libs import ParseUtil, SysUtil
|
6
8
|
|
7
9
|
|
8
10
|
class CodeForm(ActionForm):
|