lionagi 0.0.112__py3-none-any.whl → 0.0.113__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/__init__.py +3 -3
- lionagi/bridge/__init__.py +7 -0
- lionagi/bridge/langchain.py +131 -0
- lionagi/bridge/llama_index.py +157 -0
- lionagi/configs/__init__.py +7 -0
- lionagi/configs/oai_configs.py +49 -0
- lionagi/configs/openrouter_config.py +49 -0
- lionagi/core/__init__.py +8 -2
- lionagi/core/instruction_sets.py +1 -3
- lionagi/core/messages.py +2 -2
- lionagi/core/sessions.py +174 -27
- lionagi/datastore/__init__.py +1 -0
- lionagi/loader/__init__.py +9 -4
- lionagi/loader/chunker.py +157 -0
- lionagi/loader/reader.py +124 -0
- lionagi/objs/__init__.py +7 -0
- lionagi/objs/messenger.py +163 -0
- lionagi/objs/tool_registry.py +247 -0
- lionagi/schema/__init__.py +11 -0
- lionagi/schema/base_schema.py +239 -0
- lionagi/schema/base_tool.py +9 -0
- lionagi/schema/data_logger.py +94 -0
- lionagi/services/__init__.py +14 -0
- lionagi/{service_/oai.py → services/base_api_service.py} +49 -82
- lionagi/{endpoint/base_endpoint.py → services/chatcompletion.py} +19 -22
- lionagi/services/oai.py +34 -0
- lionagi/services/openrouter.py +32 -0
- lionagi/{service_/service_utils.py → services/service_objs.py} +0 -1
- lionagi/structure/__init__.py +7 -0
- lionagi/structure/relationship.py +128 -0
- lionagi/structure/structure.py +160 -0
- lionagi/tests/test_flatten_util.py +426 -0
- lionagi/tools/__init__.py +0 -5
- lionagi/tools/coder.py +1 -0
- lionagi/tools/scorer.py +1 -0
- lionagi/tools/validator.py +1 -0
- lionagi/utils/__init__.py +46 -20
- lionagi/utils/api_util.py +86 -0
- lionagi/utils/call_util.py +347 -0
- lionagi/utils/flat_util.py +540 -0
- lionagi/utils/io_util.py +102 -0
- lionagi/utils/load_utils.py +190 -0
- lionagi/utils/sys_util.py +191 -0
- lionagi/utils/tool_util.py +92 -0
- lionagi/utils/type_util.py +81 -0
- lionagi/version.py +1 -1
- {lionagi-0.0.112.dist-info → lionagi-0.0.113.dist-info}/METADATA +37 -13
- lionagi-0.0.113.dist-info/RECORD +84 -0
- lionagi/endpoint/chat_completion.py +0 -20
- lionagi/endpoint/endpoint_utils.py +0 -0
- lionagi/llm_configs.py +0 -21
- lionagi/loader/load_utils.py +0 -161
- lionagi/schema.py +0 -275
- lionagi/service_/__init__.py +0 -6
- lionagi/service_/base_service.py +0 -48
- lionagi/service_/openrouter.py +0 -1
- lionagi/services.py +0 -1
- lionagi/tools/tool_utils.py +0 -75
- lionagi/utils/sys_utils.py +0 -799
- lionagi-0.0.112.dist-info/RECORD +0 -67
- /lionagi/{core/responses.py → datastore/chroma.py} +0 -0
- /lionagi/{endpoint/assistants.py → datastore/deeplake.py} +0 -0
- /lionagi/{endpoint/audio.py → datastore/elasticsearch.py} +0 -0
- /lionagi/{endpoint/embeddings.py → datastore/lantern.py} +0 -0
- /lionagi/{endpoint/files.py → datastore/pinecone.py} +0 -0
- /lionagi/{endpoint/fine_tuning.py → datastore/postgres.py} +0 -0
- /lionagi/{endpoint/images.py → datastore/qdrant.py} +0 -0
- /lionagi/{endpoint/messages.py → schema/base_condition.py} +0 -0
- /lionagi/{service_ → services}/anthropic.py +0 -0
- /lionagi/{service_ → services}/anyscale.py +0 -0
- /lionagi/{service_ → services}/azure.py +0 -0
- /lionagi/{service_ → services}/bedrock.py +0 -0
- /lionagi/{service_ → services}/everlyai.py +0 -0
- /lionagi/{service_ → services}/gemini.py +0 -0
- /lionagi/{service_ → services}/gpt4all.py +0 -0
- /lionagi/{service_ → services}/huggingface.py +0 -0
- /lionagi/{service_ → services}/litellm.py +0 -0
- /lionagi/{service_ → services}/localai.py +0 -0
- /lionagi/{service_ → services}/mistralai.py +0 -0
- /lionagi/{service_ → services}/ollama.py +0 -0
- /lionagi/{service_ → services}/openllm.py +0 -0
- /lionagi/{service_ → services}/perplexity.py +0 -0
- /lionagi/{service_ → services}/predibase.py +0 -0
- /lionagi/{service_ → services}/rungpt.py +0 -0
- /lionagi/{service_ → services}/vllm.py +0 -0
- /lionagi/{service_ → services}/xinference.py +0 -0
- /lionagi/{endpoint → tests}/__init__.py +0 -0
- /lionagi/{endpoint/models.py → tools/planner.py} +0 -0
- /lionagi/{endpoint/moderations.py → tools/prompter.py} +0 -0
- /lionagi/{endpoint/runs.py → tools/sandbox.py} +0 -0
- /lionagi/{endpoint/threads.py → tools/summarizer.py} +0 -0
- {lionagi-0.0.112.dist-info → lionagi-0.0.113.dist-info}/LICENSE +0 -0
- {lionagi-0.0.112.dist-info → lionagi-0.0.113.dist-info}/WHEEL +0 -0
- {lionagi-0.0.112.dist-info → lionagi-0.0.113.dist-info}/top_level.txt +0 -0
lionagi/tools/tool_utils.py
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
import asyncio
|
3
|
-
from typing import Dict
|
4
|
-
from ..utils.sys_utils import l_call, str_to_num
|
5
|
-
from ..schema import BaseNode
|
6
|
-
|
7
|
-
|
8
|
-
class ToolManager(BaseNode):
|
9
|
-
registry : Dict = {}
|
10
|
-
|
11
|
-
def _name_existed(self, name: str):
|
12
|
-
return True if name in self.registry.keys() else False
|
13
|
-
|
14
|
-
def _register_tool(self, tool, name: str=None, update=False, new=False, prefix=None, postfix=None):
|
15
|
-
|
16
|
-
if self._name_existed(name):
|
17
|
-
if update and new:
|
18
|
-
raise ValueError(f"Cannot both update and create new registry for existing function {name} at the same time")
|
19
|
-
|
20
|
-
if len(name) > len(tool.func.__name__):
|
21
|
-
if new and not postfix:
|
22
|
-
try:
|
23
|
-
idx = str_to_num(name[-3:], int)
|
24
|
-
if idx > 0:
|
25
|
-
postfix = idx + 1
|
26
|
-
except:
|
27
|
-
pass
|
28
|
-
|
29
|
-
name = f"{prefix or ''}{name}{postfix}" if new else tool.func.__name__
|
30
|
-
self.registry.update({name:tool})
|
31
|
-
|
32
|
-
async def invoke(self, name, kwargs):
|
33
|
-
if self._name_existed(name):
|
34
|
-
tool = self.registry[name]
|
35
|
-
func = tool.func
|
36
|
-
parser = tool.parser
|
37
|
-
try:
|
38
|
-
if asyncio.iscoroutinefunction(func):
|
39
|
-
return await parser(func(**kwargs)) if parser else func(**kwargs)
|
40
|
-
else:
|
41
|
-
return parser(func(**kwargs)) if parser else func(**kwargs)
|
42
|
-
except Exception as e:
|
43
|
-
raise ValueError(f"Error when invoking function {name} with arguments {kwargs} with error message {e}")
|
44
|
-
else:
|
45
|
-
raise ValueError(f"Function {name} is not registered.")
|
46
|
-
|
47
|
-
@staticmethod
|
48
|
-
def _get_function_call(response):
|
49
|
-
"""
|
50
|
-
Extract function name and arguments from a response JSON.
|
51
|
-
|
52
|
-
Parameters:
|
53
|
-
response (str): The JSON response containing function information.
|
54
|
-
|
55
|
-
Returns:
|
56
|
-
Tuple[str, dict]: The function name and its arguments.
|
57
|
-
"""
|
58
|
-
try:
|
59
|
-
out = json.loads(response)
|
60
|
-
func = out['function'][5:]
|
61
|
-
args = json.loads(out['arguments'])
|
62
|
-
return (func, args)
|
63
|
-
except:
|
64
|
-
try:
|
65
|
-
out = json.loads(response)
|
66
|
-
out = out['tool_uses'][0]
|
67
|
-
func = out['recipient_name'].split('.')[-1]
|
68
|
-
args = out['parameters']
|
69
|
-
return (func, args)
|
70
|
-
except:
|
71
|
-
raise ValueError('response is not a valid function call')
|
72
|
-
|
73
|
-
def register_tools(self, tools, update=False, new=False, prefix=None, postfix=None ):
|
74
|
-
l_call(tools, self._register_tool, update=update, new=new, prefix=prefix, postfix=postfix)
|
75
|
-
|