blue-assistant 4.104.1__tar.gz → 4.137.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 (72) hide show
  1. {blue_assistant-4.104.1/blue_assistant.egg-info → blue_assistant-4.137.1}/PKG-INFO +7 -3
  2. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/README.md +6 -2
  3. blue_assistant-4.137.1/blue_assistant/README.py +48 -0
  4. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/__init__.py +1 -1
  5. blue_assistant-4.137.1/blue_assistant/script/actions/__init__.py +16 -0
  6. blue_assistant-4.137.1/blue_assistant/script/actions/generate_image.py +52 -0
  7. blue_assistant-4.137.1/blue_assistant/script/actions/generate_text.py +85 -0
  8. blue_assistant-4.137.1/blue_assistant/script/actions/generic.py +15 -0
  9. blue_assistant-4.137.1/blue_assistant/script/actions/skip.py +15 -0
  10. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/repository/__init__.py +4 -2
  11. blue_assistant-4.137.1/blue_assistant/script/repository/base/classes.py +137 -0
  12. blue_assistant-4.137.1/blue_assistant/script/repository/blue_amo/actions/__init__.py +13 -0
  13. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions/slice_into_frames.py → blue_assistant-4.137.1/blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py +5 -3
  14. blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions/stitch_the_frames.py → blue_assistant-4.137.1/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +2 -2
  15. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/repository/blue_amo/classes.py +7 -18
  16. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/repository/generic/classes.py +8 -18
  17. blue_assistant-4.137.1/blue_assistant/script/repository/hue/__init__.py +1 -0
  18. {blue_assistant-4.104.1/blue_assistant/script/repository/moon_datasets → blue_assistant-4.137.1/blue_assistant/script/repository/hue}/classes.py +1 -1
  19. blue_assistant-4.137.1/blue_assistant/script/repository/orbital_data_explorer/__init__.py +3 -0
  20. blue_assistant-4.137.1/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py +11 -0
  21. blue_assistant-4.137.1/blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py +18 -0
  22. blue_assistant-4.137.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +25 -0
  23. {blue_assistant-4.104.1 → blue_assistant-4.137.1/blue_assistant.egg-info}/PKG-INFO +7 -3
  24. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant.egg-info/SOURCES.txt +11 -6
  25. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/setup.py +4 -1
  26. blue_assistant-4.104.1/blue_assistant/README.py +0 -33
  27. blue_assistant-4.104.1/blue_assistant/script/actions/__init__.py +0 -14
  28. blue_assistant-4.104.1/blue_assistant/script/actions/functions.py +0 -22
  29. blue_assistant-4.104.1/blue_assistant/script/actions/generate_image.py +0 -58
  30. blue_assistant-4.104.1/blue_assistant/script/actions/generate_text.py +0 -97
  31. blue_assistant-4.104.1/blue_assistant/script/actions/generic.py +0 -27
  32. blue_assistant-4.104.1/blue_assistant/script/actions/wip.py +0 -7
  33. blue_assistant-4.104.1/blue_assistant/script/repository/moon_datasets/__init__.py +0 -1
  34. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/LICENSE +0 -0
  35. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/MANIFEST.in +0 -0
  36. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/abcli.sh +0 -0
  37. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/actions.sh +0 -0
  38. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/alias.sh +0 -0
  39. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  40. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/browse.sh +0 -0
  41. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/script/list.sh +0 -0
  42. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/script/run.sh +0 -0
  43. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/script.sh +0 -0
  44. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  45. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  46. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  47. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/tests/script_run.sh +0 -0
  48. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  49. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/__main__.py +0 -0
  50. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/config.env +0 -0
  51. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/env.py +0 -0
  52. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/functions.py +0 -0
  53. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/help/__init__.py +0 -0
  54. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/help/__main__.py +0 -0
  55. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/help/functions.py +0 -0
  56. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/help/script.py +0 -0
  57. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/host.py +0 -0
  58. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/logger.py +0 -0
  59. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/sample.env +0 -0
  60. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/__init__.py +0 -0
  61. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/__main__.py +0 -0
  62. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/load.py +0 -0
  63. {blue_assistant-4.104.1/blue_assistant/script/repository/blue_amo/actions → blue_assistant-4.137.1/blue_assistant/script/repository/base}/__init__.py +0 -0
  64. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  65. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
  66. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant/urls.py +0 -0
  67. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  68. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant.egg-info/requires.txt +0 -0
  69. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/blue_assistant.egg-info/top_level.txt +0 -0
  70. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/pyproject.toml +0 -0
  71. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/requirements.txt +0 -0
  72. {blue_assistant-4.104.1 → blue_assistant-4.137.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.104.1
3
+ Version: 4.137.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -44,7 +44,11 @@ Dynamic: summary
44
44
 
45
45
  # 🧠 blue-assistant
46
46
 
47
- 🧠 `@assistant` is an AI assistant.
47
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
48
+
49
+ | | |
50
+ | --- | --- |
51
+ | [`orbital-data-explorer`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer/README.md) Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/), through AI. | [`blue-amo`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-amo-2025-02-03-nswnx6/stitching_the_frames-2.png?raw=true)](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) A story developed and visualized, by AI. |
48
52
 
