blue-assistant 4.46.1__tar.gz → 4.62.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 (61) hide show
  1. {blue_assistant-4.46.1/blue_assistant.egg-info → blue_assistant-4.62.1}/PKG-INFO +9 -2
  2. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/README.md +4 -1
  3. blue_assistant-4.62.1/blue_assistant/.abcli/script/list.sh +7 -0
  4. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/tests/help.sh +1 -0
  5. blue_assistant-4.62.1/blue_assistant/.abcli/tests/script_list.sh +8 -0
  6. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/tests/script_run.sh +3 -3
  7. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/__init__.py +1 -1
  8. blue_assistant-4.62.1/blue_assistant/config.env +3 -0
  9. blue_assistant-4.62.1/blue_assistant/env.py +17 -0
  10. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/help/script.py +25 -1
  11. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/__main__.py +17 -5
  12. blue_assistant-4.62.1/blue_assistant/script/actions/__init__.py +14 -0
  13. blue_assistant-4.62.1/blue_assistant/script/actions/functions.py +52 -0
  14. blue_assistant-4.62.1/blue_assistant/script/actions/generate_image.py +24 -0
  15. blue_assistant-4.62.1/blue_assistant/script/actions/generate_text.py +66 -0
  16. blue_assistant-4.62.1/blue_assistant/script/actions/generic.py +34 -0
  17. blue_assistant-4.62.1/blue_assistant/script/actions/wip.py +7 -0
  18. blue_assistant-4.62.1/blue_assistant/script/load.py +27 -0
  19. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/repository/__init__.py +3 -1
  20. blue_assistant-4.62.1/blue_assistant/script/repository/blue_amo/classes.py +9 -0
  21. blue_assistant-4.62.1/blue_assistant/script/repository/generic/classes.py +72 -0
  22. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/repository/moon_datasets/classes.py +0 -9
  23. {blue_assistant-4.46.1 → blue_assistant-4.62.1/blue_assistant.egg-info}/PKG-INFO +9 -2
  24. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant.egg-info/SOURCES.txt +8 -0
  25. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant.egg-info/requires.txt +4 -0
  26. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/requirements.txt +6 -0
  27. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/setup.py +1 -0
  28. blue_assistant-4.46.1/blue_assistant/config.env +0 -1
  29. blue_assistant-4.46.1/blue_assistant/env.py +0 -11
  30. blue_assistant-4.46.1/blue_assistant/script/load.py +0 -17
  31. blue_assistant-4.46.1/blue_assistant/script/repository/blue_amo/classes.py +0 -42
  32. blue_assistant-4.46.1/blue_assistant/script/repository/generic/classes.py +0 -69
  33. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/LICENSE +0 -0
  34. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/MANIFEST.in +0 -0
  35. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/abcli.sh +0 -0
  36. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/actions.sh +0 -0
  37. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/alias.sh +0 -0
  38. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  39. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/browse.sh +0 -0
  40. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/script/run.sh +0 -0
  41. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/script.sh +0 -0
  42. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  43. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  44. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/README.py +0 -0
  45. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/__main__.py +0 -0
  46. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/functions.py +0 -0
  47. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/help/__init__.py +0 -0
  48. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/help/__main__.py +0 -0
  49. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/help/functions.py +0 -0
  50. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/host.py +0 -0
  51. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/logger.py +0 -0
  52. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/sample.env +0 -0
  53. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/__init__.py +0 -0
  54. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  55. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
  56. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/script/repository/moon_datasets/__init__.py +0 -0
  57. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant/urls.py +0 -0
  58. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  59. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/blue_assistant.egg-info/top_level.txt +0 -0
  60. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/pyproject.toml +0 -0
  61. {blue_assistant-4.46.1 → blue_assistant-4.62.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.46.1
3
+ Version: 4.62.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
@@ -48,11 +52,14 @@ pip install blue-assistant
48
52
 
49
53
  ```mermaid
50
54
  graph LR
55
+ assistant_script_list["@assistant<br>script<br>list"]
51
56
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
52
57
 
53
58
  script["📜 script"]:::folder
54
59
  object["📂 object"]:::folder
55
60
 
61
+ script --> assistant_script_list
62
+
56
63
  script --> assistant_script_run
57
64
  object --> assistant_script_run
58
65
  assistant_script_run --> object
@@ -65,4 +72,4 @@ graph LR
65
72
 
66
73
  [![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
74
 
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).
75
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.62.1`](https://github.com/kamangir/blue-assistant).
@@ -8,11 +8,14 @@ pip install blue-assistant
8
8
 
9
9
  ```mermaid
10
10
  graph LR
11
+ assistant_script_list["@assistant<br>script<br>list"]
11
12
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
12
13
 
13
14
  script["📜 script"]:::folder
14
15
  object["📂 object"]:::folder
15
16
 
17
+ script --> assistant_script_list
18
+
16
19
  script --> assistant_script_run
17
20
  object --> assistant_script_run
18
21
  assistant_script_run --> object
@@ -25,4 +28,4 @@ graph LR
25
28
 
26
29
  [![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)
27
30
 
28
- 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).
31
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.62.1`](https://github.com/kamangir/blue-assistant).
@@ -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.62.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -0,0 +1,3 @@
1
+ BLUE_ASSISTANT_DEFAULT_MODEL=gpt-4o
2
+
3
+ BLUE_ASSISTANT_MAX_TOKEN=2000
@@ -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
@@ -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,24 +34,36 @@ 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,
61
+ object_name=args.object_name,
50
62
  verbose=args.verbose == 1,
51
63
  )
