blue-assistant 4.78.1__tar.gz → 4.97.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 (63) hide show
  1. {blue_assistant-4.78.1/blue_assistant.egg-info → blue_assistant-4.97.1}/PKG-INFO +2 -2
  2. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/README.md +1 -1
  3. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/tests/script_run.sh +2 -1
  4. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/__init__.py +1 -1
  5. blue_assistant-4.97.1/blue_assistant/config.env +6 -0
  6. blue_assistant-4.97.1/blue_assistant/env.py +33 -0
  7. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/help/script.py +4 -1
  8. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/__main__.py +7 -0
  9. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/actions/functions.py +0 -26
  10. blue_assistant-4.97.1/blue_assistant/script/actions/generate_image.py +58 -0
  11. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/actions/generate_text.py +13 -9
  12. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/actions/generic.py +1 -8
  13. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/load.py +2 -0
  14. blue_assistant-4.97.1/blue_assistant/script/repository/blue_amo/actions/__init__.py +0 -0
  15. blue_assistant-4.97.1/blue_assistant/script/repository/blue_amo/actions/slice_into_frames.py +35 -0
  16. blue_assistant-4.97.1/blue_assistant/script/repository/blue_amo/actions/stitch_the_frames.py +81 -0
  17. blue_assistant-4.97.1/blue_assistant/script/repository/blue_amo/classes.py +90 -0
  18. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/generic/classes.py +33 -8
  19. {blue_assistant-4.78.1 → blue_assistant-4.97.1/blue_assistant.egg-info}/PKG-INFO +2 -2
  20. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant.egg-info/SOURCES.txt +3 -0
  21. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/setup.py +1 -0
  22. blue_assistant-4.78.1/blue_assistant/config.env +0 -3
  23. blue_assistant-4.78.1/blue_assistant/env.py +0 -17
  24. blue_assistant-4.78.1/blue_assistant/script/actions/generate_image.py +0 -21
  25. blue_assistant-4.78.1/blue_assistant/script/repository/blue_amo/classes.py +0 -9
  26. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/LICENSE +0 -0
  27. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/MANIFEST.in +0 -0
  28. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/abcli.sh +0 -0
  29. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/actions.sh +0 -0
  30. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/alias.sh +0 -0
  31. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  32. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/browse.sh +0 -0
  33. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/script/list.sh +0 -0
  34. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/script/run.sh +0 -0
  35. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/script.sh +0 -0
  36. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  37. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  38. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  39. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  40. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/README.py +0 -0
  41. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/__main__.py +0 -0
  42. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/functions.py +0 -0
  43. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/help/__init__.py +0 -0
  44. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/help/__main__.py +0 -0
  45. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/help/functions.py +0 -0
  46. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/host.py +0 -0
  47. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/logger.py +0 -0
  48. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/sample.env +0 -0
  49. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/__init__.py +0 -0
  50. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/actions/__init__.py +0 -0
  51. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/actions/wip.py +0 -0
  52. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/__init__.py +0 -0
  53. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  54. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
  55. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/moon_datasets/__init__.py +0 -0
  56. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/script/repository/moon_datasets/classes.py +0 -0
  57. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant/urls.py +0 -0
  58. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  59. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant.egg-info/requires.txt +0 -0
  60. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/blue_assistant.egg-info/top_level.txt +0 -0
  61. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/pyproject.toml +0 -0
  62. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/requirements.txt +0 -0
  63. {blue_assistant-4.78.1 → blue_assistant-4.97.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.78.1
3
+ Version: 4.97.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -72,4 +72,4 @@ graph LR
72
72
 
73
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)
74
74
 
