blue-assistant 4.24.1__tar.gz → 4.43.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.
- {blue_assistant-4.24.1/blue_assistant.egg-info → blue_assistant-4.43.1}/PKG-INFO +10 -8
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/README.md +8 -6
- blue_assistant-4.24.1/blue_assistant/.abcli/chat.sh → blue_assistant-4.43.1/blue_assistant/.abcli/script/run.sh +9 -7
- blue_assistant-4.43.1/blue_assistant/.abcli/script.sh +15 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/tests/help.sh +2 -1
- blue_assistant-4.43.1/blue_assistant/.abcli/tests/script_run.sh +27 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/__init__.py +2 -2
- blue_assistant-4.43.1/blue_assistant/config.env +1 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/env.py +2 -2
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/help/functions.py +2 -2
- blue_assistant-4.24.1/blue_assistant/help/chat.py → blue_assistant-4.43.1/blue_assistant/help/script.py +14 -5
- blue_assistant-4.43.1/blue_assistant/script/__main__.py +58 -0
- blue_assistant-4.43.1/blue_assistant/script/load.py +17 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/__init__.py +15 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/blue_amo/__init__.py +1 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/blue_amo/classes.py +42 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/generic/__init__.py +1 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/generic/classes.py +51 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/moon_datasets/__init__.py +1 -0
- blue_assistant-4.43.1/blue_assistant/script/repository/moon_datasets/classes.py +16 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1/blue_assistant.egg-info}/PKG-INFO +10 -8
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant.egg-info/SOURCES.txt +15 -8
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/setup.py +5 -4
- blue_assistant-4.24.1/blue_assistant/.abcli/tests/chat.sh +0 -12
- blue_assistant-4.24.1/blue_assistant/chat/__main__.py +0 -46
- blue_assistant-4.24.1/blue_assistant/chat/context.py +0 -107
- blue_assistant-4.24.1/blue_assistant/chat/functions.py +0 -36
- blue_assistant-4.24.1/blue_assistant/config.env +0 -1
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/LICENSE +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/MANIFEST.in +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/abcli.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/actions.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/alias.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/browse.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/tests/README.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/.abcli/tests/version.sh +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/README.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/__main__.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/functions.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/help/__init__.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/help/__main__.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/host.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/logger.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/sample.env +0 -0
- {blue_assistant-4.24.1/blue_assistant/chat → blue_assistant-4.43.1/blue_assistant/script}/__init__.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant/urls.py +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant.egg-info/requires.txt +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant.egg-info/top_level.txt +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/pyproject.toml +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/requirements.txt +0 -0
- {blue_assistant-4.24.1 → blue_assistant-4.43.1}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
4
|
-
Summary:
|
3
|
+
Version: 4.43.1
|
4
|
+
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
7
7
|
Author-email: arash@kamangir.net
|
@@ -38,9 +38,9 @@ Dynamic: license
|
|
38
38
|
Dynamic: requires-dist
|
39
39
|
Dynamic: summary
|
40
40
|
|
41
|
-
#
|
41
|
+
# 🧠 blue-assistant
|
42
42
|
|
43
|
-
|
43
|
+
🧠 `@assistant` is an AI assistant.
|
44
44
|
|
45
45
|
```bash
|
46
46
|
pip install blue-assistant
|
@@ -48,12 +48,14 @@ pip install blue-assistant
|
|
48
48
|
|
49
49
|
```mermaid
|
50
50
|
graph LR
|
51
|
-
|
51
|
+
assistant_script_run["@assistant<br>script<br>run -<br><script><br><object-name>"]
|
52
52
|
|
53
|
+
script["📜 script"]:::folder
|
53
54
|
object["📂 object"]:::folder
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
script --> assistant_script_run
|
57
|
+
object --> assistant_script_run
|
58
|
+
assistant_script_run --> object
|
57
59
|
|
58
60
|
classDef folder fill:#999,stroke:#333,stroke-width:2px;
|
59
61
|
```
|
@@ -63,4 +65,4 @@ graph LR
|
|
63
65
|
|
64
66
|
[](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)
|
65
67
|
|
66
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on
|
68
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.43.1`](https://github.com/kamangir/blue-assistant).
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# 🧠 blue-assistant
|
2
2
|
|
3
|
-
|
3
|
+
🧠 `@assistant` is an AI assistant.
|
4
4
|
|
5
5
|
```bash
|
6
6
|
pip install blue-assistant
|
@@ -8,12 +8,14 @@ pip install blue-assistant
|
|
8
8
|
|
9
9
|
```mermaid
|
10
10
|
graph LR
|
11
|
-
|
11
|
+
assistant_script_run["@assistant<br>script<br>run -<br><script><br><object-name>"]
|
12
12
|
|
13
|
+
script["📜 script"]:::folder
|
13
14
|
object["📂 object"]:::folder
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
script --> assistant_script_run
|
17
|
+
object --> assistant_script_run
|
18
|
+
assistant_script_run --> object
|
17
19
|
|
18
20
|
classDef folder fill:#999,stroke:#333,stroke-width:2px;
|
19
21
|
```
|
@@ -23,4 +25,4 @@ graph LR
|
|
23
25
|
|
24
26
|
[](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)
|
25
27
|
|
26
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on
|
28
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.43.1`](https://github.com/kamangir/blue-assistant).
|
@@ -1,23 +1,25 @@
|
|
1
1
|
#! /usr/bin/env bash
|
2
2
|
|
3
|
-
function
|
3
|
+
function blue_assistant_script_run() {
|
4
4
|
local options=$1
|
5
5
|
local do_dryrun=$(abcli_option_int "$options" dryrun 0)
|
6
6
|
local do_download=$(abcli_option_int "$options" download 0)
|
7
7
|
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
|
8
8
|
|
9
|
-
local
|
10
|
-
local
|
9
|
+
local script_options=$2
|
10
|
+
local script_name=$(abcli_option "$script_options" script generic)
|
11
11
|
|
12
|
-
local object_name=$(abcli_clarify_object $3
|
12
|
+
local object_name=$(abcli_clarify_object $3 $script_name-$(abcli_string_timestamp_short))
|
13
13
|
[[ "$do_download" == 1 ]] &&
|
14
14
|
abcli_download - $object_name
|
15
15
|
|
16
|
+
abcli_log "running $script_name -> $object_name ..."
|
17
|
+
|
16
18
|
abcli_eval dryrun=$do_dryrun \
|
17
|
-
python3 -m blue_assistant.
|
18
|
-
|
19
|
+
python3 -m blue_assistant.script \
|
20
|
+
run \
|
21
|
+
--script_name $script_name \
|
19
22
|
--object_name $object_name \
|
20
|
-
--interactive $interactive \
|
21
23
|
"${@:4}"
|
22
24
|
[[ $? -ne 0 ]] && return 1
|
23
25
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
function blue_assistant_script() {
|
4
|
+
local task=$(abcli_unpack_keyword $1 help)
|
5
|
+
|
6
|
+
local function_name=blue_assistant_script_$task
|
7
|
+
if [[ $(type -t $function_name) == "function" ]]; then
|
8
|
+
$function_name "${@:2}"
|
9
|
+
return
|
10
|
+
fi
|
11
|
+
|
12
|
+
python3 -m blue_assistant.script "$@"
|
13
|
+
}
|
14
|
+
|
15
|
+
abcli_source_caller_suffix_path /script
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
function test_blue_assistant_script_run() {
|
4
|
+
local options=$1
|
5
|
+
local list_of_script_name=$(python3 -m blue_assistant.script \
|
6
|
+
get_list_of \
|
7
|
+
--delim +)
|
8
|
+
list_of_script_name=$(abcli_option "$options" script $list_of_script_name)
|
9
|
+
|
10
|
+
local script_name
|
11
|
+
for script_name in $(echo "$list_of_script_name" | tr + " "); do
|
12
|
+
abcli_log "testing $script_name ..."
|
13
|
+
|
14
|
+
abcli_eval ,$options \
|
15
|
+
blue_assistant_script_run \
|
16
|
+
~upload,$options \
|
17
|
+
script=$script_name \
|
18
|
+
test_blue_assistant_script_run-$(abcli_string_timestamp_short) \
|
19
|
+
"${@:2}"
|
20
|
+
|
21
|
+
[[ $? -ne 0 ]] && return 1
|
22
|
+
|
23
|
+
abcli_hr
|
24
|
+
done
|
25
|
+
|
26
|
+
return 0
|
27
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
BLUE_ASSISTANT_TEST_OBJECT=blue-amo
|
@@ -4,7 +4,7 @@ from blue_options.terminal import show_usage, xtra
|
|
4
4
|
from abcli.help.generic import help_functions as generic_help_functions
|
5
5
|
|
6
6
|
from blue_assistant import ALIAS
|
7
|
-
from blue_assistant.help.
|
7
|
+
from blue_assistant.help.script import help_functions as help_script
|
8
8
|
|
9
9
|
|
10
10
|
def help_browse(
|
@@ -29,6 +29,6 @@ help_functions = generic_help_functions(plugin_name=ALIAS)
|
|
29
29
|
help_functions.update(
|
30
30
|
{
|
31
31
|
"browse": help_browse,
|
32
|
-
"
|
32
|
+
"script": help_script,
|
33
33
|
}
|
34
34
|
)
|
@@ -2,26 +2,35 @@ from typing import List
|
|
2
2
|
|
3
3
|
from blue_options.terminal import show_usage, xtra
|
4
4
|
|
5
|
+
from blue_assistant.script.repository import list_of_script_names
|
5
6
|
|
6
|
-
|
7
|
+
|
8
|
+
def help_run(
|
7
9
|
tokens: List[str],
|
8
10
|
mono: bool,
|
9
11
|
) -> str:
|
10
12
|
options = xtra("download,dryrun,~upload", mono=mono)
|
11
13
|
|
12
|
-
|
14
|
+
script_options = "script=<script>"
|
13
15
|
|
14
16
|
args = ["--verbose 1"]
|
15
17
|
|
16
18
|
return show_usage(
|
17
19
|
[
|
18
20
|
"@assistant",
|
19
|
-
"
|
21
|
+
"script",
|
22
|
+
"run",
|
20
23
|
f"[{options}]",
|
21
|
-
f"[{
|
24
|
+
f"[{script_options}]",
|
22
25
|
"[-|<object-name>]",
|
23
26
|
]
|
24
27
|
+ args,
|
25
|
-
"
|
28
|
+
"run <object-name>.",
|
29
|
+
{
|
30
|
+
"script: {}".format(" | ".join(list_of_script_names)): [],
|
31
|
+
},
|
26
32
|
mono=mono,
|
27
33
|
)
|
34
|
+
|
35
|
+
|
36
|
+
help_functions = {"run": help_run}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import argparse
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blueness.argparse.generic import sys_exit
|
5
|
+
|
6
|
+
from blue_assistant import NAME
|
7
|
+
from blue_assistant.script.load import load_script
|
8
|
+
from blue_assistant.script.repository import list_of_script_names
|
9
|
+
from blue_assistant.logger import logger
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
parser = argparse.ArgumentParser(NAME)
|
14
|
+
parser.add_argument(
|
15
|
+
"task",
|
16
|
+
type=str,
|
17
|
+
help="get_list_of | run",
|
18
|
+
)
|
19
|
+
parser.add_argument(
|
20
|
+
"--script_name",
|
21
|
+
type=str,
|
22
|
+
help=" | ".join(list_of_script_names),
|
23
|
+
)
|
24
|
+
parser.add_argument(
|
25
|
+
"--object_name",
|
26
|
+
type=str,
|
27
|
+
)
|
28
|
+
parser.add_argument(
|
29
|
+
"--verbose",
|
30
|
+
type=int,
|
31
|
+
default=0,
|
32
|
+
help="0 | 1",
|
33
|
+
)
|
34
|
+
parser.add_argument(
|
35
|
+
"--delim",
|
36
|
+
type=str,
|
37
|
+
default="+",
|
38
|
+
)
|
39
|
+
args = parser.parse_args()
|
40
|
+
|
41
|
+
delim = " " if args.delim == "space" else args.delim
|
42
|
+
|
43
|
+
success = False
|
44
|
+
if args.task == "get_list_of":
|
45
|
+
success = True
|
46
|
+
print(delim.join(list_of_script_names))
|
47
|
+
elif args.task == "run":
|
48
|
+
success, script = load_script(
|
49
|
+
script_name=args.script_name,
|
50
|
+
verbose=args.verbose == 1,
|
51
|
+
)
|
52
|
+
|
53
|
+
if success:
|
54
|
+
success = script.run(object_name=args.object_name)
|
55
|
+
else:
|
56
|
+
success = None
|
57
|
+
|
58
|
+
sys_exit(logger, NAME, args.task, success)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from typing import Tuple
|
2
|
+
|
3
|
+
from blue_assistant.script.repository import list_of_script_classes
|
4
|
+
from blue_assistant.script.repository.generic import GenericScript
|
5
|
+
from blue_assistant.logger import logger
|
6
|
+
|
7
|
+
|
8
|
+
def load_script(
|
9
|
+
script_name: str,
|
10
|
+
verbose: bool = False,
|
11
|
+
) -> Tuple[bool, GenericScript]:
|
12
|
+
for script_class in list_of_script_classes:
|
13
|
+
if script_class.name == script_name:
|
14
|
+
return True, script_class(verbose=verbose)
|
15
|
+
|
16
|
+
logger.error(f"{script_name}: script not found.")
|
17
|
+
return False, GenericScript(verbose=verbose)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from typing import List, Type
|
2
|
+
|
3
|
+
from blue_assistant.script.repository.generic import GenericScript
|
4
|
+
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
5
|
+
from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
|
6
|
+
|
7
|
+
list_of_script_classes: List[Type[GenericScript]] = [
|
8
|
+
GenericScript,
|
9
|
+
BlueAmoScript,
|
10
|
+
MiningOnMoonScript,
|
11
|
+
]
|
12
|
+
|
13
|
+
list_of_script_names: List[str] = [
|
14
|
+
script_class.name for script_class in list_of_script_classes
|
15
|
+
]
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.blue_amo.classes import BlueAmoScript
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from tqdm import tqdm
|
3
|
+
|
4
|
+
from blue_objects import file, path
|
5
|
+
from blue_objects.metadata import post_to_object
|
6
|
+
|
7
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
|
11
|
+
class BlueAmoScript(GenericScript):
|
12
|
+
name = path.name(file.path(__file__))
|
13
|
+
|
14
|
+
def __init__(
|
15
|
+
self,
|
16
|
+
verbose: bool = False,
|
17
|
+
):
|
18
|
+
super().__init__(verbose=verbose)
|
19
|
+
|
20
|
+
def run(
|
21
|
+
self,
|
22
|
+
object_name: str,
|
23
|
+
) -> bool:
|
24
|
+
if not super().run(object_name=object_name):
|
25
|
+
return False
|
26
|
+
|
27
|
+
metadata: Dict[Dict] = {"nodes": {}}
|
28
|
+
for node_name, node in tqdm(self.script["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
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
from blueness import module
|
4
|
+
from blue_objects import file, path
|
5
|
+
from blue_objects.metadata import post_to_object
|
6
|
+
|
7
|
+
from blue_assistant import NAME
|
8
|
+
from blue_assistant.logger import logger
|
9
|
+
|
10
|
+
|
11
|
+
NAME = module.name(__file__, NAME)
|
12
|
+
|
13
|
+
|
14
|
+
class GenericScript:
|
15
|
+
name = path.name(file.path(__file__))
|
16
|
+
|
17
|
+
def __init__(
|
18
|
+
self,
|
19
|
+
verbose: bool = False,
|
20
|
+
):
|
21
|
+
self.verbose = verbose
|
22
|
+
|
23
|
+
metadata_filename = os.path.join(
|
24
|
+
file.path(__file__),
|
25
|
+
f"../{self.name}",
|
26
|
+
"metadata.yaml",
|
27
|
+
)
|
28
|
+
success, self.metadata = file.load_yaml(metadata_filename)
|
29
|
+
|
30
|
+
self.script = self.metadata.get("script", [])
|
31
|
+
|
32
|
+
assert success, f"cannot load {self.name}/metadata.yaml"
|
33
|
+
|
34
|
+
def run(
|
35
|
+
self,
|
36
|
+
object_name: str,
|
37
|
+
) -> bool:
|
38
|
+
logger.info(
|
39
|
+
"{}.run: {}:{} -> {}".format(
|
40
|
+
NAME,
|
41
|
+
self.__class__.__name__,
|
42
|
+
self.name,
|
43
|
+
object_name,
|
44
|
+
)
|
45
|
+
)
|
46
|
+
|
47
|
+
return post_to_object(
|
48
|
+
object_name,
|
49
|
+
"input",
|
50
|
+
self.script,
|
51
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
from blue_assistant.script.repository.moon_datasets.classes import MiningOnMoonScript
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from tqdm import tqdm
|
3
|
+
|
4
|
+
from blue_objects import file, path
|
5
|
+
|
6
|
+
from blue_assistant.script.repository.generic.classes import GenericScript
|
7
|
+
|
8
|
+
|
9
|
+
class MiningOnMoonScript(GenericScript):
|
10
|
+
name = path.name(file.path(__file__))
|
11
|
+
|
12
|
+
def __init__(
|
13
|
+
self,
|
14
|
+
verbose: bool = False,
|
15
|
+
):
|
16
|
+
super().__init__(verbose=verbose)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
4
|
-
Summary:
|
3
|
+
Version: 4.43.1
|
4
|
+
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
7
7
|
Author-email: arash@kamangir.net
|
@@ -38,9 +38,9 @@ Dynamic: license
|
|
38
38
|
Dynamic: requires-dist
|
39
39
|
Dynamic: summary
|
40
40
|
|
41
|
-
#
|
41
|
+
# 🧠 blue-assistant
|
42
42
|
|
43
|
-
|
43
|
+
🧠 `@assistant` is an AI assistant.
|
44
44
|
|
45
45
|
```bash
|
46
46
|
pip install blue-assistant
|
@@ -48,12 +48,14 @@ pip install blue-assistant
|
|
48
48
|
|
49
49
|
```mermaid
|
50
50
|
graph LR
|
51
|
-
|
51
|
+
assistant_script_run["@assistant<br>script<br>run -<br><script><br><object-name>"]
|
52
52
|
|
53
|
+
script["📜 script"]:::folder
|
53
54
|
object["📂 object"]:::folder
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
script --> assistant_script_run
|
57
|
+
object --> assistant_script_run
|
58
|
+
assistant_script_run --> object
|
57
59
|
|
58
60
|
classDef folder fill:#999,stroke:#333,stroke-width:2px;
|
59
61
|
```
|
@@ -63,4 +65,4 @@ graph LR
|
|
63
65
|
|
64
66
|
[](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)
|
65
67
|
|
66
|
-
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on
|
68
|
+
built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.43.1`](https://github.com/kamangir/blue-assistant).
|
@@ -24,16 +24,23 @@ blue_assistant/.abcli/actions.sh
|
|
24
24
|
blue_assistant/.abcli/alias.sh
|
25
25
|
blue_assistant/.abcli/blue_assistant.sh
|
26
26
|
blue_assistant/.abcli/browse.sh
|
27
|
-
blue_assistant/.abcli/
|
27
|
+
blue_assistant/.abcli/script.sh
|
28
|
+
blue_assistant/.abcli/script/run.sh
|
28
29
|
blue_assistant/.abcli/tests/README.sh
|
29
|
-
blue_assistant/.abcli/tests/chat.sh
|
30
30
|
blue_assistant/.abcli/tests/help.sh
|
31
|
+
blue_assistant/.abcli/tests/script_run.sh
|
31
32
|
blue_assistant/.abcli/tests/version.sh
|
32
|
-
blue_assistant/chat/__init__.py
|
33
|
-
blue_assistant/chat/__main__.py
|
34
|
-
blue_assistant/chat/context.py
|
35
|
-
blue_assistant/chat/functions.py
|
36
33
|
blue_assistant/help/__init__.py
|
37
34
|
blue_assistant/help/__main__.py
|
38
|
-
blue_assistant/help/
|
39
|
-
blue_assistant/help/
|
35
|
+
blue_assistant/help/functions.py
|
36
|
+
blue_assistant/help/script.py
|
37
|
+
blue_assistant/script/__init__.py
|
38
|
+
blue_assistant/script/__main__.py
|
39
|
+
blue_assistant/script/load.py
|
40
|
+
blue_assistant/script/repository/__init__.py
|
41
|
+
blue_assistant/script/repository/blue_amo/__init__.py
|
42
|
+
blue_assistant/script/repository/blue_amo/classes.py
|
43
|
+
blue_assistant/script/repository/generic/__init__.py
|
44
|
+
blue_assistant/script/repository/generic/classes.py
|
45
|
+
blue_assistant/script/repository/moon_datasets/__init__.py
|
46
|
+
blue_assistant/script/repository/moon_datasets/classes.py
|
@@ -10,7 +10,11 @@ setup(
|
|
10
10
|
packages=[
|
11
11
|
NAME,
|
12
12
|
f"{NAME}.help",
|
13
|
-
f"{NAME}.
|
13
|
+
f"{NAME}.script",
|
14
|
+
f"{NAME}.script.repository",
|
15
|
+
f"{NAME}.script.repository.blue_amo",
|
16
|
+
f"{NAME}.script.repository.generic",
|
17
|
+
f"{NAME}.script.repository.moon_datasets",
|
14
18
|
],
|
15
19
|
include_package_data=True,
|
16
20
|
package_data={
|
@@ -21,6 +25,3 @@ setup(
|
|
21
25
|
],
|
22
26
|
},
|
23
27
|
)
|
24
|
-
|
25
|
-
|
26
|
-
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import argparse
|
2
|
-
|
3
|
-
from blueness import module
|
4
|
-
from blueness.argparse.generic import sys_exit
|
5
|
-
|
6
|
-
from blue_assistant import NAME
|
7
|
-
from blue_assistant.chat.functions import chat
|
8
|
-
from blue_assistant.logger import logger
|
9
|
-
|
10
|
-
NAME = module.name(__file__, NAME)
|
11
|
-
|
12
|
-
parser = argparse.ArgumentParser(NAME)
|
13
|
-
parser.add_argument(
|
14
|
-
"task",
|
15
|
-
type=str,
|
16
|
-
help="chat",
|
17
|
-
)
|
18
|
-
parser.add_argument(
|
19
|
-
"--object_name",
|
20
|
-
type=str,
|
21
|
-
)
|
22
|
-
parser.add_argument(
|
23
|
-
"--interactive",
|
24
|
-
type=int,
|
25
|
-
default=0,
|
26
|
-
help="0 | 1",
|
27
|
-
)
|
28
|
-
parser.add_argument(
|
29
|
-
"--verbose",
|
30
|
-
type=int,
|
31
|
-
default=0,
|
32
|
-
help="0 | 1",
|
33
|
-
)
|
34
|
-
args = parser.parse_args()
|
35
|
-
|
36
|
-
success = False
|
37
|
-
if args.task == "chat":
|
38
|
-
success = chat(
|
39
|
-
object_name=args.object_name,
|
40
|
-
interactive=args.interactive == 1,
|
41
|
-
verbose=args.verbose == 1,
|
42
|
-
)
|
43
|
-
else:
|
44
|
-
success = None
|
45
|
-
|
46
|
-
sys_exit(logger, NAME, args.task, success)
|
@@ -1,107 +0,0 @@
|
|
1
|
-
from blue_objects import file, objects
|
2
|
-
from blue_options import string
|
3
|
-
from blue_objects.metadata import post_to_object, get_from_object
|
4
|
-
from blue_options.terminal.functions import hr
|
5
|
-
from openai_commands.prompt_completion.api import complete_prompt
|
6
|
-
|
7
|
-
from blue_assistant import ICON
|
8
|
-
from blue_assistant.logger import logger
|
9
|
-
|
10
|
-
|
11
|
-
class ChatContext:
|
12
|
-
def __init__(
|
13
|
-
self,
|
14
|
-
object_name: str,
|
15
|
-
load_history: bool = True,
|
16
|
-
verbose: bool = False,
|
17
|
-
):
|
18
|
-
self.verbose = verbose
|
19
|
-
|
20
|
-
self.ended: bool = False
|
21
|
-
|
22
|
-
self.object_name = object_name
|
23
|
-
|
24
|
-
self.history = (
|
25
|
-
get_from_object(
|
26
|
-
self.object_name,
|
27
|
-
"history",
|
28
|
-
[],
|
29
|
-
)
|
30
|
-
if load_history
|
31
|
-
else []
|
32
|
-
)
|
33
|
-
|
34
|
-
def chat(
|
35
|
-
self,
|
36
|
-
interactive: bool = True,
|
37
|
-
) -> bool:
|
38
|
-
logger.info('Type in "help" for help.')
|
39
|
-
|
40
|
-
while True:
|
41
|
-
prompt = input(f"{ICON} > ") if interactive else ""
|
42
|
-
|
43
|
-
if not self.process_prompt(prompt):
|
44
|
-
return False
|
45
|
-
|
46
|
-
if self.ended or not interactive:
|
47
|
-
break
|
48
|
-
|
49
|
-
print(hr(width=21))
|
50
|
-
|
51
|
-
return True
|
52
|
-
|
53
|
-
def process_prompt(
|
54
|
-
self,
|
55
|
-
prompt: str,
|
56
|
-
max_tokens: int = 2000,
|
57
|
-
) -> bool:
|
58
|
-
if prompt in ["help", "?", ""]:
|
59
|
-
return self.show_help()
|
60
|
-
|
61
|
-
if prompt in ["quit", "exit", "q"]:
|
62
|
-
self.ended = True
|
63
|
-
return True
|
64
|
-
|
65
|
-
success, response, metadata = complete_prompt(
|
66
|
-
prompt=prompt,
|
67
|
-
max_tokens=max_tokens,
|
68
|
-
verbose=self.verbose,
|
69
|
-
)
|
70
|
-
if not success:
|
71
|
-
return success
|
72
|
-
logger.info(response)
|
73
|
-
|
74
|
-
id_ = string.pretty_date(
|
75
|
-
as_filename=True,
|
76
|
-
unique=True,
|
77
|
-
)
|
78
|
-
self.history.append(
|
79
|
-
{
|
80
|
-
"id": id_,
|
81
|
-
"prompt": prompt,
|
82
|
-
"response": response,
|
83
|
-
}
|
84
|
-
)
|
85
|
-
|
86
|
-
return file.save_yaml(
|
87
|
-
objects.path_of(
|
88
|
-
object_name=self.object_name,
|
89
|
-
filename=f"{id_}.yaml",
|
90
|
-
),
|
91
|
-
metadata,
|
92
|
-
)
|
93
|
-
|
94
|
-
def save(self) -> bool:
|
95
|
-
return post_to_object(
|
96
|
-
self.object_name,
|
97
|
-
"history",
|
98
|
-
self.history,
|
99
|
-
)
|
100
|
-
|
101
|
-
def show_help(self) -> bool:
|
102
|
-
for command, description in {
|
103
|
-
"help": "show this help.",
|
104
|
-
"quit": "quit the chat.",
|
105
|
-
}.items():
|
106
|
-
logger.info(f"{command}: {description}")
|
107
|
-
return True
|
@@ -1,36 +0,0 @@
|
|
1
|
-
from blueness import module
|
2
|
-
|
3
|
-
from blue_assistant import NAME
|
4
|
-
from blue_assistant.chat.context import ChatContext
|
5
|
-
from blue_assistant.logger import logger
|
6
|
-
|
7
|
-
|
8
|
-
NAME = module.name(__file__, NAME)
|
9
|
-
|
10
|
-
|
11
|
-
def chat(
|
12
|
-
object_name: str,
|
13
|
-
interactive: bool = True,
|
14
|
-
verbose: bool = False,
|
15
|
-
load_history: bool = True,
|
16
|
-
) -> bool:
|
17
|
-
logger.info(
|
18
|
-
"{}.chat -{}> {}".format(
|
19
|
-
NAME,
|
20
|
-
"interactive-" if interactive else "",
|
21
|
-
object_name,
|
22
|
-
)
|
23
|
-
)
|
24
|
-
|
25
|
-
context = ChatContext(
|
26
|
-
object_name,
|
27
|
-
load_history=load_history,
|
28
|
-
verbose=verbose,
|
29
|
-
)
|
30
|
-
|
31
|
-
if not context.chat(
|
32
|
-
interactive=interactive,
|
33
|
-
):
|
34
|
-
return False
|
35
|
-
|
36
|
-
return context.save()
|
@@ -1 +0,0 @@
|
|
1
|
-
BLUE_PLUGIN_CONFIG=value
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{blue_assistant-4.24.1 → blue_assistant-4.43.1}/blue_assistant.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|