blue-assistant 4.53.1__tar.gz → 4.66.1__tar.gz
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.
- {blue_assistant-4.53.1/blue_assistant.egg-info → blue_assistant-4.66.1}/PKG-INFO +6 -2
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/README.md +1 -1
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/README.py +13 -10
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/__init__.py +1 -1
- blue_assistant-4.66.1/blue_assistant/config.env +3 -0
- blue_assistant-4.66.1/blue_assistant/env.py +17 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/__main__.py +3 -2
- blue_assistant-4.66.1/blue_assistant/script/actions/__init__.py +14 -0
- blue_assistant-4.66.1/blue_assistant/script/actions/functions.py +48 -0
- blue_assistant-4.66.1/blue_assistant/script/actions/generate_image.py +21 -0
- blue_assistant-4.66.1/blue_assistant/script/actions/generate_text.py +93 -0
- blue_assistant-4.66.1/blue_assistant/script/actions/generic.py +34 -0
- blue_assistant-4.66.1/blue_assistant/script/load.py +27 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/__init__.py +1 -1
- blue_assistant-4.66.1/blue_assistant/script/repository/generic/classes.py +69 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1/blue_assistant.egg-info}/PKG-INFO +6 -2
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant.egg-info/SOURCES.txt +1 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant.egg-info/requires.txt +4 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/requirements.txt +6 -0
- blue_assistant-4.53.1/blue_assistant/config.env +0 -1
- blue_assistant-4.53.1/blue_assistant/env.py +0 -11
- blue_assistant-4.53.1/blue_assistant/script/actions/__init__.py +0 -40
- blue_assistant-4.53.1/blue_assistant/script/actions/generate_image.py +0 -21
- blue_assistant-4.53.1/blue_assistant/script/actions/generate_text.py +0 -21
- blue_assistant-4.53.1/blue_assistant/script/actions/generic.py +0 -25
- blue_assistant-4.53.1/blue_assistant/script/load.py +0 -17
- blue_assistant-4.53.1/blue_assistant/script/repository/generic/classes.py +0 -104
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/LICENSE +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/MANIFEST.in +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/abcli.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/actions.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/alias.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/browse.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/script/list.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/script/run.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/script.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/tests/README.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/tests/help.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/tests/script_run.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/.abcli/tests/version.sh +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/__main__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/functions.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/help/__init__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/help/__main__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/help/functions.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/help/script.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/host.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/logger.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/sample.env +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/__init__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/actions/wip.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/blue_amo/classes.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/moon_datasets/__init__.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/moon_datasets/classes.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/urls.py +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant.egg-info/top_level.txt +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/pyproject.toml +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/setup.cfg +0 -0
- {blue_assistant-4.53.1 → blue_assistant-4.66.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.66.1
|
4
4
|
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
@@ -16,7 +16,9 @@ Requires-Dist: blueness
|
|
16
16
|
Requires-Dist: blue-options
|
17
17
|
Requires-Dist: abcli
|
18
18
|
Requires-Dist: openai_commands
|
19
|
+
Requires-Dist: blueflow
|
19
20
|
Requires-Dist: boto3
|
21
|
+
Requires-Dist: openai
|
20
22
|
Requires-Dist: geojson
|
21
23
|
Requires-Dist: geopandas
|
22
24
|
Requires-Dist: matplotlib
|
@@ -28,6 +30,8 @@ Requires-Dist: pylint
|
|
28
30
|
Requires-Dist: pytest
|
29
31
|
Requires-Dist: python-dotenv[cli]
|
30
32
|
Requires-Dist: tqdm
|
33
|
+
Requires-Dist: networkx
|
34
|
+
Requires-Dist: pydot
|
31
35
|
Dynamic: author
|
32
36
|
Dynamic: author-email
|
33
37
|
Dynamic: classifier
|
@@ -68,4 +72,4 @@ graph LR
|
|
68
72
|
|
69
73
|
[](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [](https://pypi.org/project/blue-assistant/) [](https://pypistats.org/packages/blue-assistant)
|
70
74
|
|
71
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
75
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.66.1`](https://github.com/kamangir/blue-assistant).
|
@@ -28,4 +28,4 @@ graph LR
|
|
28
28
|
|
29
29
|
[](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [](https://pypi.org/project/blue-assistant/) [](https://pypistats.org/packages/blue-assistant)
|
30
30
|
|
31
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
31
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.66.1`](https://github.com/kamangir/blue-assistant).
|
@@ -17,14 +17,17 @@ items = [
|
|
17
17
|
|
18
18
|
|
19
19
|
def build():
|
20
|
-
return
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
return all(
|
21
|
+
README.build(
|
22
|
+
items=readme.get("items", []),
|
23
|
+
path=os.path.join(file.path(__file__), readme["path"]),
|
24
|
+
ICON=ICON,
|
25
|
+
NAME=NAME,
|
26
|
+
VERSION=VERSION,
|
27
|
+
REPO_NAME=REPO_NAME,
|
28
|
+
)
|
29
|
+
for readme in [
|
30
|
+
{"items": items, "path": ".."},
|
31
|
+
{"path": "docs/blue-amo-01.md"},
|
32
|
+
]
|
27
33
|
)
|
28
|
-
|
29
|
-
|
30
|
-
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import os
|
2
|
+
from blue_options.env import load_config, load_env
|
3
|
+
|
4
|
+
load_env(__name__)
|
5
|
+
load_config(__name__)
|
6
|
+
|
7
|
+
|
8
|
+
BLUE_ASSISTANT_DEFAULT_MODEL = os.getenv(
|
9
|
+
"BLUE_ASSISTANT_DEFAULT_MODEL",
|
10
|
+
"",
|
11
|
+
)
|
12
|
+
|
13
|
+
BLUE_ASSISTANT_MAX_TOKEN_str = os.getenv("BLUE_ASSISTANT_MAX_TOKEN", "")
|
14
|
+
try:
|
15
|
+
BLUE_ASSISTANT_MAX_TOKEN = int(BLUE_ASSISTANT_MAX_TOKEN_str)
|
16
|
+
except Exception:
|
17
|
+
BLUE_ASSISTANT_MAX_TOKEN = 2000
|
@@ -28,7 +28,7 @@ parser.add_argument(
|
|
28
28
|
parser.add_argument(
|
29
29
|
"--verbose",
|
30
30
|
type=int,
|
31
|
-
default=
|
31
|
+
default=1,
|
32
32
|
help="0 | 1",
|
33
33
|
)
|
34
34
|
parser.add_argument(
|
@@ -58,11 +58,12 @@ if args.task == "list":
|
|
58
58
|
elif args.task == "run":
|
59
59
|
success, script = load_script(
|
60
60
|
script_name=args.script_name,
|
61
|
+
object_name=args.object_name,
|
61
62
|
verbose=args.verbose == 1,
|
62
63
|
)
|
63
64
|
|
64
65
|
if success:
|
65
|
-
success = script.run(
|
66
|
+
success = script.run()
|
66
67
|
else:
|
67
68
|
success = None
|
68
69
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from typing import List
|
2
|
+
|
3
|
+
from blue_assistant.script.actions.generic import GenericAction
|
4
|
+
from blue_assistant.script.actions.generate_image import GenerateImageAction
|
5
|
+
from blue_assistant.script.actions.generate_text import GenerateTextAction
|
6
|
+
from blue_assistant.script.actions.wip import WorkInProgressAction
|
7
|
+
from blue_assistant.logger import logger
|
8
|
+
|
9
|
+
list_of_actions: List[GenericAction] = [
|
10
|
+
GenericAction,
|
11
|
+
GenerateImageAction,
|
12
|
+
GenerateTextAction,
|
13
|
+
WorkInProgressAction,
|
14
|
+
]
|
@@ -0,0 +1,48 @@
|
|
1
|
+
from typing import List, Dict, Tuple, Type
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_assistant.script.actions.generic import GenericAction
|
5
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
6
|
+
from blue_assistant.script.actions import list_of_actions
|
7
|
+
|
8
|
+
from blue_assistant import NAME
|
9
|
+
from blue_assistant.logger import logger
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
|
14
|
+
def get_action_class(
|
15
|
+
action_name: str,
|
16
|
+
) -> Tuple[bool, Type[GenericAction]]:
|
17
|
+
for action_class in list_of_actions:
|
18
|
+
if action_class.name == action_name:
|
19
|
+
return True, action_class
|
20
|
+
|
21
|
+
logger.error(f"{action_name}: action not found.")
|
22
|
+
return False, GenericAction
|
23
|
+
|
24
|
+
|
25
|
+
def perform_action(
|
26
|
+
script: BaseScript,
|
27
|
+
node_name: str,
|
28
|
+
) -> bool:
|
29
|
+
action_name = script.nodes[node_name].get("action", "unknown")
|
30
|
+
|
31
|
+
success, action_class = get_action_class(action_name=action_name)
|
32
|
+
if not success:
|
33
|
+
return success
|
34
|
+
|
35
|
+
logger.info(
|
36
|
+
"{}.perform_action: {} == {} on {}".format(
|
37
|
+
NAME,
|
38
|
+
action_name,
|
39
|
+
action_class.__name__,
|
40
|
+
node_name,
|
41
|
+
)
|
42
|
+
)
|
43
|
+
|
44
|
+
action_object = action_class(
|
45
|
+
script=script,
|
46
|
+
)
|
47
|
+
|
48
|
+
return action_object.perform(node_name=node_name)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from typing import Dict, Tuple
|
2
|
+
|
3
|
+
from blue_objects import file
|
4
|
+
|
5
|
+
from blue_assistant.script.actions.generic import GenericAction
|
6
|
+
from blue_assistant.logger import logger
|
7
|
+
|
8
|
+
|
9
|
+
class GenerateImageAction(GenericAction):
|
10
|
+
name = file.name(__file__)
|
11
|
+
|
12
|
+
def perform(
|
13
|
+
self,
|
14
|
+
node_name: str,
|
15
|
+
) -> bool:
|
16
|
+
if not super().perform(node_name=node_name):
|
17
|
+
return False
|
18
|
+
|
19
|
+
logger.info(f"🪄 generating image ...: {node_name}")
|
20
|
+
|
21
|
+
return True
|
@@ -0,0 +1,93 @@
|
|
1
|
+
from typing import Dict, Tuple, List
|
2
|
+
from openai import OpenAI
|
3
|
+
import pprint
|
4
|
+
|
5
|
+
from blueness import module
|
6
|
+
from blue_objects import file
|
7
|
+
from openai_commands.env import OPENAI_API_KEY
|
8
|
+
|
9
|
+
from blue_assistant import NAME
|
10
|
+
from blue_assistant.env import BLUE_ASSISTANT_DEFAULT_MODEL, BLUE_ASSISTANT_MAX_TOKEN
|
11
|
+
from blue_assistant.script.actions.generic import GenericAction
|
12
|
+
from blue_assistant.logger import logger
|
13
|
+
|
14
|
+
NAME = module.name(__file__, NAME)
|
15
|
+
|
16
|
+
|
17
|
+
class GenerateTextAction(GenericAction):
|
18
|
+
name = file.name(__file__)
|
19
|
+
|
20
|
+
def perform(
|
21
|
+
self,
|
22
|
+
node_name: str,
|
23
|
+
) -> bool:
|
24
|
+
if not OPENAI_API_KEY:
|
25
|
+
logger.error("OPENAI_API_KEY is not set.")
|
26
|
+
return False
|
27
|
+
|
28
|
+
if not super().perform(node_name=node_name):
|
29
|
+
return False
|
30
|
+
|
31
|
+
messages: List = []
|
32
|
+
node_history = self.script.get_history(node_name)
|
33
|
+
logger.info("node history: {}".format(node_history))
|
34
|
+
for successor in reversed(node_history):
|
35
|
+
messages += [
|
36
|
+
{
|
37
|
+
"role": "user",
|
38
|
+
"content": [
|
39
|
+
{
|
40
|
+
"type": "text",
|
41
|
+
"text": self.script.apply_vars(
|
42
|
+
self.script.nodes[successor]["prompt"]
|
43
|
+
),
|
44
|
+
}
|
45
|
+
],
|
46
|
+
}
|
47
|
+
]
|
48
|
+
|
49
|
+
if self.script.G.nodes[successor]["completed"]:
|
50
|
+
messages += [
|
51
|
+
{
|
52
|
+
"role": "assistant",
|
53
|
+
"content": [
|
54
|
+
{
|
55
|
+
"type": "text",
|
56
|
+
"text": self.script.nodes[successor]["output"],
|
57
|
+
}
|
58
|
+
],
|
59
|
+
}
|
60
|
+
]
|
61
|
+
|
62
|
+
if self.script.verbose:
|
63
|
+
logger.info(f"messages: {pprint.pformat(messages)}")
|
64
|
+
|
65
|
+
client = OpenAI(api_key=OPENAI_API_KEY)
|
66
|
+
|
67
|
+
try:
|
68
|
+
response = client.chat.completions.create(
|
69
|
+
messages=messages,
|
70
|
+
model=BLUE_ASSISTANT_DEFAULT_MODEL,
|
71
|
+
max_tokens=BLUE_ASSISTANT_MAX_TOKEN,
|
72
|
+
)
|
73
|
+
except Exception as e:
|
74
|
+
logger.error(str(e))
|
75
|
+
return False
|
76
|
+
|
77
|
+
if self.script.verbose:
|
78
|
+
logger.info("response: {}".format(response))
|
79
|
+
|
80
|
+
if not response.choices:
|
81
|
+
logger.error("no choice.")
|
82
|
+
return False
|
83
|
+
|
84
|
+
output = response.choices[0].message.content
|
85
|
+
logger.info(f"🗣️ output: {output}")
|
86
|
+
|
87
|
+
self.script.G.nodes[node_name]["output"] = output
|
88
|
+
|
89
|
+
var_name = self.script.nodes[node_name].get("output", "")
|
90
|
+
if var_name:
|
91
|
+
self.script.vars[var_name] = output
|
92
|
+
|
93
|
+
return True
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from typing import Dict, Tuple
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_objects import file
|
5
|
+
|
6
|
+
from blue_assistant import NAME
|
7
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
NAME = module.name(__file__, NAME)
|
11
|
+
|
12
|
+
|
13
|
+
class GenericAction:
|
14
|
+
name = file.name(__file__)
|
15
|
+
|
16
|
+
def __init__(
|
17
|
+
self,
|
18
|
+
script: BaseScript,
|
19
|
+
):
|
20
|
+
self.script = script
|
21
|
+
|
22
|
+
def perform(
|
23
|
+
self,
|
24
|
+
node_name: str,
|
25
|
+
) -> bool:
|
26
|
+
logger.info(
|
27
|
+
"{}.perform({}) on {}.{} ...".format(
|
28
|
+
NAME,
|
29
|
+
self.__class__.__name__,
|
30
|
+
self.script.name,
|
31
|
+
node_name,
|
32
|
+
),
|
33
|
+
)
|
34
|
+
return True
|
@@ -0,0 +1,27 @@
|
|
1
|
+
from typing import Tuple, Type
|
2
|
+
|
3
|
+
from blue_assistant.script.repository import list_of_script_classes
|
4
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
5
|
+
from blue_assistant.logger import logger
|
6
|
+
|
7
|
+
|
8
|
+
def load_script(
|
9
|
+
script_name: str,
|
10
|
+
object_name: str,
|
11
|
+
verbose: bool = False,
|
12
|
+
) -> Tuple[bool, BaseScript]:
|
13
|
+
found: bool = False
|
14
|
+
script_class: Type[BaseScript] = BaseScript
|
15
|
+
for script_class_option in list_of_script_classes:
|
16
|
+
if script_class_option.name == script_name:
|
17
|
+
found = True
|
18
|
+
script_class = script_class_option
|
19
|
+
break
|
20
|
+
|
21
|
+
if not found:
|
22
|
+
logger.error(f"{script_name}: script not found.")
|
23
|
+
|
24
|
+
return found, script_class(
|
25
|
+
object_name=object_name,
|
26
|
+
verbose=verbose,
|
27
|
+
)
|
{blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/__init__.py
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import List, Type
|
2
2
|
|
3
|
-
from blue_assistant.script.repository.generic import GenericScript
|
3
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
4
4
|
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
5
5
|
from blue_assistant.script.repository.hue.classes import HueScript
|
6
6
|
from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
|
@@ -0,0 +1,69 @@
|
|
1
|
+
from typing import Dict, List
|
2
|
+
import os
|
3
|
+
from tqdm import tqdm
|
4
|
+
|
5
|
+
|
6
|
+
from blueness import module
|
7
|
+
from blue_objects import file, path
|
8
|
+
from blue_objects.metadata import post_to_object
|
9
|
+
|
10
|
+
from blue_assistant import NAME
|
11
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
12
|
+
from blue_assistant.script.actions.functions import perform_action
|
13
|
+
from blue_assistant.logger import logger
|
14
|
+
|
15
|
+
|
16
|
+
NAME = module.name(__file__, NAME)
|
17
|
+
|
18
|
+
|
19
|
+
class GenericScript(BaseScript):
|
20
|
+
name = path.name(file.path(__file__))
|
21
|
+
|
22
|
+
def run(
|
23
|
+
self,
|
24
|
+
) -> bool:
|
25
|
+
if not super().run():
|
26
|
+
return False
|
27
|
+
|
28
|
+
metadata: Dict[Dict] = {"nodes": {}}
|
29
|
+
success: bool = True
|
30
|
+
while (
|
31
|
+
not all(self.G.nodes[node]["completed"] for node in self.G.nodes)
|
32
|
+
and success
|
33
|
+
):
|
34
|
+
for node_name in tqdm(self.G.nodes):
|
35
|
+
if self.G.nodes[node_name]["completed"]:
|
36
|
+
continue
|
37
|
+
|
38
|
+
pending_dependencies = [
|
39
|
+
node_name_
|
40
|
+
for node_name_ in self.G.successors(node_name)
|
41
|
+
if not self.G.nodes[node_name_]["completed"]
|
42
|
+
]
|
43
|
+
if pending_dependencies:
|
44
|
+
logger.info(
|
45
|
+
'node "{}": {} pending dependenci(es): {}'.format(
|
46
|
+
node_name,
|
47
|
+
len(pending_dependencies),
|
48
|
+
", ".join(pending_dependencies),
|
49
|
+
)
|
50
|
+
)
|
51
|
+
continue
|
52
|
+
|
53
|
+
if not perform_action(
|
54
|
+
script=self,
|
55
|
+
node_name=node_name,
|
56
|
+
):
|
57
|
+
success = False
|
58
|
+
break
|
59
|
+
|
60
|
+
self.G.nodes[node_name]["completed"] = True
|
61
|
+
|
62
|
+
if not post_to_object(
|
63
|
+
self.object_name,
|
64
|
+
"output",
|
65
|
+
metadata,
|
66
|
+
):
|
67
|
+
return False
|
68
|
+
|
69
|
+
return success
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.66.1
|
4
4
|
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
@@ -16,7 +16,9 @@ Requires-Dist: blueness
|
|
16
16
|
Requires-Dist: blue-options
|
17
17
|
Requires-Dist: abcli
|
18
18
|
Requires-Dist: openai_commands
|
19
|
+
Requires-Dist: blueflow
|
19
20
|
Requires-Dist: boto3
|
21
|
+
Requires-Dist: openai
|
20
22
|
Requires-Dist: geojson
|
21
23
|
Requires-Dist: geopandas
|
22
24
|
Requires-Dist: matplotlib
|
@@ -28,6 +30,8 @@ Requires-Dist: pylint
|
|
28
30
|
Requires-Dist: pytest
|
29
31
|
Requires-Dist: python-dotenv[cli]
|
30
32
|
Requires-Dist: tqdm
|
33
|
+
Requires-Dist: networkx
|
34
|
+
Requires-Dist: pydot
|
31
35
|
Dynamic: author
|
32
36
|
Dynamic: author-email
|
33
37
|
Dynamic: classifier
|
@@ -68,4 +72,4 @@ graph LR
|
|
68
72
|
|
69
73
|
[](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [](https://pypi.org/project/blue-assistant/) [](https://pypistats.org/packages/blue-assistant)
|
70
74
|
|
71
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
75
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.66.1`](https://github.com/kamangir/blue-assistant).
|
@@ -40,6 +40,7 @@ blue_assistant/script/__init__.py
|
|
40
40
|
blue_assistant/script/__main__.py
|
41
41
|
blue_assistant/script/load.py
|
42
42
|
blue_assistant/script/actions/__init__.py
|
43
|
+
blue_assistant/script/actions/functions.py
|
43
44
|
blue_assistant/script/actions/generate_image.py
|
44
45
|
blue_assistant/script/actions/generate_text.py
|
45
46
|
blue_assistant/script/actions/generic.py
|
@@ -1 +0,0 @@
|
|
1
|
-
BLUE_ASSISTANT_TEST_OBJECT=blue-amo
|
@@ -1,40 +0,0 @@
|
|
1
|
-
from typing import List, Dict, Tuple, Type
|
2
|
-
|
3
|
-
from blue_assistant.script.actions.generic import GenericAction
|
4
|
-
from blue_assistant.script.actions.generate_image import GenerateImageAction
|
5
|
-
from blue_assistant.script.actions.generate_text import GenerateTextAction
|
6
|
-
from blue_assistant.script.actions.wip import WorkInProgressAction
|
7
|
-
from blue_assistant.logger import logger
|
8
|
-
|
9
|
-
list_of_actions: List[GenericAction] = [
|
10
|
-
GenericAction,
|
11
|
-
GenerateImageAction,
|
12
|
-
GenerateTextAction,
|
13
|
-
WorkInProgressAction,
|
14
|
-
]
|
15
|
-
|
16
|
-
|
17
|
-
def get_action_class(
|
18
|
-
action_name: str,
|
19
|
-
) -> Tuple[bool, Type[GenericAction]]:
|
20
|
-
for action_class in list_of_actions:
|
21
|
-
if action_class.name == action_name:
|
22
|
-
return True, action_class
|
23
|
-
|
24
|
-
logger.error(f"{action_name}: action not found.")
|
25
|
-
return False, GenericAction
|
26
|
-
|
27
|
-
|
28
|
-
def perform_action(
|
29
|
-
action_name: str,
|
30
|
-
node: Dict,
|
31
|
-
) -> Tuple[bool, Dict]:
|
32
|
-
success, action_class = get_action_class(action_name=action_name)
|
33
|
-
if not success:
|
34
|
-
return False, {
|
35
|
-
"error": f"{action_name}: action not found.",
|
36
|
-
}
|
37
|
-
|
38
|
-
action_object = action_class(node=node)
|
39
|
-
|
40
|
-
return action_object.perform()
|
@@ -1,21 +0,0 @@
|
|
1
|
-
from typing import Dict, Tuple
|
2
|
-
|
3
|
-
from blue_objects import file
|
4
|
-
|
5
|
-
from blue_assistant.script.actions.generic import GenericAction
|
6
|
-
from blue_assistant.logger import logger
|
7
|
-
|
8
|
-
|
9
|
-
class GenerateImageAction(GenericAction):
|
10
|
-
name = file.name(__file__)
|
11
|
-
|
12
|
-
def perform(self) -> Tuple[bool, Dict]:
|
13
|
-
success, generic_metadata = super().perform()
|
14
|
-
if not success:
|
15
|
-
return success, generic_metadata
|
16
|
-
|
17
|
-
logger.info(f"🪄 generating image ...: {self.node}")
|
18
|
-
metadata = {}
|
19
|
-
|
20
|
-
metadata.update(generic_metadata)
|
21
|
-
return True, metadata
|
@@ -1,21 +0,0 @@
|
|
1
|
-
from typing import Dict, Tuple
|
2
|
-
|
3
|
-
from blue_objects import file
|
4
|
-
|
5
|
-
from blue_assistant.script.actions.generic import GenericAction
|
6
|
-
from blue_assistant.logger import logger
|
7
|
-
|
8
|
-
|
9
|
-
class GenerateTextAction(GenericAction):
|
10
|
-
name = file.name(__file__)
|
11
|
-
|
12
|
-
def perform(self) -> Tuple[bool, Dict]:
|
13
|
-
success, generic_metadata = super().perform()
|
14
|
-
if not success:
|
15
|
-
return success, generic_metadata
|
16
|
-
|
17
|
-
logger.info(f"🪄 generating text ...: {self.node}")
|
18
|
-
metadata = {}
|
19
|
-
|
20
|
-
metadata.update(generic_metadata)
|
21
|
-
return True, metadata
|
@@ -1,25 +0,0 @@
|
|
1
|
-
from typing import Dict, Tuple
|
2
|
-
|
3
|
-
from blueness import module
|
4
|
-
from blue_objects import file
|
5
|
-
|
6
|
-
from blue_assistant import NAME
|
7
|
-
from blue_assistant.logger import logger
|
8
|
-
|
9
|
-
NAME = module.name(__file__, NAME)
|
10
|
-
|
11
|
-
|
12
|
-
class GenericAction:
|
13
|
-
name = file.name(__file__)
|
14
|
-
|
15
|
-
def __init__(self, node: Dict):
|
16
|
-
self.node = node
|
17
|
-
|
18
|
-
def perform(self) -> Tuple[bool, Dict]:
|
19
|
-
logger.info(
|
20
|
-
"{}.perform({}) ...".format(
|
21
|
-
NAME,
|
22
|
-
self.__class__.__name__,
|
23
|
-
),
|
24
|
-
)
|
25
|
-
return True, {}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
from typing import Tuple
|
2
|
-
|
3
|
-
from blue_assistant.script.repository import list_of_script_classes
|
4
|
-
from blue_assistant.script.repository.generic import GenericScript
|
5
|
-
from blue_assistant.logger import logger
|
6
|
-
|
7
|
-
|
8
|
-
def load_script(
|
9
|
-
script_name: str,
|
10
|
-
verbose: bool = False,
|
11
|
-
) -> Tuple[bool, GenericScript]:
|
12
|
-
for script_class in list_of_script_classes:
|
13
|
-
if script_class.name == script_name:
|
14
|
-
return True, script_class(verbose=verbose)
|
15
|
-
|
16
|
-
logger.error(f"{script_name}: script not found.")
|
17
|
-
return False, GenericScript(verbose=verbose)
|
@@ -1,104 +0,0 @@
|
|
1
|
-
from typing import Dict, List
|
2
|
-
import os
|
3
|
-
from tqdm import tqdm
|
4
|
-
|
5
|
-
|
6
|
-
from blueness import module
|
7
|
-
from blue_objects import file, path
|
8
|
-
from blue_objects.metadata import post_to_object
|
9
|
-
|
10
|
-
from blue_assistant import NAME
|
11
|
-
from blue_assistant.script.actions import perform_action
|
12
|
-
from blue_assistant.logger import logger
|
13
|
-
|
14
|
-
|
15
|
-
NAME = module.name(__file__, NAME)
|
16
|
-
|
17
|
-
|
18
|
-
class GenericScript:
|
19
|
-
name = path.name(file.path(__file__))
|
20
|
-
|
21
|
-
def __init__(
|
22
|
-
self,
|
23
|
-
verbose: bool = False,
|
24
|
-
):
|
25
|
-
self.verbose = verbose
|
26
|
-
|
27
|
-
metadata_filename = os.path.join(
|
28
|
-
file.path(__file__),
|
29
|
-
f"../{self.name}",
|
30
|
-
"metadata.yaml",
|
31
|
-
)
|
32
|
-
self.metadata: Dict
|
33
|
-
success, self.metadata = file.load_yaml(metadata_filename)
|
34
|
-
assert success, f"cannot load {self.name}/metadata.yaml"
|
35
|
-
|
36
|
-
logger.info("loaded {} node(s)".format(len(self.nodes)))
|
37
|
-
|
38
|
-
logger.info("loaded {} variable(s)".format(len(self.vars)))
|
39
|
-
if verbose:
|
40
|
-
for var_name, var_value in self.vars.items():
|
41
|
-
logger.info("{}: {}".format(var_name, var_value))
|
42
|
-
|
43
|
-
@property
|
44
|
-
def script(self) -> str:
|
45
|
-
return self.metadata.get("script", {})
|
46
|
-
|
47
|
-
@property
|
48
|
-
def nodes(self) -> str:
|
49
|
-
return self.metadata.get("script", {}).get("nodes", [])
|
50
|
-
|
51
|
-
@property
|
52
|
-
def vars(self) -> str:
|
53
|
-
return self.metadata.get("script", {}).get("vars", {})
|
54
|
-
|
55
|
-
def run(
|
56
|
-
self,
|
57
|
-
object_name: str,
|
58
|
-
) -> bool:
|
59
|
-
logger.info(
|
60
|
-
"{}.run: {}:{} -> {}".format(
|
61
|
-
NAME,
|
62
|
-
self.__class__.__name__,
|
63
|
-
self.name,
|
64
|
-
object_name,
|
65
|
-
)
|
66
|
-
)
|
67
|
-
|
68
|
-
if not post_to_object(
|
69
|
-
object_name,
|
70
|
-
"script",
|
71
|
-
self.script,
|
72
|
-
):
|
73
|
-
return False
|
74
|
-
|
75
|
-
metadata: Dict[Dict] = {"nodes": {}}
|
76
|
-
success: bool = True
|
77
|
-
for node_name, node in tqdm(self.nodes.items()):
|
78
|
-
logger.info(
|
79
|
-
"{}{}".format(
|
80
|
-
node_name,
|
81
|
-
f": {node}" if self.verbose else " ...",
|
82
|
-
)
|
83
|
-
)
|
84
|
-
|
85
|
-
assert isinstance(node, dict)
|
86
|
-
success, output = perform_action(
|
87
|
-
action_name=node.get("action", "unknown"),
|
88
|
-
node=node,
|
89
|
-
)
|
90
|
-
metadata["nodes"][node_name] = {
|
91
|
-
"success": success,
|
92
|
-
"output": output,
|
93
|
-
}
|
94
|
-
if not success:
|
95
|
-
break
|
96
|
-
|
97
|
-
if not post_to_object(
|
98
|
-
object_name,
|
99
|
-
"output",
|
100
|
-
metadata,
|
101
|
-
):
|
102
|
-
return False
|
103
|
-
|
104
|
-
return success
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/blue_amo/classes.py
RENAMED
File without changes
|
{blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant/script/repository/generic/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{blue_assistant-4.53.1 → blue_assistant-4.66.1}/blue_assistant.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|