lionagi 0.2.9__py3-none-any.whl → 0.2.11__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
lionagi/core/unit/unit.py CHANGED
@@ -2,6 +2,7 @@ from typing import Callable
2
2
 
3
3
  from lionagi.core.collections import iModel
4
4
  from lionagi.core.collections.abc import Directive
5
+ from lionagi.core.report.form import Form
5
6
  from lionagi.core.validator.validator import Validator
6
7
  from lionagi.libs.ln_func_call import rcall
7
8
 
@@ -361,3 +362,48 @@ class Unit(Directive, DirectiveMixin):
361
362
  )
362
363
 
363
364
  raise ValueError(f"invalid directive: {directive}")
365
+
366
+ async def ReactInstruct(
367
+ self,
368
+ instruction: str | dict,
369
+ context: str | dict,
370
+ form_cls: type[Form],
371
+ branch=None,
372
+ tools: list = None,
373
+ imodel1: iModel = None,
374
+ imodel2: iModel = None,
375
+ allow_extension1: bool = False,
376
+ allow_extension2: bool = False,
377
+ max_extension1: int = None,
378
+ max_extension2: int = None,
379
+ form_kwargs: dict = {},
380
+ **kwargs,
381
+ ):
382
+ """
383
+ kwargs for direct
384
+ """
385
+
386
+ kwargs.pop("allow_action", None)
387
+
388
+ direct_form: UnitForm = await self.direct(
389
+ instruction=instruction,
390
+ context=context,
391
+ branch=branch,
392
+ allow_extension=allow_extension1,
393
+ tools=tools if tools else True,
394
+ max_extension=max_extension1,
395
+ imodel=imodel1,
396
+ allow_action=True,
397
+ **kwargs,
398
+ )
399
+
400
+ form: Form = await self.direct(
401
+ form=form_cls(**form_kwargs),
402
+ imodel=imodel2,
403
+ branch=branch,
404
+ allow_extension=allow_extension2,
405
+ max_extension=max_extension2,
406
+ **kwargs,
407
+ )
408
+
409
+ return direct_form, form
@@ -1,15 +1,14 @@
1
1
  from typing import Dict, Union
2
2
 
3
+ from lionfuncs import check_import
4
+
3
5
 
4
6
  def get_ipython_user_proxy():
5
7
 
6
8
  try:
7
- from lionagi.libs import SysUtil
8
-
9
- SysUtil.check_import("autogen", pip_name="pyautogen")
10
-
11
- import autogen
9
+ autogen = check_import("autogen", pip_name="pyautogen")
12
10
  from IPython import get_ipython
11
+
13
12
  except Exception as e:
14
13
  raise ImportError(f"Please install autogen and IPython. {e}")
15
14
 
@@ -1,5 +1,7 @@
1
1
  from typing import Any, Callable, Dict, List, TypeVar, Union
2
2
 
3
+ from lionfuncs import check_import
4
+
3
5
  from lionagi.libs.sys_util import SysUtil
4
6
 
5
7
  T = TypeVar("T")
@@ -21,8 +23,9 @@ def to_langchain_document(datanode: T, **kwargs: Any) -> Any:
21
23
  Any: An instance of `LangchainDocument` populated with data from the input node.
22
24
  """
23
25
 
24
- SysUtil.check_import("langchain")
25
- from langchain.schema import Document as LangchainDocument
26
+ LangchainDocument = check_import(
27
+ "langchain", module_name="schema", import_name="Document"
28
+ )
26
29
 
27
30
  dnode = datanode.to_dict()
28
31
  SysUtil.change_dict_key(dnode, old_key="content", new_key="page_content")
@@ -63,8 +66,9 @@ def langchain_loader(
63
66
  True
64
67
  """
65
68
 
66
- SysUtil.check_import("langchain")
67
- import langchain_community.document_loaders as document_loaders
69
+ document_loaders = check_import(
70
+ "langchain_community", module_name="document_loaders", pip_name="langchain"
71
+ )
68
72
 
69
73
  try:
70
74
  if isinstance(loader, str):