52
64
 
53
65
  if success:
54
- success = script.run(object_name=args.object_name)
66
+ success = script.run()
55
67
  else:
56
68
  success = None
57
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,52 @@
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
+ ) -> Tuple[bool, Dict]:
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 False, {
34
+ "error": f"{action_name}: action not found.",
35
+ }
36
+
37
+ logger.info(
38
+ "{}.perform_action: {} == {} on {}".format(
39
+ NAME,
40
+ action_name,
41
+ action_class.__name__,
42
+ node_name,
43
+ )
44
+ )
45
+
46
+ action_object = action_class(
47
+ script=script,
48
+ )
49
+
50
+ return action_object.perform(
51
+ node_name=node_name,
52
+ )
@@ -0,0 +1,24 @@
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
+ ) -> Tuple[bool, Dict]:
16
+ success, generic_metadata = super().perform(node_name=node_name)
17
+ if not success:
18
+ return success, generic_metadata
19
+
20
+ logger.info(f"🪄 generating image ...: {node_name}")
21
+ metadata = {}
22
+
23
+ metadata.update(generic_metadata)
24
+ return True, metadata
@@ -0,0 +1,66 @@
1
+ from typing import Dict, Tuple
2
+ from openai import OpenAI
3
+
4
+ from blueness import module
5
+ from blue_objects import file
6
+ from openai_commands.env import OPENAI_API_KEY
7
+
8
+ from blue_assistant import NAME
9
+ from blue_assistant.env import BLUE_ASSISTANT_DEFAULT_MODEL, BLUE_ASSISTANT_MAX_TOKEN
10
+ from blue_assistant.script.actions.generic import GenericAction
11
+ from blue_assistant.logger import logger
12
+
13
+ NAME = module.name(__file__, NAME)
14
+
15
+
16
+ class GenerateTextAction(GenericAction):
17
+ name = file.name(__file__)
18
+
19
+ def perform(
20
+ self,
21
+ node_name: str,
22
+ ) -> Tuple[bool, Dict]:
23
+ metadata = {}
24
+
25
+ if not OPENAI_API_KEY:
26
+ logger.error("OPENAI_API_KEY is not set.")
27
+ return False, {}
28
+
29
+ success, generic_metadata = super().perform(node_name=node_name)
30
+ if not success:
31
+ return success, generic_metadata
32
+
33
+ client = OpenAI(api_key=OPENAI_API_KEY)
34
+
35
+ try:
36
+ response = client.chat.completions.create(
37
+ messages=[
38
+ {
39
+ "role": "user",
40
+ "content": [
41
+ {
42
+ "type": "text",
43
+ "text": self.script.nodes[node_name]["prompt"],
44
+ }
45
+ ],
46
+ }
47
+ ],
48
+ model=BLUE_ASSISTANT_DEFAULT_MODEL,
49
+ max_tokens=BLUE_ASSISTANT_MAX_TOKEN,
50
+ )
51
+ except Exception as e:
52
+ logger.error(str(e))
53
+ return False, {"error": str(e)}
54
+
55
+ if self.script.verbose:
56
+ logger.info("response: {}".format(response))
57
+
58
+ if not response.choices:
59
+ logger.error("no choice.")
60
+ return False, {}
61
+
62
+ metadata["reply"] = response.choices[0].message.content
63
+ logger.info("🗣️ reply: {}".format(metadata["reply"]))
64
+
65
+ metadata.update(generic_metadata)
66
+ return True, metadata
@@ -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
+ ) -> Tuple[bool, Dict]:
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,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__)
@@ -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
+ )
@@ -1,12 +1,14 @@
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
+ 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
 
