blue-assistant 4.297.1__tar.gz → 4.307.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.
Files changed (84) hide show
  1. {blue_assistant-4.297.1/blue_assistant.egg-info → blue_assistant-4.307.1}/PKG-INFO +2 -2
  2. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/README.md +1 -1
  3. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/script/run.sh +1 -1
  4. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/script_run.sh +2 -2
  5. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/__init__.py +1 -1
  6. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/actions/__init__.py +2 -2
  7. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/actions/generate_image.py +4 -4
  8. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/actions/generate_text.py +8 -4
  9. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/actions/generic.py +3 -3
  10. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/actions/web_crawl.py +3 -3
  11. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/__init__.py +4 -3
  12. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/base/classes.py +87 -29
  13. blue_assistant-4.307.1/blue_assistant/script/repository/base/root.py +5 -0
  14. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/blue_amo/actions/__init__.py +2 -2
  15. blue_assistant-4.297.1/blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py → blue_assistant-4.307.1/blue_assistant/script/repository/blue_amo/actions/setting_frame_prompts.py +5 -5
  16. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/blue_amo/classes.py +20 -34
  17. blue_assistant-4.307.1/blue_assistant/script/repository/hue/classes.py +7 -0
  18. blue_assistant-4.307.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +7 -0
  19. {blue_assistant-4.297.1 → blue_assistant-4.307.1/blue_assistant.egg-info}/PKG-INFO +2 -2
  20. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant.egg-info/SOURCES.txt +2 -3
  21. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/setup.py +0 -1
  22. blue_assistant-4.297.1/blue_assistant/script/repository/generic/__init__.py +0 -1
  23. blue_assistant-4.297.1/blue_assistant/script/repository/generic/classes.py +0 -88
  24. blue_assistant-4.297.1/blue_assistant/script/repository/hue/classes.py +0 -7
  25. blue_assistant-4.297.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +0 -7
  26. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/LICENSE +0 -0
  27. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/MANIFEST.in +0 -0
  28. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/abcli.sh +0 -0
  29. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/actions.sh +0 -0
  30. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/alias.sh +0 -0
  31. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  32. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/browse.sh +0 -0
  33. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/hue/create_user.sh +0 -0
  34. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/hue/list.sh +0 -0
  35. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/hue/set.sh +0 -0
  36. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/hue.sh +0 -0
  37. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/script/list.sh +0 -0
  38. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/script.sh +0 -0
  39. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  40. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  41. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  42. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  43. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/web_crawl.sh +0 -0
  44. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/tests/web_fetch.sh +0 -0
  45. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/web/crawl.sh +0 -0
  46. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/web/fetch.sh +0 -0
  47. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/.abcli/web.sh +0 -0
  48. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/README.py +0 -0
  49. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/__main__.py +0 -0
  50. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/config.env +0 -0
  51. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/env.py +0 -0
  52. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/functions.py +0 -0
  53. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/__init__.py +0 -0
  54. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/__main__.py +0 -0
  55. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/functions.py +0 -0
  56. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/hue.py +0 -0
  57. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/script.py +0 -0
  58. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/help/web.py +0 -0
  59. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/host.py +0 -0
  60. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/logger.py +0 -0
  61. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/sample.env +0 -0
  62. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/__init__.py +0 -0
  63. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/__main__.py +0 -0
  64. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/load.py +0 -0
  65. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/base/__init__.py +0 -0
  66. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  67. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +0 -0
  68. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/hue/__init__.py +0 -0
  69. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/hue/__main__.py +0 -0
  70. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/hue/api.py +0 -0
  71. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/hue/colors.py +0 -0
  72. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/script/repository/orbital_data_explorer/__init__.py +0 -0
  73. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/urls.py +0 -0
  74. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/web/__init__.py +0 -0
  75. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/web/__main__.py +0 -0
  76. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/web/crawl.py +0 -0
  77. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/web/fetch.py +0 -0
  78. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant/web/functions.py +0 -0
  79. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  80. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant.egg-info/requires.txt +0 -0
  81. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/blue_assistant.egg-info/top_level.txt +0 -0
  82. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/pyproject.toml +0 -0
  83. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/requirements.txt +0 -0
  84. {blue_assistant-4.297.1 → blue_assistant-4.307.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.297.1
3
+ Version: 4.307.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
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/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.297.1`](https://github.com/kamangir/blue-assistant).
127
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.1`](https://github.com/kamangir/blue-assistant).
@@ -79,4 +79,4 @@ Also home to [`@web`](./blue_assistant/web/)
79
79
 
80
80
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/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.297.1`](https://github.com/kamangir/blue-assistant).
82
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.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 generic)
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 ]] &&
@@ -18,9 +18,9 @@ function test_blue_assistant_script_run() {
18
18
  ~upload,$options \
19
19
  script=$script_name \
20
20
  $object_name \
21
- "${@:2}" \
22
21
  --test_mode 1 \
23
- --verbose 1
22
+ --verbose 1 \
23
+ "${@:2}"
24
24
 
25
25
  [[ $? -ne 0 ]] && return 1
26
26
 
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.297.1"
7
+ VERSION = "4.307.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -1,13 +1,13 @@
1
1
  from typing import Dict, Callable
2
2
 
3
- from blue_assistant.script.repository.base.classes import BaseScript
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[[BaseScript, str], bool]] = {
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,
@@ -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.classes import BaseScript
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: BaseScript,
18
+ script: RootScript,
19
19
  node_name: str,
20
20
  ) -> bool:
21
- logger.info(f"{NAME}: {script} @ {node_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,
@@ -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.classes import BaseScript
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: BaseScript,
19
+ script: RootScript,
20
20
  node_name: str,
21
21
  ) -> bool:
22
- logger.info(f"{NAME}: {script} @ {node_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.classes import BaseScript
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: BaseScript,
11
+ script: RootScript,
12
12
  node_name: str,
13
13
  ) -> bool:
14
- logger.info(f"{NAME}: {script} @ {node_name} ...")
14
+ logger.info(f"{NAME}: @ {node_name} ...")
15
15
  return True
@@ -4,7 +4,7 @@ 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.script.repository.base.classes import BaseScript
7
+ from blue_assistant.script.repository.base.root import RootScript
8
8
  from blue_assistant.logger import logger
9
9
 
10
10
 
@@ -12,10 +12,10 @@ NAME = module.name(__file__, NAME)
12
12
 
13
13
 
14
14
  def web_crawl(
15
- script: BaseScript,
15
+ script: RootScript,
16
16
  node_name: str,
17
17
  ) -> bool:
18
- logger.info(f"{NAME}: {script} @ {node_name} ...")
18
+ logger.info(f"{NAME}: @ {node_name} ...")
19
19
 
20
20
  seed_url_var_name = script.nodes[node_name].get("seed_urls", "")
21
21
  if not isinstance(seed_url_var_name, str):
@@ -1,14 +1,15 @@
1
1
  from typing import List, Type
2
2
 
3
- from blue_assistant.script.repository.generic.classes import GenericScript
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[GenericScript]] = [
11
- GenericScript,
11
+ list_of_script_classes: List[Type[RootScript]] = [
12
+ BaseScript,
12
13
  BlueAmoScript,
13
14
  HueScript,
14
15
  OrbitalDataExplorerScript,
@@ -1,22 +1,26 @@
1
- from typing import Dict, List
1
+ from typing import Dict, List, Callable
2
2
  import os
3
3
  import networkx as nx
4
4
  from functools import reduce
5
+ from tqdm import tqdm
6
+ import copy
5
7
 
6
8
  from blueness import module
7
- from blue_objects import file, objects
9
+ from blue_objects import file, objects, path
8
10
  from blue_objects.metadata import post_to_object
9
11
  from blueflow.workflow import dot_file
10
12
 
11
13
  from blue_assistant import NAME
14
+ from blue_assistant.script.repository.base.root import RootScript
15
+ from blue_assistant.script.actions import dict_of_actions
12
16
  from blue_assistant.logger import logger
13
17
 
14
18
 
15
19
  NAME = module.name(__file__, NAME)
16
20
 
17
21
 
18
- class BaseScript:
19
- name = "base"
22
+ class BaseScript(RootScript):
23
+ name = path.name(file.path(__file__))
20
24
 
21
25
  def __init__(
22
26
  self,
@@ -30,6 +34,8 @@ class BaseScript:
30
34
 
31
35
  self.verbose = verbose
32
36
 
37
+ self.dict_of_actions = copy.deepcopy(dict_of_actions)
38
+
33
39
  metadata_filename = os.path.join(
34
40
  file.path(__file__),
35
41
  f"../{self.name}",
@@ -66,12 +72,12 @@ class BaseScript:
66
72
  if self.test_mode:
67
73
  logger.info("🧪 test mode is on.")
68
74
 
69
- for node_name, node in self.nodes.items():
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)
75
+ if "test_mode" in self.script:
76
+ updates = self.script["test_mode"]
77
+ logger.info(f"🧪 vars.update({updates})")
78
+ self.vars.update(updates)
74
79
 
80
+ for node_name, node in self.nodes.items():
75
81
  if "test_mode" in node:
76
82
  updates = node["test_mode"]
77
83
  logger.info(f"🧪 {node_name}.update({updates})")
@@ -85,9 +91,9 @@ class BaseScript:
85
91
  )
86
92
 
87
93
  logger.info(
88
- "loaded {} var(s){}".format(
94
+ "loaded {} var(s): {}".format(
89
95
  len(self.vars),
90
- "" if verbose else ": {}".format(", ".join(self.vars.keys())),
96
+ ", ".join(self.vars.keys()),
91
97
  )
92
98
  )
93
99
  if verbose:
@@ -108,9 +114,15 @@ class BaseScript:
108
114
  for var_name, var_value in self.vars.items():
109
115
  text = text.replace(f":::{var_name}", str(var_value))
110
116
 
117
+ for node_name, node in self.nodes.items():
118
+ text = text.replace(f":::{node_name}", node.get("output", ""))
119
+
111
120
  return text
112
121
 
113
- def generate_graph(self) -> bool:
122
+ def generate_graph(
123
+ self,
124
+ verbose: bool = False,
125
+ ) -> bool:
114
126
  self.G: nx.DiGraph = nx.DiGraph()
115
127
 
116
128
  list_of_nodes = list(self.nodes.keys())
@@ -118,12 +130,13 @@ class BaseScript:
118
130
  list_of_nodes += node.get("depends-on", "").split(",")
119
131
 
120
132
  list_of_nodes = list({node_name for node_name in list_of_nodes if node_name})
121
- logger.info(
122
- "{} node(s): {}".format(
123
- len(list_of_nodes),
124
- ", ".join(list_of_nodes),
133
+ if verbose:
134
+ logger.info(
135
+ "{} node(s): {}".format(
136
+ len(list_of_nodes),
137
+ ", ".join(list_of_nodes),
138
+ )
125
139
  )
126
- )
127
140
 
128
141
  for node_name in list_of_nodes:
129
142
  self.G.add_node(node_name)
@@ -145,23 +158,68 @@ class BaseScript:
145
158
  [node_name],
146
159
  )
147
160
 
148
- def run(
161
+ def perform_action(
149
162
  self,
163
+ node_name: str,
150
164
  ) -> bool:
151
- logger.info(
152
- "{}.run: {}:{} -> {}".format(
153
- NAME,
154
- self.__class__.__name__,
155
- self.name,
156
- self.object_name,
165
+ action_name = self.nodes[node_name].get("action", "unknown")
166
+ logger.info(f"---- node: {node_name} ---- ")
167
+
168
+ if action_name in self.dict_of_actions:
169
+ return self.dict_of_actions[action_name](
170
+ script=self,
171
+ node_name=node_name,
157
172
  )
158
- )
159
173
 
160
- return post_to_object(
174
+ logger.error(f"{action_name}: action not found.")
175
+ return False
176
+
177
+ def run(self) -> bool:
178
+ logger.info(f"{self.name}.run -> {self.object_name}")
179
+
180
+ success: bool = True
181
+ while (
182
+ not all(self.nodes[node].get("completed", False) for node in self.nodes)
183
+ and success
184
+ ):
185
+ for node_name in tqdm(self.nodes):
186
+ if self.nodes[node_name].get("completed", False):
187
+ continue
188
+
189
+ if not self.nodes[node_name].get("runnable", True):
190
+ logger.info(f"Not runnable, skipped: {node_name}.")
191
+ self.nodes[node_name]["completed"] = True
192
+ continue
193
+
194
+ pending_dependencies = [
195
+ node_name_
196
+ for node_name_ in self.G.successors(node_name)
197
+ if not self.nodes[node_name_].get("completed", False)
198
+ ]
199
+ if pending_dependencies:
200
+ logger.info(
201
+ 'node "{}": {} pending dependenci(es): {}'.format(
202
+ node_name,
203
+ len(pending_dependencies),
204
+ ", ".join(pending_dependencies),
205
+ )
206
+ )
207
+ continue
208
+
209
+ if not self.perform_action(node_name=node_name):
210
+ success = False
211
+ break
212
+
213
+ self.nodes[node_name]["completed"] = True
214
+
215
+ if not post_to_object(
161
216
  self.object_name,
162
- "script",
163
- self.script,
164
- )
217
+ "output",
218
+ self.metadata,
219
+ ):
220
+ success = False
221
+
222
+ return success
165
223
 
166
224
  def save_graph(self) -> bool:
167
225
  return dot_file.save_to_file(
@@ -0,0 +1,5 @@
1
+ from blue_objects import file, objects, path
2
+
3
+
4
+ class RootScript:
5
+ name = path.name(file.path(__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
- slicing_into_frames,
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
- "slicing_into_frames": slicing_into_frames.slicing_into_frames,
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 slicing_into_frames(
10
+ def setting_frame_prompts(
11
11
  script: BaseScript,
12
12
  node_name: str,
13
13
  ) -> bool:
14
- logger.info(f"{NAME}: processing the output...")
14
+ logger.info(NAME)
15
15
 
16
- list_of_frame_prompts = script.nodes[node_name]["output"].split("---")
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(":::story", " ".join(list_of_frame_prompts[:index]))
35
- .replace(":::input", list_of_frame_prompts[index])
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
@@ -4,14 +4,14 @@ from blueness import module
4
4
  from blue_objects import file, path
5
5
 
6
6
  from blue_assistant import NAME
7
- from blue_assistant.script.repository.generic.classes import GenericScript
7
+ from blue_assistant.script.repository.base.classes import BaseScript
8
8
  from blue_assistant.script.repository.blue_amo.actions import dict_of_actions
9
9
  from blue_assistant.logger import logger
10
10
 
11
11
  NAME = module.name(__file__, NAME)
12
12
 
13
13
 
14
- class BlueAmoScript(GenericScript):
14
+ class BlueAmoScript(BaseScript):
15
15
  name = path.name(file.path(__file__))
16
16
 
17
17
  def __init__(
@@ -26,56 +26,42 @@ class BlueAmoScript(GenericScript):
26
26
  verbose=verbose,
27
27
  )
28
28
 
29
- if self.test_mode:
30
- self.vars["frame_count"] = 1
29
+ self.dict_of_actions.update(dict_of_actions)
31
30
 
32
- holder_node_name = "generating_the_frames"
31
+ def generate_graph(
32
+ self,
33
+ verbose: bool = False,
34
+ ) -> bool:
35
+ if not super().generate_graph(verbose=verbose):
36
+ return False
37
+
38
+ map_node_name = "generating_the_frames"
33
39
  logger.info(
34
40
  "{}: expanding {} X {}...".format(
35
41
  NAME,
36
- holder_node_name,
42
+ map_node_name,
37
43
  self.vars["frame_count"],
38
44
  )
39
45
  )
40
46
 
41
- holder_node = self.nodes[holder_node_name]
42
- del self.nodes[holder_node_name]
43
- self.G.remove_node(holder_node_name)
44
-
45
- reduce_node = "stitching_the_frames"
46
- self.G.add_node(reduce_node)
47
- self.nodes[reduce_node] = {"action": "generic"}
47
+ map_node = self.nodes[map_node_name]
48
+ del self.nodes[map_node_name]
49
+ self.G.remove_node(map_node_name)
48
50
 
51
+ reduce_node_name = "stitching_the_frames"
49
52
  for index in range(self.vars["frame_count"]):
50
53
  node_name = f"generating_frame_{index+1:03d}"
51
54
 
52
- self.nodes[node_name] = copy.deepcopy(holder_node)
55
+ self.nodes[node_name] = copy.deepcopy(map_node)
53
56
 
54
57
  self.G.add_node(node_name)
55
58
  self.G.add_edge(
56
59
  node_name,
57
- "slicing_into_frames",
60
+ "setting_frame_prompts",
58
61
  )
59
62
  self.G.add_edge(
60
- reduce_node,
63
+ reduce_node_name,
61
64
  node_name,
62
65
  )
63
66
 
64
- assert self.save_graph()
65
-
66
- def perform_action(
67
- self,
68
- node_name: str,
69
- ) -> bool:
70
- if not super().perform_action(
71
- node_name=node_name,
72
- ):
73
- return False
74
-
75
- if node_name in dict_of_actions:
76
- return dict_of_actions[node_name](
77
- script=self,
78
- node_name=node_name,
79
- )
80
-
81
- return True
67
+ return self.save_graph()
@@ -0,0 +1,7 @@
1
+ from blue_objects import file, path
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+
5
+
6
+ class HueScript(BaseScript):
7
+ name = path.name(file.path(__file__))
@@ -0,0 +1,7 @@
1
+ from blue_objects import file, path
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+
5
+
6
+ class OrbitalDataExplorerScript(BaseScript):
7
+ name = path.name(file.path(__file__))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.297.1
3
+ Version: 4.307.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
  [![pylint](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-assistant.svg)](https://pypi.org/project/blue-assistant/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/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.297.1`](https://github.com/kamangir/blue-assistant).
127
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.1`](https://github.com/kamangir/blue-assistant).
@@ -58,13 +58,12 @@ blue_assistant/script/actions/web_crawl.py
58
58
  blue_assistant/script/repository/__init__.py
59
59
  blue_assistant/script/repository/base/__init__.py
60
60
  blue_assistant/script/repository/base/classes.py
61
+ blue_assistant/script/repository/base/root.py
61
62
  blue_assistant/script/repository/blue_amo/__init__.py
62
63
  blue_assistant/script/repository/blue_amo/classes.py
63
64
  blue_assistant/script/repository/blue_amo/actions/__init__.py
64
- blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py
65
+ blue_assistant/script/repository/blue_amo/actions/setting_frame_prompts.py
65
66
  blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py
66
- blue_assistant/script/repository/generic/__init__.py
67
- blue_assistant/script/repository/generic/classes.py
68
67
  blue_assistant/script/repository/hue/__init__.py
69
68
  blue_assistant/script/repository/hue/__main__.py
70
69
  blue_assistant/script/repository/hue/api.py
@@ -16,7 +16,6 @@ setup(
16
16
  f"{NAME}.script.repository.base",
17
17
  f"{NAME}.script.repository.blue_amo",
18
18
  f"{NAME}.script.repository.blue_amo.actions",
19
- f"{NAME}.script.repository.generic",
20
19
  f"{NAME}.script.repository.hue",
21
20
  f"{NAME}.script.repository.orbital_data_explorer",
22
21
  f"{NAME}.web",
@@ -1 +0,0 @@
1
- from blue_assistant.script.repository.generic.classes import GenericScript
@@ -1,88 +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.repository.base.classes import BaseScript
12
- from blue_assistant.script.actions import dict_of_actions
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 perform_action(
23
- self,
24
- node_name: str,
25
- ) -> bool:
26
- action_name = self.nodes[node_name].get("action", "unknown")
27
- logger.info(f"---- node: {node_name} ---- ")
28
-
29
- if action_name not in dict_of_actions:
30
- logger.error(f"{action_name}: action not found.")
31
- return False
32
-
33
- return dict_of_actions[action_name](
34
- script=self,
35
- node_name=node_name,
36
- )
37
-
38
- def run(
39
- self,
40
- ) -> bool:
41
- if not super().run():
42
- return False
43
-
44
- success: bool = True
45
- while (
46
- not all(self.nodes[node].get("completed", False) for node in self.nodes)
47
- and success
48
- ):
49
- for node_name in tqdm(self.nodes):
50
- if self.nodes[node_name].get("completed", False):
51
- continue
52
-
53
- if not self.nodes[node_name].get("runnable", True):
54
- logger.info(f"Not runnable, skipped: {node_name}.")
55
- self.nodes[node_name]["completed"] = True
56
- continue
57
-
58
- pending_dependencies = [
59
- node_name_
60
- for node_name_ in self.G.successors(node_name)
61
- if not self.nodes[node_name_].get("completed", False)
62
- ]
63
- if pending_dependencies:
64
- logger.info(
65
- 'node "{}": {} pending dependenci(es): {}'.format(
66
- node_name,
67
- len(pending_dependencies),
68
- ", ".join(pending_dependencies),
69
- )
70
- )
71
- continue
72
-
73
- if not self.perform_action(
74
- node_name=node_name,
75
- ):
76
- success = False
77
- break
78
-
79
- self.nodes[node_name]["completed"] = True
80
-
81
- if not post_to_object(
82
- self.object_name,
83
- "output",
84
- self.metadata,
85
- ):
86
- return False
87
-
88
- return success
@@ -1,7 +0,0 @@
1
- from blue_objects import file, path
2
-
3
- from blue_assistant.script.repository.generic.classes import GenericScript
4
-
5
-
6
- class HueScript(GenericScript):
7
- name = path.name(file.path(__file__))
@@ -1,7 +0,0 @@
1
- from blue_objects import file, path
2
-
3
- from blue_assistant.script.repository.generic.classes import GenericScript
4
-
5
-
6
- class OrbitalDataExplorerScript(GenericScript):
7
- name = path.name(file.path(__file__))