lionagi 0.0.209__py3-none-any.whl → 0.0.211__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.
Files changed (86) hide show
  1. lionagi/__init__.py +2 -4
  2. lionagi/api_service/base_endpoint.py +65 -0
  3. lionagi/api_service/base_rate_limiter.py +121 -0
  4. lionagi/api_service/base_service.py +146 -0
  5. lionagi/api_service/chat_completion.py +6 -0
  6. lionagi/api_service/embeddings.py +6 -0
  7. lionagi/api_service/payload_package.py +47 -0
  8. lionagi/api_service/status_tracker.py +29 -0
  9. lionagi/core/__init__.py +3 -3
  10. lionagi/core/branch.py +22 -3
  11. lionagi/core/session.py +14 -2
  12. lionagi/schema/__init__.py +5 -8
  13. lionagi/schema/base_schema.py +821 -0
  14. lionagi/structures/graph.py +1 -1
  15. lionagi/structures/relationship.py +1 -1
  16. lionagi/structures/structure.py +1 -1
  17. lionagi/tools/tool_manager.py +0 -163
  18. lionagi/tools/tool_util.py +2 -1
  19. lionagi/utils/__init__.py +5 -6
  20. lionagi/utils/api_util.py +6 -1
  21. lionagi/version.py +1 -1
  22. {lionagi-0.0.209.dist-info → lionagi-0.0.211.dist-info}/METADATA +3 -18
  23. lionagi-0.0.211.dist-info/RECORD +56 -0
  24. lionagi/agents/planner.py +0 -1
  25. lionagi/agents/prompter.py +0 -1
  26. lionagi/agents/scorer.py +0 -1
  27. lionagi/agents/summarizer.py +0 -1
  28. lionagi/agents/validator.py +0 -1
  29. lionagi/bridge/__init__.py +0 -22
  30. lionagi/bridge/langchain.py +0 -195
  31. lionagi/bridge/llama_index.py +0 -266
  32. lionagi/datastores/__init__.py +0 -1
  33. lionagi/datastores/chroma.py +0 -1
  34. lionagi/datastores/deeplake.py +0 -1
  35. lionagi/datastores/elasticsearch.py +0 -1
  36. lionagi/datastores/lantern.py +0 -1
  37. lionagi/datastores/pinecone.py +0 -1
  38. lionagi/datastores/postgres.py +0 -1
  39. lionagi/datastores/qdrant.py +0 -1
  40. lionagi/iservices/anthropic.py +0 -79
  41. lionagi/iservices/anyscale.py +0 -0
  42. lionagi/iservices/azure.py +0 -1
  43. lionagi/iservices/bedrock.py +0 -0
  44. lionagi/iservices/everlyai.py +0 -0
  45. lionagi/iservices/gemini.py +0 -0
  46. lionagi/iservices/gpt4all.py +0 -0
  47. lionagi/iservices/huggingface.py +0 -0
  48. lionagi/iservices/litellm.py +0 -33
  49. lionagi/iservices/localai.py +0 -0
  50. lionagi/iservices/openllm.py +0 -0
  51. lionagi/iservices/openrouter.py +0 -44
  52. lionagi/iservices/perplexity.py +0 -0
  53. lionagi/iservices/predibase.py +0 -0
  54. lionagi/iservices/rungpt.py +0 -0
  55. lionagi/iservices/vllm.py +0 -0
  56. lionagi/iservices/xinference.py +0 -0
  57. lionagi/loaders/__init__.py +0 -18
  58. lionagi/loaders/chunker.py +0 -166
  59. lionagi/loaders/load_util.py +0 -240
  60. lionagi/loaders/reader.py +0 -122
  61. lionagi/models/__init__.py +0 -0
  62. lionagi/models/base_model.py +0 -0
  63. lionagi/models/imodel.py +0 -53
  64. lionagi/parsers/__init__.py +0 -1
  65. lionagi/schema/async_queue.py +0 -158
  66. lionagi/schema/base_condition.py +0 -1
  67. lionagi/schema/base_node.py +0 -422
  68. lionagi/schema/base_tool.py +0 -44
  69. lionagi/schema/data_logger.py +0 -131
  70. lionagi/schema/data_node.py +0 -88
  71. lionagi/schema/status_tracker.py +0 -37
  72. lionagi/tests/test_utils/test_encrypt_util.py +0 -323
  73. lionagi/utils/encrypt_util.py +0 -283
  74. lionagi-0.0.209.dist-info/RECORD +0 -98
  75. /lionagi/{agents → api_service}/__init__.py +0 -0
  76. /lionagi/{iservices → services}/__init__.py +0 -0
  77. /lionagi/{iservices → services}/base_service.py +0 -0
  78. /lionagi/{iservices → services}/mistralai.py +0 -0
  79. /lionagi/{iservices → services}/mlx_service.py +0 -0
  80. /lionagi/{iservices → services}/oai.py +0 -0
  81. /lionagi/{iservices → services}/ollama.py +0 -0
  82. /lionagi/{iservices → services}/services.py +0 -0
  83. /lionagi/{iservices → services}/transformers.py +0 -0
  84. {lionagi-0.0.209.dist-info → lionagi-0.0.211.dist-info}/LICENSE +0 -0
  85. {lionagi-0.0.209.dist-info → lionagi-0.0.211.dist-info}/WHEEL +0 -0
  86. {lionagi-0.0.209.dist-info → lionagi-0.0.211.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@ from typing import List, Any
2
2
  from pydantic import Field
3
3
 
4
4
  from ..utils.call_util import lcall
5
- from ..schema.base_node import BaseNode
5
+ from ..schema.base_schema import BaseNode
6
6
  from .relationship import Relationship
7
7
 
8
8
 
@@ -1,6 +1,6 @@
1
1
  from pydantic import Field
2
2
  from typing import Dict, Optional, Any
3
- from ..schema.base_node import BaseNode
3
+ from ..schema.base_schema import BaseNode
4
4
 
5
5
 
6
6
  class Relationship(BaseNode):
@@ -1,5 +1,5 @@
1
1
  from typing import TypeVar
2
- from ..schema import BaseNode
2
+ from ..schema.base_schema import BaseNode
3
3
  from .graph import Graph
4
4
  from .relationship import Relationship
5
5
 
@@ -1,163 +0,0 @@
1
- import json
2
- import asyncio
3
- from typing import Dict, Union, List, Tuple, Any
4
- from lionagi.utils.call_util import lcall, is_coroutine_func, _call_handler, alcall
5
- from lionagi.schema import BaseNode, Tool
6
-
7
-
8
- class ToolManager(BaseNode):
9
- """
10
- A manager class for handling the registration and invocation of tools that are subclasses of Tool.
11
-
12
- This class maintains a registry of tool instances, allowing for dynamic invocation based on
13
- tool name and provided arguments. It supports both synchronous and asynchronous tool function
14
- calls.
15
-
16
- Attributes:
17
- registry (Dict[str, Tool]): A dictionary to hold registered tools, keyed by their names.
18
- """
19
- registry: Dict = {}
20
-
21
- def name_existed(self, name: str) -> bool:
22
- """
23
- Checks if a tool name already exists in the registry.
24
-
25
- Args:
26
- name (str): The name of the tool to check.
27
-
28
- Returns:
29
- bool: True if the name exists, False otherwise.
30
- """
31
- return True if name in self.registry.keys() else False
32
-
33
- def _register_tool(self, tool: Tool) -> None:
34
- """
35
- Registers a tool in the registry. Raises a TypeError if the object is not an instance of Tool.
36
-
37
- Args:
38
- tool (Tool): The tool instance to register.
39
-
40
- Raises:
41
- TypeError: If the provided object is not an instance of Tool.
42
- """
43
- if not isinstance(tool, Tool):
44
- raise TypeError('Please register a Tool object.')
45
- name = tool.schema_['function']['name']
46
- self.registry.update({name: tool})
47
-
48
- async def invoke(self, func_call: Tuple[str, Dict[str, Any]]) -> Any:
49
- """
50
- Invokes a registered tool's function with the given arguments. Supports both coroutine and regular functions.
51
-
52
- Args:
53
- func_call (Tuple[str, Dict[str, Any]]): A tuple containing the function name and a dictionary of keyword arguments.
54
-
55
- Returns:
56
- Any: The result of the function call.
57
-
58
- Raises:
59
- ValueError: If the function name is not registered or if there's an error during function invocation.
60
- """
61
- name, kwargs = func_call
62
- if self.name_existed(name):
63
- tool = self.registry[name]
64
- func = tool.func
65
- parser = tool.parser
66
- try:
67
- if is_coroutine_func(func):
68
- tasks = [_call_handler(func, **kwargs)]
69
- out = await asyncio.gather(*tasks)
70
- return parser(out[0]) if parser else out[0]
71
- else:
72
- out = func(**kwargs)
73
- return parser(out) if parser else out
74
- except Exception as e:
75
- raise ValueError(f"Error when invoking function {name} with arguments {kwargs} with error message {e}")
76
- else:
77
- raise ValueError(f"Function {name} is not registered.")
78
-
79
- @staticmethod
80
- def get_function_call(response: Dict) -> Tuple[str, Dict]:
81
- """
82
- Extracts a function call and arguments from a response dictionary.
83
-
84
- Args:
85
- response (Dict): The response dictionary containing the function call information.
86
-
87
- Returns:
88
- Tuple[str, Dict]: A tuple containing the function name and a dictionary of arguments.
89
-
90
- Raises:
91
- ValueError: If the response does not contain valid function call information.
92
- """
93
- try:
94
- func = response['action'][7:]
95
- args = json.loads(response['arguments'])
96
- return (func, args)
97
- except:
98
- try:
99
- func = response['recipient_name'].split('.')[-1]
100
- args = response['parameters']
101
- return (func, args)
102
- except:
103
- raise ValueError('response is not a valid function call')
104
-
105
- def register_tools(self, tools: List[Tool]) -> None:
106
- """
107
- Registers multiple tools in the registry.
108
-
109
- Args:
110
- tools (List[Tool]): A list of tool instances to register.
111
- """
112
- lcall(tools, self._register_tool)
113
-
114
- def to_tool_schema_list(self) -> List[Dict[str, Any]]:
115
- """
116
- Generates a list of schemas for all registered tools.
117
-
118
- Returns:
119
- List[Dict[str, Any]]: A list of tool schemas.
120
-
121
- """
122
- schema_list = []
123
- for tool in self.registry.values():
124
- schema_list.append(tool.schema_)
125
- return schema_list
126
-
127
- def _tool_parser(self, tools: Union[Dict, Tool, List[Tool], str, List[str], List[Dict]], **kwargs) -> Dict:
128
- """
129
- Parses tool information and generates a dictionary for tool invocation.
130
-
131
- Args:
132
- tools: Tool information which can be a single Tool instance, a list of Tool instances, a tool name, or a list of tool names.
133
- **kwargs: Additional keyword arguments.
134
-
135
- Returns:
136
- Dict: A dictionary containing tool schema information and any additional keyword arguments.
137
-
138
- Raises:
139
- ValueError: If a tool name is provided that is not registered.
140
- """
141
- def tool_check(tool):
142
- if isinstance(tool, dict):
143
- return tool
144
- elif isinstance(tool, Tool):
145
- return tool.schema_
146
- elif isinstance(tool, str):
147
- if self.name_existed(tool):
148
- tool = self.registry[tool]
149
- return tool.schema_
150
- else:
151
- raise ValueError(f'Function {tool} is not registered.')
152
-
153
- if isinstance(tools, bool):
154
- tool_kwarg = {"tools": self.to_tool_schema_list()}
155
- kwargs = {**tool_kwarg, **kwargs}
156
-
157
- else:
158
- if not isinstance(tools, list):
159
- tools = [tools]
160
- tool_kwarg = {"tools": lcall(tools, tool_check)}
161
- kwargs = {**tool_kwarg, **kwargs}
162
-
163
- return kwargs
@@ -1,5 +1,6 @@
1
+ from ..schema.base_schema import Tool
2
+
1
3
  import inspect
2
- from ..schema.base_tool import Tool
3
4
 
4
5
  def _extract_docstring_details_google(func):
5
6
  """
lionagi/utils/__init__.py CHANGED
@@ -7,7 +7,6 @@ from .nested_util import (
7
7
 
8
8
  from .core_utils import CoreUtil
9
9
  from .api_util import APIUtil
10
- from .encrypt_util import EncrytionUtil
11
10
  from .io_util import IOUtil
12
11
 
13
12
  from .call_util import (
@@ -17,9 +16,9 @@ from .call_util import (
17
16
 
18
17
 
19
18
  __all__ = [
20
- 'as_dict', 'create_copy', 'get_bins', 'get_timestamp', 'str_to_num', 'to_df',
21
- 'to_readable_dict', 'nfilter', 'nset', 'nget', 'nmerge', 'ninsert', 'flatten', 'unflatten',
22
- 'is_structure_homogeneous', 'get_flattened_keys',
23
- 'CoreUtil', 'APIUtil', 'EncrytionUtil', 'IOUtil',
24
- 'to_list', 'lcall', 'alcall', 'mcall', 'tcall', 'bcall', 'rcall', 'CallDecorator'
19
+ "as_dict", "create_copy", "get_bins", "get_timestamp", "str_to_num", "to_df",
20
+ "to_readable_dict", "nfilter", "nset", "nget", "nmerge", "ninsert",
21
+ "flatten", "unflatten", "is_structure_homogeneous", "get_flattened_keys",
22
+ "CoreUtil", "APIUtil", "IOUtil",
23
+ "to_list", "lcall", "alcall", "mcall", "tcall", "bcall", "rcall", "CallDecorator"
25
24
  ]
lionagi/utils/api_util.py CHANGED
@@ -286,6 +286,8 @@ class APIUtil:
286
286
  payload: Dict[str, Any] = None,
287
287
  api_endpoint: str = None,
288
288
  token_encoding_name: str = None,
289
+ disallowed_special = None,
290
+ **kwargs
289
291
  ) -> int:
290
292
  """
291
293
  Calculates the number of tokens required for a request based on the payload and API endpoint.
@@ -311,7 +313,10 @@ class APIUtil:
311
313
  # Expected token calculation for the given payload and endpoint.
312
314
  """
313
315
 
314
- encoding = tiktoken.get_encoding(token_encoding_name)
316
+ if disallowed_special:
317
+ kwargs['disallowed_special'] = disallowed_special
318
+
319
+ encoding = tiktoken.get_encoding(token_encoding_name, **kwargs)
315
320
  if api_endpoint.endswith("completions"):
316
321
  max_tokens = payload.get("max_tokens", 15)
317
322
  n = payload.get("n", 1)
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.209"
1
+ __version__ = "0.0.211"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lionagi
3
- Version: 0.0.209
3
+ Version: 0.0.211
4
4
  Summary: Towards automated general intelligence.
5
5
  Author: HaiyangLi
6
6
  Author-email: Haiyang Li <ocean@lionagi.ai>
@@ -254,22 +254,6 @@ pip install lionagi
254
254
  Download the `.env_template` file, input your appropriate `API_KEY`, save the file, rename as `.env` and put in your project's root directory.
255
255
  by default we use `OPENAI_API_KEY`.
256
256
 
257
-
258
- ### Intelligence Services
259
-
260
- | Provider | Type | Parallel Chat | Perform Action | Embeddings | MultiModal |
261
- | ---- | ---- | ---- | ---- | ---- | ---- |
262
- | OpenAI | API | ✅ | ✅ | | |
263
- | OpenRouter | API | ✅ | | | |
264
- | Ollama | Local | ✅ | | | |
265
- | LiteLLM | Mixed | ✅ | | | |
266
- | HuggingFace | Local | ✅ | | | |
267
- | MLX | Local | ✅ | | | |
268
- | Anthropic | API | | | | |
269
- | Azure | API | | | | |
270
- | Amazon | API | | | | |
271
- | Google | API | | | | |
272
- | MistralAI | API | | | | |
273
257
 
274
258
  ### Quick Start
275
259
 
@@ -326,7 +310,8 @@ LionAGI is designed to be `asynchronous` only, please check python official docu
326
310
  * please know what you are doing, and check the usage on OpenAI regularly
327
311
  * default rate limits are set to be 1,000 requests, 100,000 tokens per miniute, please check the [OpenAI usage limit documentation](https://platform.openai.com/docs/guides/rate-limits?context=tier-free) you can modify token rate parameters to fit different use cases.
328
312
  * if you would like to build from source, please download the [latest release](https://github.com/lion-agi/lionagi/releases), **main is under development and will be changed without notice**
329
-
313
+
314
+ **we are undergoing major refocus of this package and depreciated plenty features, roadmap is agent only in future**
330
315
 
331
316
  ### Community
332
317
 
@@ -0,0 +1,56 @@
1
+ lionagi/__init__.py,sha256=s_uVgIFLjAfvy3v_boDVUxOW2kGxOiEvnqRLMUr4Ev4,898
2
+ lionagi/version.py,sha256=I9YDb-qTfkwvZtUZEwpNogsDfb6zcYcToR2RmHG39To,24
3
+ lionagi/api_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ lionagi/api_service/base_endpoint.py,sha256=kbGp4vRFlBkkP21YE0_ZRh7EQDt69IojDfST_fogYOY,2461
5
+ lionagi/api_service/base_rate_limiter.py,sha256=_9i1n6IvIR8C90zTT3u9XrVbaltz1aAbKAlqp9i6zjM,5216
6
+ lionagi/api_service/base_service.py,sha256=Vd_FoEa6BKxid5Z8KX3tRRuJtCJvlMBNO2VlBddWVtQ,6254
7
+ lionagi/api_service/chat_completion.py,sha256=IZsdky14jL221FPMNbKF0JWEC_TUVGB-FEB-2z8xYfA,134
8
+ lionagi/api_service/embeddings.py,sha256=VO7I3SvCEmfBCeyWw09nt_VK9qkaauQncaf9O2-PrRc,130
9
+ lionagi/api_service/payload_package.py,sha256=t_LYHyz6gvncQhkpdkkdLACYnO06dLQ2PMESGuf91Yw,1550
10
+ lionagi/api_service/status_tracker.py,sha256=Sg5kUXgrq4mArWuMVw4l7OIZtySkGzVVZmdPiPS792U,1101
11
+ lionagi/configs/__init__.py,sha256=QOd4Rs7vjIpNWvIocxWQeU-q-MPRC-AOxh-gM-eBJ2o,142
12
+ lionagi/configs/oai_configs.py,sha256=Q2ESc5QiMprnRc_w7SeMlaTYUWl_Y4SEzZSE4iOkz4Q,2646
13
+ lionagi/configs/openrouter_configs.py,sha256=IBQHqb8mo4Jb3kYAm_7NOHSKRPwSdGbPpDJoiwHxLYw,1269
14
+ lionagi/core/__init__.py,sha256=qoWWDKV5d-3LMP-GBzMtE-cW0X3q5zaGwGCwijp3y7o,98
15
+ lionagi/core/branch.py,sha256=t5C8fJD4g0evlNnitH1bq2wsIFcgOlvmvqrUVETSsIY,50425
16
+ lionagi/core/branch_manager.py,sha256=zA_dECz9XYKLk7kK6zDWfHLs1ttRGYDfyCj4B7XKDqo,4903
17
+ lionagi/core/flow.py,sha256=8IRcRTSrwCIuLTni33PGYb4PeuR5bjuqr1_YnDh8PFc,16764
18
+ lionagi/core/instruction_set.py,sha256=-hMg6UDXmxG1oYqTXWhona5gDZbNcQxaK06iMuHJr6I,13694
19
+ lionagi/core/messages.py,sha256=I91WqZPW-8kgG4xQ2w6DxJ55V5H2ivgGWO777_y0O9M,6533
20
+ lionagi/core/session.py,sha256=Oj9BapZ4FODadRvvJNzbzsT77WnaiB9x4_K7bJoQC1k,36166
21
+ lionagi/schema/__init__.py,sha256=3D30R38-bxegsdfIYZMOIGHCwhZ4HBYx9E3PPd5weUY,137
22
+ lionagi/schema/base_schema.py,sha256=xB8vfclShpRdCf7aJxFcZoDJQZL4QB6n57a_OcDV48A,26579
23
+ lionagi/services/__init__.py,sha256=zU5sxmSI9-Jtp_WsI-Zsb6hmT8y5zF9YtJ7XikAjnbs,60
24
+ lionagi/services/base_service.py,sha256=FnmljjPaNX6tqEy1P2HS_i4k3ZMRi2B074DA0SiFAP0,17354
25
+ lionagi/services/mistralai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ lionagi/services/mlx_service.py,sha256=1AF_RcV4KQmpxC67n2E0zRbssSlsTFmdnojydUXdJn4,1285
27
+ lionagi/services/oai.py,sha256=-xWE8zc_o9eYcyV-NW8GfURMafObcufbJrHIb13V6Yg,4055
28
+ lionagi/services/ollama.py,sha256=I2GvWtWA9WMyq_bhLe2JQlrkP_mAeqm2Bhf8ItOpEzQ,1190
29
+ lionagi/services/services.py,sha256=TwjAizQCTFCv_I8XZbTvpcryJPGt4vQAGYkGdZqJST0,5077
30
+ lionagi/services/transformers.py,sha256=nGfQbcECKzA1biHe4i9l01aKCMgULKFQ4LZyqjtvSXk,2934
31
+ lionagi/structures/__init__.py,sha256=wMPekT2vbWwUkJ5aW5o-lzJC9Fzhta6RHDiFPTNUm_0,120
32
+ lionagi/structures/graph.py,sha256=N_jIsDn9zQt7vr_KurfjRNg1VO81CMFze64lJa6ZjWU,7790
33
+ lionagi/structures/relationship.py,sha256=XBYNCNmkpTLSXfE8f41I7yEUfaqlPOhajmosYVzgiw8,6061
34
+ lionagi/structures/structure.py,sha256=NJOnesHBJ24snSzsSt_Nrx20eElKymJ4WdlRRaG9zDc,3497
35
+ lionagi/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ lionagi/tests/test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ lionagi/tests/test_utils/test_api_util.py,sha256=7Zyc0J1glZrIWI1HrTRSRhzw8jaUW1L2vVLFAlUhI4g,9721
38
+ lionagi/tests/test_utils/test_call_util.py,sha256=7xmfFaWvniMQfaOyfwasA2enJQVuSlcAwc8gUyAR_7k,26277
39
+ lionagi/tests/test_utils/test_io_util.py,sha256=cFZCT6EikVeuXB13w-UbtO3YceCHBO5RlNXxGICqg_U,11002
40
+ lionagi/tests/test_utils/test_nested_util.py,sha256=Z1boHufhjZryw51qW2lABOnnyJ1snAFp26KKzzzD8Bs,12612
41
+ lionagi/tests/test_utils/test_sys_util.py,sha256=TDCkzll-JLa6NuBbN_-ay5Rw9KTa_HcSHHAq62RVwGI,13545
42
+ lionagi/tools/__init__.py,sha256=ZEck-ReP5Co05nAA2gUXTpKoDN2QZqrL7DvU9Z09gqg,69
43
+ lionagi/tools/tool_manager.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
+ lionagi/tools/tool_util.py,sha256=FeWWD8hIqPxgT7xC3yZmbPkbgatm7Ozlt1rlfN7LG_U,9255
45
+ lionagi/utils/__init__.py,sha256=HymzWXPhVa2xqijEOVUT2rK14JoQBSnHzmjocqQgfD0,820
46
+ lionagi/utils/api_util.py,sha256=lEsDmnDts7fPUZPNcMI7n1M4Bsx0nOHY6e6EY_xloOI,17610
47
+ lionagi/utils/call_util.py,sha256=nqrqUjRtTAaOSnRoEyLy5j6B7Pauv-MgzApOv9xrVkc,33187
48
+ lionagi/utils/core_utils.py,sha256=56vGEUU1idDZIt6b1YOj7-hH4kNRYJFfvTQqEj3IW50,13120
49
+ lionagi/utils/io_util.py,sha256=xoVsq8sP5JGsosuC80Kad3GkGjm8Qm0OLYyTw-U5ru8,6455
50
+ lionagi/utils/nested_util.py,sha256=67j-ySQtuMGxtjnC-Ty2mwQgqp2g1gZhXRy1MulUu1U,26656
51
+ lionagi/utils/sys_util.py,sha256=DtcIRoGkOPYaXM9iuMSR8FNdEKX3Sjoym348SA3kZ8A,15884
52
+ lionagi-0.0.211.dist-info/LICENSE,sha256=TBnSyG8fs_tMRtK805GzA1cIyExleKyzoN_kuVxT9IY,11358
53
+ lionagi-0.0.211.dist-info/METADATA,sha256=e11PXGJMRpysM2NWvUPzkPd41ssmYT0Eie8ZTweeKjk,17810
54
+ lionagi-0.0.211.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
55
+ lionagi-0.0.211.dist-info/top_level.txt,sha256=szvch_d2jE1Lu9ZIKsl26Ll6BGfYfbOgt5lm-UpFSo4,8
56
+ lionagi-0.0.211.dist-info/RECORD,,
lionagi/agents/planner.py DELETED
@@ -1 +0,0 @@
1
- # TODO
@@ -1 +0,0 @@
1
- # TODO
lionagi/agents/scorer.py DELETED
@@ -1 +0,0 @@
1
- # TODO
@@ -1 +0,0 @@
1
- # TODO
@@ -1 +0,0 @@
1
- # TODO
@@ -1,22 +0,0 @@
1
- from .langchain import(
2
- from_langchain, to_langchain_document, langchain_loader,
3
- langchain_loader, langchain_text_splitter
4
- )
5
-
6
- from .llama_index import (
7
- from_llama_index, to_llama_index_textnode, get_llama_reader,
8
- llama_index_reader, get_llama_parser, llama_index_node_parser
9
- )
10
-
11
- __all__ = [
12
- 'from_langchain',
13
- 'to_langchain_document',
14
- 'langchain_loader',
15
- 'from_llama_index',
16
- 'to_llama_index_textnode',
17
- 'get_llama_reader',
18
- 'llama_index_reader',
19
- 'get_llama_parser',
20
- 'llama_index_node_parser',
21
- 'langchain_text_splitter'
22
- ]
@@ -1,195 +0,0 @@
1
- from typing import Union, Callable, List, Dict, Any, TypeVar
2
- from ..utils.sys_util import change_dict_key, install_import
3
- from ..schema.data_node import DataNode
4
-
5
-
6
- T = TypeVar('T', bound='DataNode')
7
-
8
- def from_langchain(lc_doc: Any) -> T:
9
- """
10
- Converts a langchain document into a DataNode object.
11
-
12
- Args:
13
- lc_doc (Any): The langchain document to be converted.
14
-
15
- Returns:
16
- T: A DataNode object created from the langchain document.
17
-
18
- Examples:
19
- >>> lc_doc = LangchainDocument(...)
20
- >>> data_node = from_langchain(lc_doc)
21
- >>> isinstance(data_node, DataNode)
22
- True
23
- """
24
- info_json = lc_doc.to_json()
25
- info_node = {'lc_id': info_json['id']}
26
- info_node = {**info_node, **info_json['kwargs']}
27
- return DataNode(**info_node)
28
-
29
- def to_langchain_document(datanode: T, **kwargs: Any) -> Any:
30
- """
31
- Converts a DataNode into a langchain Document.
32
-
33
- Args:
34
- datanode (T): The DataNode to be converted.
35
- **kwargs: Additional keyword arguments to be included in the Document.
36
-
37
- Returns:
38
- Any: A langchain Document created from the DataNode.
39
-
40
- Examples:
41
- >>> data_node = DataNode(...)
42
- >>> lc_document = to_langchain_document(data_node, author="John Doe")
43
- >>> isinstance(lc_document, LangchainDocument)
44
- True
45
- """
46
- try:
47
- from langchain.schema import Document
48
- except ImportError:
49
- try:
50
- install_import(
51
- package_name='langchain',
52
- module_name='schema',
53
- import_name='Document',
54
- )
55
- from langchain.schema import Document
56
- except Exception as e:
57
- raise ImportError(f'Unable to import required module from langchain. Please make sure that langchain is installed. Error: {e}')
58
-
59
- dnode = datanode.to_dict()
60
- change_dict_key(dnode, old_key='content', new_key='page_content')
61
- change_dict_key(dnode, old_key='lc_id', new_key='id_')
62
- dnode = {**dnode, **kwargs}
63
- return Document(**dnode)
64
-
65
- def langchain_loader(loader: Union[str, Callable],
66
- loader_args: List[Any] = [],
67
- loader_kwargs: Dict[str, Any] = {}) -> Any:
68
- """
69
- Loads data using a specified langchain loader.
70
-
71
- Args:
72
- loader (Union[str, Callable]): The name of the loader function or the loader function itself.
73
- loader_args (List[Any]): Positional arguments to pass to the loader function.
74
- loader_kwargs (Dict[str, Any]): Keyword arguments to pass to the loader function.
75
-
76
- Returns:
77
- Any: The data loaded by the loader function.
78
-
79
- Raises:
80
- ValueError: If the specified loader is invalid or if the loader fails to load data.
81
-
82
- Examples:
83
- >>> data = langchain_loader("json_loader", loader_args=["data.json"])
84
- >>> isinstance(data, dict)
85
- True
86
- """
87
- try:
88
- import langchain.document_loaders as document_loaders
89
- except ImportError:
90
- try:
91
- install_import(
92
- package_name='langchain',
93
- module_name='document_loaders',
94
- )
95
- import langchain.document_loaders as document_loaders
96
- except Exception as e:
97
- raise ImportError(f'Unable to import required module from langchain. Please make sure that langchain is installed. Error: {e}')
98
-
99
- try:
100
- if isinstance(loader, str):
101
- try:
102
- loader = getattr(document_loaders, loader)
103
- except ImportError as e:
104
- raise ValueError(f'Unable to import {loader} from langchain.document_loaders. Some dependency of LangChain are not installed. Error: {e}')
105
- else:
106
- loader = loader
107
- except Exception as e:
108
- raise ValueError(f'Invalid loader: {loader}. Error: {e}')
109
-
110
- try:
111
- loader_obj = loader(*loader_args, **loader_kwargs)
112
- data = loader_obj.load()
113
- return data
114
- except Exception as e:
115
- raise ValueError(f'Failed to load. Error: {e}')
116
-
117
- def langchain_text_splitter(data: Union[str, List],
118
- splitter: Union[str, Callable],
119
- splitter_args: List[Any] = [],
120
- splitter_kwargs: Dict[str, Any] = {}) -> List[str]:
121
- """
122
- Splits text or a list of documents using a specified langchain text splitter.
123
-
124
- Args:
125
- data (Union[str, List]): The input text or list of documents to be split.
126
- splitter (Union[str, Callable]): The name of the text splitter function or the function itself.
127
- splitter_args (List[Any]): Positional arguments to pass to the splitter function.
128
- splitter_kwargs (Dict[str, Any]): Keyword arguments to pass to the splitter function.
129
-
130
- Returns:
131
- List[str]: A list of chunks obtained by splitting the input.
132
-
133
- Raises:
134
- ValueError: If the specified text splitter is invalid or if the splitting fails.
135
- """
136
-
137
- try:
138
- import langchain.text_splitter as text_splitter
139
- except ImportError:
140
- try:
141
- install_import(
142
- package_name='langchain',
143
- module_name='text_splitter'
144
- )
145
- import langchain.text_splitter as text_splitter
146
- except Exception as e:
147
- raise ImportError(f'Unable to import required module from langchain. Please make sure that langchain is installed. Error: {e}')
148
-
149
- try:
150
- if isinstance(splitter, str):
151
- splitter = getattr(text_splitter, splitter)
152
- else:
153
- splitter = splitter
154
- except Exception as e:
155
- raise ValueError(f'Invalid text splitter: {splitter}. Error: {e}')
156
-
157
- try:
158
- splitter_obj = splitter(*splitter_args, **splitter_kwargs)
159
- if isinstance(data, str):
160
- chunk = splitter_obj.split_text(data)
161
- else:
162
- chunk = splitter_obj.split_documents(data)
163
- return chunk
164
- except Exception as e:
165
- raise ValueError(f'Failed to split. Error: {e}')
166
-
167
- # def langchain_code_splitter(doc: str,
168
- # language: str,
169
- # splitter_args: List[Any] = [],
170
- # splitter_kwargs: Dict[str, Any] = {}) -> List[Any]:
171
- # """
172
- # Splits code into smaller chunks using a RecursiveCharacterTextSplitter specific to a language.
173
- #
174
- # Parameters:
175
- # doc (str): The code document to be split.
176
- # language (str): The programming language of the code.
177
- # splitter_args (List[Any]): Positional arguments to pass to the splitter.
178
- # splitter_kwargs (Dict[str, Any]): Keyword arguments to pass to the splitter.
179
- #
180
- # Returns:
181
- # List[Any]: A list of Documents, each representing a chunk of the original code.
182
- #
183
- # Raises:
184
- # ValueError: If the splitter fails to split the code document.
185
- # """
186
- # from langchain.text_splitter import RecursiveCharacterTextSplitter
187
- #
188
- # try:
189
- # splitter = RecursiveCharacterTextSplitter.from_language(
190
- # language=language, *splitter_args, **splitter_kwargs
191
- # )
192
- # docs = splitter.create_documents([doc])
193
- # return docs
194
- # except Exception as e:
195
- # raise ValueError(f'Failed to split. Error: {e}')