blue-assistant 4.62.1__py3-none-any.whl → 4.66.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/README.py +13 -10
- blue_assistant/__init__.py +1 -1
- blue_assistant/script/__main__.py +1 -1
- blue_assistant/script/actions/functions.py +3 -7
- blue_assistant/script/actions/generate_image.py +4 -7
- blue_assistant/script/actions/generate_text.py +48 -21
- blue_assistant/script/actions/generic.py +2 -2
- blue_assistant/script/repository/generic/classes.py +5 -8
- {blue_assistant-4.62.1.dist-info → blue_assistant-4.66.1.dist-info}/METADATA +2 -2
- {blue_assistant-4.62.1.dist-info → blue_assistant-4.66.1.dist-info}/RECORD +13 -13
- {blue_assistant-4.62.1.dist-info → blue_assistant-4.66.1.dist-info}/LICENSE +0 -0
- {blue_assistant-4.62.1.dist-info → blue_assistant-4.66.1.dist-info}/WHEEL +0 -0
- {blue_assistant-4.62.1.dist-info → blue_assistant-4.66.1.dist-info}/top_level.txt +0 -0
blue_assistant/README.py
CHANGED
@@ -17,14 +17,17 @@ items = [
|
|
17
17
|
|
18
18
|
|
19
19
|
def build():
|
20
|
-
return
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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-01.md"},
|
32
|
+
]
|
27
33
|
)
|
28
|
-
|
29
|
-
|
30
|
-
|
blue_assistant/__init__.py
CHANGED
@@ -25,14 +25,12 @@ def get_action_class(
|
|
25
25
|
def perform_action(
|
26
26
|
script: BaseScript,
|
27
27
|
node_name: str,
|
28
|
-
) ->
|
28
|
+
) -> bool:
|
29
29
|
action_name = script.nodes[node_name].get("action", "unknown")
|
30
30
|
|
31
31
|
success, action_class = get_action_class(action_name=action_name)
|
32
32
|
if not success:
|
33
|
-
return
|
34
|
-
"error": f"{action_name}: action not found.",
|
35
|
-
}
|
33
|
+
return success
|
36
34
|
|
37
35
|
logger.info(
|
38
36
|
"{}.perform_action: {} == {} on {}".format(
|
@@ -47,6 +45,4 @@ def perform_action(
|
|
47
45
|
script=script,
|
48
46
|
)
|
49
47
|
|
50
|
-
return action_object.perform(
|
51
|
-
node_name=node_name,
|
52
|
-
)
|
48
|
+
return action_object.perform(node_name=node_name)
|
@@ -12,13 +12,10 @@ class GenerateImageAction(GenericAction):
|
|
12
12
|
def perform(
|
13
13
|
self,
|
14
14
|
node_name: str,
|
15
|
-
) ->
|
16
|
-
|
17
|
-
|
18
|
-
return success, generic_metadata
|
15
|
+
) -> bool:
|
16
|
+
if not super().perform(node_name=node_name):
|
17
|
+
return False
|
19
18
|
|
20
19
|
logger.info(f"🪄 generating image ...: {node_name}")
|
21
|
-
metadata = {}
|
22
20
|
|
23
|
-
|
24
|
-
return True, metadata
|
21
|
+
return True
|
@@ -1,5 +1,6 @@
|
|
1
|
-
from typing import Dict, Tuple
|
1
|
+
from typing import Dict, Tuple, List
|
2
2
|
from openai import OpenAI
|
3
|
+
import pprint
|
3
4
|
|
4
5
|
from blueness import module
|
5
6
|
from blue_objects import file
|
@@ -19,48 +20,74 @@ class GenerateTextAction(GenericAction):
|
|
19
20
|
def perform(
|
20
21
|
self,
|
21
22
|
node_name: str,
|
22
|
-
) ->
|
23
|
-
metadata = {}
|
24
|
-
|
23
|
+
) -> bool:
|
25
24
|
if not OPENAI_API_KEY:
|
26
25
|
logger.error("OPENAI_API_KEY is not set.")
|
27
|
-
return False
|
26
|
+
return False
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
return success, generic_metadata
|
28
|
+
if not super().perform(node_name=node_name):
|
29
|
+
return False
|
32
30
|
|
33
|
-
|
31
|
+
messages: List = []
|
32
|
+
node_history = self.script.get_history(node_name)
|
33
|
+
logger.info("node history: {}".format(node_history))
|
34
|
+
for successor in reversed(node_history):
|
35
|
+
messages += [
|
36
|
+
{
|
37
|
+
"role": "user",
|
38
|
+
"content": [
|
39
|
+
{
|
40
|
+
"type": "text",
|
41
|
+
"text": self.script.apply_vars(
|
42
|
+
self.script.nodes[successor]["prompt"]
|
43
|
+
),
|
44
|
+
}
|
45
|
+
],
|
46
|
+
}
|
47
|
+
]
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
messages=[
|
49
|
+
if self.script.G.nodes[successor]["completed"]:
|
50
|
+
messages += [
|
38
51
|
{
|
39
|
-
"role": "
|
52
|
+
"role": "assistant",
|
40
53
|
"content": [
|
41
54
|
{
|
42
55
|
"type": "text",
|
43
|
-
"text": self.script.nodes[
|
56
|
+
"text": self.script.nodes[successor]["output"],
|
44
57
|
}
|
45
58
|
],
|
46
59
|
}
|
47
|
-
]
|
60
|
+
]
|
61
|
+
|
62
|
+
if self.script.verbose:
|
63
|
+
logger.info(f"messages: {pprint.pformat(messages)}")
|
64
|
+
|
65
|
+
client = OpenAI(api_key=OPENAI_API_KEY)
|
66
|
+
|
67
|
+
try:
|
68
|
+
response = client.chat.completions.create(
|
69
|
+
messages=messages,
|
48
70
|
model=BLUE_ASSISTANT_DEFAULT_MODEL,
|
49
71
|
max_tokens=BLUE_ASSISTANT_MAX_TOKEN,
|
50
72
|
)
|
51
73
|
except Exception as e:
|
52
74
|
logger.error(str(e))
|
53
|
-
return False
|
75
|
+
return False
|
54
76
|
|
55
77
|
if self.script.verbose:
|
56
78
|
logger.info("response: {}".format(response))
|
57
79
|
|
58
80
|
if not response.choices:
|
59
81
|
logger.error("no choice.")
|
60
|
-
return False
|
82
|
+
return False
|
83
|
+
|
84
|
+
output = response.choices[0].message.content
|
85
|
+
logger.info(f"🗣️ output: {output}")
|
86
|
+
|
87
|
+
self.script.G.nodes[node_name]["output"] = output
|
61
88
|
|
62
|
-
|
63
|
-
|
89
|
+
var_name = self.script.nodes[node_name].get("output", "")
|
90
|
+
if var_name:
|
91
|
+
self.script.vars[var_name] = output
|
64
92
|
|
65
|
-
|
66
|
-
return True, metadata
|
93
|
+
return True
|
@@ -22,7 +22,7 @@ class GenericAction:
|
|
22
22
|
def perform(
|
23
23
|
self,
|
24
24
|
node_name: str,
|
25
|
-
) ->
|
25
|
+
) -> bool:
|
26
26
|
logger.info(
|
27
27
|
"{}.perform({}) on {}.{} ...".format(
|
28
28
|
NAME,
|
@@ -31,4 +31,4 @@ class GenericAction:
|
|
31
31
|
node_name,
|
32
32
|
),
|
33
33
|
)
|
34
|
-
return True
|
34
|
+
return True
|
@@ -50,18 +50,15 @@ class GenericScript(BaseScript):
|
|
50
50
|
)
|
51
51
|
continue
|
52
52
|
|
53
|
-
|
53
|
+
if not perform_action(
|
54
54
|
script=self,
|
55
55
|
node_name=node_name,
|
56
|
-
)
|
57
|
-
|
58
|
-
metadata["nodes"][node_name] = {
|
59
|
-
"success": success,
|
60
|
-
"output": output,
|
61
|
-
}
|
62
|
-
if not success:
|
56
|
+
):
|
57
|
+
success = False
|
63
58
|
break
|
64
59
|
|
60
|
+
self.G.nodes[node_name]["completed"] = True
|
61
|
+
|
65
62
|
if not post_to_object(
|
66
63
|
self.object_name,
|
67
64
|
"output",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: blue_assistant
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.66.1
|
4
4
|
Summary: 🧠 An AI Assistant.
|
5
5
|
Home-page: https://github.com/kamangir/blue-assistant
|
6
6
|
Author: Arash Abadpour (Kamangir)
|
@@ -72,4 +72,4 @@ graph LR
|
|
72
72
|
|
73
73
|
[](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)
|
74
74
|
|
75
|
-
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.66.1`](https://github.com/kamangir/blue-assistant).
|
@@ -1,5 +1,5 @@
|
|
1
|
-
blue_assistant/README.py,sha256=
|
2
|
-
blue_assistant/__init__.py,sha256=
|
1
|
+
blue_assistant/README.py,sha256=Nzr3v-VSa8CISkqkLHd8ILyY_WiJ7x2igYPH-lYpzEY,795
|
2
|
+
blue_assistant/__init__.py,sha256=0v_LdK6vN-oGFPitqPD_ntVE3VlcyYyrddqz4xbjDnM,310
|
3
3
|
blue_assistant/__main__.py,sha256=URtal70XZc0--3FDTYWcLtnGOqBYjMX9gt-L1k8hDXI,361
|
4
4
|
blue_assistant/config.env,sha256=JV9zx17FflIPmV1hK-yuM0GlrUjkGuaQ_EzPFPTkoXM,66
|
5
5
|
blue_assistant/env.py,sha256=rgIlKVsALrRD1sYJV3SkFfzIvWNavix2HN0sSy2cCi4,391
|
@@ -26,23 +26,23 @@ blue_assistant/help/__main__.py,sha256=cVejR7OpoWPg0qLbm-PZf5TuJS27x49jzfiyCLyzE
|
|
26
26
|
blue_assistant/help/functions.py,sha256=9WsmXGMN-R7sqlkGLK0nY90Peg8Gah4rIu75QbLhImo,689
|
27
27
|
blue_assistant/help/script.py,sha256=wvS_5FWu9LAsaDDq7UoxXEadRwGseYqwu2P-9dNc5Bo,1077
|
28
28
|
blue_assistant/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
blue_assistant/script/__main__.py,sha256=
|
29
|
+
blue_assistant/script/__main__.py,sha256=D5APoSVe-l5H0Nrgyq5do4cSbmRyYmflq1x_Dd5d1fM,1529
|
30
30
|
blue_assistant/script/load.py,sha256=Bd5L9HBL0Yh1MLGAyGrQX3XQLH-UiOWLsHJvzCmNs3g,773
|
31
31
|
blue_assistant/script/actions/__init__.py,sha256=8Sp6avoJGDXVORvx5mvkxTNaxjz_KevKN4Wb8qLZHsQ,487
|
32
|
-
blue_assistant/script/actions/functions.py,sha256=
|
33
|
-
blue_assistant/script/actions/generate_image.py,sha256=
|
34
|
-
blue_assistant/script/actions/generate_text.py,sha256=
|
35
|
-
blue_assistant/script/actions/generic.py,sha256=
|
32
|
+
blue_assistant/script/actions/functions.py,sha256=0fiihOWbFiwZEXV6t9oxJaxJ5E5X-k3weqGTOKTu3sA,1233
|
33
|
+
blue_assistant/script/actions/generate_image.py,sha256=bGDdP9XfBtFFFNL4d7DA7_FJvsFKadPOgwVAXkFgyjE,477
|
34
|
+
blue_assistant/script/actions/generate_text.py,sha256=rKDjY_keN_E_vdboQ_SqG2APyUanpAKRDVGCxzghO3k,2817
|
35
|
+
blue_assistant/script/actions/generic.py,sha256=dIjqocIEpLEb1BI76kHivVpDUG5QpeZHLA2onsYn1SU,731
|
36
36
|
blue_assistant/script/actions/wip.py,sha256=K4kJE4bn3u6o-QWTESPydO_eD54zOwZbU9WLAO94z1Q,171
|
37
37
|
blue_assistant/script/repository/__init__.py,sha256=WFkbe-6yyljpmeVpXgLhOPt-YRc7BwkRNzPO-7Wz0Dg,573
|
38
38
|
blue_assistant/script/repository/blue_amo/__init__.py,sha256=WjL9GIlN-DBnbUMJ8O_FxTp0rcVGlsIS3H9YtXEefTk,76
|
39
39
|
blue_assistant/script/repository/blue_amo/classes.py,sha256=RY1gjZVPX8xu7nfeiZoTL8RTpu73RsoaNv4ZoGv9NNs,234
|
40
40
|
blue_assistant/script/repository/generic/__init__.py,sha256=kLffGsQMQAFJTw6IZBE5eBxvshP1x9wwHHR4hsDJblo,75
|
41
|
-
blue_assistant/script/repository/generic/classes.py,sha256=
|
41
|
+
blue_assistant/script/repository/generic/classes.py,sha256=X6h-cWFleUQF9flyq6ClYSdi5ysGOTsy156w8jT1wvY,1964
|
42
42
|
blue_assistant/script/repository/moon_datasets/__init__.py,sha256=aCtmP2avh3yKAJ668S3GsLR9vbBOm5zt9FSFCqy_tAs,86
|
43
43
|
blue_assistant/script/repository/moon_datasets/classes.py,sha256=68zThDhjF9gGRnsw8EKNLGOMBFbCSljt0jGovuOzCAc,197
|
44
|
-
blue_assistant-4.
|
45
|
-
blue_assistant-4.
|
46
|
-
blue_assistant-4.
|
47
|
-
blue_assistant-4.
|
48
|
-
blue_assistant-4.
|
44
|
+
blue_assistant-4.66.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
|
45
|
+
blue_assistant-4.66.1.dist-info/METADATA,sha256=o9HM9_F9s8xZ0lhJhtngCE2qqdbASHaRGOMzhuFw4XE,2625
|
46
|
+
blue_assistant-4.66.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
47
|
+
blue_assistant-4.66.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
|
48
|
+
blue_assistant-4.66.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|