blue-assistant 4.297.1__tar.gz → 4.319.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.297.1/blue_assistant.egg-info → blue_assistant-4.319.1}/PKG-INFO +2 -2
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/README.md +1 -1
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script/run.sh +1 -1
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/script_run.sh +2 -2
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/__init__.py +1 -1
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/script.py +1 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/__main__.py +10 -1
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/__init__.py +2 -2
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_image.py +4 -4
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_text.py +8 -4
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generic.py +3 -3
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/web_crawl.py +7 -6
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/__init__.py +4 -3
- blue_assistant-4.319.1/blue_assistant/script/repository/base/classes.py +21 -0
- blue_assistant-4.297.1/blue_assistant/script/repository/base/classes.py → blue_assistant-4.319.1/blue_assistant/script/repository/base/root.py +118 -35
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/actions/__init__.py +2 -2
- blue_assistant-4.297.1/blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py → blue_assistant-4.319.1/blue_assistant/script/repository/blue_amo/actions/setting_frame_prompts.py +5 -5
- blue_assistant-4.319.1/blue_assistant/script/repository/blue_amo/classes.py +58 -0
- blue_assistant-4.319.1/blue_assistant/script/repository/hue/classes.py +7 -0
- blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py +11 -0
- blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/actions/expanding_the_extractions.py +109 -0
- blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +15 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/web/crawl.py +5 -5
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/web/fetch.py +2 -2
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/web/functions.py +11 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1/blue_assistant.egg-info}/PKG-INFO +2 -2
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/SOURCES.txt +4 -3
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/setup.py +1 -1
- blue_assistant-4.297.1/blue_assistant/script/repository/blue_amo/classes.py +0 -81
- blue_assistant-4.297.1/blue_assistant/script/repository/generic/__init__.py +0 -1
- blue_assistant-4.297.1/blue_assistant/script/repository/generic/classes.py +0 -88
- blue_assistant-4.297.1/blue_assistant/script/repository/hue/classes.py +0 -7
- blue_assistant-4.297.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +0 -7
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/LICENSE +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/MANIFEST.in +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/abcli.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/actions.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/alias.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/browse.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/create_user.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/list.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/set.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script/list.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/README.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/help.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/version.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/web_crawl.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/web_fetch.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web/crawl.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web/fetch.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web.sh +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/README.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/__main__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/config.env +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/env.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/functions.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/__main__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/functions.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/hue.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/help/web.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/host.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/logger.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/sample.env +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/load.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/base/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/__main__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/api.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/colors.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/orbital_data_explorer/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/urls.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/web/__init__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/web/__main__.py +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/requires.txt +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/top_level.txt +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/pyproject.toml +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/requirements.txt +0 -0
- {blue_assistant-4.297.1 → blue_assistant-4.319.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.319.1
|
4
4
|
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
@@ -124,4 +124,4 @@ Also home to [`@web`](https://raw.githubusercontent.com/kamangir/blue-assistant/
|
|
124
124
|
|
125
125
|
[](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)
|
126
126
|
|
127
|
-
built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
127
|
+
built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.319.1`](https://github.com/kamangir/blue-assistant).
|
@@ -79,4 +79,4 @@ Also home to [`@web`](./blue_assistant/web/)
|
|
79
79
|
|
80
80
|
[](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)
|
81
81
|
|
82
|
-
built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.
|
82
|
+
built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.319.1`](https://github.com/kamangir/blue-assistant).
|
@@ -7,7 +7,7 @@ function blue_assistant_script_run() {
|
|
7
7
|
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
|
8
8
|
|
9
9
|
local script_options=$2
|
10
|
-
local script_name=$(abcli_option "$script_options" script
|
10
|
+
local script_name=$(abcli_option "$script_options" script base)
|
11
11
|
|
12
12
|
local object_name=$(abcli_clarify_object $3 $script_name-$(abcli_string_timestamp_short))
|
13
13
|
[[ "$do_download" == 1 ]] &&
|
@@ -48,6 +48,13 @@ parser.add_argument(
|
|
48
48
|
default=1,
|
49
49
|
help="0 | 1",
|
50
50
|
)
|
51
|
+
parser.add_argument(
|
52
|
+
"--runnable",
|
53
|
+
type=str,
|
54
|
+
default="",
|
55
|
+
help="~node_1,~node_2",
|
56
|
+
)
|
57
|
+
|
51
58
|
args = parser.parse_args()
|
52
59
|
|
53
60
|
delim = " " if args.delim == "space" else args.delim
|
@@ -70,7 +77,9 @@ elif args.task == "run":
|
|
70
77
|
)
|
71
78
|
|
72
79
|
if success:
|
73
|
-
success = script.run(
|
80
|
+
success = script.run(
|
81
|
+
runnable=args.runnable,
|
82
|
+
)
|
74
83
|
else:
|
75
84
|
success = None
|
76
85
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
from typing import Dict, Callable
|
2
2
|
|
3
|
-
from blue_assistant.script.repository.base.
|
3
|
+
from blue_assistant.script.repository.base.root import RootScript
|
4
4
|
from blue_assistant.script.actions.generic import generic_action
|
5
5
|
from blue_assistant.script.actions.generate_image import generate_image
|
6
6
|
from blue_assistant.script.actions.generate_text import generate_text
|
7
7
|
from blue_assistant.script.actions.web_crawl import web_crawl
|
8
8
|
|
9
9
|
|
10
|
-
dict_of_actions: Dict[str, Callable[[
|
10
|
+
dict_of_actions: Dict[str, Callable[[RootScript, str], bool]] = {
|
11
11
|
"generic": generic_action,
|
12
12
|
"generate_image": generate_image,
|
13
13
|
"generate_text": generate_text,
|
{blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_image.py
RENAMED
@@ -7,7 +7,7 @@ from blue_assistant.env import (
|
|
7
7
|
BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE,
|
8
8
|
BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY,
|
9
9
|
)
|
10
|
-
from blue_assistant.script.repository.base.
|
10
|
+
from blue_assistant.script.repository.base.root import RootScript
|
11
11
|
from blue_assistant.logger import logger
|
12
12
|
|
13
13
|
NAME = module.name(__file__, NAME)
|
@@ -15,15 +15,15 @@ NAME = module.name(__file__, NAME)
|
|
15
15
|
|
16
16
|
# https://platform.openai.com/docs/guides/images
|
17
17
|
def generate_image(
|
18
|
-
script:
|
18
|
+
script: RootScript,
|
19
19
|
node_name: str,
|
20
20
|
) -> bool:
|
21
|
-
logger.info(f"{NAME}:
|
21
|
+
logger.info(f"{NAME}: @ {node_name} ...")
|
22
22
|
|
23
23
|
filename = f"{node_name}.png"
|
24
24
|
|
25
25
|
success, _ = api.generate_image(
|
26
|
-
prompt=script.nodes[node_name]["prompt"],
|
26
|
+
prompt=script.apply_vars(script.nodes[node_name]["prompt"]),
|
27
27
|
filename=filename,
|
28
28
|
object_name=script.object_name,
|
29
29
|
model=BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
|
{blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_text.py
RENAMED
@@ -4,7 +4,7 @@ from blueness import module
|
|
4
4
|
from openai_commands.text_generation import api
|
5
5
|
|
6
6
|
from blue_assistant import NAME
|
7
|
-
from blue_assistant.script.repository.base.
|
7
|
+
from blue_assistant.script.repository.base.root import RootScript
|
8
8
|
from blue_assistant.env import (
|
9
9
|
BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
|
10
10
|
BLUE_ASSISTANT_TEXT_MAX_TOKENS,
|
@@ -16,13 +16,17 @@ NAME = module.name(__file__, NAME)
|
|
16
16
|
|
17
17
|
# https://platform.openai.com/docs/guides/text-generation
|
18
18
|
def generate_text(
|
19
|
-
script:
|
19
|
+
script: RootScript,
|
20
20
|
node_name: str,
|
21
21
|
) -> bool:
|
22
|
-
logger.info(f"{NAME}:
|
22
|
+
logger.info(f"{NAME}: @ {node_name} ...")
|
23
|
+
|
24
|
+
list_of_context_nodes = [node_name]
|
25
|
+
if script.nodes[node_name].get("use_context", False):
|
26
|
+
logger.info("📜 using context.")
|
27
|
+
list_of_context_nodes = script.get_context(node_name)
|
23
28
|
|
24
29
|
messages: List = []
|
25
|
-
list_of_context_nodes = script.get_context(node_name)
|
26
30
|
logger.info("node context: {}".format(" <- ".join(list_of_context_nodes)))
|
27
31
|
for context_node in reversed(list_of_context_nodes):
|
28
32
|
messages += [
|
@@ -1,15 +1,15 @@
|
|
1
1
|
from blueness import module
|
2
2
|
|
3
3
|
from blue_assistant import NAME
|
4
|
-
from blue_assistant.script.repository.base.
|
4
|
+
from blue_assistant.script.repository.base.root import RootScript
|
5
5
|
from blue_assistant.logger import logger
|
6
6
|
|
7
7
|
NAME = module.name(__file__, NAME)
|
8
8
|
|
9
9
|
|
10
10
|
def generic_action(
|
11
|
-
script:
|
11
|
+
script: RootScript,
|
12
12
|
node_name: str,
|
13
13
|
) -> bool:
|
14
|
-
logger.info(f"{NAME}:
|
14
|
+
logger.info(f"{NAME}: @ {node_name} ...")
|
15
15
|
return True
|
{blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/web_crawl.py
RENAMED
@@ -4,7 +4,8 @@ from blue_options.logger import log_list
|
|
4
4
|
|
5
5
|
from blue_assistant import NAME
|
6
6
|
from blue_assistant.web.crawl import crawl_list_of_urls
|
7
|
-
from blue_assistant.
|
7
|
+
from blue_assistant.web.functions import normalize_url
|
8
|
+
from blue_assistant.script.repository.base.root import RootScript
|
8
9
|
from blue_assistant.logger import logger
|
9
10
|
|
10
11
|
|
@@ -12,10 +13,10 @@ NAME = module.name(__file__, NAME)
|
|
12
13
|
|
13
14
|
|
14
15
|
def web_crawl(
|
15
|
-
script:
|
16
|
+
script: RootScript,
|
16
17
|
node_name: str,
|
17
18
|
) -> bool:
|
18
|
-
logger.info(f"{NAME}:
|
19
|
+
logger.info(f"{NAME}: @ {node_name} ...")
|
19
20
|
|
20
21
|
seed_url_var_name = script.nodes[node_name].get("seed_urls", "")
|
21
22
|
if not isinstance(seed_url_var_name, str):
|
@@ -32,16 +33,16 @@ def web_crawl(
|
|
32
33
|
if seed_url_var_name not in script.vars:
|
33
34
|
logger.error(f"{node_name}: {seed_url_var_name}: seed_urls not found in vars.")
|
34
35
|
return False
|
35
|
-
seed_urls = script.vars[seed_url_var_name]
|
36
|
+
seed_urls = list({normalize_url(url) for url in script.vars[seed_url_var_name]})
|
36
37
|
log_list(logger, "using", seed_urls, "seed url(s)")
|
37
38
|
|
38
|
-
success,
|
39
|
+
success, crawl_cache = crawl_list_of_urls(
|
39
40
|
seed_urls=seed_urls,
|
40
41
|
object_name=script.object_name,
|
41
42
|
max_iterations=script.nodes[node_name]["max_iterations"],
|
42
43
|
cache_prefix=node_name,
|
43
44
|
)
|
44
45
|
|
45
|
-
script.nodes[node_name]["output"] =
|
46
|
+
script.nodes[node_name]["output"] = crawl_cache
|
46
47
|
|
47
48
|
return success
|
{blue_assistant-4.297.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/__init__.py
RENAMED
@@ -1,14 +1,15 @@
|
|
1
1
|
from typing import List, Type
|
2
2
|
|
3
|
-
from blue_assistant.script.repository.
|
3
|
+
from blue_assistant.script.repository.base.root import RootScript
|
4
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
4
5
|
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
5
6
|
from blue_assistant.script.repository.hue.classes import HueScript
|
6
7
|
from blue_assistant.script.repository.orbital_data_explorer.classes import (
|
7
8
|
OrbitalDataExplorerScript,
|
8
9
|
)
|
9
10
|
|
10
|
-
list_of_script_classes: List[Type[
|
11
|
-
|
11
|
+
list_of_script_classes: List[Type[RootScript]] = [
|
12
|
+
BaseScript,
|
12
13
|
BlueAmoScript,
|
13
14
|
HueScript,
|
14
15
|
OrbitalDataExplorerScript,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_objects import file, path
|
5
|
+
|
6
|
+
from blue_assistant import NAME
|
7
|
+
from blue_assistant.script.repository.base.root import RootScript
|
8
|
+
from blue_assistant.script.actions import dict_of_actions
|
9
|
+
from blue_assistant.logger import logger
|
10
|
+
|
11
|
+
|
12
|
+
NAME = module.name(__file__, NAME)
|
13
|
+
|
14
|
+
|
15
|
+
class BaseScript(RootScript):
|
16
|
+
name = path.name(file.path(__file__))
|
17
|
+
|
18
|
+
def __init__(self, **kwargs):
|
19
|
+
super().__init__(**kwargs)
|
20
|
+
|
21
|
+
self.dict_of_actions = copy.deepcopy(dict_of_actions)
|
@@ -1,22 +1,19 @@
|
|
1
|
-
from typing import Dict, List
|
2
1
|
import os
|
3
|
-
import
|
2
|
+
from typing import Dict, List
|
4
3
|
from functools import reduce
|
4
|
+
import networkx as nx
|
5
|
+
from tqdm import tqdm
|
5
6
|
|
6
|
-
from
|
7
|
-
from blue_objects import file, objects
|
7
|
+
from blue_options.options import Options
|
8
|
+
from blue_objects import file, path, objects
|
8
9
|
from blue_objects.metadata import post_to_object
|
9
10
|
from blueflow.workflow import dot_file
|
10
11
|
|
11
|
-
from blue_assistant import NAME
|
12
12
|
from blue_assistant.logger import logger
|
13
13
|
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
class BaseScript:
|
19
|
-
name = "base"
|
15
|
+
class RootScript:
|
16
|
+
name = path.name(file.path(__file__))
|
20
17
|
|
21
18
|
def __init__(
|
22
19
|
self,
|
@@ -24,12 +21,16 @@ class BaseScript:
|
|
24
21
|
test_mode: bool = False,
|
25
22
|
verbose: bool = False,
|
26
23
|
):
|
24
|
+
self.nodes_changed = False
|
25
|
+
|
27
26
|
self.object_name = object_name
|
28
27
|
|
29
28
|
self.test_mode = test_mode
|
30
29
|
|
31
30
|
self.verbose = verbose
|
32
31
|
|
32
|
+
self.dict_of_actions = {}
|
33
|
+
|
33
34
|
metadata_filename = os.path.join(
|
34
35
|
file.path(__file__),
|
35
36
|
f"../{self.name}",
|
@@ -66,12 +67,12 @@ class BaseScript:
|
|
66
67
|
if self.test_mode:
|
67
68
|
logger.info("🧪 test mode is on.")
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
self.vars.update(updates)
|
70
|
+
if "test_mode" in self.script:
|
71
|
+
updates = self.script["test_mode"]
|
72
|
+
logger.info(f"🧪 vars.update({updates})")
|
73
|
+
self.vars.update(updates)
|
74
74
|
|
75
|
+
for node_name, node in self.nodes.items():
|
75
76
|
if "test_mode" in node:
|
76
77
|
updates = node["test_mode"]
|
77
78
|
logger.info(f"🧪 {node_name}.update({updates})")
|
@@ -85,9 +86,9 @@ class BaseScript:
|
|
85
86
|
)
|
86
87
|
|
87
88
|
logger.info(
|
88
|
-
"loaded {} var(s){}".format(
|
89
|
+
"loaded {} var(s): {}".format(
|
89
90
|
len(self.vars),
|
90
|
-
"
|
91
|
+
", ".join(self.vars.keys()),
|
91
92
|
)
|
92
93
|
)
|
93
94
|
if verbose:
|
@@ -108,9 +109,17 @@ class BaseScript:
|
|
108
109
|
for var_name, var_value in self.vars.items():
|
109
110
|
text = text.replace(f":::{var_name}", str(var_value))
|
110
111
|
|
112
|
+
for node_name, node in self.nodes.items():
|
113
|
+
node_output = node.get("output", "")
|
114
|
+
if isinstance(node_output, str):
|
115
|
+
text = text.replace(f":::{node_name}", node_output)
|
116
|
+
|
111
117
|
return text
|
112
118
|
|
113
|
-
def generate_graph(
|
119
|
+
def generate_graph(
|
120
|
+
self,
|
121
|
+
verbose: bool = False,
|
122
|
+
) -> bool:
|
114
123
|
self.G: nx.DiGraph = nx.DiGraph()
|
115
124
|
|
116
125
|
list_of_nodes = list(self.nodes.keys())
|
@@ -118,12 +127,13 @@ class BaseScript:
|
|
118
127
|
list_of_nodes += node.get("depends-on", "").split(",")
|
119
128
|
|
120
129
|
list_of_nodes = list({node_name for node_name in list_of_nodes if node_name})
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
130
|
+
if verbose:
|
131
|
+
logger.info(
|
132
|
+
"{} node(s): {}".format(
|
133
|
+
len(list_of_nodes),
|
134
|
+
", ".join(list_of_nodes),
|
135
|
+
)
|
125
136
|
)
|
126
|
-
)
|
127
137
|
|
128
138
|
for node_name in list_of_nodes:
|
129
139
|
self.G.add_node(node_name)
|
@@ -145,23 +155,96 @@ class BaseScript:
|
|
145
155
|
[node_name],
|
146
156
|
)
|
147
157
|
|
148
|
-
def
|
158
|
+
def perform_action(
|
149
159
|
self,
|
160
|
+
node_name: str,
|
150
161
|
) -> bool:
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
self
|
162
|
+
action_name = self.nodes[node_name].get("action", "unknown")
|
163
|
+
logger.info(f"---- node: {node_name} ---- ")
|
164
|
+
|
165
|
+
if action_name in self.dict_of_actions:
|
166
|
+
return self.dict_of_actions[action_name](
|
167
|
+
script=self,
|
168
|
+
node_name=node_name,
|
157
169
|
)
|
158
|
-
)
|
159
170
|
|
160
|
-
|
171
|
+
logger.error(f"{action_name}: action not found.")
|
172
|
+
return False
|
173
|
+
|
174
|
+
def run(
|
175
|
+
self,
|
176
|
+
runnable: str = "",
|
177
|
+
) -> bool:
|
178
|
+
logger.info(f"{self.name}.run -> {self.object_name}")
|
179
|
+
|
180
|
+
if runnable:
|
181
|
+
logger.info(f"applying runnables: {runnable}")
|
182
|
+
runnable_options = Options(runnable)
|
183
|
+
for node_name, node_is_runnable in runnable_options.items():
|
184
|
+
logger.info(f"{node_name}.runnable={node_is_runnable}")
|
185
|
+
self.nodes[node_name]["runnable"] = node_is_runnable
|
186
|
+
|
187
|
+
success: bool = True
|
188
|
+
while (
|
189
|
+
not all(self.nodes[node].get("completed", False) for node in self.nodes)
|
190
|
+
and success
|
191
|
+
):
|
192
|
+
self.nodes_changed = False
|
193
|
+
|
194
|
+
for node_name in tqdm(self.nodes):
|
195
|
+
if self.nodes[node_name].get("completed", False):
|
196
|
+
continue
|
197
|
+
|
198
|
+
if not self.nodes[node_name].get("runnable", True):
|
199
|
+
logger.info(f"Not runnable, skipped: {node_name}.")
|
200
|
+
self.nodes[node_name]["completed"] = True
|
201
|
+
continue
|
202
|
+
|
203
|
+
pending_dependencies = [
|
204
|
+
node_name_
|
205
|
+
for node_name_ in self.G.successors(node_name)
|
206
|
+
if not self.nodes[node_name_].get("completed", False)
|
207
|
+
]
|
208
|
+
if pending_dependencies:
|
209
|
+
logger.info(
|
210
|
+
'node "{}": {} pending dependenci(es): {}'.format(
|
211
|
+
node_name,
|
212
|
+
len(pending_dependencies),
|
213
|
+
", ".join(pending_dependencies),
|
214
|
+
)
|
215
|
+
)
|
216
|
+
continue
|
217
|
+
|
218
|
+
if not self.perform_action(node_name=node_name):
|
219
|
+
success = False
|
220
|
+
break
|
221
|
+
|
222
|
+
self.nodes[node_name]["completed"] = True
|
223
|
+
|
224
|
+
cache_filename = self.nodes[node_name].get("cache", "")
|
225
|
+
if cache_filename:
|
226
|
+
if not file.save_text(
|
227
|
+
objects.path_of(
|
228
|
+
object_name=self.object_name,
|
229
|
+
filename=cache_filename,
|
230
|
+
),
|
231
|
+
[self.nodes[node_name].get("output", "")],
|
232
|
+
):
|
233
|
+
success = False
|
234
|
+
break
|
235
|
+
|
236
|
+
if self.nodes_changed:
|
237
|
+
logger.info("🪄 nodes changed.")
|
238
|
+
break
|
239
|
+
|
240
|
+
if not post_to_object(
|
161
241
|
self.object_name,
|
162
|
-
"
|
163
|
-
self.
|
164
|
-
)
|
242
|
+
"output",
|
243
|
+
self.metadata,
|
244
|
+
):
|
245
|
+
success = False
|
246
|
+
|
247
|
+
return success
|
165
248
|
|
166
249
|
def save_graph(self) -> bool:
|
167
250
|
return dot_file.save_to_file(
|
@@ -2,12 +2,12 @@ from typing import Dict, Callable
|
|
2
2
|
|
3
3
|
from blue_assistant.script.repository.base.classes import BaseScript
|
4
4
|
from blue_assistant.script.repository.blue_amo.actions import (
|
5
|
-
|
5
|
+
setting_frame_prompts,
|
6
6
|
stitching_the_frames,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
|
11
|
-
"
|
11
|
+
"setting_frame_prompts": setting_frame_prompts.setting_frame_prompts,
|
12
12
|
"stitching_the_frames": stitching_the_frames.stitching_the_frames,
|
13
13
|
}
|
@@ -7,13 +7,13 @@ from blue_assistant.logger import logger
|
|
7
7
|
NAME = module.name(__file__, NAME)
|
8
8
|
|
9
9
|
|
10
|
-
def
|
10
|
+
def setting_frame_prompts(
|
11
11
|
script: BaseScript,
|
12
12
|
node_name: str,
|
13
13
|
) -> bool:
|
14
|
-
logger.info(
|
14
|
+
logger.info(NAME)
|
15
15
|
|
16
|
-
list_of_frame_prompts = script.nodes[
|
16
|
+
list_of_frame_prompts = script.nodes["slicing_into_frames"]["output"].split("---")
|
17
17
|
if len(list_of_frame_prompts) != script.vars["frame_count"]:
|
18
18
|
logger.warning(
|
19
19
|
"{} != {}, frame count doesn't match, bad AI! 😁".format(
|
@@ -31,8 +31,8 @@ def slicing_into_frames(
|
|
31
31
|
|
32
32
|
script.nodes[node_name]["prompt"] = (
|
33
33
|
script.nodes[node_name]["prompt"]
|
34
|
-
.replace(":::
|
35
|
-
.replace(":::
|
34
|
+
.replace(":::story_so_far", " ".join(list_of_frame_prompts[:index]))
|
35
|
+
.replace(":::story_of_this_frame", list_of_frame_prompts[index])
|
36
36
|
)
|
37
37
|
|
38
38
|
return True
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_objects import file, path
|
5
|
+
|
6
|
+
from blue_assistant import NAME
|
7
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
8
|
+
from blue_assistant.script.repository.blue_amo.actions import dict_of_actions
|
9
|
+
from blue_assistant.logger import logger
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
|
14
|
+
class BlueAmoScript(BaseScript):
|
15
|
+
name = path.name(file.path(__file__))
|
16
|
+
|
17
|
+
def __init__(self, **kwargs):
|
18
|
+
super().__init__(**kwargs)
|
19
|
+
|
20
|
+
self.dict_of_actions.update(dict_of_actions)
|
21
|
+
|
22
|
+
def generate_graph(
|
23
|
+
self,
|
24
|
+
verbose: bool = False,
|
25
|
+
) -> bool:
|
26
|
+
if not super().generate_graph(verbose=verbose):
|
27
|
+
return False
|
28
|
+
|
29
|
+
map_node_name = "generating_the_frames"
|
30
|
+
logger.info(
|
31
|
+
"{}: expanding {} X {}...".format(
|
32
|
+
NAME,
|
33
|
+
map_node_name,
|
34
|
+
self.vars["frame_count"],
|
35
|
+
)
|
36
|
+
)
|
37
|
+
|
38
|
+
map_node = self.nodes[map_node_name]
|
39
|
+
del self.nodes[map_node_name]
|
40
|
+
self.G.remove_node(map_node_name)
|
41
|
+
|
42
|
+
reduce_node_name = "stitching_the_frames"
|
43
|
+
for index in range(self.vars["frame_count"]):
|
44
|
+
node_name = f"generating_frame_{index+1:03d}"
|
45
|
+
|
46
|
+
self.nodes[node_name] = copy.deepcopy(map_node)
|
47
|
+
|
48
|
+
self.G.add_node(node_name)
|
49
|
+
self.G.add_edge(
|
50
|
+
node_name,
|
51
|
+
"setting_frame_prompts",
|
52
|
+
)
|
53
|
+
self.G.add_edge(
|
54
|
+
reduce_node_name,
|
55
|
+
node_name,
|
56
|
+
)
|
57
|
+
|
58
|
+
return self.save_graph()
|
blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
from typing import Dict, Callable
|
2
|
+
|
3
|
+
from blue_assistant.script.repository.base.classes import BaseScript
|
4
|
+
from blue_assistant.script.repository.orbital_data_explorer.actions import (
|
5
|
+
expanding_the_extractions,
|
6
|
+
)
|
7
|
+
|
8
|
+
|
9
|
+
dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
|
10
|
+
"expanding_the_extractions": expanding_the_extractions.expanding_the_extractions,
|
11
|
+
}
|