blue-assistant 4.46.1__py3-none-any.whl → 4.62.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- blue_assistant/.abcli/script/list.sh +7 -0
- blue_assistant/.abcli/tests/help.sh +1 -0
- blue_assistant/.abcli/tests/script_list.sh +8 -0
- blue_assistant/.abcli/tests/script_run.sh +3 -3
- blue_assistant/__init__.py +1 -1
- blue_assistant/config.env +3 -1
- blue_assistant/env.py +8 -2
- blue_assistant/help/script.py +25 -1
- blue_assistant/script/__main__.py +17 -5
- blue_assistant/script/actions/__init__.py +14 -0
- blue_assistant/script/actions/functions.py +52 -0
- blue_assistant/script/actions/generate_image.py +24 -0
- blue_assistant/script/actions/generate_text.py +66 -0
- blue_assistant/script/actions/generic.py +34 -0
- blue_assistant/script/actions/wip.py +7 -0
- blue_assistant/script/load.py +18 -8
- blue_assistant/script/repository/__init__.py +3 -1
- blue_assistant/script/repository/blue_amo/classes.py +1 -34
- blue_assistant/script/repository/generic/classes.py +50 -47
- blue_assistant/script/repository/moon_datasets/classes.py +0 -9
- {blue_assistant-4.46.1.dist-info → blue_assistant-4.62.1.dist-info}/METADATA +9 -2
- {blue_assistant-4.46.1.dist-info → blue_assistant-4.62.1.dist-info}/RECORD +25 -17
- {blue_assistant-4.46.1.dist-info → blue_assistant-4.62.1.dist-info}/LICENSE +0 -0
- {blue_assistant-4.46.1.dist-info → blue_assistant-4.62.1.dist-info}/WHEEL +0 -0
- {blue_assistant-4.46.1.dist-info → blue_assistant-4.62.1.dist-info}/top_level.txt +0 -0
| @@ -2,9 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            function test_blue_assistant_script_run() {
         | 
| 4 4 | 
             
                local options=$1
         | 
| 5 | 
            -
                local list_of_script_name=$( | 
| 6 | 
            -
                     | 
| 7 | 
            -
                    -- | 
| 5 | 
            +
                local list_of_script_name=$(blue_assistant_script_list \
         | 
| 6 | 
            +
                    --delim + \
         | 
| 7 | 
            +
                    --log 0)
         | 
| 8 8 | 
             
                list_of_script_name=$(abcli_option "$options" script $list_of_script_name)
         | 
| 9 9 |  | 
| 10 10 | 
             
                local script_name
         | 
    
        blue_assistant/__init__.py
    CHANGED
    
    
    
        blue_assistant/config.env
    CHANGED
    
    
    
        blue_assistant/env.py
    CHANGED
    
    | @@ -5,7 +5,13 @@ load_env(__name__) | |
| 5 5 | 
             
            load_config(__name__)
         | 
| 6 6 |  | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
                " | 
| 8 | 
            +
            BLUE_ASSISTANT_DEFAULT_MODEL = os.getenv(
         | 
| 9 | 
            +
                "BLUE_ASSISTANT_DEFAULT_MODEL",
         | 
| 10 10 | 
             
                "",
         | 
| 11 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
         | 
    
        blue_assistant/help/script.py
    CHANGED
    
    | @@ -5,6 +5,27 @@ from blue_options.terminal import show_usage, xtra | |
| 5 5 | 
             
            from blue_assistant.script.repository import list_of_script_names
         | 
| 6 6 |  | 
| 7 7 |  | 
| 8 | 
            +
            def help_list(
         | 
| 9 | 
            +
                tokens: List[str],
         | 
| 10 | 
            +
                mono: bool,
         | 
| 11 | 
            +
            ) -> str:
         | 
| 12 | 
            +
                args = [
         | 
| 13 | 
            +
                    "[--delim +]",
         | 
| 14 | 
            +
                    "[--log 0]",
         | 
| 15 | 
            +
                ]
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                return show_usage(
         | 
| 18 | 
            +
                    [
         | 
| 19 | 
            +
                        "@assistant",
         | 
| 20 | 
            +
                        "script",
         | 
| 21 | 
            +
                        "list",
         | 
| 22 | 
            +
                    ]
         | 
| 23 | 
            +
                    + args,
         | 
| 24 | 
            +
                    "list scripts.",
         | 
| 25 | 
            +
                    mono=mono,
         | 
| 26 | 
            +
                )
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 8 29 | 
             
            def help_run(
         | 
| 9 30 | 
             
                tokens: List[str],
         | 
| 10 31 | 
             
                mono: bool,
         | 
| @@ -33,4 +54,7 @@ def help_run( | |
| 33 54 | 
             
                )
         | 
| 34 55 |  | 
| 35 56 |  | 
| 36 | 
            -
            help_functions = { | 
| 57 | 
            +
            help_functions = {
         | 
| 58 | 
            +
                "list": help_list,
         | 
| 59 | 
            +
                "run": help_run,
         | 
| 60 | 
            +
            }
         | 
| @@ -14,7 +14,7 @@ parser = argparse.ArgumentParser(NAME) | |
| 14 14 | 
             
            parser.add_argument(
         | 
| 15 15 | 
             
                "task",
         | 
| 16 16 | 
             
                type=str,
         | 
| 17 | 
            -
                help=" | 
| 17 | 
            +
                help="list | run",
         | 
| 18 18 | 
             
            )
         | 
| 19 19 | 
             
            parser.add_argument(
         | 
| 20 20 | 
             
                "--script_name",
         | 
| @@ -34,24 +34,36 @@ parser.add_argument( | |
| 34 34 | 
             
            parser.add_argument(
         | 
| 35 35 | 
             
                "--delim",
         | 
| 36 36 | 
             
                type=str,
         | 
| 37 | 
            -
                default=" | 
| 37 | 
            +
                default=", ",
         | 
| 38 | 
            +
            )
         | 
| 39 | 
            +
            parser.add_argument(
         | 
| 40 | 
            +
                "--log",
         | 
| 41 | 
            +
                type=int,
         | 
| 42 | 
            +
                default=1,
         | 
| 43 | 
            +
                help="0 | 1",
         | 
| 38 44 | 
             
            )
         | 
| 39 45 | 
             
            args = parser.parse_args()
         | 
| 40 46 |  | 
| 41 47 | 
             
            delim = " " if args.delim == "space" else args.delim
         | 
| 42 48 |  | 
| 43 49 | 
             
            success = False
         | 
| 44 | 
            -
            if args.task == " | 
| 50 | 
            +
            if args.task == "list":
         | 
| 45 51 | 
             
                success = True
         | 
| 46 | 
            -
                 | 
| 52 | 
            +
                if args.log:
         | 
| 53 | 
            +
                    logger.info(f"{len(list_of_script_names)} script(s)")
         | 
| 54 | 
            +
                    for index, script_name in enumerate(list_of_script_names):
         | 
| 55 | 
            +
                        logger.info(f"#{index + 1: 3d}: {script_name}")
         | 
| 56 | 
            +
                else:
         | 
| 57 | 
            +
                    print(delim.join(list_of_script_names))
         | 
| 47 58 | 
             
            elif args.task == "run":
         | 
| 48 59 | 
             
                success, script = load_script(
         | 
| 49 60 | 
             
                    script_name=args.script_name,
         | 
| 61 | 
            +
                    object_name=args.object_name,
         | 
| 50 62 | 
             
                    verbose=args.verbose == 1,
         | 
| 51 63 | 
             
                )
         | 
| 52 64 |  | 
| 53 65 | 
             
                if success:
         | 
| 54 | 
            -
                    success = script.run( | 
| 66 | 
            +
                    success = script.run()
         | 
| 55 67 | 
             
            else:
         | 
| 56 68 | 
             
                success = None
         | 
| 57 69 |  | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            from typing import List
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            from blue_assistant.script.actions.generic import GenericAction
         | 
| 4 | 
            +
            from blue_assistant.script.actions.generate_image import GenerateImageAction
         | 
| 5 | 
            +
            from blue_assistant.script.actions.generate_text import GenerateTextAction
         | 
| 6 | 
            +
            from blue_assistant.script.actions.wip import WorkInProgressAction
         | 
| 7 | 
            +
            from blue_assistant.logger import logger
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            list_of_actions: List[GenericAction] = [
         | 
| 10 | 
            +
                GenericAction,
         | 
| 11 | 
            +
                GenerateImageAction,
         | 
| 12 | 
            +
                GenerateTextAction,
         | 
| 13 | 
            +
                WorkInProgressAction,
         | 
| 14 | 
            +
            ]
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            from typing import List, Dict, Tuple, Type
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            from blueness import module
         | 
| 4 | 
            +
            from blue_assistant.script.actions.generic import GenericAction
         | 
| 5 | 
            +
            from blue_assistant.script.repository.base.classes import BaseScript
         | 
| 6 | 
            +
            from blue_assistant.script.actions import list_of_actions
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            from blue_assistant import NAME
         | 
| 9 | 
            +
            from blue_assistant.logger import logger
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            NAME = module.name(__file__, NAME)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
            def get_action_class(
         | 
| 15 | 
            +
                action_name: str,
         | 
| 16 | 
            +
            ) -> Tuple[bool, Type[GenericAction]]:
         | 
| 17 | 
            +
                for action_class in list_of_actions:
         | 
| 18 | 
            +
                    if action_class.name == action_name:
         | 
| 19 | 
            +
                        return True, action_class
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                logger.error(f"{action_name}: action not found.")
         | 
| 22 | 
            +
                return False, GenericAction
         | 
| 23 | 
            +
             | 
| 24 | 
            +
             | 
| 25 | 
            +
            def perform_action(
         | 
| 26 | 
            +
                script: BaseScript,
         | 
| 27 | 
            +
                node_name: str,
         | 
| 28 | 
            +
            ) -> Tuple[bool, Dict]:
         | 
| 29 | 
            +
                action_name = script.nodes[node_name].get("action", "unknown")
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                success, action_class = get_action_class(action_name=action_name)
         | 
| 32 | 
            +
                if not success:
         | 
| 33 | 
            +
                    return False, {
         | 
| 34 | 
            +
                        "error": f"{action_name}: action not found.",
         | 
| 35 | 
            +
                    }
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                logger.info(
         | 
| 38 | 
            +
                    "{}.perform_action: {} == {} on {}".format(
         | 
| 39 | 
            +
                        NAME,
         | 
| 40 | 
            +
                        action_name,
         | 
| 41 | 
            +
                        action_class.__name__,
         | 
| 42 | 
            +
                        node_name,
         | 
| 43 | 
            +
                    )
         | 
| 44 | 
            +
                )
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                action_object = action_class(
         | 
| 47 | 
            +
                    script=script,
         | 
| 48 | 
            +
                )
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                return action_object.perform(
         | 
| 51 | 
            +
                    node_name=node_name,
         | 
| 52 | 
            +
                )
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            from typing import Dict, Tuple
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            from blue_objects import file
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            from blue_assistant.script.actions.generic import GenericAction
         | 
| 6 | 
            +
            from blue_assistant.logger import logger
         | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
            class GenerateImageAction(GenericAction):
         | 
| 10 | 
            +
                name = file.name(__file__)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def perform(
         | 
| 13 | 
            +
                    self,
         | 
| 14 | 
            +
                    node_name: str,
         | 
| 15 | 
            +
                ) -> Tuple[bool, Dict]:
         | 
| 16 | 
            +
                    success, generic_metadata = super().perform(node_name=node_name)
         | 
| 17 | 
            +
                    if not success:
         | 
| 18 | 
            +
                        return success, generic_metadata
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    logger.info(f"🪄 generating image ...: {node_name}")
         | 
| 21 | 
            +
                    metadata = {}
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    metadata.update(generic_metadata)
         | 
| 24 | 
            +
                    return True, metadata
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            from typing import Dict, Tuple
         | 
| 2 | 
            +
            from openai import OpenAI
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            from blueness import module
         | 
| 5 | 
            +
            from blue_objects import file
         | 
| 6 | 
            +
            from openai_commands.env import OPENAI_API_KEY
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            from blue_assistant import NAME
         | 
| 9 | 
            +
            from blue_assistant.env import BLUE_ASSISTANT_DEFAULT_MODEL, BLUE_ASSISTANT_MAX_TOKEN
         | 
| 10 | 
            +
            from blue_assistant.script.actions.generic import GenericAction
         | 
| 11 | 
            +
            from blue_assistant.logger import logger
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            NAME = module.name(__file__, NAME)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
            class GenerateTextAction(GenericAction):
         | 
| 17 | 
            +
                name = file.name(__file__)
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def perform(
         | 
| 20 | 
            +
                    self,
         | 
| 21 | 
            +
                    node_name: str,
         | 
| 22 | 
            +
                ) -> Tuple[bool, Dict]:
         | 
| 23 | 
            +
                    metadata = {}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    if not OPENAI_API_KEY:
         | 
| 26 | 
            +
                        logger.error("OPENAI_API_KEY is not set.")
         | 
| 27 | 
            +
                        return False, {}
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    success, generic_metadata = super().perform(node_name=node_name)
         | 
| 30 | 
            +
                    if not success:
         | 
| 31 | 
            +
                        return success, generic_metadata
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    client = OpenAI(api_key=OPENAI_API_KEY)
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    try:
         | 
| 36 | 
            +
                        response = client.chat.completions.create(
         | 
| 37 | 
            +
                            messages=[
         | 
| 38 | 
            +
                                {
         | 
| 39 | 
            +
                                    "role": "user",
         | 
| 40 | 
            +
                                    "content": [
         | 
| 41 | 
            +
                                        {
         | 
| 42 | 
            +
                                            "type": "text",
         | 
| 43 | 
            +
                                            "text": self.script.nodes[node_name]["prompt"],
         | 
| 44 | 
            +
                                        }
         | 
| 45 | 
            +
                                    ],
         | 
| 46 | 
            +
                                }
         | 
| 47 | 
            +
                            ],
         | 
| 48 | 
            +
                            model=BLUE_ASSISTANT_DEFAULT_MODEL,
         | 
| 49 | 
            +
                            max_tokens=BLUE_ASSISTANT_MAX_TOKEN,
         | 
| 50 | 
            +
                        )
         | 
| 51 | 
            +
                    except Exception as e:
         | 
| 52 | 
            +
                        logger.error(str(e))
         | 
| 53 | 
            +
                        return False, {"error": str(e)}
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    if self.script.verbose:
         | 
| 56 | 
            +
                        logger.info("response: {}".format(response))
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    if not response.choices:
         | 
| 59 | 
            +
                        logger.error("no choice.")
         | 
| 60 | 
            +
                        return False, {}
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    metadata["reply"] = response.choices[0].message.content
         | 
| 63 | 
            +
                    logger.info("🗣️ reply: {}".format(metadata["reply"]))
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    metadata.update(generic_metadata)
         | 
| 66 | 
            +
                    return True, metadata
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            from typing import Dict, Tuple
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            from blueness import module
         | 
| 4 | 
            +
            from blue_objects import file
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            from blue_assistant import NAME
         | 
| 7 | 
            +
            from blue_assistant.script.repository.base.classes import BaseScript
         | 
| 8 | 
            +
            from blue_assistant.logger import logger
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            NAME = module.name(__file__, NAME)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
             | 
| 13 | 
            +
            class GenericAction:
         | 
| 14 | 
            +
                name = file.name(__file__)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def __init__(
         | 
| 17 | 
            +
                    self,
         | 
| 18 | 
            +
                    script: BaseScript,
         | 
| 19 | 
            +
                ):
         | 
| 20 | 
            +
                    self.script = script
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def perform(
         | 
| 23 | 
            +
                    self,
         | 
| 24 | 
            +
                    node_name: str,
         | 
| 25 | 
            +
                ) -> Tuple[bool, Dict]:
         | 
| 26 | 
            +
                    logger.info(
         | 
| 27 | 
            +
                        "{}.perform({}) on {}.{} ...".format(
         | 
| 28 | 
            +
                            NAME,
         | 
| 29 | 
            +
                            self.__class__.__name__,
         | 
| 30 | 
            +
                            self.script.name,
         | 
| 31 | 
            +
                            node_name,
         | 
| 32 | 
            +
                        ),
         | 
| 33 | 
            +
                    )
         | 
| 34 | 
            +
                    return True, {}
         | 
    
        blue_assistant/script/load.py
    CHANGED
    
    | @@ -1,17 +1,27 @@ | |
| 1 | 
            -
            from typing import Tuple
         | 
| 1 | 
            +
            from typing import Tuple, Type
         | 
| 2 2 |  | 
| 3 3 | 
             
            from blue_assistant.script.repository import list_of_script_classes
         | 
| 4 | 
            -
            from blue_assistant.script.repository. | 
| 4 | 
            +
            from blue_assistant.script.repository.base.classes import BaseScript
         | 
| 5 5 | 
             
            from blue_assistant.logger import logger
         | 
| 6 6 |  | 
| 7 7 |  | 
| 8 8 | 
             
            def load_script(
         | 
| 9 9 | 
             
                script_name: str,
         | 
| 10 | 
            +
                object_name: str,
         | 
| 10 11 | 
             
                verbose: bool = False,
         | 
| 11 | 
            -
            ) -> Tuple[bool,  | 
| 12 | 
            -
                 | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 12 | 
            +
            ) -> Tuple[bool, BaseScript]:
         | 
| 13 | 
            +
                found: bool = False
         | 
| 14 | 
            +
                script_class: Type[BaseScript] = BaseScript
         | 
| 15 | 
            +
                for script_class_option in list_of_script_classes:
         | 
| 16 | 
            +
                    if script_class_option.name == script_name:
         | 
| 17 | 
            +
                        found = True
         | 
| 18 | 
            +
                        script_class = script_class_option
         | 
| 19 | 
            +
                        break
         | 
| 15 20 |  | 
| 16 | 
            -
                 | 
| 17 | 
            -
             | 
| 21 | 
            +
                if not found:
         | 
| 22 | 
            +
                    logger.error(f"{script_name}: script not found.")
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                return found, script_class(
         | 
| 25 | 
            +
                    object_name=object_name,
         | 
| 26 | 
            +
                    verbose=verbose,
         | 
| 27 | 
            +
                )
         | 
| @@ -1,12 +1,14 @@ | |
| 1 1 | 
             
            from typing import List, Type
         | 
| 2 2 |  | 
| 3 | 
            -
            from blue_assistant.script.repository.generic import GenericScript
         | 
| 3 | 
            +
            from blue_assistant.script.repository.generic.classes import GenericScript
         | 
| 4 4 | 
             
            from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
         | 
| 5 | 
            +
            from blue_assistant.script.repository.hue.classes import HueScript
         | 
| 5 6 | 
             
            from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
         | 
| 6 7 |  | 
| 7 8 | 
             
            list_of_script_classes: List[Type[GenericScript]] = [
         | 
| 8 9 | 
             
                GenericScript,
         | 
| 9 10 | 
             
                BlueAmoScript,
         | 
| 11 | 
            +
                HueScript,
         | 
| 10 12 | 
             
                MiningOnMoonScript,
         | 
| 11 13 | 
             
            ]
         | 
| 12 14 |  | 
| @@ -1,8 +1,5 @@ | |
| 1 | 
            -
            from typing import Dict
         | 
| 2 | 
            -
            from tqdm import tqdm
         | 
| 3 | 
            -
             | 
| 4 1 | 
             
            from blue_objects import file, path
         | 
| 5 | 
            -
             | 
| 2 | 
            +
             | 
| 6 3 |  | 
| 7 4 | 
             
            from blue_assistant.script.repository.generic.classes import GenericScript
         | 
| 8 5 | 
             
            from blue_assistant.logger import logger
         | 
| @@ -10,33 +7,3 @@ from blue_assistant.logger import logger | |
| 10 7 |  | 
| 11 8 | 
             
            class BlueAmoScript(GenericScript):
         | 
| 12 9 | 
             
                name = path.name(file.path(__file__))
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                def __init__(
         | 
| 15 | 
            -
                    self,
         | 
| 16 | 
            -
                    verbose: bool = False,
         | 
| 17 | 
            -
                ):
         | 
| 18 | 
            -
                    super().__init__(verbose=verbose)
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                def run(
         | 
| 21 | 
            -
                    self,
         | 
| 22 | 
            -
                    object_name: str,
         | 
| 23 | 
            -
                ) -> bool:
         | 
| 24 | 
            -
                    if not super().run(object_name=object_name):
         | 
| 25 | 
            -
                        return False
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    metadata: Dict[Dict] = {"nodes": {}}
         | 
| 28 | 
            -
                    for node_name, node in tqdm(self.nodes.items()):
         | 
| 29 | 
            -
                        logger.info(
         | 
| 30 | 
            -
                            "{}{}".format(
         | 
| 31 | 
            -
                                node_name,
         | 
| 32 | 
            -
                                f": {node}" if self.verbose else " ...",
         | 
| 33 | 
            -
                            )
         | 
| 34 | 
            -
                        )
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                        metadata["nodes"][node_name] = "..."
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                    return post_to_object(
         | 
| 39 | 
            -
                        object_name,
         | 
| 40 | 
            -
                        "output",
         | 
| 41 | 
            -
                        metadata,
         | 
| 42 | 
            -
                    )
         | 
| @@ -1,69 +1,72 @@ | |
| 1 1 | 
             
            from typing import Dict, List
         | 
| 2 2 | 
             
            import os
         | 
| 3 | 
            +
            from tqdm import tqdm
         | 
| 4 | 
            +
             | 
| 3 5 |  | 
| 4 6 | 
             
            from blueness import module
         | 
| 5 7 | 
             
            from blue_objects import file, path
         | 
| 6 8 | 
             
            from blue_objects.metadata import post_to_object
         | 
| 7 9 |  | 
| 8 10 | 
             
            from blue_assistant import NAME
         | 
| 11 | 
            +
            from blue_assistant.script.repository.base.classes import BaseScript
         | 
| 12 | 
            +
            from blue_assistant.script.actions.functions import perform_action
         | 
| 9 13 | 
             
            from blue_assistant.logger import logger
         | 
| 10 14 |  | 
| 11 15 |  | 
| 12 16 | 
             
            NAME = module.name(__file__, NAME)
         | 
| 13 17 |  | 
| 14 18 |  | 
| 15 | 
            -
            class GenericScript:
         | 
| 19 | 
            +
            class GenericScript(BaseScript):
         | 
| 16 20 | 
             
                name = path.name(file.path(__file__))
         | 
| 17 21 |  | 
| 18 | 
            -
                def  | 
| 22 | 
            +
                def run(
         | 
| 19 23 | 
             
                    self,
         | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
                    metadata_filename = os.path.join(
         | 
| 25 | 
            -
                        file.path(__file__),
         | 
| 26 | 
            -
                        f"../{self.name}",
         | 
| 27 | 
            -
                        "metadata.yaml",
         | 
| 28 | 
            -
                    )
         | 
| 29 | 
            -
                    self.metadata: Dict
         | 
| 30 | 
            -
                    success, self.metadata = file.load_yaml(metadata_filename)
         | 
| 31 | 
            -
                    assert success, f"cannot load {self.name}/metadata.yaml"
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                    logger.info("loaded {} node(s)".format(len(self.nodes)))
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                    logger.info("loaded {} variable(s)".format(len(self.vars)))
         | 
| 36 | 
            -
                    if verbose:
         | 
| 37 | 
            -
                        for var_name, var_value in self.vars.items():
         | 
| 38 | 
            -
                            logger.info("{}: {}".format(var_name, var_value))
         | 
| 24 | 
            +
                ) -> bool:
         | 
| 25 | 
            +
                    if not super().run():
         | 
| 26 | 
            +
                        return False
         | 
| 39 27 |  | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
                     | 
| 28 | 
            +
                    metadata: Dict[Dict] = {"nodes": {}}
         | 
| 29 | 
            +
                    success: bool = True
         | 
| 30 | 
            +
                    while (
         | 
| 31 | 
            +
                        not all(self.G.nodes[node]["completed"] for node in self.G.nodes)
         | 
| 32 | 
            +
                        and success
         | 
| 33 | 
            +
                    ):
         | 
| 34 | 
            +
                        for node_name in tqdm(self.G.nodes):
         | 
| 35 | 
            +
                            if self.G.nodes[node_name]["completed"]:
         | 
| 36 | 
            +
                                continue
         | 
| 43 37 |  | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 38 | 
            +
                            pending_dependencies = [
         | 
| 39 | 
            +
                                node_name_
         | 
| 40 | 
            +
                                for node_name_ in self.G.successors(node_name)
         | 
| 41 | 
            +
                                if not self.G.nodes[node_name_]["completed"]
         | 
| 42 | 
            +
                            ]
         | 
| 43 | 
            +
                            if pending_dependencies:
         | 
| 44 | 
            +
                                logger.info(
         | 
| 45 | 
            +
                                    'node "{}": {} pending dependenci(es): {}'.format(
         | 
| 46 | 
            +
                                        node_name,
         | 
| 47 | 
            +
                                        len(pending_dependencies),
         | 
| 48 | 
            +
                                        ", ".join(pending_dependencies),
         | 
| 49 | 
            +
                                    )
         | 
| 50 | 
            +
                                )
         | 
| 51 | 
            +
                                continue
         | 
| 47 52 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 53 | 
            +
                            success, output = perform_action(
         | 
| 54 | 
            +
                                script=self,
         | 
| 55 | 
            +
                                node_name=node_name,
         | 
| 56 | 
            +
                            )
         | 
| 57 | 
            +
                            self.G.nodes[node_name]["completed"] = success
         | 
| 58 | 
            +
                            metadata["nodes"][node_name] = {
         | 
| 59 | 
            +
                                "success": success,
         | 
| 60 | 
            +
                                "output": output,
         | 
| 61 | 
            +
                            }
         | 
| 62 | 
            +
                            if not success:
         | 
| 63 | 
            +
                                break
         | 
| 51 64 |  | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
                     | 
| 57 | 
            -
                         | 
| 58 | 
            -
                            NAME,
         | 
| 59 | 
            -
                            self.__class__.__name__,
         | 
| 60 | 
            -
                            self.name,
         | 
| 61 | 
            -
                            object_name,
         | 
| 62 | 
            -
                        )
         | 
| 63 | 
            -
                    )
         | 
| 65 | 
            +
                    if not post_to_object(
         | 
| 66 | 
            +
                        self.object_name,
         | 
| 67 | 
            +
                        "output",
         | 
| 68 | 
            +
                        metadata,
         | 
| 69 | 
            +
                    ):
         | 
| 70 | 
            +
                        return False
         | 
| 64 71 |  | 
| 65 | 
            -
                    return  | 
| 66 | 
            -
                        object_name,
         | 
| 67 | 
            -
                        "script",
         | 
| 68 | 
            -
                        self.script,
         | 
| 69 | 
            -
                    )
         | 
| 72 | 
            +
                    return success
         | 
| @@ -1,6 +1,3 @@ | |
| 1 | 
            -
            from typing import Dict
         | 
| 2 | 
            -
            from tqdm import tqdm
         | 
| 3 | 
            -
             | 
| 4 1 | 
             
            from blue_objects import file, path
         | 
| 5 2 |  | 
| 6 3 | 
             
            from blue_assistant.script.repository.generic.classes import GenericScript
         | 
| @@ -8,9 +5,3 @@ from blue_assistant.script.repository.generic.classes import GenericScript | |
| 8 5 |  | 
| 9 6 | 
             
            class MiningOnMoonScript(GenericScript):
         | 
| 10 7 | 
             
                name = path.name(file.path(__file__))
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                def __init__(
         | 
| 13 | 
            -
                    self,
         | 
| 14 | 
            -
                    verbose: bool = False,
         | 
| 15 | 
            -
                ):
         | 
| 16 | 
            -
                    super().__init__(verbose=verbose)
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Metadata-Version: 2.2
         | 
| 2 2 | 
             
            Name: blue_assistant
         | 
| 3 | 
            -
            Version: 4. | 
| 3 | 
            +
            Version: 4.62.1
         | 
| 4 4 | 
             
            Summary: 🧠 An AI Assistant.
         | 
| 5 5 | 
             
            Home-page: https://github.com/kamangir/blue-assistant
         | 
| 6 6 | 
             
            Author: Arash Abadpour (Kamangir)
         | 
| @@ -16,7 +16,9 @@ Requires-Dist: blueness | |
| 16 16 | 
             
            Requires-Dist: blue-options
         | 
| 17 17 | 
             
            Requires-Dist: abcli
         | 
| 18 18 | 
             
            Requires-Dist: openai_commands
         | 
| 19 | 
            +
            Requires-Dist: blueflow
         | 
| 19 20 | 
             
            Requires-Dist: boto3
         | 
| 21 | 
            +
            Requires-Dist: openai
         | 
| 20 22 | 
             
            Requires-Dist: geojson
         | 
| 21 23 | 
             
            Requires-Dist: geopandas
         | 
| 22 24 | 
             
            Requires-Dist: matplotlib
         | 
| @@ -28,6 +30,8 @@ Requires-Dist: pylint | |
| 28 30 | 
             
            Requires-Dist: pytest
         | 
| 29 31 | 
             
            Requires-Dist: python-dotenv[cli]
         | 
| 30 32 | 
             
            Requires-Dist: tqdm
         | 
| 33 | 
            +
            Requires-Dist: networkx
         | 
| 34 | 
            +
            Requires-Dist: pydot
         | 
| 31 35 | 
             
            Dynamic: author
         | 
| 32 36 | 
             
            Dynamic: author-email
         | 
| 33 37 | 
             
            Dynamic: classifier
         | 
| @@ -48,11 +52,14 @@ pip install blue-assistant | |
| 48 52 |  | 
| 49 53 | 
             
            ```mermaid
         | 
| 50 54 | 
             
            graph LR
         | 
| 55 | 
            +
                assistant_script_list["@assistant<br>script<br>list"]
         | 
| 51 56 | 
             
                assistant_script_run["@assistant<br>script<br>run -<br><script><br><object-name>"]
         | 
| 52 57 |  | 
| 53 58 | 
             
                script["📜 script"]:::folder
         | 
| 54 59 | 
             
                object["📂 object"]:::folder
         | 
| 55 60 |  | 
| 61 | 
            +
                script --> assistant_script_list
         | 
| 62 | 
            +
             | 
| 56 63 | 
             
                script --> assistant_script_run
         | 
| 57 64 | 
             
                object --> assistant_script_run
         | 
| 58 65 | 
             
                assistant_script_run --> object
         | 
| @@ -65,4 +72,4 @@ graph LR | |
| 65 72 |  | 
| 66 73 | 
             
            [](https://github.com/kamangir/blue-assistant/actions/workflows/pylint.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/pytest.yml) [](https://github.com/kamangir/blue-assistant/actions/workflows/bashtest.yml) [](https://pypi.org/project/blue-assistant/) [](https://pypistats.org/packages/blue-assistant)
         | 
| 67 74 |  | 
| 68 | 
            -
            built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4. | 
| 75 | 
            +
            built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.62.1`](https://github.com/kamangir/blue-assistant).
         | 
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            blue_assistant/README.py,sha256=q6EWCy7zojQESGDF-2xEoXS1Bl0wRJTe2jw_1QM_WYw,600
         | 
| 2 | 
            -
            blue_assistant/__init__.py,sha256= | 
| 2 | 
            +
            blue_assistant/__init__.py,sha256=raQKlM2ZVTRayybALjBn2GVLRPH_vj0B49nDQRFJZls,310
         | 
| 3 3 | 
             
            blue_assistant/__main__.py,sha256=URtal70XZc0--3FDTYWcLtnGOqBYjMX9gt-L1k8hDXI,361
         | 
| 4 | 
            -
            blue_assistant/config.env,sha256= | 
| 5 | 
            -
            blue_assistant/env.py,sha256= | 
| 4 | 
            +
            blue_assistant/config.env,sha256=JV9zx17FflIPmV1hK-yuM0GlrUjkGuaQ_EzPFPTkoXM,66
         | 
| 5 | 
            +
            blue_assistant/env.py,sha256=rgIlKVsALrRD1sYJV3SkFfzIvWNavix2HN0sSy2cCi4,391
         | 
| 6 6 | 
             
            blue_assistant/functions.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
         | 
| 7 7 | 
             
            blue_assistant/host.py,sha256=SapEe4s9J-7gV3F9JuWEmSfslCeWuJ5f7a-nFObFBrI,208
         | 
| 8 8 | 
             
            blue_assistant/logger.py,sha256=3MfsXwivdRfVPjAjqdQld3iOg9JB6olbACL8t8gIRgI,105
         | 
| @@ -14,27 +14,35 @@ blue_assistant/.abcli/alias.sh,sha256=MCJzXaDnX1QMllWsZJJkDePBYt1nY9ZWa3o4msfGD2 | |
| 14 14 | 
             
            blue_assistant/.abcli/blue_assistant.sh,sha256=plLTQQerVmfb_SNlOkv0MEaQCF7YdsOHzCq0M3FWT4c,239
         | 
| 15 15 | 
             
            blue_assistant/.abcli/browse.sh,sha256=qZ_RK_WnsjmF-hfWKiMEOnnv22QtZh9HQ0VFJUbP6aI,294
         | 
| 16 16 | 
             
            blue_assistant/.abcli/script.sh,sha256=XIkY4eZyFPKLi_mLoPMbnq76E4K1GG3xxha8VYJC2zI,356
         | 
| 17 | 
            +
            blue_assistant/.abcli/script/list.sh,sha256=2lcVfqDfZP50NszF8o5YCo3TrJKeDc_qo7MTAF3XTGw,131
         | 
| 17 18 | 
             
            blue_assistant/.abcli/script/run.sh,sha256=kSXmyM9NUj2X2orSGyu5t_P5frG-gyumbRq-xqF692c,911
         | 
| 18 19 | 
             
            blue_assistant/.abcli/tests/README.sh,sha256=Qs0YUxVB1OZZ70Nqw2kT1LKXeUnC5-XfQRMfqb8Cbwg,152
         | 
| 19 | 
            -
            blue_assistant/.abcli/tests/help.sh,sha256= | 
| 20 | 
            -
            blue_assistant/.abcli/tests/ | 
| 20 | 
            +
            blue_assistant/.abcli/tests/help.sh,sha256=mENB9ZNBEEPmIs9tp8WkQW3dq75_US7EI7_-d4IJQpo,724
         | 
| 21 | 
            +
            blue_assistant/.abcli/tests/script_list.sh,sha256=OVOwWO9wR0eeDZTM6uub-eTKbz3eswU3vEUPWXcK-gQ,178
         | 
| 22 | 
            +
            blue_assistant/.abcli/tests/script_run.sh,sha256=mBFLaIl2bMQhVjRr2EN4ciVUvYkaKcO7bY4uvt1oqB0,715
         | 
| 21 23 | 
             
            blue_assistant/.abcli/tests/version.sh,sha256=oR2rvYR8zi-0VDPIdPJsmsmWwYaamT8dmNTqUh3-8Gw,154
         | 
| 22 24 | 
             
            blue_assistant/help/__init__.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
         | 
| 23 25 | 
             
            blue_assistant/help/__main__.py,sha256=cVejR7OpoWPg0qLbm-PZf5TuJS27x49jzfiyCLyzEns,241
         | 
| 24 26 | 
             
            blue_assistant/help/functions.py,sha256=9WsmXGMN-R7sqlkGLK0nY90Peg8Gah4rIu75QbLhImo,689
         | 
| 25 | 
            -
            blue_assistant/help/script.py,sha256= | 
| 27 | 
            +
            blue_assistant/help/script.py,sha256=wvS_5FWu9LAsaDDq7UoxXEadRwGseYqwu2P-9dNc5Bo,1077
         | 
| 26 28 | 
             
            blue_assistant/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
         | 
| 27 | 
            -
            blue_assistant/script/__main__.py,sha256= | 
| 28 | 
            -
            blue_assistant/script/load.py,sha256= | 
| 29 | 
            -
            blue_assistant/script/ | 
| 29 | 
            +
            blue_assistant/script/__main__.py,sha256=immGrRfasPHdPDxZJweu0coi_V0jg8_2zfqTnRxNfaU,1529
         | 
| 30 | 
            +
            blue_assistant/script/load.py,sha256=Bd5L9HBL0Yh1MLGAyGrQX3XQLH-UiOWLsHJvzCmNs3g,773
         | 
| 31 | 
            +
            blue_assistant/script/actions/__init__.py,sha256=8Sp6avoJGDXVORvx5mvkxTNaxjz_KevKN4Wb8qLZHsQ,487
         | 
| 32 | 
            +
            blue_assistant/script/actions/functions.py,sha256=DcgNzDvGM2rz4DJE6kNSblPZ-qePdVwPOUdV8uKdcjw,1330
         | 
| 33 | 
            +
            blue_assistant/script/actions/generate_image.py,sha256=wRfWU_xA26rhl7BAXDS_XLPFhxLLl2q1tVuqx5QSGIE,628
         | 
| 34 | 
            +
            blue_assistant/script/actions/generate_text.py,sha256=6JtNikwl1ESgIuv6Kfzyonn0FImyI0O0Te6uJEVNmtg,1986
         | 
| 35 | 
            +
            blue_assistant/script/actions/generic.py,sha256=3sHSzPgrOnYGLebUa1ToUBJCD-GCiN5xVwCqjqaLChQ,748
         | 
| 36 | 
            +
            blue_assistant/script/actions/wip.py,sha256=K4kJE4bn3u6o-QWTESPydO_eD54zOwZbU9WLAO94z1Q,171
         | 
| 37 | 
            +
            blue_assistant/script/repository/__init__.py,sha256=WFkbe-6yyljpmeVpXgLhOPt-YRc7BwkRNzPO-7Wz0Dg,573
         | 
| 30 38 | 
             
            blue_assistant/script/repository/blue_amo/__init__.py,sha256=WjL9GIlN-DBnbUMJ8O_FxTp0rcVGlsIS3H9YtXEefTk,76
         | 
| 31 | 
            -
            blue_assistant/script/repository/blue_amo/classes.py,sha256= | 
| 39 | 
            +
            blue_assistant/script/repository/blue_amo/classes.py,sha256=RY1gjZVPX8xu7nfeiZoTL8RTpu73RsoaNv4ZoGv9NNs,234
         | 
| 32 40 | 
             
            blue_assistant/script/repository/generic/__init__.py,sha256=kLffGsQMQAFJTw6IZBE5eBxvshP1x9wwHHR4hsDJblo,75
         | 
| 33 | 
            -
            blue_assistant/script/repository/generic/classes.py,sha256= | 
| 41 | 
            +
            blue_assistant/script/repository/generic/classes.py,sha256=goE6n1VUtp-FJGJxZ2fmeakFPKowPKK07dzndI2Ay0k,2117
         | 
| 34 42 | 
             
            blue_assistant/script/repository/moon_datasets/__init__.py,sha256=aCtmP2avh3yKAJ668S3GsLR9vbBOm5zt9FSFCqy_tAs,86
         | 
| 35 | 
            -
            blue_assistant/script/repository/moon_datasets/classes.py,sha256= | 
| 36 | 
            -
            blue_assistant-4. | 
| 37 | 
            -
            blue_assistant-4. | 
| 38 | 
            -
            blue_assistant-4. | 
| 39 | 
            -
            blue_assistant-4. | 
| 40 | 
            -
            blue_assistant-4. | 
| 43 | 
            +
            blue_assistant/script/repository/moon_datasets/classes.py,sha256=68zThDhjF9gGRnsw8EKNLGOMBFbCSljt0jGovuOzCAc,197
         | 
| 44 | 
            +
            blue_assistant-4.62.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
         | 
| 45 | 
            +
            blue_assistant-4.62.1.dist-info/METADATA,sha256=nB-ghPlc86Ahf4c1--qJ3OK5OzBKxu3EJ4pEODBfzOE,2625
         | 
| 46 | 
            +
            blue_assistant-4.62.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
         | 
| 47 | 
            +
            blue_assistant-4.62.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
         | 
| 48 | 
            +
            blue_assistant-4.62.1.dist-info/RECORD,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         |