blue-assistant 4.46.1__py3-none-any.whl → 4.53.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function blue_assistant_script_list() {
4
+ python3 -m blue_assistant.script \
5
+ list \
6
+ "$@"
7
+ }
@@ -20,6 +20,7 @@ function test_blue_assistant_help() {
20
20
  "@assistant browse" \
21
21
  \
22
22
  "@assistant script" \
23
+ "@assistant script list" \
23
24
  "@assistant script run" \
24
25
  \
25
26
  "blue_assistant"; do
@@ -0,0 +1,8 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_blue_assistant_script_list() {
4
+ abcli_assert "$(blue_assistant_script_list \
5
+ --delim + \
6
+ --log 0)" \
7
+ - non-empty
8
+ }
@@ -2,9 +2,9 @@
2
2
 
3
3
  function test_blue_assistant_script_run() {
4
4
  local options=$1
5
- local list_of_script_name=$(python3 -m blue_assistant.script \
6
- get_list_of \
7
- --delim +)
5
+ local list_of_script_name=$(blue_assistant_script_list \
6
+ --delim + \
7
+ --log 0)
8
8
  list_of_script_name=$(abcli_option "$options" script $list_of_script_name)
9
9
 
10
10
  local script_name
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.46.1"
7
+ VERSION = "4.53.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -5,6 +5,27 @@ from blue_options.terminal import show_usage, xtra
5
5
  from blue_assistant.script.repository import list_of_script_names
6
6
 
7
7
 
8
+ def help_list(
9
+ tokens: List[str],
10
+ mono: bool,
11
+ ) -> str:
12
+ args = [
13
+ "[--delim +]",
14
+ "[--log 0]",
15
+ ]
16
+
17
+ return show_usage(
18
+ [
19
+ "@assistant",
20
+ "script",
21
+ "list",
22
+ ]
23
+ + args,
24
+ "list scripts.",
25
+ mono=mono,
26
+ )
27
+
28
+
8
29
  def help_run(
9
30
  tokens: List[str],
10
31
  mono: bool,
@@ -33,4 +54,7 @@ def help_run(
33
54
  )
34
55
 
35
56
 
36
- help_functions = {"run": help_run}
57
+ help_functions = {
58
+ "list": help_list,
59
+ "run": help_run,
60
+ }
@@ -14,7 +14,7 @@ parser = argparse.ArgumentParser(NAME)
14
14
  parser.add_argument(
15
15
  "task",
16
16
  type=str,
17
- help="get_list_of | run",
17
+ help="list | run",
18
18
  )
19
19
  parser.add_argument(
20
20
  "--script_name",
@@ -34,16 +34,27 @@ parser.add_argument(
34
34
  parser.add_argument(
35
35
  "--delim",
36
36
  type=str,
37
- default="+",
37
+ default=", ",
38
+ )
39
+ parser.add_argument(
40
+ "--log",
41
+ type=int,
42
+ default=1,
43
+ help="0 | 1",
38
44
  )
39
45
  args = parser.parse_args()
40
46
 
41
47
  delim = " " if args.delim == "space" else args.delim
42
48
 
43
49
  success = False
44
- if args.task == "get_list_of":
50
+ if args.task == "list":
45
51
  success = True
46
- print(delim.join(list_of_script_names))
52
+ if args.log:
53
+ logger.info(f"{len(list_of_script_names)} script(s)")
54
+ for index, script_name in enumerate(list_of_script_names):
55
+ logger.info(f"#{index + 1: 3d}: {script_name}")
56
+ else:
57
+ print(delim.join(list_of_script_names))
47
58
  elif args.task == "run":
48
59
  success, script = load_script(
49
60
  script_name=args.script_name,
@@ -0,0 +1,40 @@
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()
@@ -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(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
@@ -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 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
@@ -0,0 +1,25 @@
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, {}
@@ -0,0 +1,7 @@
1
+ from blue_objects import file
2
+
3
+ from blue_assistant.script.actions.generic import GenericAction
4
+
5
+
6
+ class WorkInProgressAction(GenericAction):
7
+ name = file.name(__file__)
@@ -2,11 +2,13 @@ from typing import List, Type
2
2
 
3
3
  from blue_assistant.script.repository.generic import GenericScript
4
4
  from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
5
+ from blue_assistant.script.repository.hue.classes import HueScript
5
6
  from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
6
7
 
7
8
  list_of_script_classes: List[Type[GenericScript]] = [
8
9
  GenericScript,
9
10
  BlueAmoScript,
11
+ HueScript,
10
12
  MiningOnMoonScript,
11
13
  ]
12
14
 
@@ -1,8 +1,5 @@
1
- from typing import Dict
2
- from tqdm import tqdm
3
-
4
1
  from blue_objects import file, path
5
- from blue_objects.metadata import post_to_object
2
+
6
3
 
7
4
  from blue_assistant.script.repository.generic.classes import GenericScript
8
5
  from blue_assistant.logger import logger
@@ -10,33 +7,3 @@ from blue_assistant.logger import logger
10
7
 
11
8
  class BlueAmoScript(GenericScript):
12
9
  name = path.name(file.path(__file__))
13
-
14
- def __init__(
15
- self,
16
- verbose: bool = False,
17
- ):
18
- super().__init__(verbose=verbose)
19
-
20
- def run(
21
- self,
22
- object_name: str,
23
- ) -> bool:
24
- if not super().run(object_name=object_name):
25
- return False
26
-
27
- metadata: Dict[Dict] = {"nodes": {}}
28
- for node_name, node in tqdm(self.nodes.items()):
29
- logger.info(
30
- "{}{}".format(
31
- node_name,
32
- f": {node}" if self.verbose else " ...",
33
- )
34
- )
35
-
36
- metadata["nodes"][node_name] = "..."
37
-
38
- return post_to_object(
39
- object_name,
40
- "output",
41
- metadata,
42
- )
@@ -1,11 +1,14 @@
1
1
  from typing import Dict, List
2
2
  import os
3
+ from tqdm import tqdm
4
+
3
5
 
4
6
  from blueness import module
5
7
  from blue_objects import file, path
6
8
  from blue_objects.metadata import post_to_object
7
9
 
8
10
  from blue_assistant import NAME
11
+ from blue_assistant.script.actions import perform_action
9
12
  from blue_assistant.logger import logger
10
13
 
11
14
 
@@ -62,8 +65,40 @@ class GenericScript:
62
65
  )
63
66
  )
64
67
 
65
- return post_to_object(
68
+ if not post_to_object(
66
69
  object_name,
67
70
  "script",
68
71
  self.script,
69
- )
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
@@ -1,6 +1,3 @@
1
- from typing import Dict
2
- from tqdm import tqdm
3
-
4
1
  from blue_objects import file, path
5
2
 
6
3
  from blue_assistant.script.repository.generic.classes import GenericScript
@@ -8,9 +5,3 @@ from blue_assistant.script.repository.generic.classes import GenericScript
8
5
 
9
6
  class MiningOnMoonScript(GenericScript):
10
7
  name = path.name(file.path(__file__))
11
-
12
- def __init__(
13
- self,
14
- verbose: bool = False,
15
- ):
16
- super().__init__(verbose=verbose)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.46.1
3
+ Version: 4.53.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -48,11 +48,14 @@ pip install blue-assistant
48
48
 
49
49
  ```mermaid
50
50
  graph LR
51
+ assistant_script_list["@assistant<br>script<br>list"]
51
52
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
52
53
 
53
54
  script["📜 script"]:::folder
54
55
  object["📂 object"]:::folder
55
56
 
57
+ script --> assistant_script_list
58
+
56
59
  script --> assistant_script_run
57
60
  object --> assistant_script_run
58
61
  assistant_script_run --> object
@@ -65,4 +68,4 @@ graph LR
65
68
 
66
69
  [![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)
67
70
 
68
- built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.46.1`](https://github.com/kamangir/blue-assistant).
71
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.53.1`](https://github.com/kamangir/blue-assistant).
@@ -1,5 +1,5 @@
1
1
  blue_assistant/README.py,sha256=q6EWCy7zojQESGDF-2xEoXS1Bl0wRJTe2jw_1QM_WYw,600
2
- blue_assistant/__init__.py,sha256=2crVJo5raQnwN079oeoh9eqWGZ5kXO8K8mLcMtkvKS8,310
2
+ blue_assistant/__init__.py,sha256=ijv5qglSsBVMM0y7yEZ0y93LdWuwIKBCbQpDONBb8qk,310
3
3
  blue_assistant/__main__.py,sha256=URtal70XZc0--3FDTYWcLtnGOqBYjMX9gt-L1k8hDXI,361
4
4
  blue_assistant/config.env,sha256=es6XIU6yOA69IV0WXtLru5uTM5Dvvmq-q6BJmcE8NyY,36
5
5
  blue_assistant/env.py,sha256=TG2YL5jn7qJApHIGi7IuXvqcPFT771zXKJHomGC63Z4,189
@@ -14,27 +14,34 @@ blue_assistant/.abcli/alias.sh,sha256=MCJzXaDnX1QMllWsZJJkDePBYt1nY9ZWa3o4msfGD2
14
14
  blue_assistant/.abcli/blue_assistant.sh,sha256=plLTQQerVmfb_SNlOkv0MEaQCF7YdsOHzCq0M3FWT4c,239
15
15
  blue_assistant/.abcli/browse.sh,sha256=qZ_RK_WnsjmF-hfWKiMEOnnv22QtZh9HQ0VFJUbP6aI,294
16
16
  blue_assistant/.abcli/script.sh,sha256=XIkY4eZyFPKLi_mLoPMbnq76E4K1GG3xxha8VYJC2zI,356
17
+ blue_assistant/.abcli/script/list.sh,sha256=2lcVfqDfZP50NszF8o5YCo3TrJKeDc_qo7MTAF3XTGw,131
17
18
  blue_assistant/.abcli/script/run.sh,sha256=kSXmyM9NUj2X2orSGyu5t_P5frG-gyumbRq-xqF692c,911
18
19
  blue_assistant/.abcli/tests/README.sh,sha256=Qs0YUxVB1OZZ70Nqw2kT1LKXeUnC5-XfQRMfqb8Cbwg,152
19
- blue_assistant/.abcli/tests/help.sh,sha256=bxocRb83kKjrA7eeCmI-UaAlVPJZ_xfKy-woJciig_Y,689
20
- blue_assistant/.abcli/tests/script_run.sh,sha256=UXOvYOBe2FcqWywZvjyazDly6j9_GYAwuxLmmM4GLMM,725
20
+ blue_assistant/.abcli/tests/help.sh,sha256=mENB9ZNBEEPmIs9tp8WkQW3dq75_US7EI7_-d4IJQpo,724
21
+ blue_assistant/.abcli/tests/script_list.sh,sha256=OVOwWO9wR0eeDZTM6uub-eTKbz3eswU3vEUPWXcK-gQ,178
22
+ blue_assistant/.abcli/tests/script_run.sh,sha256=mBFLaIl2bMQhVjRr2EN4ciVUvYkaKcO7bY4uvt1oqB0,715
21
23
  blue_assistant/.abcli/tests/version.sh,sha256=oR2rvYR8zi-0VDPIdPJsmsmWwYaamT8dmNTqUh3-8Gw,154
22
24
  blue_assistant/help/__init__.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
23
25
  blue_assistant/help/__main__.py,sha256=cVejR7OpoWPg0qLbm-PZf5TuJS27x49jzfiyCLyzEns,241
24
26
  blue_assistant/help/functions.py,sha256=9WsmXGMN-R7sqlkGLK0nY90Peg8Gah4rIu75QbLhImo,689
25
- blue_assistant/help/script.py,sha256=knI6aNntFh8OxXuIaWYgcswLqHXz6_cppTvClvuSK-I,740
27
+ blue_assistant/help/script.py,sha256=wvS_5FWu9LAsaDDq7UoxXEadRwGseYqwu2P-9dNc5Bo,1077
26
28
  blue_assistant/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- blue_assistant/script/__main__.py,sha256=LAbStVfkw1-kCa7GcutCmimwLB37dTx1hG4LNU-6hXg,1229
29
+ blue_assistant/script/__main__.py,sha256=KLsDL226oI4aQDGeWEYfMdawIa766hCDNj8LZbeRjjI,1519
28
30
  blue_assistant/script/load.py,sha256=9hzXmHzJ9t8VcWna-oZbo7GWYDUnHou5LUMWD9l0HmA,555
29
- blue_assistant/script/repository/__init__.py,sha256=iuiwMKpqTjL4iaVnj4bS5Nev_MgiWKJmeJgZFlM5-lU,483
31
+ blue_assistant/script/actions/__init__.py,sha256=Hu7M_RpqbJN1xOi6v7qypGc42VRc7qL3oWuDf2ON0NE,1149
32
+ blue_assistant/script/actions/generate_image.py,sha256=mKRWOJ2wqarkSqbhkSmF_wpQKq30lUhHw7Xb0beFmLc,570
33
+ blue_assistant/script/actions/generate_text.py,sha256=_yRn_fKe9Fbu6-5r6T_F38LuLvNkBXdA7CEQIl_YcYE,568
34
+ blue_assistant/script/actions/generic.py,sha256=jdut1FJwEmYJ8IH20QOlbHr4eKq5lakF-ydJRdxKsCc,535
35
+ blue_assistant/script/actions/wip.py,sha256=K4kJE4bn3u6o-QWTESPydO_eD54zOwZbU9WLAO94z1Q,171
36
+ blue_assistant/script/repository/__init__.py,sha256=daNjBpj8gflXHcw5LR7vsIlDkRYH5-thMzJL3Al7Dnk,565
30
37
  blue_assistant/script/repository/blue_amo/__init__.py,sha256=WjL9GIlN-DBnbUMJ8O_FxTp0rcVGlsIS3H9YtXEefTk,76
31
- blue_assistant/script/repository/blue_amo/classes.py,sha256=8pG1yvpffAlg9GZ468DTpa8Cjs5nbGdMrnigJRvVq3A,1033
38
+ blue_assistant/script/repository/blue_amo/classes.py,sha256=RY1gjZVPX8xu7nfeiZoTL8RTpu73RsoaNv4ZoGv9NNs,234
32
39
  blue_assistant/script/repository/generic/__init__.py,sha256=kLffGsQMQAFJTw6IZBE5eBxvshP1x9wwHHR4hsDJblo,75
33
- blue_assistant/script/repository/generic/classes.py,sha256=2Op0rWgCy05WgVsEOt35bUzzBFL3IlPi_8zwMov4Vvo,1709
40
+ blue_assistant/script/repository/generic/classes.py,sha256=Rpctzo1E8XD30woNymDNu7oFgBOdVsW6GzWHuIHQ3y0,2656
34
41
  blue_assistant/script/repository/moon_datasets/__init__.py,sha256=aCtmP2avh3yKAJ668S3GsLR9vbBOm5zt9FSFCqy_tAs,86
35
- blue_assistant/script/repository/moon_datasets/classes.py,sha256=9LFbLAo06Jux9lWBRNOv_8QaXznPgqTqxmcZBWaWPDI,357
36
- blue_assistant-4.46.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
37
- blue_assistant-4.46.1.dist-info/METADATA,sha256=p4h03p5tr9WcIIrKfKZBd0pgCZxZ5EYONpF8Mw4DyC0,2438
38
- blue_assistant-4.46.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
39
- blue_assistant-4.46.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
40
- blue_assistant-4.46.1.dist-info/RECORD,,
42
+ blue_assistant/script/repository/moon_datasets/classes.py,sha256=68zThDhjF9gGRnsw8EKNLGOMBFbCSljt0jGovuOzCAc,197
43
+ blue_assistant-4.53.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
44
+ blue_assistant-4.53.1.dist-info/METADATA,sha256=gJZxJdSYagLNbM9EzJS6wyAg7wTrmzmKXsR66nRsixg,2534
45
+ blue_assistant-4.53.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
46
+ blue_assistant-4.53.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
47
+ blue_assistant-4.53.1.dist-info/RECORD,,