75
- built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.78.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.97.1`](https://github.com/kamangir/blue-assistant).
@@ -28,4 +28,4 @@ graph LR
28
28
 
29
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)
30
30
 
31
- built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.78.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.97.1`](https://github.com/kamangir/blue-assistant).
@@ -16,7 +16,8 @@ function test_blue_assistant_script_run() {
16
16
  ~upload,$options \
17
17
  script=$script_name \
18
18
  test_blue_assistant_script_run-$(abcli_string_timestamp_short) \
19
- "${@:2}"
19
+ "${@:2}" \
20
+ --test_mode 1
20
21
 
21
22
  [[ $? -ne 0 ]] && return 1
22
23
 
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.78.1"
7
+ VERSION = "4.97.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -0,0 +1,6 @@
1
+ BLUE_ASSISTANT_TEXT_DEFAULT_MODEL=gpt-4o
2
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN=2000
3
+
4
+ BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL=dall-e-3
5
+ BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY=standard
6
+ BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE=1024x1024
@@ -0,0 +1,33 @@
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_TEXT_DEFAULT_MODEL = os.getenv(
9
+ "BLUE_ASSISTANT_TEXT_DEFAULT_MODEL",
10
+ "",
11
+ )
12
+
13
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN_str = os.getenv("BLUE_ASSISTANT_TEXT_MAX_TOKEN", "")
14
+ try:
15
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN = int(BLUE_ASSISTANT_TEXT_MAX_TOKEN_str)
16
+ except Exception:
17
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN = 2000
18
+
19
+
20
+ BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL = os.getenv(
21
+ "BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL",
22
+ "",
23
+ )
24
+
25
+ BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY = os.getenv(
26
+ "BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY",
27
+ "",
28
+ )
29
+
30
+ BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE = os.getenv(
31
+ "BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE",
32
+ "",
33
+ )
@@ -34,7 +34,10 @@ def help_run(
34
34
 
35
35
  script_options = "script=<script>"
36
36
 
37
- args = ["--verbose 1"]
37
+ args = [
38
+ "[--test_mode 1]",
39
+ "[--verbose 1]",
40
+ ]
38
41
 
39
42
  return show_usage(
40
43
  [
@@ -31,6 +31,12 @@ parser.add_argument(
31
31
  default=0,
32
32
  help="0 | 1",
33
33
  )
34
+ parser.add_argument(
35
+ "--test_mode",
36
+ type=int,
37
+ default=0,
38
+ help="0 | 1",
39
+ )
34
40
  parser.add_argument(
35
41
  "--delim",
36
42
  type=str,
@@ -59,6 +65,7 @@ elif args.task == "run":
59
65
  success, script = load_script(
60
66
  script_name=args.script_name,
61
67
  object_name=args.object_name,
68
+ test_mode=args.test_mode == 1,
62
69
  verbose=args.verbose == 1,
63
70
  )
64
71
 
@@ -20,29 +20,3 @@ def get_action_class(
20
20
 
21
21
  logger.error(f"{action_name}: action not found.")
22
22
  return False, GenericAction
23
-
24
-
25
- def perform_action(
26
- script: BaseScript,
27
- node_name: str,
28
- ) -> bool:
29
- action_name = script.nodes[node_name].get("action", "unknown")
30
-
31
- success, action_class = get_action_class(action_name=action_name)
32
- if not success:
33
- return success
34
-
35
- logger.info(
36
- "{}.perform_action: {} == {} on {}".format(
37
- NAME,
38
- action_name,
39
- action_class.__name__,
40
- node_name,
41
- )
42
- )
43
-
44
- action_object = action_class(
45
- script=script,
46
- )
47
-
48
- return action_object.perform(node_name=node_name)
@@ -0,0 +1,58 @@
1
+ from blue_objects import file, objects
2
+ from openai_commands.image_generation.api import OpenAIImageGenerator
3
+
4
+ from blue_assistant.env import (
5
+ BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
6
+ BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE,
7
+ BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY,
8
+ )
9
+ from blue_assistant.script.actions.generic import GenericAction
10
+ from blue_assistant.script.repository.base.classes import BaseScript
11
+ from blue_assistant.logger import logger
12
+
13
+
14
+ class GenerateImageAction(GenericAction):
15
+ name = file.name(__file__)
16
+
17
+ def __init__(
18
+ self,
19
+ script: BaseScript,
20
+ ):
21
+ super().__init__(script=script)
22
+
23
+ self.generator = OpenAIImageGenerator(
24
+ model=BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
25
+ verbose=self.script.verbose,
26
+ )
27
+
28
+ # https://platform.openai.com/docs/guides/images
29
+ def perform(
30
+ self,
31
+ node_name: str,
32
+ ) -> bool:
33
+ if not super().perform(node_name=node_name):
34
+ return False
35
+
36
+ filename = f"{node_name}.png"
37
+
38
+ success = self.generator.generate(
39
+ prompt=self.script.nodes[node_name]["prompt"],
40
+ filename=objects.path_of(
41
+ filename=filename,
42
+ object_name=self.script.object_name,
43
+ create=True,
44
+ ),
45
+ quality=(
46
+ BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY if self.script.test_mode else "hd"
47
+ ),
48
+ size=(
49
+ BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE
50
+ if self.script.test_mode
51
+ else "1792x1024"
52
+ ),
53
+ )[0]
54
+
55
+ if success:
56
+ self.script.nodes[node_name]["filename"] = filename
57
+
58
+ return success
@@ -7,7 +7,10 @@ from blue_objects import file
7
7
  from openai_commands.env import OPENAI_API_KEY
8
8
 
9
9
  from blue_assistant import NAME
10
- from blue_assistant.env import BLUE_ASSISTANT_DEFAULT_MODEL, BLUE_ASSISTANT_MAX_TOKEN
10
+ from blue_assistant.env import (
11
+ BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
12
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN,
13
+ )
11
14
  from blue_assistant.script.actions.generic import GenericAction
12
15
  from blue_assistant.logger import logger
13
16
 
@@ -17,6 +20,7 @@ NAME = module.name(__file__, NAME)
17
20
  class GenerateTextAction(GenericAction):
18
21
  name = file.name(__file__)
19
22
 
23
+ # https://platform.openai.com/docs/guides/text-generation
20
24
  def perform(
21
25
  self,
22
26
  node_name: str,
@@ -29,9 +33,9 @@ class GenerateTextAction(GenericAction):
29
33
  return False
30
34
 
31
35
  messages: List = []
32
- node_context = self.script.get_history(node_name)
33
- logger.info("node context: {}".format(" -> ".join(node_context)))
34
- for successor in reversed(node_context):
36
+ list_of_context_nodes = self.script.get_history(node_name)
37
+ logger.info("node context: {}".format(" <- ".join(list_of_context_nodes)))
38
+ for context_node in reversed(list_of_context_nodes):
35
39
  messages += [
36
40
  {
37
41
  "role": "user",
@@ -39,21 +43,21 @@ class GenerateTextAction(GenericAction):
39
43
  {
40
44
  "type": "text",
41
45
  "text": self.script.apply_vars(
42
- self.script.nodes[successor]["prompt"]
46
+ self.script.nodes[context_node]["prompt"]
43
47
  ),
44
48
  }
45
49
  ],
46
50
  }
47
51
  ]
48
52
 
49
- if self.script.nodes[successor]["completed"]:
53
+ if self.script.nodes[context_node].get("completed", False):
50
54
  messages += [
51
55
  {
52
56
  "role": "assistant",
53
57
  "content": [
54
58
  {
55
59
  "type": "text",
56
- "text": self.script.nodes[successor]["output"],
60
+ "text": self.script.nodes[context_node]["output"],
57
61
  }
58
62
  ],
59
63
  }
@@ -67,8 +71,8 @@ class GenerateTextAction(GenericAction):
67
71
  try:
68
72
  response = client.chat.completions.create(
69
73
  messages=messages,
70
- model=BLUE_ASSISTANT_DEFAULT_MODEL,
71
- max_tokens=BLUE_ASSISTANT_MAX_TOKEN,
74
+ model=BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
75
+ max_tokens=BLUE_ASSISTANT_TEXT_MAX_TOKEN,
72
76
  )
73
77
  except Exception as e:
74
78
  logger.error(str(e))
@@ -1,14 +1,8 @@
1
- from typing import Dict, Tuple
2
-
3
- from blueness import module
4
1
  from blue_objects import file
5
2
 
6
- from blue_assistant import NAME
7
3
  from blue_assistant.script.repository.base.classes import BaseScript
8
4
  from blue_assistant.logger import logger
9
5
 
10
- NAME = module.name(__file__, NAME)
11
-
12
6
 
13
7
  class GenericAction:
14
8
  name = file.name(__file__)
@@ -24,8 +18,7 @@ class GenericAction:
24
18
  node_name: str,
25
19
  ) -> bool:
26
20
  logger.info(
27
- "{}.perform({}) on {}.{} ...".format(
28
- NAME,
21
+ "{}.perform on {}.{} ...".format(
29
22
  self.__class__.__name__,
30
23
  self.script.name,
31
24
  node_name,
@@ -8,6 +8,7 @@ from blue_assistant.logger import logger
8
8
  def load_script(
9
9
  script_name: str,
10
10
  object_name: str,
11
+ test_mode: bool = False,
11
12
  verbose: bool = False,
12
13
  ) -> Tuple[bool, BaseScript]:
13
14
  found: bool = False
@@ -23,5 +24,6 @@ def load_script(
23
24
 
24
25
  return found, script_class(
25
26
  object_name=object_name,
27
+ test_mode=test_mode,
26
28
  verbose=verbose,
27
29
  )
@@ -0,0 +1,35 @@
1
+ from blueness import module
2
+
3
+ from blue_assistant import NAME
4
+ from blue_assistant.script.repository.base.classes import BaseScript
5
+ from blue_assistant.logger import logger
6
+
7
+ NAME = module.name(__file__, NAME)
8
+
9
+
10
+ def slice_into_frames(
11
+ script: BaseScript,
12
+ node_name: str,
13
+ ) -> bool:
14
+ logger.info(f"{NAME}: processing the output...")
15
+
16
+ list_of_frame_prompts = script.nodes[node_name]["output"].split("---")
17
+ if len(list_of_frame_prompts) != script.vars["frame_count"]:
18
+ logger.warning(
19
+ "{} != {}, frame count doesn't match, bad AI! 😁".format(
20
+ len(list_of_frame_prompts),
21
+ script.vars["frame_count"],
22
+ )
23
+ )
24
+
25
+ list_of_frame_prompts += script.vars["frame_count"] * [""]
26
+
27
+ for index in range(script.vars["frame_count"]):
28
+ node_name = f"generating-frame-{index+1:03d}"
29
+
30
+ script.nodes[node_name]["prompt"] = script.nodes[node_name]["prompt"].replace(
31
+ ":::input",
32
+ list_of_frame_prompts[index],
33
+ )
34
+
35
+ return True
@@ -0,0 +1,81 @@
1
+ from typing import List
2
+ import numpy as np
3
+ import cv2
4
+ from tqdm import trange
5
+
6
+ from blueness import module
7
+ from blue_objects import file, objects
8
+ from blue_options import string
9
+
10
+ from blue_assistant import NAME
11
+ from blue_assistant.script.repository.base.classes import BaseScript
12
+ from blue_assistant.logger import logger
13
+
14
+ NAME = module.name(__file__, NAME)
15
+
16
+
17
+ def stitch_the_frames(
18
+ script: BaseScript,
19
+ node_name: str,
20
+ ) -> bool:
21
+ list_of_frames_filenames: List[str] = [
22
+ filename
23
+ for filename in [
24
+ script.nodes[node_name_].get("filename", "")
25
+ for node_name_ in [
26
+ f"generating-frame-{index+1:03d}"
27
+ for index in range(script.vars["frame_count"])
28
+ ]
29
+ ]
30
+ if filename
31
+ ]
32
+ if not list_of_frames_filenames:
33
+ return True
34
+
35
+ logger.info(
36
+ "{} frames to stitch: {}".format(
37
+ len(list_of_frames_filenames),
38
+ ", ".join(list_of_frames_filenames),
39
+ )
40
+ )
41
+
42
+ list_of_frames: List[np.ndarray] = []
43
+ for filename in list_of_frames_filenames:
44
+ success, frame = file.load_image(
45
+ objects.path_of(
46
+ filename=filename,
47
+ object_name=script.object_name,
48
+ )
49
+ )
50
+
51
+ if success:
52
+ list_of_frames += [frame]
53
+
54
+ if not list_of_frames:
55
+ return True
56
+
57
+ common_height = list_of_frames[0].shape[0]
58
+ for index in trange(len(list_of_frames)):
59
+ if list_of_frames[index].shape[0] != common_height:
60
+ aspect_ratio = (
61
+ list_of_frames[index].shape[1] / list_of_frames[index].shape[0]
62
+ )
63
+ new_width = int(common_height * aspect_ratio)
64
+
65
+ list_of_frames[index] = cv2.resize(
66
+ list_of_frames[index],
67
+ (new_width, common_height),
68
+ interpolation=cv2.INTER_AREA,
69
+ )
70
+
71
+ full_frame = np.concatenate(list_of_frames, axis=1)
72
+ logger.info(f"full_frame: {string.pretty_shape_of_matrix(full_frame)}")
73
+
74
+ return file.save_image(
75
+ objects.path_of(
76
+ filename=f"{node_name}.png",
77
+ object_name=script.object_name,
78
+ ),
79
+ full_frame,
80
+ log=True,
81
+ )
@@ -0,0 +1,90 @@
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.generic.classes import GenericScript
8
+ from blue_assistant.script.repository.blue_amo.actions.slice_into_frames import (
9
+ slice_into_frames,
10
+ )
11
+ from blue_assistant.script.repository.blue_amo.actions.stitch_the_frames import (
12
+ stitch_the_frames,
13
+ )
14
+ from blue_assistant.logger import logger
15
+
16
+ NAME = module.name(__file__, NAME)
17
+
18
+
19
+ class BlueAmoScript(GenericScript):
20
+ name = path.name(file.path(__file__))
21
+
22
+ def __init__(
23
+ self,
24
+ object_name: str,
25
+ test_mode: bool = False,
26
+ verbose: bool = False,
27
+ ):
28
+ super().__init__(
29
+ object_name=object_name,
30
+ test_mode=test_mode,
31
+ verbose=verbose,
32
+ )
33
+
34
+ if self.test_mode:
35
+ self.vars["frame_count"] = 1
36
+
37
+ holder_node_name = "generating-the-frames"
38
+ logger.info(
39
+ "{}: expanding {} X {}...".format(
40
+ NAME,
41
+ holder_node_name,
42
+ self.vars["frame_count"],
43
+ )
44
+ )
45
+
46
+ holder_node = self.nodes[holder_node_name]
47
+ del self.nodes[holder_node_name]
48
+ self.G.remove_node(holder_node_name)
49
+
50
+ reduce_node = "stitching-the-frames"
51
+ self.G.add_node(reduce_node)
52
+ self.nodes[reduce_node] = {"action": "skip"}
53
+
54
+ for index in range(self.vars["frame_count"]):
55
+ node_name = f"generating-frame-{index+1:03d}"
56
+
57
+ self.nodes[node_name] = copy.deepcopy(holder_node)
58
+
59
+ self.G.add_node(node_name)
60
+ self.G.add_edge(
61
+ node_name,
62
+ "slicing-into-frames",
63
+ )
64
+ self.G.add_edge(
65
+ reduce_node,
66
+ node_name,
67
+ )
68
+
69
+ assert self.save_graph()
70
+
71
+ def perform_action(
72
+ self,
73
+ node_name: str,
74
+ ) -> bool:
75
+ if not super().perform_action(node_name=node_name):
76
+ return False
77
+
78
+ if node_name == "slicing-into-frames":
79
+ return slice_into_frames(
80
+ script=self,
81
+ node_name=node_name,
82
+ )
83
+
84
+ if node_name == "stitching-the-frames":
85
+ return stitch_the_frames(
86
+ script=self,
87
+ node_name=node_name,
88
+ )
89
+
90
+ return True
@@ -9,7 +9,7 @@ from blue_objects.metadata import post_to_object
9
9
 
10
10
  from blue_assistant import NAME
11
11
  from blue_assistant.script.repository.base.classes import BaseScript
12
- from blue_assistant.script.actions.functions import perform_action
12
+ from blue_assistant.script.actions.functions import get_action_class
13
13
  from blue_assistant.logger import logger
14
14
 
15
15
 
@@ -19,6 +19,31 @@ NAME = module.name(__file__, NAME)
19
19
  class GenericScript(BaseScript):
20
20
  name = path.name(file.path(__file__))
21
21
 
22
+ def perform_action(
23
+ self,
24
+ node_name: str,
25
+ ) -> bool:
26
+ action_name = self.nodes[node_name].get("action", "unknown")
27
+ if action_name == "skip":
28
+ return True
29
+
30
+ success, action_class = get_action_class(action_name=action_name)
31
+ if not success:
32
+ return success
33
+
34
+ logger.info(
35
+ "{}.perform_action: {} == {} on {}".format(
36
+ NAME,
37
+ action_name,
38
+ action_class.__name__,
39
+ node_name,
40
+ )
41
+ )
42
+
43
+ action_object = action_class(script=self)
44
+
45
+ return action_object.perform(node_name=node_name)
46
+
22
47
  def run(
23
48
  self,
24
49
  ) -> bool:
@@ -26,15 +51,18 @@ class GenericScript(BaseScript):
26
51
  return False
27
52
 
28
53
  success: bool = True
29
- while not all(self.nodes[node]["completed"] for node in self.nodes) and success:
54
+ while (
55
+ not all(self.nodes[node].get("completed", False) for node in self.nodes)
56
+ and success
57
+ ):
30
58
  for node_name in tqdm(self.nodes):
31
- if self.nodes[node_name]["completed"]:
59
+ if self.nodes[node_name].get("completed", False):
32
60
  continue
33
61
 
34
62
  pending_dependencies = [
35
63
  node_name_
36
64
  for node_name_ in self.G.successors(node_name)
37
- if not self.nodes[node_name_]["completed"]
65
+ if not self.nodes[node_name_].get("completed", False)
38
66
  ]
39
67
  if pending_dependencies:
40
68
  logger.info(
@@ -46,10 +74,7 @@ class GenericScript(BaseScript):
46
74
  )
47
75
  continue
48
76
 
49
- if not perform_action(
50
- script=self,
51
- node_name=node_name,
52
- ):
77
+ if not self.perform_action(node_name=node_name):
53
78
  success = False
54
79
  break
55
80
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.78.1
3
+ Version: 4.97.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -72,4 +72,4 @@ graph LR
72
72
 
73
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)
74
74
 
75
- built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.78.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.97.1`](https://github.com/kamangir/blue-assistant).
@@ -48,6 +48,9 @@ blue_assistant/script/actions/wip.py
48
48
  blue_assistant/script/repository/__init__.py
49
49
  blue_assistant/script/repository/blue_amo/__init__.py
50
50
  blue_assistant/script/repository/blue_amo/classes.py
51
+ blue_assistant/script/repository/blue_amo/actions/__init__.py
52
+ blue_assistant/script/repository/blue_amo/actions/slice_into_frames.py
53
+ blue_assistant/script/repository/blue_amo/actions/stitch_the_frames.py
51
54
  blue_assistant/script/repository/generic/__init__.py
52
55
  blue_assistant/script/repository/generic/classes.py
53
56
  blue_assistant/script/repository/moon_datasets/__init__.py
@@ -14,6 +14,7 @@ setup(
14
14
  f"{NAME}.script.actions",
15
15
  f"{NAME}.script.repository",
16
16
  f"{NAME}.script.repository.blue_amo",
17
+ f"{NAME}.script.repository.blue_amo.actions",
17
18
  f"{NAME}.script.repository.generic",
18
19
  f"{NAME}.script.repository.moon_datasets",
19
20
  ],
@@ -1,3 +0,0 @@
1
- BLUE_ASSISTANT_DEFAULT_MODEL=gpt-4o
2
-
3
- BLUE_ASSISTANT_MAX_TOKEN=2000
@@ -1,17 +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_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
@@ -1,21 +0,0 @@
1
- from typing import Dict, Tuple
2
-
3
- from blue_objects import file
4
-
5
- from blue_assistant.script.actions.generic import GenericAction
6
- from blue_assistant.logger import logger
7
-
8
-
9
- class GenerateImageAction(GenericAction):
10
- name = file.name(__file__)
11
-
12
- def perform(
13
- self,
14
- node_name: str,
15
- ) -> bool:
16
- if not super().perform(node_name=node_name):
17
- return False
18
-
19
- logger.info(f"🪄 generating image ...: {node_name}")
20
-
21
- return True
@@ -1,9 +0,0 @@
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__))
File without changes