blue-assistant 4.87.1__tar.gz → 4.104.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.87.1/blue_assistant.egg-info → blue_assistant-4.104.1}/PKG-INFO +2 -2
  2. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/README.md +1 -1
  3. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/tests/script_run.sh +3 -1
  4. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/README.py +1 -1
  5. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/__init__.py +1 -1
  6. blue_assistant-4.104.1/blue_assistant/config.env +6 -0
  7. blue_assistant-4.104.1/blue_assistant/env.py +33 -0
  8. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/help/script.py +4 -1
  9. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/__main__.py +7 -0
  10. blue_assistant-4.104.1/blue_assistant/script/actions/generate_image.py +58 -0
  11. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/actions/generate_text.py +13 -9
  12. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/actions/generic.py +1 -8
  13. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/load.py +2 -0
  14. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions/__init__.py +0 -0
  15. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions/slice_into_frames.py +36 -0
  16. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions/stitch_the_frames.py +128 -0
  17. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/classes.py +90 -0
  18. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/generic/classes.py +8 -3
  19. {blue_assistant-4.87.1 → blue_assistant-4.104.1/blue_assistant.egg-info}/PKG-INFO +2 -2
  20. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant.egg-info/SOURCES.txt +3 -0
  21. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/setup.py +1 -0
  22. blue_assistant-4.87.1/blue_assistant/config.env +0 -3
  23. blue_assistant-4.87.1/blue_assistant/env.py +0 -17
  24. blue_assistant-4.87.1/blue_assistant/script/actions/generate_image.py +0 -21
  25. blue_assistant-4.87.1/blue_assistant/script/repository/blue_amo/classes.py +0 -38
  26. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/LICENSE +0 -0
  27. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/MANIFEST.in +0 -0
  28. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/abcli.sh +0 -0
  29. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/actions.sh +0 -0
  30. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/alias.sh +0 -0
  31. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  32. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/browse.sh +0 -0
  33. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/script/list.sh +0 -0
  34. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/script/run.sh +0 -0
  35. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/script.sh +0 -0
  36. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  37. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  38. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  39. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  40. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/__main__.py +0 -0
  41. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/functions.py +0 -0
  42. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/help/__init__.py +0 -0
  43. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/help/__main__.py +0 -0
  44. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/help/functions.py +0 -0
  45. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/host.py +0 -0
  46. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/logger.py +0 -0
  47. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/sample.env +0 -0
  48. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/__init__.py +0 -0
  49. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/actions/__init__.py +0 -0
  50. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/actions/functions.py +0 -0
  51. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/actions/wip.py +0 -0
  52. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/__init__.py +0 -0
  53. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  54. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
  55. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/moon_datasets/__init__.py +0 -0
  56. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/script/repository/moon_datasets/classes.py +0 -0
  57. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant/urls.py +0 -0
  58. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  59. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant.egg-info/requires.txt +0 -0
  60. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/blue_assistant.egg-info/top_level.txt +0 -0
  61. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/pyproject.toml +0 -0
  62. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/requirements.txt +0 -0
  63. {blue_assistant-4.87.1 → blue_assistant-4.104.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.87.1
3
+ Version: 4.104.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.87.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.104.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.87.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.104.1`](https://github.com/kamangir/blue-assistant).
@@ -16,7 +16,9 @@ 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 \
21
+ --verbose 1
20
22
 
21
23
  [[ $? -ne 0 ]] && return 1
22
24
 
@@ -28,6 +28,6 @@ def build():
28
28
  )
29
29
  for readme in [
30
30
  {"items": items, "path": ".."},
31
- {"path": "docs/blue-amo-01.md"},
31
+ {"path": "docs/blue-amo.md"},
32
32
  ]
33
33
  )
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.87.1"
7
+ VERSION = "4.104.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
 
@@ -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,36 @@
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"] = (
31
+ script.nodes[node_name]["prompt"]
32
+ .replace(":::story", script.nodes["generating-the-story"]["output"])
33
+ .replace(":::input", list_of_frame_prompts[index])
34
+ )
35
+
36
+ return True
@@ -0,0 +1,128 @@
1
+ from typing import List
2
+ import numpy as np
3
+ import cv2
4
+ from tqdm import trange
5
+ import math
6
+
7
+ from blueness import module
8
+ from blue_objects import file, objects
9
+ from blue_options import string
10
+
11
+ from blue_assistant import NAME
12
+ from blue_assistant.script.repository.base.classes import BaseScript
13
+ from blue_assistant.logger import logger
14
+
15
+ NAME = module.name(__file__, NAME)
16
+
17
+
18
+ def stitch_the_frames(
19
+ script: BaseScript,
20
+ node_name: str,
21
+ ) -> bool:
22
+ list_of_frames_filenames: List[str] = [
23
+ filename
24
+ for filename in [
25
+ script.nodes[node_name_].get("filename", "")
26
+ for node_name_ in [
27
+ f"generating-frame-{index+1:03d}"
28
+ for index in range(script.vars["frame_count"])
29
+ ]
30
+ ]
31
+ if filename
32
+ ]
33
+ if not list_of_frames_filenames:
34
+ return True
35
+
36
+ logger.info(
37
+ "{} frames to stitch: {}".format(
38
+ len(list_of_frames_filenames),
39
+ ", ".join(list_of_frames_filenames),
40
+ )
41
+ )
42
+
43
+ list_of_frames: List[np.ndarray] = []
44
+ for filename in list_of_frames_filenames:
45
+ success, frame = file.load_image(
46
+ objects.path_of(
47
+ filename=filename,
48
+ object_name=script.object_name,
49
+ )
50
+ )
51
+
52
+ if success:
53
+ list_of_frames += [frame]
54
+
55
+ if not list_of_frames:
56
+ return True
57
+
58
+ common_height = list_of_frames[0].shape[0]
59
+ common_width = list_of_frames[0].shape[1]
60
+ for index in trange(1, len(list_of_frames)):
61
+ frame_height = list_of_frames[index].shape[0]
62
+ frame_width = list_of_frames[index].shape[1]
63
+
64
+ if frame_height != common_height or frame_width != common_width:
65
+ list_of_frames[index] = cv2.resize(
66
+ list_of_frames[index],
67
+ (common_width, common_height),
68
+ interpolation=cv2.INTER_AREA,
69
+ )
70
+
71
+ width_count = int(math.ceil(math.sqrt(len(list_of_frames))))
72
+ height_count = int(math.ceil(len(list_of_frames) / width_count))
73
+ logger.info(
74
+ "{} x {} -> {} x {}".format(
75
+ len(list_of_frames),
76
+ string.pretty_shape_of_matrix(list_of_frames[0]),
77
+ height_count,
78
+ width_count,
79
+ )
80
+ )
81
+
82
+ list_of_frames += (height_count * width_count - len(list_of_frames)) * [
83
+ np.zeros_like(list_of_frames[0])
84
+ ]
85
+
86
+ full_frame: np.ndarray = None
87
+ for height_index in trange(height_count):
88
+ row = np.concatenate(
89
+ list_of_frames[
90
+ height_index * width_count : (height_index + 1) * width_count
91
+ ],
92
+ axis=1,
93
+ )
94
+
95
+ if not height_index:
96
+ full_frame = row
97
+ else:
98
+ full_frame = np.concatenate([full_frame, row], axis=0)
99
+ logger.info(f"full frame: {string.pretty_shape_of_matrix(full_frame)}")
100
+
101
+ for scale in [1, 2, 4]:
102
+ scaled_full_frame = (
103
+ full_frame
104
+ if scale == 1
105
+ else cv2.resize(
106
+ full_frame,
107
+ (
108
+ int(full_frame.shape[1] / scale),
109
+ int(full_frame.shape[0] / scale),
110
+ ),
111
+ interpolation=cv2.INTER_AREA,
112
+ )
113
+ )
114
+
115
+ if not file.save_image(
116
+ objects.path_of(
117
+ filename="{}{}.png".format(
118
+ node_name,
119
+ "" if scale == 1 else f"-{scale}",
120
+ ),
121
+ object_name=script.object_name,
122
+ ),
123
+ scaled_full_frame,
124
+ log=True,
125
+ ):
126
+ return False
127
+
128
+ return True
@@ -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
@@ -24,6 +24,8 @@ class GenericScript(BaseScript):
24
24
  node_name: str,
25
25
  ) -> bool:
26
26
  action_name = self.nodes[node_name].get("action", "unknown")
27
+ if action_name == "skip":
28
+ return True
27
29
 
28
30
  success, action_class = get_action_class(action_name=action_name)
29
31
  if not success:
@@ -49,15 +51,18 @@ class GenericScript(BaseScript):
49
51
  return False
50
52
 
51
53
  success: bool = True
52
- 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
+ ):
53
58
  for node_name in tqdm(self.nodes):
54
- if self.nodes[node_name]["completed"]:
59
+ if self.nodes[node_name].get("completed", False):
55
60
  continue
56
61
 
57
62
  pending_dependencies = [
58
63
  node_name_
59
64
  for node_name_ in self.G.successors(node_name)
60
- if not self.nodes[node_name_]["completed"]
65
+ if not self.nodes[node_name_].get("completed", False)
61
66
  ]
62
67
  if pending_dependencies:
63
68
  logger.info(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.87.1
3
+ Version: 4.104.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.87.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.104.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,38 +0,0 @@
1
- from blue_objects import file, path
2
- import copy
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__))
10
-
11
- def __init__(
12
- self,
13
- object_name: str,
14
- verbose: bool = False,
15
- ):
16
- super().__init__(
17
- object_name=object_name,
18
- verbose=verbose,
19
- )
20
-
21
- holder_node_name = "generating-the-frames"
22
-
23
- holder_node = self.nodes[holder_node_name]
24
- del self.nodes[holder_node_name]
25
- self.G.remove_node(holder_node_name)
26
-
27
- for index in range(self.vars["frame_count"]):
28
- node_name = f"generating-frame-{index+1:03d}"
29
-
30
- self.nodes[node_name] = copy.deepcopy(holder_node)
31
-
32
- self.G.add_node(node_name)
33
- self.G.add_edge(
34
- node_name,
35
- "slicing-into-frames",
36
- )
37
-
38
- assert self.save_graph()