@@ -1,5 +1,10 @@
1
+ from lionfuncs import check_import
2
+
3
+
1
4
  class LlamaIndex:
2
5
 
6
+ llama_index = check_import("llama_index", pip_name="llama-index")
7
+
3
8
  @classmethod
4
9
  def index(
5
10
  cls,
@@ -10,8 +15,8 @@ class LlamaIndex:
10
15
  index_type=None,
11
16
  **kwargs,
12
17
  ):
13
- from llama_index.core import Settings
14
- from llama_index.llms.openai import OpenAI
18
+ Settings = check_import("llama_index.core", import_name="Settings")
19
+ OpenAI = check_import("llama_index.llms.openai", import_name="OpenAI")
15
20
 
16
21
  if not llm_obj:
17
22
  llm_class = llm_class or OpenAI
@@ -23,8 +28,9 @@ class LlamaIndex:
23
28
  Settings.llm = llm_obj
24
29
 
25
30
  if not index_type:
26
- from llama_index.core import VectorStoreIndex
27
-
31
+ VectorStoreIndex = check_import(
32
+ "llama_index.core", import_name="VectorStoreIndex"
33
+ )
28
34
  index_type = VectorStoreIndex
29
35
 
30
36
  return index_type(nodes, **kwargs)
@@ -1,9 +1,14 @@
1
+ from lionfuncs import check_import
2
+
3
+
1
4
  class LlamaPack:
2
5
 
3
6
  @staticmethod
4
7
  def download(pack_name, pack_path):
5
8
  try:
6
- from llama_index.llama_pack import download_llama_pack
9
+ download_llama_pack = check_import(
10
+ "llama_index.llama_pack", import_name="download_llama_pack"
11
+ )
7
12
 
8
13
  return download_llama_pack(pack_name, pack_path)
9
14
  except Exception as e:
@@ -1,5 +1,7 @@
1
1
  from typing import Any
2
2
 
3
+ from lionfuncs import check_import, import_module
4
+
3
5
  from lionagi.libs.sys_util import SysUtil
4
6
 
5
7
 
@@ -25,9 +27,11 @@ def get_llama_index_node_parser(node_parser: Any):
25
27
  found within the llama_index.core.node_parser module.
