lionagi 0.0.111__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 +7 -2
- 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 +15 -0
- lionagi/{session/conversation.py → core/conversations.py} +10 -17
- lionagi/core/flows.py +1 -0
- lionagi/core/instruction_sets.py +1 -0
- lionagi/{session/message.py → core/messages.py} +5 -5
- lionagi/core/sessions.py +262 -0
- lionagi/datastore/__init__.py +1 -0
- lionagi/datastore/chroma.py +1 -0
- lionagi/datastore/deeplake.py +1 -0
- lionagi/datastore/elasticsearch.py +1 -0
- lionagi/datastore/lantern.py +1 -0
- lionagi/datastore/pinecone.py +1 -0
- lionagi/datastore/postgres.py +1 -0
- lionagi/datastore/qdrant.py +1 -0
- lionagi/loader/__init__.py +12 -0
- 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_condition.py +1 -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/services/anthropic.py +1 -0
- lionagi/services/anyscale.py +0 -0
- lionagi/services/azure.py +1 -0
- lionagi/{api/oai_service.py → services/base_api_service.py} +74 -148
- lionagi/services/bedrock.py +0 -0
- lionagi/services/chatcompletion.py +48 -0
- lionagi/services/everlyai.py +0 -0
- lionagi/services/gemini.py +0 -0
- lionagi/services/gpt4all.py +0 -0
- lionagi/services/huggingface.py +0 -0
- lionagi/services/litellm.py +1 -0
- lionagi/services/localai.py +0 -0
- lionagi/services/mistralai.py +0 -0
- lionagi/services/oai.py +34 -0
- lionagi/services/ollama.py +1 -0
- lionagi/services/openllm.py +0 -0
- lionagi/services/openrouter.py +32 -0
- lionagi/services/perplexity.py +0 -0
- lionagi/services/predibase.py +0 -0
- lionagi/services/rungpt.py +0 -0
- lionagi/services/service_objs.py +282 -0
- lionagi/services/vllm.py +0 -0
- lionagi/services/xinference.py +0 -0
- lionagi/structure/__init__.py +7 -0
- lionagi/structure/relationship.py +128 -0
- lionagi/structure/structure.py +160 -0
- lionagi/tests/__init__.py +0 -0
- lionagi/tests/test_flatten_util.py +426 -0
- lionagi/tools/__init__.py +0 -0
- lionagi/tools/coder.py +1 -0
- lionagi/tools/planner.py +1 -0
- lionagi/tools/prompter.py +1 -0
- lionagi/tools/sandbox.py +1 -0
- lionagi/tools/scorer.py +1 -0
- lionagi/tools/summarizer.py +1 -0
- lionagi/tools/validator.py +1 -0
- lionagi/utils/__init__.py +46 -8
- lionagi/utils/api_util.py +63 -416
- 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 +85 -660
- lionagi/utils/tool_util.py +82 -199
- lionagi/utils/type_util.py +81 -0
- lionagi/version.py +1 -1
- {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/METADATA +44 -15
- lionagi-0.0.113.dist-info/RECORD +84 -0
- lionagi/api/__init__.py +0 -8
- lionagi/api/oai_config.py +0 -16
- lionagi/session/__init__.py +0 -7
- lionagi/session/session.py +0 -380
- lionagi/utils/doc_util.py +0 -331
- lionagi/utils/log_util.py +0 -86
- lionagi-0.0.111.dist-info/RECORD +0 -20
- {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/LICENSE +0 -0
- {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/WHEEL +0 -0
- {lionagi-0.0.111.dist-info → lionagi-0.0.113.dist-info}/top_level.txt +0 -0
lionagi/utils/tool_util.py
CHANGED
@@ -1,209 +1,92 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
from .sys_util import l_call
|
4
|
-
|
5
|
-
|
6
|
-
class ToolManager:
|
7
|
-
"""
|
8
|
-
A manager class for handling and invoking registered tools and functions.
|
9
|
-
|
10
|
-
This class allows the registration of tools and functions, enabling their invocation.
|
11
|
-
|
12
|
-
Attributes:
|
13
|
-
registry (dict):
|
14
|
-
A dictionary storing the registered tools and their corresponding functions.
|
15
|
-
|
16
|
-
Methods:
|
17
|
-
_to_dict(name, function, content=None) -> dict:
|
18
|
-
Convert tool information to a dictionary entry.
|
1
|
+
import inspect
|
2
|
+
from ..schema.base_tool import Tool
|
19
3
|
|
20
|
-
_name_existed(name) -> bool:
|
21
|
-
Check if a given name exists in the registry.
|
22
4
|
|
23
|
-
|
24
|
-
Register a function with a specified name in the registry.
|
25
|
-
|
26
|
-
invoke(name, args) -> Any:
|
27
|
-
Invoke a registered function with the provided arguments.
|
28
|
-
|
29
|
-
ainvoke(func_call) -> Any:
|
30
|
-
Asynchronously invoke a registered function with the provided arguments.
|
31
|
-
|
32
|
-
_get_function_call(response) -> Tuple[str, dict]:
|
33
|
-
Extract function name and arguments from a response JSON.
|
34
|
-
|
35
|
-
_from_tool(tool, func) -> Tuple[str, callable, list]:
|
36
|
-
Convert tool information to function registration parameters.
|
37
|
-
|
38
|
-
register_tools(tools, functions, update=False, new=False, prefix=None, postfix=None) -> None:
|
39
|
-
Register multiple tools and their corresponding functions.
|
5
|
+
def extract_docstring_details(func):
|
40
6
|
"""
|
41
|
-
|
42
|
-
"""
|
43
|
-
Initialize a ToolManager object with an empty registry.
|
44
|
-
"""
|
45
|
-
self.registry = {}
|
46
|
-
|
47
|
-
@staticmethod
|
48
|
-
def _to_dict(name, func, content=None):
|
49
|
-
"""
|
50
|
-
Convert tool information to a dictionary entry.
|
51
|
-
|
52
|
-
Parameters:
|
53
|
-
name (str): The name of the tool.
|
54
|
-
|
55
|
-
func (callable): The function associated with the tool.
|
56
|
-
|
57
|
-
content (Optional[str]): Additional content for the tool.
|
58
|
-
|
59
|
-
Returns:
|
60
|
-
dict: A dictionary entry representing the tool.
|
61
|
-
"""
|
62
|
-
return {name: {"function": func, "content": content or "none"}}
|
63
|
-
|
64
|
-
def _name_existed(self, name):
|
65
|
-
"""
|
66
|
-
Check if a given name exists in the registry.
|
67
|
-
|
68
|
-
Parameters:
|
69
|
-
name (str): The name to check.
|
70
|
-
|
71
|
-
Returns:
|
72
|
-
bool: True if the name exists in the registry, False otherwise.
|
73
|
-
|
74
|
-
"""
|
75
|
-
return True if name in self.registry.keys() else False
|
76
|
-
|
77
|
-
def _register_function(self, name, func, content=None, update=False, new=False, prefix=None, postfix=None):
|
78
|
-
"""
|
79
|
-
Register a function with a specified name in the registry.
|
80
|
-
|
81
|
-
Parameters:
|
82
|
-
name (str): The name of the function.
|
83
|
-
|
84
|
-
func (callable): The function to register.
|
85
|
-
|
86
|
-
content (Optional[str]): Additional content for the function.
|
87
|
-
|
88
|
-
update (bool): Whether to update an existing function with the same name.
|
7
|
+
Extracts detailed descriptions for each parameter and the function from the docstring.
|
89
8
|
|
90
|
-
|
9
|
+
Args:
|
10
|
+
- func (function): The function to extract details from.
|
91
11
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
12
|
+
Returns:
|
13
|
+
- Tuple[str, dict]: Function description and a dictionary of parameter descriptions.
|
14
|
+
"""
|
15
|
+
docstring = inspect.getdoc(func)
|
16
|
+
if not docstring:
|
17
|
+
return "No description available.", {}
|
18
|
+
|
19
|
+
# Splitting the docstring into lines
|
20
|
+
lines = docstring.split('\n')
|
21
|
+
|
22
|
+
# Extracting the function description
|
23
|
+
func_description = lines[0].strip()
|
24
|
+
|
25
|
+
# Extracting parameter descriptions
|
26
|
+
param_descriptions = {}
|
27
|
+
current_param = None
|
28
|
+
for line in lines[1:]:
|
29
|
+
line = line.strip()
|
30
|
+
if line.startswith(':param'):
|
31
|
+
_, param, desc = line.split(' ', 2)
|
32
|
+
current_param = param.strip(':')
|
33
|
+
param_descriptions[current_param] = desc
|
34
|
+
elif current_param and line:
|
35
|
+
# Continue the description of the current parameter
|
36
|
+
param_descriptions[current_param] += ' ' + line
|
37
|
+
|
38
|
+
return func_description, param_descriptions
|
39
|
+
|
40
|
+
def func_to_schema(func):
|
41
|
+
"""
|
42
|
+
Generates a schema description for a given function, using typing hints and docstrings.
|
43
|
+
The schema includes the function's name, description, and parameters.
|
110
44
|
|
111
|
-
|
45
|
+
Args:
|
46
|
+
- func (function): The function to generate a schema for.
|
112
47
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
except Exception as e:
|
120
|
-
raise ValueError(f"Error when invoking function {name} with arguments {kwargs} with error message {e}")
|
121
|
-
else:
|
122
|
-
raise ValueError(f"Function {name} is not registered.")
|
48
|
+
Returns:
|
49
|
+
- dict: A schema describing the function.
|
50
|
+
"""
|
51
|
+
# Extracting function name and docstring details
|
52
|
+
func_name = func.__name__
|
53
|
+
func_description, param_descriptions = extract_docstring_details(func)
|
123
54
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
Returns:
|
132
|
-
Any: The result of invoking the function asynchronously.
|
133
|
-
|
134
|
-
"""
|
135
|
-
name, kwargs = func_call
|
136
|
-
if self._name_existed(name):
|
137
|
-
func = self.registry[name]["function"]
|
138
|
-
try:
|
139
|
-
if asyncio.iscoroutinefunction(func):
|
140
|
-
return await func(**kwargs)
|
141
|
-
else:
|
142
|
-
return func(**kwargs)
|
143
|
-
except Exception as e:
|
144
|
-
raise ValueError(f"Error when invoking function {name} with arguments {kwargs} with error message {e}")
|
145
|
-
else:
|
146
|
-
raise ValueError(f"Function {name} is not registered.")
|
55
|
+
# Extracting parameters with typing hints
|
56
|
+
sig = inspect.signature(func)
|
57
|
+
parameters = {
|
58
|
+
"type": "object",
|
59
|
+
"properties": {},
|
60
|
+
"required": [],
|
61
|
+
}
|
147
62
|
|
148
|
-
|
149
|
-
|
150
|
-
""
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
""
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
return (func, args)
|
164
|
-
except:
|
165
|
-
try:
|
166
|
-
func = response['recipient_name'].split('.')[-1]
|
167
|
-
args = response['parameters']
|
168
|
-
return (func, args)
|
169
|
-
except:
|
170
|
-
raise ValueError('response is not a valid function call')
|
63
|
+
for name, param in sig.parameters.items():
|
64
|
+
# Default type to string and update if type hint is available
|
65
|
+
param_type = "string"
|
66
|
+
if param.annotation is not inspect.Parameter.empty:
|
67
|
+
param_type = param.annotation.__name__
|
68
|
+
|
69
|
+
# Extract parameter description from docstring, if available
|
70
|
+
param_description = param_descriptions.get(name, "No description available.")
|
71
|
+
|
72
|
+
# Assuming all parameters are required for simplicity
|
73
|
+
parameters["required"].append(name)
|
74
|
+
parameters["properties"][name] = {
|
75
|
+
"type": param_type,
|
76
|
+
"description": param_description,
|
77
|
+
}
|
171
78
|
|
172
|
-
|
173
|
-
|
174
|
-
"""
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
return (tool['function']['name'], func,
|
187
|
-
tool['function']['parameters']['properties'].keys())
|
188
|
-
|
189
|
-
def register_tools(self, tools, functions, update=False, new=False, prefix=None, postfix=None):
|
190
|
-
"""
|
191
|
-
Register multiple tools and their corresponding functions.
|
192
|
-
|
193
|
-
Parameters:
|
194
|
-
tools (list): The list of tool information dictionaries.
|
195
|
-
|
196
|
-
functions (list): The list of corresponding functions.
|
197
|
-
|
198
|
-
update (bool): Whether to update existing functions.
|
199
|
-
|
200
|
-
new (bool): Whether to create new registries for existing functions.
|
201
|
-
|
202
|
-
prefix (Optional[str]): A prefix to add to the function names.
|
203
|
-
|
204
|
-
postfix (Optional[str]): A postfix to add to the function names.
|
205
|
-
|
206
|
-
"""
|
207
|
-
funcs = l_call(range(len(tools)), lambda i: self._from_tool(tools[i], functions[i]))
|
208
|
-
l_call(range(len(tools)), lambda i: self._register_function(funcs[i][0], funcs[i][1], update=update, new=new, prefix=prefix, postfix=postfix))
|
209
|
-
|
79
|
+
# Constructing the schema
|
80
|
+
schema = {
|
81
|
+
"type": "function",
|
82
|
+
"function": {
|
83
|
+
"name": func_name,
|
84
|
+
"description": func_description,
|
85
|
+
"parameters": parameters,
|
86
|
+
}
|
87
|
+
}
|
88
|
+
return schema
|
89
|
+
|
90
|
+
def func_to_tool(func_, schema, parser=None):
|
91
|
+
# schema = func_to_schema(func_)
|
92
|
+
return Tool(func=func_, parser=parser, schema_=schema)
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import re
|
2
|
+
from typing import Optional, Union, Iterable, List, Any, Type
|
3
|
+
|
4
|
+
from .flat_util import flatten_list
|
5
|
+
|
6
|
+
|
7
|
+
def str_to_num(input_: str,
|
8
|
+
upper_bound: Optional[Union[int, float]] = None,
|
9
|
+
lower_bound: Optional[Union[int, float]] = None,
|
10
|
+
num_type: Type[Union[int, float]] = int,
|
11
|
+
precision: Optional[int] = None) -> Union[int, float]:
|
12
|
+
"""
|
13
|
+
Converts the first number in the input string to the specified numeric type.
|
14
|
+
|
15
|
+
Args:
|
16
|
+
input_str (str): The input string to extract the number from.
|
17
|
+
|
18
|
+
upper_bound (Optional[Union[int, float]]): The upper bound for the number. Defaults to None.
|
19
|
+
|
20
|
+
lower_bound (Optional[Union[int, float]]): The lower bound for the number. Defaults to None.
|
21
|
+
|
22
|
+
num_type (Type[Union[int, float]]): The type of the number to return (int or float). Defaults to int.
|
23
|
+
|
24
|
+
precision (Optional[int]): The precision for the floating-point number. Defaults to None.
|
25
|
+
|
26
|
+
Returns:
|
27
|
+
Union[int, float]: The converted number.
|
28
|
+
|
29
|
+
Raises:
|
30
|
+
ValueError: If no numeric values are found in the string or if there are conversion errors.
|
31
|
+
"""
|
32
|
+
numbers = re.findall(r'-?\d+\.?\d*', input_)
|
33
|
+
if not numbers:
|
34
|
+
raise ValueError(f"No numeric values found in the string: {input_}")
|
35
|
+
|
36
|
+
try:
|
37
|
+
numbers = numbers[0]
|
38
|
+
if num_type is int:
|
39
|
+
numbers = int(float(numbers))
|
40
|
+
elif num_type is float:
|
41
|
+
numbers = round(float(numbers), precision) if precision is not None else float(numbers)
|
42
|
+
else:
|
43
|
+
raise ValueError(f"Invalid number type: {num_type}")
|
44
|
+
if upper_bound is not None and numbers > upper_bound:
|
45
|
+
raise ValueError(f"Number {numbers} is greater than the upper bound of {upper_bound}.")
|
46
|
+
if lower_bound is not None and numbers < lower_bound:
|
47
|
+
raise ValueError(f"Number {numbers} is less than the lower bound of {lower_bound}.")
|
48
|
+
return numbers
|
49
|
+
|
50
|
+
except ValueError as e:
|
51
|
+
raise ValueError(f"Error converting string to number: {e}")
|
52
|
+
|
53
|
+
def to_list(input_: Any, flatten: bool = True, dropna: bool = False) -> List[Any]:
|
54
|
+
"""
|
55
|
+
Converts the input to a list, optionally flattening it and dropping None values.
|
56
|
+
|
57
|
+
Args:
|
58
|
+
input_item (Any): The input to convert to a list.
|
59
|
+
|
60
|
+
flatten (bool): Whether to flatten the input if it is a nested list. Defaults to True.
|
61
|
+
|
62
|
+
dropna (bool): Whether to drop None values from the list. Defaults to False.
|
63
|
+
|
64
|
+
Returns:
|
65
|
+
List[Any]: The input converted to a list.
|
66
|
+
|
67
|
+
Raises:
|
68
|
+
ValueError: If the input cannot be converted to a list.
|
69
|
+
"""
|
70
|
+
if isinstance(input_, list) and flatten:
|
71
|
+
input_ = flatten_list(input_)
|
72
|
+
if dropna:
|
73
|
+
input_ = [i for i in input_ if i is not None]
|
74
|
+
elif isinstance(input_, Iterable) and not isinstance(input_, (str, dict)):
|
75
|
+
try:
|
76
|
+
input_ = list(input_)
|
77
|
+
except:
|
78
|
+
raise ValueError("Input cannot be converted to a list.")
|
79
|
+
else:
|
80
|
+
input_ = [input_]
|
81
|
+
return input_
|
lionagi/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.0.
|
1
|
+
__version__ = "0.0.113"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: lionagi
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.113
|
4
4
|
Summary: Towards automated general intelligence.
|
5
5
|
Author: HaiyangLi
|
6
6
|
Author-email: Haiyang Li <ocean@lionagi.ai>
|
@@ -220,39 +220,50 @@ Requires-Dist: python-dotenv ==1.0.0
|
|
220
220
|
Requires-Dist: tiktoken ==0.5.1
|
221
221
|
Requires-Dist: httpx ==0.25.1
|
222
222
|
|
223
|
-
    
|
224
224
|
|
225
|
-
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
[PyPI](https://pypi.org/project/lionagi/) | [Documentation](https://lionagi.readthedocs.io/en/latest/) | [Discord](https://discord.gg/7RGWqpSxze)
|
226
230
|
|
227
231
|
|
228
232
|
# LionAGI
|
229
233
|
**Towards Automated General Intelligence**
|
230
234
|
|
231
|
-
|
235
|
+
|
236
|
+
LionAGI is a cutting-edge **intelligent agent framework**. It integrates data manipulation with advanced machine learning tools, such as Large Language Models (i.e. OpenAI's GPT).
|
237
|
+
- Designed for data-centric, production-level projects,
|
238
|
+
- dramatically lowers the barrier in creating intelligent, automated systems
|
239
|
+
- that can understand and interact meaningfully with large volumes of data.
|
232
240
|
|
233
241
|
Install LionAGI with pip:
|
234
242
|
|
235
243
|
```bash
|
236
244
|
pip install lionagi
|
237
245
|
```
|
238
|
-
Download the `.env_template` file, input your
|
246
|
+
Download the `.env_template` file, input your appropriate `API_KEY`, save the file, rename as `.env` and put in your project's root directory.
|
247
|
+
by default we use `OPENAI_API_KEY`.
|
239
248
|
|
240
|
-
### Features
|
241
249
|
|
242
|
-
- Robust performance. LionAGI is written in almost pure python. With minimum external dependency (`aiohttp`, `httpx`, `python-dotenv`, `tiktoken`)
|
243
|
-
- Efficient data operations for reading, chunking, binning, writing, storing and managing data.
|
244
|
-
- Fast interaction with LLM services like OpenAI with **configurable rate limiting concurrent API calls** for maximum throughput.
|
245
|
-
- Create a production ready LLM application **in hours**. Intuitive workflow management to streamline and expedite the process from idea to market.
|
246
250
|
|
251
|
+
### Features
|
252
|
+
- Create a production ready LLM application **in hours**, with more than 100 models to choose from
|
253
|
+
- written in pure python, minimum dependency `aiohttp`, `python-dotenv`, `tiktoken`, `pydantic`
|
254
|
+
- Efficient and verstile data operations for reading, chunking, binning, writing, storing data with built-in support for `langchain` and `llamaindex`
|
255
|
+
- Unified interface with any LLM provider, API or local
|
256
|
+
- Fast and **concurrent** API call with **configurable rate limit**
|
257
|
+
- (Work In Progress) support for hundreds of models both API and local
|
247
258
|
---
|
248
|
-
|
259
|
+
LionAGI is designed to be `asynchronous` only, please check python official documentation on how `async` work: [here](https://docs.python.org/3/library/asyncio.html)
|
249
260
|
|
250
261
|
|
251
262
|
**Notice**:
|
252
263
|
* calling API with maximum throughput over large set of data with advanced models i.e. gpt-4 can get **EXPENSIVE IN JUST SECONDS**,
|
253
264
|
* please know what you are doing, and check the usage on OpenAI regularly
|
254
265
|
* default rate limits are set to be **tier 1** of OpenAI model `gpt-4-1104-preview`, 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.
|
255
|
-
*
|
266
|
+
* 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**
|
256
267
|
|
257
268
|
|
258
269
|
### Quick Start
|
@@ -266,11 +277,11 @@ import lionagi as li
|
|
266
277
|
system = "You are a helpful assistant designed to perform calculations."
|
267
278
|
instruction = {"Addition":"Add the two numbers together i.e. x+y"}
|
268
279
|
context = {"x": 10, "y": 5}
|
280
|
+
```
|
269
281
|
|
270
|
-
|
282
|
+
```python
|
283
|
+
# in interactive environment (.ipynb for example)
|
271
284
|
calculator = li.Session(system=system)
|
272
|
-
|
273
|
-
# run a LLM API call
|
274
285
|
result = await calculator.initiate(instruction=instruction,
|
275
286
|
context=context,
|
276
287
|
model="gpt-4-1106-preview")
|
@@ -278,6 +289,24 @@ result = await calculator.initiate(instruction=instruction,
|
|
278
289
|
print(f"Calculation Result: {result}")
|
279
290
|
```
|
280
291
|
|
292
|
+
```python
|
293
|
+
# or otherwise, you can use
|
294
|
+
import asyncio
|
295
|
+
from dotenv import loadenv
|
296
|
+
|
297
|
+
load_dotenv()
|
298
|
+
|
299
|
+
async def main():
|
300
|
+
calculator = li.Session(system=system)
|
301
|
+
result = await calculator.initiate(instruction=instruction,
|
302
|
+
context=context,
|
303
|
+
model="gpt-4-1106-preview")
|
304
|
+
print(f"Calculation Result: {result}")
|
305
|
+
|
306
|
+
if __name__ == "__main__":
|
307
|
+
asyncio.run(main())
|
308
|
+
```
|
309
|
+
|
281
310
|
Visit our notebooks for our examples.
|
282
311
|
|
283
312
|
### Community
|
@@ -0,0 +1,84 @@
|
|
1
|
+
lionagi/__init__.py,sha256=gAOIyJ-kItUn2ya8G3zW6pvuzmk60xk7zO_GN66UJAM,888
|
2
|
+
lionagi/version.py,sha256=WJPRYfehqmqr60a1h9m6a2fbtJa0dT03ixD6hahuBgE,24
|
3
|
+
lionagi/bridge/__init__.py,sha256=I19ztSDDwV1-e-GSRs45bJgjbg454e0vcFv2jwgwQY0,139
|
4
|
+
lionagi/bridge/langchain.py,sha256=nJdnv_zHpchQXUlh5ml6OZKGO9Rbaa7B-XbeKB3Ej7Y,4579
|
5
|
+
lionagi/bridge/llama_index.py,sha256=sapGIgS3RkDUyrPCdjZizoRdAmktZLHzUbYQBw6nnZw,5510
|
6
|
+
lionagi/configs/__init__.py,sha256=88KoeoB8dHhgZdQ8I4rbb7e8-FUd-_gi1dXaA95vJ3Y,141
|
7
|
+
lionagi/configs/oai_configs.py,sha256=C89jXb2Xb7qoOXIhtrMlIRVYJqjh7knpu6CAOloj9eo,1199
|
8
|
+
lionagi/configs/openrouter_config.py,sha256=qbEQQqQPpzMp3eP5U8kuvGTUYdMgemuuq-BdgOYgYI8,1256
|
9
|
+
lionagi/core/__init__.py,sha256=XAw2vF1wuQYKSAxHcBanfYN0k-5qLSggkl3yZgwjSRw,347
|
10
|
+
lionagi/core/conversations.py,sha256=Jh4Bvv0SBaW5ZG_D9hyWveQ-PXPDGfvp_V7UxbPsFoA,4084
|
11
|
+
lionagi/core/flows.py,sha256=rhPBmdN-JKo7Zcv9hiy6k0b-CjKBHMemkYITM7a9fNo,32
|
12
|
+
lionagi/core/instruction_sets.py,sha256=y-fDltfDtji4fCtHn8fJ_M9OtYCfjqeTds7bpzknvhU,51
|
13
|
+
lionagi/core/messages.py,sha256=XisuXcJBUoyYcd-6DLcV_NZnsKXzZcFf4Dk_fxTlXc8,6533
|
14
|
+
lionagi/core/sessions.py,sha256=sjg7bCORFhpaEgDBTExyhfgGxRAUwkOCft0MmP-BGoU,11161
|
15
|
+
lionagi/datastore/__init__.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
16
|
+
lionagi/datastore/chroma.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
17
|
+
lionagi/datastore/deeplake.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
18
|
+
lionagi/datastore/elasticsearch.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
19
|
+
lionagi/datastore/lantern.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
20
|
+
lionagi/datastore/pinecone.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
21
|
+
lionagi/datastore/postgres.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
22
|
+
lionagi/datastore/qdrant.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
23
|
+
lionagi/loader/__init__.py,sha256=0FNrggZnSq1ONLZY2f325SF19UfYHaqJeJXLvpu8KWQ,262
|
24
|
+
lionagi/loader/chunker.py,sha256=zGdfS-Gybxc6lm_vMIdt-f25kY2CwDFTLvY-arKxQ8c,6476
|
25
|
+
lionagi/loader/reader.py,sha256=8kxYlqhwmMpuNTWdYtsNc9g-1Mf264Y8XRu1GkevhTg,4527
|
26
|
+
lionagi/objs/__init__.py,sha256=4qxo9ZGKe37fjj_Gt2hgi4QTTIPmDf7mkyUK7euVmsU,137
|
27
|
+
lionagi/objs/messenger.py,sha256=k-ueq2LBLTTDgk8u-Vyja8WBFM7dWFInWO97HNyOXaI,6137
|
28
|
+
lionagi/objs/tool_registry.py,sha256=cnoaW1TvNhKKerQ4tTUOSHEADmsTdoUW2lT24LcHIx0,9357
|
29
|
+
lionagi/schema/__init__.py,sha256=cB7rSYeRXujDwp2f5IMK83-NzdqPfbMhGijPCPXgT_c,210
|
30
|
+
lionagi/schema/base_condition.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
31
|
+
lionagi/schema/base_schema.py,sha256=gx4LDxYnVO9vqp0JdevUSasqrat7Lu3rRURTiv7gGj0,8348
|
32
|
+
lionagi/schema/base_tool.py,sha256=sKbCrS0ZZINkr03Fj0lk0Kt0XPiBz9IXwA9A1aDgN88,192
|
33
|
+
lionagi/schema/data_logger.py,sha256=nmv0jJDkE-vzz_KyBl1_bHB8KVvhZ6sItOBQcvBkAvE,3417
|
34
|
+
lionagi/services/__init__.py,sha256=js4LnJEJv4kkxPPamkOgFkOsrc1yr2dK-z9CLTTsX04,313
|
35
|
+
lionagi/services/anthropic.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
36
|
+
lionagi/services/anyscale.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
|
+
lionagi/services/azure.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
38
|
+
lionagi/services/base_api_service.py,sha256=vGCnC1GnW8czpseOx8mcDeyiiAKc_dabUInxjytE-A0,9756
|
39
|
+
lionagi/services/bedrock.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
40
|
+
lionagi/services/chatcompletion.py,sha256=9jVkB4JUX-kzvAHsohA1ZO6ZeXdlN9OAe-cVvLCa9-0,1257
|
41
|
+
lionagi/services/everlyai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
|
+
lionagi/services/gemini.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
|
+
lionagi/services/gpt4all.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
+
lionagi/services/huggingface.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
|
+
lionagi/services/litellm.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
46
|
+
lionagi/services/localai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
|
+
lionagi/services/mistralai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
|
+
lionagi/services/oai.py,sha256=NcKiqmQ8YpKEkoVv-6a-mvIZVBumWOVpstpVD0oTiUs,1122
|
49
|
+
lionagi/services/ollama.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
50
|
+
lionagi/services/openllm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
|
+
lionagi/services/openrouter.py,sha256=vjY0ZydLY5XK4_T2cRiAl8_QNysWy26wcfyIP-1hlSw,1110
|
52
|
+
lionagi/services/perplexity.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
|
+
lionagi/services/predibase.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
|
+
lionagi/services/rungpt.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
|
+
lionagi/services/service_objs.py,sha256=w1Rs69eAGyEukTMMvwQHDmFkwTMf2pB9DdGQ-xCjTUw,9727
|
56
|
+
lionagi/services/vllm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
57
|
+
lionagi/services/xinference.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
58
|
+
lionagi/structure/__init__.py,sha256=wMPekT2vbWwUkJ5aW5o-lzJC9Fzhta6RHDiFPTNUm_0,120
|
59
|
+
lionagi/structure/relationship.py,sha256=5urGnomfhBJUwPLpYpk5YCx-zO2yprJDaPQqMsgQM0A,4124
|
60
|
+
lionagi/structure/structure.py,sha256=KWVOTFWk_IBMtY57gut_GFUuO7dKWlIrMH7xZ_ys2c4,5952
|
61
|
+
lionagi/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
|
+
lionagi/tests/test_flatten_util.py,sha256=-sOAQriGtHK1U0FTd31IpdKJpgMQREpaXp-hf6FAojQ,17362
|
63
|
+
lionagi/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
64
|
+
lionagi/tools/coder.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
65
|
+
lionagi/tools/planner.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
66
|
+
lionagi/tools/prompter.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
67
|
+
lionagi/tools/sandbox.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
68
|
+
lionagi/tools/scorer.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
69
|
+
lionagi/tools/summarizer.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
70
|
+
lionagi/tools/validator.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
|
71
|
+
lionagi/utils/__init__.py,sha256=91eJpmYZLXi_xsFV7yb_uvlRmdhBQWBqa9Bmy18nJYY,1419
|
72
|
+
lionagi/utils/api_util.py,sha256=wNYillgmAY9UJ5zP6NLo37levC3JEJGiis7nbPBRYXw,2769
|
73
|
+
lionagi/utils/call_util.py,sha256=g4MRQChRGAz_1W35ThnEkyVR0W-neEk3ylgUq9IxbR8,12440
|
74
|
+
lionagi/utils/flat_util.py,sha256=I1HJXs5llQ6oOoJudT4B7bp9u9_TLEFT_yPcXoNhrNA,22899
|
75
|
+
lionagi/utils/io_util.py,sha256=Yzzo-GACV3QXdEFpdfVrpjxc8YJEHJof7hACiTQ59gU,3515
|
76
|
+
lionagi/utils/load_utils.py,sha256=nSDWSXRFHO-tJXGMW-7icOqkeL1baQENf9BDyJZU88o,6667
|
77
|
+
lionagi/utils/sys_util.py,sha256=nxv5mFagY0zBdMLhf9LD_SsK5Cd2rz9zMslr9xIwpfM,6305
|
78
|
+
lionagi/utils/tool_util.py,sha256=RgTML1ZZbmVGdBV2pMpbDCDaNawf_p4d8bqliaOS898,2914
|
79
|
+
lionagi/utils/type_util.py,sha256=eUfsvIr_VRykruE4TEUHssBME8Iug_4U4myY8xFV2bA,3135
|
80
|
+
lionagi-0.0.113.dist-info/LICENSE,sha256=TBnSyG8fs_tMRtK805GzA1cIyExleKyzoN_kuVxT9IY,11358
|
81
|
+
lionagi-0.0.113.dist-info/METADATA,sha256=-zs_6eEFEiCbvqycmpy9YxKVOOIUdzAlB6IrnrHJadk,18027
|
82
|
+
lionagi-0.0.113.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
83
|
+
lionagi-0.0.113.dist-info/top_level.txt,sha256=szvch_d2jE1Lu9ZIKsl26Ll6BGfYfbOgt5lm-UpFSo4,8
|
84
|
+
lionagi-0.0.113.dist-info/RECORD,,
|
lionagi/api/__init__.py
DELETED
lionagi/api/oai_config.py
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
oai_llmconfig = {
|
2
|
-
"model": "gpt-4-1106-preview",
|
3
|
-
"frequency_penalty": 0,
|
4
|
-
"max_tokens": None,
|
5
|
-
"n": 1,
|
6
|
-
"presence_penalty": 0,
|
7
|
-
"response_format": {"type": "text"},
|
8
|
-
"seed": None,
|
9
|
-
"stop": None,
|
10
|
-
"stream": False,
|
11
|
-
"temperature": 0.7,
|
12
|
-
"top_p": 1,
|
13
|
-
"tools": None,
|
14
|
-
"tool_choice": "none",
|
15
|
-
"user": None
|
16
|
-
}
|