49
53
  ```bash
50
54
  pip install blue-assistant
@@ -72,4 +76,4 @@ graph LR
72
76
 
73
77
  [![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
78
 
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).
79
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.137.1`](https://github.com/kamangir/blue-assistant).
@@ -1,6 +1,10 @@
1
1
  # 🧠 blue-assistant
2
2
 
3
- 🧠 `@assistant` is an AI assistant.
3
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
4
+
5
+ | | |
6
+ | --- | --- |
7
+ | [`orbital-data-explorer`](./blue_assistant/script/repository/orbital_data_explorer/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](./blue_assistant/script/repository/orbital_data_explorer/README.md) Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/), through AI. | [`blue-amo`](./blue_assistant/script/repository/blue_amo/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-amo-2025-02-03-nswnx6/stitching_the_frames-2.png?raw=true)](./blue_assistant/script/repository/blue_amo/README.md) A story developed and visualized, by AI. |
4
8
 
5
9
  ```bash
6
10
  pip install blue-assistant
@@ -28,4 +32,4 @@ graph LR
28
32
 
29
33
  [![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
34
 
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).
35
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.137.1`](https://github.com/kamangir/blue-assistant).
@@ -0,0 +1,48 @@
1
+ import os
2
+
3
+ from blue_objects import file, README
4
+
5
+ from blue_assistant import NAME, VERSION, ICON, REPO_NAME
6
+
7
+
8
+ items = [
9
+ "[`{}`]({}) [![image]({})]({}) {}".format(
10
+ item["title"],
11
+ item["url"],
12
+ item["marquee"],
13
+ item["url"],
14
+ item["description"],
15
+ )
16
+ for item in [
17
+ {
18
+ "title": "orbital-data-explorer",
19
+ "url": "./blue_assistant/script/repository/orbital_data_explorer/README.md",
20
+ "marquee": "https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true",
21
+ "description": "Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/), through AI.",
22
+ },
23
+ {
24
+ "title": "blue-amo",
25
+ "url": "./blue_assistant/script/repository/blue_amo/README.md",
26
+ "marquee": "https://github.com/kamangir/assets/raw/main/blue-amo-2025-02-03-nswnx6/stitching_the_frames-2.png?raw=true",
27
+ "description": "A story developed and visualized, by AI.",
28
+ },
29
+ ]
30
+ ]
31
+
32
+
33
+ def build():
34
+ return all(
35
+ README.build(
36
+ items=readme.get("items", []),
37
+ path=os.path.join(file.path(__file__), readme["path"]),
38
+ ICON=ICON,
39
+ NAME=NAME,
40
+ VERSION=VERSION,
41
+ REPO_NAME=REPO_NAME,
42
+ )
43
+ for readme in [
44
+ {"items": items, "path": ".."},
45
+ {"path": "script/repository/blue_amo"},
46
+ {"path": "script/repository/orbital_data_explorer"},
47
+ ]
48
+ )
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.104.1"
7
+ VERSION = "4.137.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -0,0 +1,16 @@
1
+ from typing import Dict, Callable, Tuple
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+ from blue_assistant.script.actions.generic import generic_action
5
+ from blue_assistant.script.actions.generate_image import generate_image
6
+ from blue_assistant.script.actions.generate_text import generate_text
7
+ from blue_assistant.script.actions.skip import skip_action
8
+ from blue_assistant.logger import logger
9
+
10
+
11
+ dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
12
+ "generic_action": generic_action,
13
+ "generate_image": generate_image,
14
+ "generate_text": generate_text,
15
+ "skip": skip_action,
16
+ }
@@ -0,0 +1,52 @@
1
+ from blueness import module
2
+ from blue_objects import objects
3
+ from openai_commands.image_generation.api import OpenAIImageGenerator
4
+
5
+ from blue_assistant import NAME
6
+ from blue_assistant.env import (
7
+ BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
8
+ BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE,
9
+ BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY,
10
+ )
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
+ # https://platform.openai.com/docs/guides/images
18
+ def generate_image(
19
+ script: BaseScript,
20
+ node_name: str,
21
+ ) -> bool:
22
+ logger.info(f"{NAME}: {script} @ {node_name} ...")
23
+
24
+ generator = OpenAIImageGenerator(
25
+ model=BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
26
+ verbose=script.verbose,
27
+ )
28
+
29
+ filename = f"{node_name}.png"
30
+
31
+ success = generator.generate(
32
+ prompt=script.nodes[node_name]["prompt"],
33
+ filename=objects.path_of(
34
+ filename=filename,
35
+ object_name=script.object_name,
36
+ create=True,
37
+ ),
38
+ quality=(BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY if script.test_mode else "hd"),
39
+ size=(BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE if script.test_mode else "1792x1024"),
40
+ sign_with_prompt=False,
41
+ footer=[
42
+ script.nodes[node_name].get(
43
+ "summary_prompt",
44
+ script.nodes[node_name]["prompt"],
45
+ )
46
+ ],
47
+ )[0]
48
+
49
+ if success:
50
+ script.nodes[node_name]["filename"] = filename
51
+
52
+ return success
@@ -0,0 +1,85 @@
1
+ from typing import List
2
+ from openai import OpenAI
3
+ import pprint
4
+
5
+ from blueness import module
6
+ from openai_commands.env import OPENAI_API_KEY
7
+
8
+ from blue_assistant import NAME
9
+ from blue_assistant.script.repository.base.classes import BaseScript
10
+ from blue_assistant.env import (
11
+ BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
12
+ BLUE_ASSISTANT_TEXT_MAX_TOKEN,
13
+ )
14
+ from blue_assistant.logger import logger
15
+
16
+ NAME = module.name(__file__, NAME)
17
+
18
+
19
+ # https://platform.openai.com/docs/guides/text-generation
20
+ def generate_text(
21
+ script: BaseScript,
22
+ node_name: str,
23
+ ) -> bool:
24
+ if not OPENAI_API_KEY:
25
+ logger.error("OPENAI_API_KEY is not set.")
26
+ return False
27
+
28
+ logger.info(f"{NAME}: {script} @ {node_name} ...")
29
+
30
+ messages: List = []
31
+ list_of_context_nodes = script.get_history(node_name)
32
+ logger.info("node context: {}".format(" <- ".join(list_of_context_nodes)))
33
+ for context_node in reversed(list_of_context_nodes):
34
+ messages += [
35
+ {
36
+ "role": "user",
37
+ "content": [
38
+ {
39
+ "type": "text",
40
+ "text": script.apply_vars(script.nodes[context_node]["prompt"]),
41
+ }
42
+ ],
43
+ }
44
+ ]
45
+
46
+ if script.nodes[context_node].get("completed", False):
47
+ messages += [
48
+ {
49
+ "role": "assistant",
50
+ "content": [
51
+ {
52
+ "type": "text",
53
+ "text": script.nodes[context_node]["output"],
54
+ }
55
+ ],
56
+ }
57
+ ]
58
+
59
+ if script.verbose:
60
+ logger.info(f"messages: {pprint.pformat(messages)}")
61
+
62
+ client = OpenAI(api_key=OPENAI_API_KEY)
63
+
64
+ try:
65
+ response = client.chat.completions.create(
66
+ messages=messages,
67
+ model=BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
68
+ max_tokens=BLUE_ASSISTANT_TEXT_MAX_TOKEN,
69
+ )
70
+ except Exception as e:
71
+ logger.error(str(e))
72
+ return False
73
+
74
+ if script.verbose:
75
+ logger.info("response: {}".format(response))
76
+
77
+ if not response.choices:
78
+ logger.error("no choice.")
79
+ return False
80
+
81
+ output = response.choices[0].message.content
82
+ logger.info(f"🗣️ output: {output}")
83
+ script.nodes[node_name]["output"] = output
84
+
85
+ return True
@@ -0,0 +1,15 @@
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 generic_action(
11
+ script: BaseScript,
12
+ node_name: str,
13
+ ) -> bool:
14
+ logger.info(f"{NAME}: {script} @ {node_name} ...")
15
+ return True
@@ -0,0 +1,15 @@
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 skip_action(
11
+ script: BaseScript,
12
+ node_name: str,
13
+ ) -> bool:
14
+ logger.info(f"{NAME}: {script} @ {node_name} ...")
15
+ return True
@@ -3,13 +3,15 @@ from typing import List, Type
3
3
  from blue_assistant.script.repository.generic.classes import GenericScript