@@ -0,0 +1,9 @@
1
+ from blue_objects import file, path
2
+
3
+
4
+ from blue_assistant.script.repository.generic.classes import GenericScript
5
+ from blue_assistant.logger import logger
6
+
7
+
8
+ class BlueAmoScript(GenericScript):
9
+ name = path.name(file.path(__file__))
@@ -0,0 +1,72 @@
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
+ success, output = perform_action(
54
+ script=self,
55
+ node_name=node_name,
56
+ )
57
+ self.G.nodes[node_name]["completed"] = success
58
+ metadata["nodes"][node_name] = {
59
+ "success": success,
60
+ "output": output,
61
+ }
62
+ if not success:
63
+ break
64
+
65
+ if not post_to_object(
66
+ self.object_name,
67
+ "output",
68
+ metadata,
69
+ ):
70
+ return False
71
+
72
+ 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.62.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
@@ -48,11 +52,14 @@ pip install blue-assistant
48
52
 
49
53
  ```mermaid
50
54
  graph LR
55
+ assistant_script_list["@assistant<br>script<br>list"]
51
56
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
52
57
 
53
58
  script["📜 script"]:::folder
54
59
  object["📂 object"]:::folder
55
60
 
61
+ script --> assistant_script_list
62
+
56
63
  script --> assistant_script_run
57
64
  object --> assistant_script_run
58
65
  assistant_script_run --> object
@@ -65,4 +72,4 @@ graph LR
65
72
 
66
73
  [![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
74
 
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).
75
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.62.1`](https://github.com/kamangir/blue-assistant).
@@ -25,9 +25,11 @@ blue_assistant/.abcli/alias.sh
25
25
  blue_assistant/.abcli/blue_assistant.sh
26
26
  blue_assistant/.abcli/browse.sh
27
27
  blue_assistant/.abcli/script.sh
28
+ blue_assistant/.abcli/script/list.sh
28
29
  blue_assistant/.abcli/script/run.sh
29
30
  blue_assistant/.abcli/tests/README.sh
30
31
  blue_assistant/.abcli/tests/help.sh
32
+ blue_assistant/.abcli/tests/script_list.sh
31
33
  blue_assistant/.abcli/tests/script_run.sh
32
34
  blue_assistant/.abcli/tests/version.sh
33
35
  blue_assistant/help/__init__.py
@@ -37,6 +39,12 @@ blue_assistant/help/script.py
37
39
  blue_assistant/script/__init__.py
38
40
  blue_assistant/script/__main__.py
39
41
  blue_assistant/script/load.py
42
+ blue_assistant/script/actions/__init__.py
43
+ blue_assistant/script/actions/functions.py
44
+ blue_assistant/script/actions/generate_image.py
45
+ blue_assistant/script/actions/generate_text.py
46
+ blue_assistant/script/actions/generic.py
47
+ blue_assistant/script/actions/wip.py
40
48
  blue_assistant/script/repository/__init__.py
41
49
  blue_assistant/script/repository/blue_amo/__init__.py
42
50
  blue_assistant/script/repository/blue_amo/classes.py
@@ -2,7 +2,9 @@ blueness
2
2
  blue-options
3
3
  abcli
4
4
  openai_commands
5
+ blueflow
5
6
  boto3
7
+ openai
6
8
  geojson
7
9
  geopandas
8
10
  matplotlib
@@ -14,3 +16,5 @@ pylint
14
16
  pytest
15
17
  python-dotenv[cli]
16
18
  tqdm
19
+ networkx
20
+ pydot
@@ -2,7 +2,10 @@ blueness
2
2
  blue-options
3
3
  abcli
4
4
  openai_commands
5
+ blueflow
6
+
5
7
  boto3
8
+ openai
6
9
  geojson
7
10
  geopandas
8
11
  matplotlib
@@ -14,3 +17,6 @@ pylint
14
17
  pytest
15
18
  python-dotenv[cli]
16
19
  tqdm
20
+
21
+ networkx
22
+ pydot
@@ -11,6 +11,7 @@ setup(
11
11
  NAME,
12
12
  f"{NAME}.help",
13
13
  f"{NAME}.script",
14
+ f"{NAME}.script.actions",
14
15
  f"{NAME}.script.repository",
15
16
  f"{NAME}.script.repository.blue_amo",
16
17
  f"{NAME}.script.repository.generic",
@@ -1 +0,0 @@
1
- BLUE_ASSISTANT_TEST_OBJECT=blue-amo
@@ -1,11 +0,0 @@
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_TEST_OBJECT = os.getenv(
9
- "BLUE_ASSISTANT_TEST_OBJECT",
10
- "",
11
- )
@@ -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,42 +0,0 @@
1
- from typing import Dict
2
- from tqdm import tqdm
3
-
4
- from blue_objects import file, path
5
- from blue_objects.metadata import post_to_object
6
-
7
- from blue_assistant.script.repository.generic.classes import GenericScript
8
- from blue_assistant.logger import logger
9
-
10
-
11
- class BlueAmoScript(GenericScript):
12
- 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,69 +0,0 @@
1
- from typing import Dict, List
2
- import os
3
-
4
- from blueness import module
5
- from blue_objects import file, path
6
- from blue_objects.metadata import post_to_object
7
-
8
- from blue_assistant import NAME
9
- from blue_assistant.logger import logger
10
-
11
-
12
- NAME = module.name(__file__, NAME)
13
-
14
-
15
- class GenericScript:
16
- name = path.name(file.path(__file__))
17
-
18
- def __init__(
19
- self,
20
- verbose: bool = False,
21
- ):
22
- self.verbose = verbose
23
-
24
- metadata_filename = os.path.join(
25
- file.path(__file__),
26
- f"../{self.name}",
27
- "metadata.yaml",
28
- )
29
- self.metadata: Dict
30
- success, self.metadata = file.load_yaml(metadata_filename)
31
- assert success, f"cannot load {self.name}/metadata.yaml"
32
-
33
- logger.info("loaded {} node(s)".format(len(self.nodes)))
34
-
35
- logger.info("loaded {} variable(s)".format(len(self.vars)))
36
- if verbose:
37
- for var_name, var_value in self.vars.items():
38
- logger.info("{}: {}".format(var_name, var_value))
39
-
40
- @property
41
- def script(self) -> str:
42
- return self.metadata.get("script", {})
43
-
44
- @property
45
- def nodes(self) -> str:
46
- return self.metadata.get("script", {}).get("nodes", [])
47
-
48
- @property
49
- def vars(self) -> str:
50
- return self.metadata.get("script", {}).get("vars", {})
51
-
52
- def run(
53
- self,
54
- object_name: str,
55
- ) -> bool:
56
- logger.info(
57
- "{}.run: {}:{} -> {}".format(
58
- NAME,
59
- self.__class__.__name__,
60
- self.name,
61
- object_name,
62
- )
63
- )
64
-
65
- return post_to_object(
66
- object_name,
67
- "script",
68
- self.script,
69
- )
File without changes