26
28
  """
27
29
 
28
- SysUtil.check_import("llama_index", pip_name="llama-index")
29
- import llama_index.core.node_parser
30
- from llama_index.core.node_parser.interface import NodeParser
30
+ NodeParser = check_import(
31
+ "llama_index.core.node_parser.interface",
32
+ import_name="NodeParser",
33
+ pip_name="llama-index",
34
+ )
31
35
 
32
36
  if not isinstance(node_parser, str) and not issubclass(node_parser, NodeParser):
33
37
  raise TypeError("node_parser must be a string or NodeParser.")
@@ -37,7 +41,8 @@ def get_llama_index_node_parser(node_parser: Any):
37
41
  SysUtil.check_import("tree_sitter_languages")
38
42
 
39
43
  try:
40
- return getattr(llama_index.core.node_parser, node_parser)
44
+ node_module = import_module("llama_index.core", module_name="node_parser")
45
+ return getattr(node_module, node_parser)
41
46
  except Exception as e:
42
47
  raise AttributeError(
43
48
  f"llama_index_core has no such attribute:" f" {node_parser}, Error: {e}"
@@ -1,6 +1,5 @@
1
- from typing import Any, Union
1
+ from typing import Any
2
2
 
3
- from lionagi.libs.ln_convert import strip_lower
4
3
  from lionagi.libs.sys_util import SysUtil
5
4
 
6
5
 
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.9"
1
+ __version__ = "0.2.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lionagi
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: Towards automated general intelligence.
5
5
  Author: HaiyangLi
6
6
  Author-email: quantocean.li@gmail.com
@@ -11,9 +11,8 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: aiocache (>=0.12.3,<0.13.0)
13
13
  Requires-Dist: ipython (>=8.27.0,<9.0.0)
14
+ Requires-Dist: lion-core (>=0.3.9,<0.4.0)
14
15
  Requires-Dist: lion-openai (>=0.1.4,<0.2.0)
15
- Requires-Dist: lionfuncs (==1.0.1)
16
- Requires-Dist: pandas (>=2.2.3,<3.0.0)
17
16
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
18
17
  Description-Content-Type: text/markdown
19
18
 
@@ -27,9 +26,12 @@ Description-Content-Type: text/markdown
27
26
  ### an AGentic Intelligence Operating System
28
27
 
29
28
  ```
30
- pip install lionagi==0.2.8
29
+ pip install lionagi
30
+ ```
31
+ or
32
+ ```
33
+ poetry add lionagi
31
34
  ```
32
-
33
35
  **Powerful Intelligent Workflow Automation**
34
36
 
35
37
  lionagi is an intelligent agentic workflow automation framework. It introduces advanced ML models into any existing workflows and data infrastructure.
@@ -105,7 +105,7 @@ lionagi/core/unit/template/plan.py,sha256=i4FmKEB8eRsRCsTanvfoX-2RZ8SaM1qvLBluuY
105
105
  lionagi/core/unit/template/predict.py,sha256=5unb8YjZ_z8uaINJ-eh8luDioDbgpLgzN73gY_Fva-4,3146
106
106
  lionagi/core/unit/template/score.py,sha256=ReUaIIr-NLjunSy4NNXQpIsH28NNceGBAUuPCRptzMc,3809
107
107
  lionagi/core/unit/template/select.py,sha256=diYFXp0UfZMlBGMUrz72i8lSfdZmmNrYi3_7Xn8OocM,3046
108
- lionagi/core/unit/unit.py,sha256=co0cxsNhQe719nW5RauV3TnWa4uq5KkB3f9pkeRK5Zg,12775
108
+ lionagi/core/unit/unit.py,sha256=mJZTtKF5J45dgL78LiNkh6urq1EdMCgEFiTV3-DruKI,14027
109
109
  lionagi/core/unit/unit_form.py,sha256=ZLlJerMomWpYPx7v6BXrewNRuGjBiBNnhwezf-jmcPg,11014
110
110
  lionagi/core/unit/unit_mixin.py,sha256=W0lQSNfd6Zk4RSdtjF77WMXLwNJnjMkHn_U9pc6y1fs,38584
111
111
  lionagi/core/unit/util.py,sha256=2OBjHvTXbyHmxZDnDarSTIy_oNXPWQ1OG8M-94297cA,1995
@@ -149,16 +149,16 @@ lionagi/experimental/strategies/base.py,sha256=DkeLUlrb7rGx3nZ04aADU9HXXu5mZTf_D
149
149
  lionagi/integrations/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
150
150
  lionagi/integrations/bridge/__init__.py,sha256=GTtqrkDb7OW5JID56bHyJTTkztZupOJyvHGAr0lN3VY,169
151
151
  lionagi/integrations/bridge/autogen_/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
152
- lionagi/integrations/bridge/autogen_/autogen_.py,sha256=D66BIcAI_4AafYHp67TqyNF-lgap6bbOxRHukLpAz2s,4055
152
+ lionagi/integrations/bridge/autogen_/autogen_.py,sha256=ABipO5_-coRh7i-W9d4tPW4YEvyQyESZd-1g4jZEuV0,4028
153
153
  lionagi/integrations/bridge/langchain_/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
154
- lionagi/integrations/bridge/langchain_/documents.py,sha256=zQbSJ-LCWe_nI86xVS_M1KNN0e6FAobus5-JRjgiN00,4938
154
+ lionagi/integrations/bridge/langchain_/documents.py,sha256=BM9bq0Wup6CxdNKUqm6Xbxuan5jsCKRdyS4JmApSOcc,5004
155
155
  lionagi/integrations/bridge/langchain_/langchain_bridge.py,sha256=-lnJtyf4iJEwHKQAwBRN6YZ7CTsyFLetl5e8_9UGouY,3163
156
156
  lionagi/integrations/bridge/llamaindex_/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
157
- lionagi/integrations/bridge/llamaindex_/index.py,sha256=6kjnqTiwFRI8x51OhBVxj_QOEzPxhG4w1S8qqbFaLY8,748
157
+ lionagi/integrations/bridge/llamaindex_/index.py,sha256=NCQpnOGTzjDZ1BYqYcjW2EFhB95WoV3DBLOMiNLRCfI,981
158
158
  lionagi/integrations/bridge/llamaindex_/llama_index_bridge.py,sha256=AxLuoaDueNPZ_vX4_-kGlxlDKezqb1E1Cn_s33Dq2pM,5203
159
- lionagi/integrations/bridge/llamaindex_/llama_pack.py,sha256=07hDT7ZlXTOkWg4arRYNqDHBR4NJE5hOmNn52GGtS4o,8397
160
- lionagi/integrations/bridge/llamaindex_/node_parser.py,sha256=Jk3aMAw6octOQKDb02Y1MUgujYZsfz7ZJGM_JS-qLcI,3459
161
- lionagi/integrations/bridge/llamaindex_/reader.py,sha256=VxdTk5h3a3_5RQzN15q75XGli52umhz9gLUrKk1Sg90,8235
159
+ lionagi/integrations/bridge/llamaindex_/llama_pack.py,sha256=YunEysKmeS4OrdgRHZ2tCQUtuWyetUmc__cvTtIqoII,8505
160
+ lionagi/integrations/bridge/llamaindex_/node_parser.py,sha256=Ab7cWU6VQTnrJrxMC81PXO7GBWOLAVsSWdsI_iIS5eM,3563
161
+ lionagi/integrations/bridge/llamaindex_/reader.py,sha256=s6Px9bv7uWQu16HGmAaXYnbgzRL25p1zsGOcSZ_Dwb8,8180
162
162
  lionagi/integrations/bridge/llamaindex_/textnode.py,sha256=NmkxBkxgFVTHObSvzay7C-OH-mOIQ7_q2zAFjTnqyNE,2323
163
163
  lionagi/integrations/bridge/pydantic_/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
164
  lionagi/integrations/bridge/pydantic_/pydantic_bridge.py,sha256=4-YPg9989u-jZ6hyEo5jiE9u7Loeje_OGo44zB-bO1A,87
@@ -260,8 +260,8 @@ lionagi/tests/test_core/test_structure/test_base_structure.py,sha256=qsaYP745fFI
260
260
  lionagi/tests/test_core/test_structure/test_graph.py,sha256=hLsTZmZMs9vCZW-KiOwYY3npk6WxaVU6zZSA9-ltDvQ,2162
261
261
  lionagi/tests/test_core/test_structure/test_tree.py,sha256=PvMJXDsNPpJFgEQCan-5Q5JREgMrBOpYIaWcwHd-WDY,1944
262
262
  lionagi/tests/test_core/test_validator.py,sha256=G8h3SMUuH9behQe0-c3-5fZ9s67vgTwlmwfcS0k6dtI,4234
263
- lionagi/version.py,sha256=F8OVhAhMXSkvvXYgZtbPn2SG1AQC3joK4yu-FrHt81Y,22
264
- lionagi-0.2.9.dist-info/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
265
- lionagi-0.2.9.dist-info/METADATA,sha256=dGz_vA0RfB-fLGj2nbyRetW_DEqRx2PIcg-G11x4xmM,3161
266
- lionagi-0.2.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
267
- lionagi-0.2.9.dist-info/RECORD,,
263
+ lionagi/version.py,sha256=_MLx4ac1juJPWEEiC9kMQISX3x3jFBr507jM2P_hxMg,23
264
+ lionagi-0.2.11.dist-info/LICENSE,sha256=VXFWsdoN5AAknBCgFqQNgPWYx7OPp-PFEP961zGdOjc,11288
265
+ lionagi-0.2.11.dist-info/METADATA,sha256=20LVdBGfK4nLHsh6EDscgS3xHezPEcr-nxvdY8hJH7s,3152
266
+ lionagi-0.2.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
267
+ lionagi-0.2.11.dist-info/RECORD,,