4
4
  from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
5
5
  from blue_assistant.script.repository.hue.classes import HueScript
6
- from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
6
+ from blue_assistant.script.repository.orbital_data_explorer.classes import (
7
+ OrbitalDataExplorerScript,
8
+ )
7
9
 
8
10
  list_of_script_classes: List[Type[GenericScript]] = [
9
11
  GenericScript,
10
12
  BlueAmoScript,
11
13
  HueScript,
12
- MiningOnMoonScript,
14
+ OrbitalDataExplorerScript,
13
15
  ]
14
16
 
15
17
  list_of_script_names: List[str] = [
@@ -0,0 +1,137 @@
1
+ from typing import Dict, List
2
+ import os
3
+ import networkx as nx
4
+ from functools import reduce
5
+
6
+ from blueness import module
7
+ from blue_objects import file, objects
8
+ from blue_objects.metadata import post_to_object
9
+ from blueflow.workflow import dot_file
10
+
11
+ from blue_assistant import NAME
12
+ from blue_assistant.logger import logger
13
+
14
+
15
+ NAME = module.name(__file__, NAME)
16
+
17
+
18
+ class BaseScript:
19
+ name = "base"
20
+
21
+ def __init__(
22
+ self,
23
+ object_name: str,
24
+ test_mode: bool = False,
25
+ verbose: bool = False,
26
+ ):
27
+ self.object_name = object_name
28
+
29
+ self.test_mode = test_mode
30
+ if self.test_mode:
31
+ logger.info("💰 test mode is on.")
32
+
33
+ self.verbose = verbose
34
+
35
+ metadata_filename = os.path.join(
36
+ file.path(__file__),
37
+ f"../{self.name}",
38
+ "metadata.yaml",
39
+ )
40
+ self.metadata: Dict
41
+ success, self.metadata = file.load_yaml(metadata_filename)
42
+ assert success, f"cannot load {self.name}/metadata.yaml"
43
+
44
+ logger.info("loaded {} node(s)".format(len(self.nodes)))
45
+
46
+ logger.info("loaded {} variable(s)".format(len(self.vars)))
47
+ if verbose:
48
+ for var_name, var_value in self.vars.items():
49
+ logger.info("{}: {}".format(var_name, var_value))
50
+
51
+ assert self.generate_graph(), "cannot generate graph"
52
+
53
+ def apply_vars(self, text: str) -> str:
54
+ for var_name, var_value in self.vars.items():
55
+ text = text.replace(f":::{var_name}", str(var_value))
56
+
57
+ return text
58
+
59
+ def generate_graph(self) -> bool:
60
+ self.G: nx.DiGraph = nx.DiGraph()
61
+
62
+ list_of_nodes = list(self.nodes.keys())
63
+ for node in self.nodes.values():
64
+ list_of_nodes += node.get("depends-on", "").split(",")
65
+
66
+ list_of_nodes = list({node_name for node_name in list_of_nodes if node_name})
67
+ logger.info(
68
+ "{} node(s): {}".format(
69
+ len(list_of_nodes),
70
+ ", ".join(list_of_nodes),
71
+ )
72
+ )
73
+
74
+ for node_name in list_of_nodes:
75
+ self.G.add_node(node_name)
76
+
77
+ for node_name, node in self.nodes.items():
78
+ for dependency in node.get("depends-on", "").split(","):
79
+ if dependency:
80
+ self.G.add_edge(node_name, dependency)
81
+
82
+ return self.save_graph()
83
+
84
+ def get_history(
85
+ self,
86
+ node_name: str,
87
+ ) -> List[str]:
88
+ return reduce(
89
+ lambda x, y: x + y,
90
+ [self.get_history(successor) for successor in self.G.successors(node_name)],
91
+ [node_name],
92
+ )
93
+
94
+ def run(self) -> bool:
95
+ logger.info(
96
+ "{}.run: {}:{} -> {}".format(
97
+ NAME,
98
+ self.__class__.__name__,
99
+ self.name,
100
+ self.object_name,
101
+ )
102
+ )
103
+
104
+ return post_to_object(
105
+ self.object_name,
106
+ "script",
107
+ self.script,
108
+ )
109
+
110
+ def save_graph(self) -> bool:
111
+ return dot_file.save_to_file(
112
+ objects.path_of(
113
+ filename="workflow.dot",
114
+ object_name=self.object_name,
115
+ ),
116
+ self.G,
117
+ caption=" | ".join(
118
+ [
119
+ self.name,
120
+ self.object_name,
121
+ ]
122
+ ),
123
+ add_legend=False,
124
+ )
125
+
126
+ # Aliases
127
+ @property
128
+ def script(self) -> Dict:
129
+ return self.metadata.get("script", {})
130
+
131
+ @property
132
+ def nodes(self) -> Dict[str, Dict]:
133
+ return self.metadata.get("script", {}).get("nodes", {})
134
+
135
+ @property
136
+ def vars(self) -> Dict:
137
+ return self.metadata.get("script", {}).get("vars", {})
@@ -0,0 +1,13 @@
1
+ from typing import Dict, Callable
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+ from blue_assistant.script.repository.blue_amo.actions import (
5
+ slicing_into_frames,
6
+ stitching_the_frames,
7
+ )
8
+
9
+
10
+ dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
11
+ "slicing_into_frames": slicing_into_frames.slicing_into_frames,
12
+ "stitching_the_frames": stitching_the_frames.stitching_the_frames,
13
+ }
@@ -7,7 +7,7 @@ from blue_assistant.logger import logger
7
7
  NAME = module.name(__file__, NAME)
