lionagi 0.3.6__py3-none-any.whl → 0.3.8__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- lionagi/core/collections/abc/component.py +26 -29
- lionagi/core/collections/abc/concepts.py +0 -6
- lionagi/core/collections/flow.py +0 -1
- lionagi/core/collections/model.py +3 -2
- lionagi/core/collections/pile.py +1 -1
- lionagi/core/collections/progression.py +4 -5
- lionagi/core/director/operations/select.py +2 -92
- lionagi/core/generic/registry/component_registry/__init__.py +0 -0
- lionagi/core/rule/choice.py +2 -2
- lionagi/core/unit/unit_mixin.py +3 -3
- lionagi/integrations/langchain_/__init__.py +0 -0
- lionagi/integrations/llamaindex_/__init__.py +0 -0
- lionagi/libs/sys_util.py +196 -32
- lionagi/lions/director/__init__.py +0 -0
- lionagi/operations/__init__.py +6 -0
- lionagi/operations/brainstorm.py +87 -0
- lionagi/operations/config.py +6 -0
- lionagi/operations/rank.py +102 -0
- lionagi/operations/score.py +144 -0
- lionagi/operations/select.py +141 -0
- lionagi/version.py +1 -1
- lionagi-0.3.8.dist-info/METADATA +241 -0
- {lionagi-0.3.6.dist-info → lionagi-0.3.8.dist-info}/RECORD +25 -21
- lionagi/core/director/models/__init__.py +0 -13
- lionagi/core/director/models/action_model.py +0 -61
- lionagi/core/director/models/brainstorm_model.py +0 -42
- lionagi/core/director/models/plan_model.py +0 -51
- lionagi/core/director/models/reason_model.py +0 -63
- lionagi/core/director/models/step_model.py +0 -65
- lionagi-0.3.6.dist-info/METADATA +0 -69
- {lionagi-0.3.6.dist-info → lionagi-0.3.8.dist-info}/LICENSE +0 -0
- {lionagi-0.3.6.dist-info → lionagi-0.3.8.dist-info}/WHEEL +0 -0
@@ -1,61 +0,0 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
from lionfuncs import to_dict, validate_str
|
4
|
-
from pydantic import BaseModel, Field, field_validator
|
5
|
-
|
6
|
-
|
7
|
-
class ActionModel(BaseModel):
|
8
|
-
|
9
|
-
title: str = Field(
|
10
|
-
...,
|
11
|
-
title="Title",
|
12
|
-
description="Provide a concise title summarizing the action.",
|
13
|
-
)
|
14
|
-
content: str = Field(
|
15
|
-
...,
|
16
|
-
title="Content",
|
17
|
-
description="Provide a brief description of the action to be performed.",
|
18
|
-
)
|
19
|
-
function: str = Field(
|
20
|
-
...,
|
21
|
-
title="Function",
|
22
|
-
description=(
|
23
|
-
"Specify the name of the function to execute. **Choose from the provided "
|
24
|
-
"`tool_schema`; do not invent function names.**"
|
25
|
-
),
|
26
|
-
examples=["print", "add", "len"],
|
27
|
-
)
|
28
|
-
arguments: dict[str, Any] = Field(
|
29
|
-
{},
|
30
|
-
title="Arguments",
|
31
|
-
description=(
|
32
|
-
"Provide the arguments to pass to the function as a dictionary. **Use "
|
33
|
-
"argument names and types as specified in the `tool_schema`; do not "
|
34
|
-
"invent argument names.**"
|
35
|
-
),
|
36
|
-
examples=[{"num1": 1, "num2": 2}, {"x": "hello", "y": "world"}],
|
37
|
-
)
|
38
|
-
|
39
|
-
@field_validator("title", mode="before")
|
40
|
-
def validate_title(cls, value: Any) -> str:
|
41
|
-
return validate_str(value, "title")
|
42
|
-
|
43
|
-
@field_validator("content", mode="before")
|
44
|
-
def validate_content(cls, value: Any) -> str:
|
45
|
-
return validate_str(value, "content")
|
46
|
-
|
47
|
-
@field_validator("function", mode="before")
|
48
|
-
def validate_function(cls, value: Any) -> str:
|
49
|
-
return validate_str(value, "function")
|
50
|
-
|
51
|
-
@field_validator("arguments", mode="before")
|
52
|
-
def validate_arguments(cls, value: Any) -> dict[str, Any]:
|
53
|
-
return to_dict(
|
54
|
-
value,
|
55
|
-
fuzzy_parse=True,
|
56
|
-
suppress=True,
|
57
|
-
recursive=True,
|
58
|
-
)
|
59
|
-
|
60
|
-
|
61
|
-
__all__ = ["ActionModel"]
|
@@ -1,42 +0,0 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
from lionfuncs import validate_str
|
4
|
-
from pydantic import BaseModel, Field, field_validator
|
5
|
-
|
6
|
-
from .reason_model import ReasonModel
|
7
|
-
from .step_model import StepModel
|
8
|
-
|
9
|
-
|
10
|
-
class BrainstormModel(BaseModel):
|
11
|
-
|
12
|
-
title: str = Field(
|
13
|
-
...,
|
14
|
-
title="Title",
|
15
|
-
description="Provide a concise title summarizing the brainstorming session.",
|
16
|
-
)
|
17
|
-
content: str = Field(
|
18
|
-
...,
|
19
|
-
title="Content",
|
20
|
-
description="Describe the context or focus of the brainstorming session.",
|
21
|
-
)
|
22
|
-
ideas: list[StepModel] = Field(
|
23
|
-
...,
|
24
|
-
title="Ideas",
|
25
|
-
description="A list of ideas for the next step, generated during brainstorming.",
|
26
|
-
)
|
27
|
-
reason: ReasonModel = Field(
|
28
|
-
...,
|
29
|
-
title="Reason",
|
30
|
-
description="Provide the high level reasoning behind the brainstorming session.",
|
31
|
-
)
|
32
|
-
|
33
|
-
@field_validator("title", mode="before")
|
34
|
-
def validate_title(cls, value: Any) -> str:
|
35
|
-
return validate_str(value, "title")
|
36
|
-
|
37
|
-
@field_validator("content", mode="before")
|
38
|
-
def validate_content(cls, value: Any) -> str:
|
39
|
-
return validate_str(value, "content")
|
40
|
-
|
41
|
-
|
42
|
-
__all__ = ["BrainstormModel"]
|
@@ -1,51 +0,0 @@
|
|
1
|
-
from typing import Any, List
|
2
|
-
|
3
|
-
from lionfuncs import validate_str
|
4
|
-
from pydantic import BaseModel, Field, field_validator
|
5
|
-
|
6
|
-
from .reason_model import ReasonModel
|
7
|
-
from .step_model import StepModel
|
8
|
-
|
9
|
-
|
10
|
-
class PlanModel(BaseModel):
|
11
|
-
"""
|
12
|
-
Represents a plan consisting of multiple steps, with an overall reason.
|
13
|
-
|
14
|
-
Attributes:
|
15
|
-
title (str): A concise title summarizing the plan.
|
16
|
-
content (str): A detailed description of the plan.
|
17
|
-
reason (ReasonModel): The overall reasoning behind the plan.
|
18
|
-
steps (List[StepModel]): A list of steps to execute the plan.
|
19
|
-
"""
|
20
|
-
|
21
|
-
title: str = Field(
|
22
|
-
...,
|
23
|
-
title="Title",
|
24
|
-
description="Provide a concise title summarizing the plan.",
|
25
|
-
)
|
26
|
-
content: str = Field(
|
27
|
-
...,
|
28
|
-
title="Content",
|
29
|
-
description="Provide a detailed description of the plan.",
|
30
|
-
)
|
31
|
-
reason: ReasonModel = Field(
|
32
|
-
...,
|
33
|
-
title="Reason",
|
34
|
-
description="Provide the reasoning behind the entire plan.",
|
35
|
-
)
|
36
|
-
steps: list[StepModel] = Field(
|
37
|
-
...,
|
38
|
-
title="Steps",
|
39
|
-
description="A list of steps to execute the plan.",
|
40
|
-
)
|
41
|
-
|
42
|
-
@field_validator("title", mode="before")
|
43
|
-
def validate_title(cls, value: Any) -> str:
|
44
|
-
return validate_str(value, "title")
|
45
|
-
|
46
|
-
@field_validator("content", mode="before")
|
47
|
-
def validate_content(cls, value: Any) -> str:
|
48
|
-
return validate_str(value, "content")
|
49
|
-
|
50
|
-
|
51
|
-
__all__ = ["PlanModel"]
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from lionfuncs import to_num, validate_str
|
5
|
-
from pydantic import BaseModel, Field, field_validator
|
6
|
-
|
7
|
-
|
8
|
-
class ReasonModel(BaseModel):
|
9
|
-
title: str = Field(
|
10
|
-
...,
|
11
|
-
title="Title",
|
12
|
-
description="Provide a concise title summarizing the reason.",
|
13
|
-
)
|
14
|
-
content: str = Field(
|
15
|
-
...,
|
16
|
-
title="Content",
|
17
|
-
description=(
|
18
|
-
"Provide a detailed explanation supporting the reason, including relevant "
|
19
|
-
"information or context."
|
20
|
-
),
|
21
|
-
)
|
22
|
-
confidence_score: float | None = Field(
|
23
|
-
None,
|
24
|
-
description=(
|
25
|
-
"Provide an objective numeric confidence score between 0 and 1 (with 3 "
|
26
|
-
"decimal places) indicating how likely you successfully achieved the task "
|
27
|
-
"according to user expectation. Interpret the score as:\n"
|
28
|
-
"- **1**: Very confident in a good job.\n"
|
29
|
-
"- **0**: Not confident at all.\n"
|
30
|
-
"- **[0.8, 1]**: You can continue the path of reasoning if needed.\n"
|
31
|
-
"- **[0.5, 0.8)**: Recheck your reasoning and consider reverting to a "
|
32
|
-
"previous, more confident reasoning path.\n"
|
33
|
-
"- **[0, 0.5)**: Stop because the reasoning is starting to be off track."
|
34
|
-
),
|
35
|
-
examples=[0.821, 0.257, 0.923, 0.439],
|
36
|
-
ge=0,
|
37
|
-
le=1,
|
38
|
-
)
|
39
|
-
|
40
|
-
@field_validator("title", mode="before")
|
41
|
-
def validate_title(cls, value: Any) -> str:
|
42
|
-
return validate_str(value, "title")
|
43
|
-
|
44
|
-
@field_validator("content", mode="before")
|
45
|
-
def validate_content(cls, value: Any) -> str:
|
46
|
-
return validate_str(value, "content")
|
47
|
-
|
48
|
-
@field_validator("confidence_score", mode="before")
|
49
|
-
def validate_confidence_score(cls, value: Any) -> float:
|
50
|
-
try:
|
51
|
-
return to_num(
|
52
|
-
value,
|
53
|
-
upper_bound=1,
|
54
|
-
lower_bound=0,
|
55
|
-
num_type=float,
|
56
|
-
precision=3,
|
57
|
-
)
|
58
|
-
except Exception as e:
|
59
|
-
logging.error(f"Failed to convert {value} to a number. Error: {e}")
|
60
|
-
return 0.0
|
61
|
-
|
62
|
-
|
63
|
-
__all__ = ["ReasonModel"]
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from lionfuncs import validate_boolean, validate_str
|
5
|
-
from pydantic import BaseModel, Field, field_validator
|
6
|
-
|
7
|
-
from .action_model import ActionModel
|
8
|
-
from .reason_model import ReasonModel
|
9
|
-
|
10
|
-
|
11
|
-
class StepModel(BaseModel):
|
12
|
-
title: str = Field(
|
13
|
-
...,
|
14
|
-
title="Title",
|
15
|
-
description="Provide a concise title summarizing the step.",
|
16
|
-
)
|
17
|
-
content: str = Field(
|
18
|
-
...,
|
19
|
-
title="Content",
|
20
|
-
description="Describe the content of the step in detail.",
|
21
|
-
)
|
22
|
-
reason: ReasonModel = Field(
|
23
|
-
...,
|
24
|
-
title="Reason",
|
25
|
-
description="Provide the reasoning behind this step, including supporting details.",
|
26
|
-
)
|
27
|
-
action_required: bool = Field(
|
28
|
-
False,
|
29
|
-
title="Action Required",
|
30
|
-
description=(
|
31
|
-
"Indicate whether this step requires an action. Set to **True** if an "
|
32
|
-
"action is required; otherwise, set to **False**."
|
33
|
-
),
|
34
|
-
)
|
35
|
-
actions: list[ActionModel] = Field(
|
36
|
-
[],
|
37
|
-
title="Actions",
|
38
|
-
description=(
|
39
|
-
"List of actions to be performed if `action_required` is **True**. Leave "
|
40
|
-
"empty if no action is required. **When providing actions, you must "
|
41
|
-
"choose from the provided `tool_schema`. Do not invent function or "
|
42
|
-
"argument names.**"
|
43
|
-
),
|
44
|
-
)
|
45
|
-
|
46
|
-
@field_validator("title", mode="before")
|
47
|
-
def validate_title(cls, value: Any) -> str:
|
48
|
-
return validate_str(value, "title")
|
49
|
-
|
50
|
-
@field_validator("content", mode="before")
|
51
|
-
def validate_content(cls, value: Any) -> str:
|
52
|
-
return validate_str(value, "content")
|
53
|
-
|
54
|
-
@field_validator("action_required", mode="before")
|
55
|
-
def validate_action_required(cls, value: Any) -> bool:
|
56
|
-
try:
|
57
|
-
return validate_boolean(value)
|
58
|
-
except Exception as e:
|
59
|
-
logging.error(
|
60
|
-
f"Failed to convert {value} to a boolean. Error: {e}"
|
61
|
-
)
|
62
|
-
return False
|
63
|
-
|
64
|
-
|
65
|
-
__all__ = ["StepModel"]
|
lionagi-0.3.6.dist-info/METADATA
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: lionagi
|
3
|
-
Version: 0.3.6
|
4
|
-
Summary: Towards automated general intelligence.
|
5
|
-
Author: HaiyangLi
|
6
|
-
Author-email: quantocean.li@gmail.com
|
7
|
-
Requires-Python: >=3.10,<4.0
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
11
|
-
Classifier: Programming Language :: Python :: 3.12
|
12
|
-
Requires-Dist: aiocache (>=0.12.0,<0.13.0)
|
13
|
-
Requires-Dist: ipython (>=8.0.0,<9.0.0)
|
14
|
-
Requires-Dist: lion-core (>=0.4.0,<0.5.0)
|
15
|
-
Requires-Dist: lion-openai (>=0.1.5,<0.2.0)
|
16
|
-
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
17
|
-
Description-Content-Type: text/markdown
|
18
|
-
|
19
|
-
![PyPI - Version](https://img.shields.io/pypi/v/lionagi?labelColor=233476aa&color=231fc935) ![PyPI - Downloads](https://img.shields.io/pypi/dm/lionagi?color=blue)
|
20
|
-
|
21
|
-
|
22
|
-
[PyPI](https://pypi.org/project/lionagi/) | [Documentation](https://ocean-lion.com/Welcome) | [Discord](https://discord.gg/aqSJ2v46vu) | [Roadmap](https://trello.com/b/3seomsrI/lionagi)
|
23
|
-
|
24
|
-
|
25
|
-
# Language InterOperable Network - LION
|
26
|
-
### an AGentic Intelligence Operating System
|
27
|
-
|
28
|
-
```
|
29
|
-
pip install lionagi
|
30
|
-
```
|
31
|
-
or
|
32
|
-
```
|
33
|
-
poetry add lionagi
|
34
|
-
```
|
35
|
-
**Powerful Intelligent Workflow Automation**
|
36
|
-
|
37
|
-
lionagi is an intelligent agentic workflow automation framework. It introduces advanced ML models into any existing workflows and data infrastructure.
|
38
|
-
|
39
|
-
|
40
|
-
### Why Automating Workflows?
|
41
|
-
|
42
|
-
Intelligent AI models such as [Large Language Model (LLM)](https://en.wikipedia.org/wiki/Large_language_model), introduced new possibilities of human-computer interaction. LLMs is drawing a lot of attention worldwide due to its “one model fits all”, and incredible performance. One way of using LLM is to use as search engine, however, this usage is complicated by the fact that LLMs [hallucinate](https://arxiv.org/abs/2311.05232).
|
43
|
-
|
44
|
-
What goes inside of a LLM is more akin to a [black-box](https://pauldeepakraj-r.medium.com/demystifying-the-black-box-a-deep-dive-into-llm-interpretability-971524966fdf), lacking interpretability, meaning we don’t know how it reaches certain answer or conclusion, thus we cannot fully trust/rely the output from such a system. Another approach of using LLM is to treat them as [intelligent agent](https://arxiv.org/html/2401.03428v1), that are equipped with various tools and data sources. A workflow conducted by such an intelligent agent have clear steps, and we can specify, observe, evaluate and optimize the logic for each decision that the `agent` made to perform actions. This approach, though we still cannot pinpoint how LLM output what it outputs, but the flow itself is **explainable**.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
### Community
|
49
|
-
|
50
|
-
We encourage contributions to LionAGI and invite you to enrich its features and capabilities. Engage with us and other community members [Join Our Discord](https://discord.gg/aqSJ2v46vu)
|
51
|
-
|
52
|
-
### Citation
|
53
|
-
|
54
|
-
When referencing LionAGI in your projects or research, please cite:
|
55
|
-
|
56
|
-
```bibtex
|
57
|
-
@software{Li_LionAGI_2023,
|
58
|
-
author = {Haiyang Li},
|
59
|
-
month = {12},
|
60
|
-
year = {2023},
|
61
|
-
title = {LionAGI: Towards Automated General Intelligence},
|
62
|
-
url = {https://github.com/lion-agi/lionagi},
|
63
|
-
}
|
64
|
-
```
|
65
|
-
|
66
|
-
|
67
|
-
### Requirements
|
68
|
-
Python 3.10 or higher.
|
69
|
-
|
File without changes
|
File without changes
|