8
8
 
9
9
 
10
- def slice_into_frames(
10
+ def slicing_into_frames(
11
11
  script: BaseScript,
12
12
  node_name: str,
13
13
  ) -> bool:
@@ -25,11 +25,13 @@ def slice_into_frames(
25
25
  list_of_frame_prompts += script.vars["frame_count"] * [""]
26
26
 
27
27
  for index in range(script.vars["frame_count"]):
28
- node_name = f"generating-frame-{index+1:03d}"
28
+ node_name = f"generating_frame_{index+1:03d}"
29
+
30
+ script.nodes[node_name]["summary_prompt"] = list_of_frame_prompts[index]
29
31
 
30
32
  script.nodes[node_name]["prompt"] = (
31
33
  script.nodes[node_name]["prompt"]
32
- .replace(":::story", script.nodes["generating-the-story"]["output"])
34
+ .replace(":::story", " ".join(list_of_frame_prompts[:index]))
33
35
  .replace(":::input", list_of_frame_prompts[index])
34
36
  )
35
37
 
@@ -15,7 +15,7 @@ from blue_assistant.logger import logger
15
15
  NAME = module.name(__file__, NAME)
16
16
 
17
17
 
18
- def stitch_the_frames(
18
+ def stitching_the_frames(
19
19
  script: BaseScript,
20
20
  node_name: str,
21
21
  ) -> bool:
@@ -24,7 +24,7 @@ def stitch_the_frames(
24
24
  for filename in [
25
25
  script.nodes[node_name_].get("filename", "")
26
26
  for node_name_ in [
27
- f"generating-frame-{index+1:03d}"
27
+ f"generating_frame_{index+1:03d}"
28
28
  for index in range(script.vars["frame_count"])
29
29
  ]
30
30
  ]
@@ -5,12 +5,7 @@ from blue_objects import file, path
5
5
 
6
6
  from blue_assistant import NAME
7
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
- )
8
+ from blue_assistant.script.repository.blue_amo.actions import dict_of_actions
14
9
  from blue_assistant.logger import logger
15
10
 
16
11
  NAME = module.name(__file__, NAME)
@@ -34,7 +29,7 @@ class BlueAmoScript(GenericScript):
34
29
  if self.test_mode:
35
30
  self.vars["frame_count"] = 1
36
31
 
37
- holder_node_name = "generating-the-frames"
32
+ holder_node_name = "generating_the_frames"
38
33
  logger.info(
39
34
  "{}: expanding {} X {}...".format(
40
35
  NAME,
@@ -47,19 +42,19 @@ class BlueAmoScript(GenericScript):
47
42
  del self.nodes[holder_node_name]
48
43
  self.G.remove_node(holder_node_name)
49
44
 
50
- reduce_node = "stitching-the-frames"
45
+ reduce_node = "stitching_the_frames"
51
46
  self.G.add_node(reduce_node)
52
47
  self.nodes[reduce_node] = {"action": "skip"}
53
48
 
54
49
  for index in range(self.vars["frame_count"]):
55
- node_name = f"generating-frame-{index+1:03d}"
50
+ node_name = f"generating_frame_{index+1:03d}"
56
51
 
57
52
  self.nodes[node_name] = copy.deepcopy(holder_node)
58
53
 
59
54
  self.G.add_node(node_name)
60
55
  self.G.add_edge(
61
56
  node_name,
62
- "slicing-into-frames",
57
+ "slicing_into_frames",
63
58
  )
64
59
  self.G.add_edge(
65
60
  reduce_node,
@@ -75,14 +70,8 @@ class BlueAmoScript(GenericScript):
75
70
  if not super().perform_action(node_name=node_name):
76
71
  return False
77
72
 
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(
73
+ if node_name in dict_of_actions:
74
+ return dict_of_actions[node_name](
86
75
  script=self,
87
76
  node_name=node_name,
88
77
  )
@@ -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 get_action_class
12
+ from blue_assistant.script.actions import dict_of_actions
13
13
  from blue_assistant.logger import logger
14
14
 
15
15
 
@@ -24,25 +24,15 @@ 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
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
27
 
43
- action_object = action_class(script=self)
28
+ if action_name not in dict_of_actions:
29
+ logger.error(f"{action_name}: action not found.")
30
+ return False
44
31
 
45
- return action_object.perform(node_name=node_name)
32
+ return dict_of_actions[action_name](
33
+ script=self,
34
+ node_name=node_name,
35
+ )
46
36
 
47
37
  def run(
48
38
  self,
@@ -0,0 +1 @@
1
+ from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
@@ -3,5 +3,5 @@ from blue_objects import file, path
3
3
  from blue_assistant.script.repository.generic.classes import GenericScript
4
4
 
5
5
 
6
- class MiningOnMoonScript(GenericScript):
6
+ class HueScript(GenericScript):
7
7
  name = path.name(file.path(__file__))
@@ -0,0 +1,3 @@
1
+ from blue_assistant.script.repository.orbital_data_explorer.classes import (
2
+ OrbitalDataExplorerScript,
3
+ )
@@ -0,0 +1,11 @@
1
+ from typing import Dict, Callable
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+ from blue_assistant.script.repository.orbital_data_explorer.actions import (
5
+ researching_the_questions,
6
+ )
7
+
8
+
9
+ dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
10
+ "researching_the_questions": researching_the_questions.researching_the_questions,
11
+ }
@@ -0,0 +1,18 @@
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 researching_the_questions(
11
+ script: BaseScript,
12
+ node_name: str,
13
+ ) -> bool:
14
+ logger.info(f"{NAME}: ...")
15
+
16
+ logger.info("🪄")
17
+
18
+ return True
@@ -0,0 +1,25 @@
1
+ from blue_objects import file, path
2
+
3
+ from blue_assistant.script.repository.generic.classes import GenericScript
4
+ from blue_assistant.script.repository.orbital_data_explorer.actions import (
5
+ dict_of_actions,
6
+ )
7
+
8
+
9
+ class OrbitalDataExplorerScript(GenericScript):
10
+ name = path.name(file.path(__file__))
11
+
12
+ def perform_action(
13
+ self,
14
+ node_name: str,
15
+ ) -> bool:
16
+ if not super().perform_action(node_name=node_name):
17
+ return False
18
+
19
+ if node_name in dict_of_actions:
20
+ return dict_of_actions[node_name](
21
+ script=self,
22
+ node_name=node_name,
23
+ )
24
+
25
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.104.1
3
+ Version: 4.137.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -44,7 +44,11 @@ Dynamic: summary
44
44
 
45
45
  # 🧠 blue-assistant
46
46
 
47
- 🧠 `@assistant` is an AI assistant.
47
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
48
+
49
+ | | |
50
+ | --- | --- |
51
+ | [`orbital-data-explorer`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true)](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/orbital_data_explorer/README.md) Access to the [Orbital Data Explorer](https://ode.rsl.wustl.edu/), through AI. | [`blue-amo`](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) [![image](https://github.com/kamangir/assets/raw/main/blue-amo-2025-02-03-nswnx6/stitching_the_frames-2.png?raw=true)](https://raw.githubusercontent.com/kamangir/blue-assistant/main/blue_assistant/script/repository/blue_amo/README.md) A story developed and visualized, by AI. |
48
52
 
49
53
  ```bash
50
54
  pip install blue-assistant
@@ -72,4 +76,4 @@ graph LR
72
76
 
73
77
  [![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
78
 
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).
79
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.137.1`](https://github.com/kamangir/blue-assistant).
@@ -40,18 +40,23 @@ blue_assistant/script/__init__.py
40
40
  blue_assistant/script/__main__.py
41
41
  blue_assistant/script/load.py
42
42
  blue_assistant/script/actions/__init__.py
43
- blue_assistant/script/actions/functions.py
44
43
  blue_assistant/script/actions/generate_image.py
45
44
  blue_assistant/script/actions/generate_text.py
46
45
  blue_assistant/script/actions/generic.py
47
- blue_assistant/script/actions/wip.py
46
+ blue_assistant/script/actions/skip.py
48
47
  blue_assistant/script/repository/__init__.py
48
+ blue_assistant/script/repository/base/__init__.py
49
+ blue_assistant/script/repository/base/classes.py
49
50
  blue_assistant/script/repository/blue_amo/__init__.py
50
51
  blue_assistant/script/repository/blue_amo/classes.py
51
52
  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
53
+ blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py
54
+ blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py
54
55
  blue_assistant/script/repository/generic/__init__.py
55
56
  blue_assistant/script/repository/generic/classes.py
56
- blue_assistant/script/repository/moon_datasets/__init__.py
57
- blue_assistant/script/repository/moon_datasets/classes.py
57
+ blue_assistant/script/repository/hue/__init__.py
58
+ blue_assistant/script/repository/hue/classes.py
59
+ blue_assistant/script/repository/orbital_data_explorer/__init__.py
60
+ blue_assistant/script/repository/orbital_data_explorer/classes.py
61
+ blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py
62
+ blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py
@@ -13,10 +13,13 @@ setup(
13
13
  f"{NAME}.script",
14
14
  f"{NAME}.script.actions",
15
15
  f"{NAME}.script.repository",
16
+ f"{NAME}.script.repository.base",
16
17
  f"{NAME}.script.repository.blue_amo",
17
18
  f"{NAME}.script.repository.blue_amo.actions",
18
19
  f"{NAME}.script.repository.generic",
19
- f"{NAME}.script.repository.moon_datasets",
20
+ f"{NAME}.script.repository.hue",
21
+ f"{NAME}.script.repository.orbital_data_explorer",
22
+ f"{NAME}.script.repository.orbital_data_explorer.actions",
20
23
  ],
21
24
  include_package_data=True,
22
25
  package_data={
@@ -1,33 +0,0 @@
1
- import os
2
-
3
- from blue_objects import file, README
4
-
5
- from blue_assistant import NAME, VERSION, ICON, REPO_NAME
6
-
7
-
8
- items = [
9
- "{}[`{}`](#) [![image]({})](#) {}".format(
10
- ICON,
11
- f"feature {index}",
12
- "https://github.com/kamangir/assets/raw/main/blue-assistant/marquee.png?raw=true",
13
- f"description of feature {index} ...",
14
- )
15
- for index in range(1, 4)
16
- ]
17
-
18
-
19
- def build():
20
- return all(
21
- README.build(
22
- items=readme.get("items", []),
23
- path=os.path.join(file.path(__file__), readme["path"]),
24
- ICON=ICON,
25
- NAME=NAME,
26
- VERSION=VERSION,
27
- REPO_NAME=REPO_NAME,
28
- )
29
- for readme in [
30
- {"items": items, "path": ".."},
31
- {"path": "docs/blue-amo.md"},
32
- ]
33
- )
@@ -1,14 +0,0 @@
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
- ]
@@ -1,22 +0,0 @@
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
@@ -1,58 +0,0 @@
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
@@ -1,97 +0,0 @@
1
- from typing import Dict, Tuple, List
2
- from openai import OpenAI
3
- import pprint
4
-
5
- from blueness import module
6
- from blue_objects import file
7
- from openai_commands.env import OPENAI_API_KEY
8
-
9
- from blue_assistant import NAME
10
- from blue_assistant.env import (
11
- BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
12
- BLUE_ASSISTANT_TEXT_MAX_TOKEN,
13
- )
14
- from blue_assistant.script.actions.generic import GenericAction
15
- from blue_assistant.logger import logger
16
-
17
- NAME = module.name(__file__, NAME)
18
-
19
-
20
- class GenerateTextAction(GenericAction):
21
- name = file.name(__file__)
22
-
23
- # https://platform.openai.com/docs/guides/text-generation
24
- def perform(
25
- self,
26
- node_name: str,
27
- ) -> bool:
28
- if not OPENAI_API_KEY:
29
- logger.error("OPENAI_API_KEY is not set.")
30
- return False
31
-
32
- if not super().perform(node_name=node_name):
33
- return False
34
-
35
- messages: List = []
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):
39
- messages += [
40
- {
41
- "role": "user",
42
- "content": [
43
- {
44
- "type": "text",
45
- "text": self.script.apply_vars(
46
- self.script.nodes[context_node]["prompt"]
47
- ),
48
- }
49
- ],
50
- }
51
- ]
52
-
53
- if self.script.nodes[context_node].get("completed", False):
54
- messages += [
55
- {
56
- "role": "assistant",
57
- "content": [
58
- {
59
- "type": "text",
60
- "text": self.script.nodes[context_node]["output"],
61
- }
62
- ],
63
- }
64
- ]
65
-
66
- if self.script.verbose:
67
- logger.info(f"messages: {pprint.pformat(messages)}")
68
-
69
- client = OpenAI(api_key=OPENAI_API_KEY)
70
-
71
- try:
72
- response = client.chat.completions.create(
73
- messages=messages,
74
- model=BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
75
- max_tokens=BLUE_ASSISTANT_TEXT_MAX_TOKEN,
76
- )
77
- except Exception as e:
78
- logger.error(str(e))
79
- return False
80
-
81
- if self.script.verbose:
82
- logger.info("response: {}".format(response))
83
-
84
- if not response.choices:
85
- logger.error("no choice.")
86
- return False
87
-
88
- output = response.choices[0].message.content
89
- logger.info(f"🗣️ output: {output}")
90
-
91
- self.script.nodes[node_name]["output"] = output
92
-
93
- var_name = self.script.nodes[node_name].get("output", "")
94
- if var_name:
95
- self.script.vars[var_name] = output
96
-
97
- return True
@@ -1,27 +0,0 @@
1
- from blue_objects import file
2
-
3
- from blue_assistant.script.repository.base.classes import BaseScript
4
- from blue_assistant.logger import logger
5
-
6
-
7
- class GenericAction:
8
- name = file.name(__file__)
9
-
10
- def __init__(
11
- self,
12
- script: BaseScript,
13
- ):
14
- self.script = script
15
-
16
- def perform(
17
- self,
18
- node_name: str,
19
- ) -> bool:
20
- logger.info(
21
- "{}.perform on {}.{} ...".format(
22
- self.__class__.__name__,
23
- self.script.name,
24
- node_name,
25
- ),
26
- )
27
- return True
@@ -1,7 +0,0 @@
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__)
@@ -1 +0,0 @@
1
- from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript