blue-assistant 4.137.1__py3-none-any.whl → 4.142.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.
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.137.1"
7
+ VERSION = "4.142.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
blue_assistant/config.env CHANGED
@@ -1,5 +1,5 @@
1
1
  BLUE_ASSISTANT_TEXT_DEFAULT_MODEL=gpt-4o
2
- BLUE_ASSISTANT_TEXT_MAX_TOKEN=2000
2
+ BLUE_ASSISTANT_TEXT_MAX_TOKENS=2000
3
3
 
4
4
  BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL=dall-e-3
5
5
  BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY=standard
blue_assistant/env.py CHANGED
@@ -10,11 +10,11 @@ BLUE_ASSISTANT_TEXT_DEFAULT_MODEL = os.getenv(
10
10
  "",
11
11
  )
12
12
 
13
- BLUE_ASSISTANT_TEXT_MAX_TOKEN_str = os.getenv("BLUE_ASSISTANT_TEXT_MAX_TOKEN", "")
13
+ BLUE_ASSISTANT_TEXT_MAX_TOKENS_str = os.getenv("BLUE_ASSISTANT_TEXT_MAX_TOKENS", "")
14
14
  try:
15
- BLUE_ASSISTANT_TEXT_MAX_TOKEN = int(BLUE_ASSISTANT_TEXT_MAX_TOKEN_str)
15
+ BLUE_ASSISTANT_TEXT_MAX_TOKENS = int(BLUE_ASSISTANT_TEXT_MAX_TOKENS_str)
16
16
  except Exception:
17
- BLUE_ASSISTANT_TEXT_MAX_TOKEN = 2000
17
+ BLUE_ASSISTANT_TEXT_MAX_TOKENS = 2000
18
18
 
19
19
 
20
20
  BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL = os.getenv(
@@ -1,6 +1,5 @@
1
1
  from blueness import module
2
- from blue_objects import objects
3
- from openai_commands.image_generation.api import OpenAIImageGenerator
2
+ from openai_commands.image_generation import api
4
3
 
5
4
  from blue_assistant import NAME
6
5
  from blue_assistant.env import (
@@ -21,20 +20,13 @@ def generate_image(
21
20
  ) -> bool:
22
21
  logger.info(f"{NAME}: {script} @ {node_name} ...")
23
22
 
24
- generator = OpenAIImageGenerator(
25
- model=BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
26
- verbose=script.verbose,
27
- )
28
-
29
23
  filename = f"{node_name}.png"
30
24
 
31
- success = generator.generate(
25
+ success, _ = api.generate_image(
32
26
  prompt=script.nodes[node_name]["prompt"],
33
- filename=objects.path_of(
34
- filename=filename,
35
- object_name=script.object_name,
36
- create=True,
37
- ),
27
+ filename=filename,
28
+ object_name=script.object_name,
29
+ model=BLUE_ASSISTANT_IMAGE_DEFAULT_MODEL,
38
30
  quality=(BLUE_ASSISTANT_IMAGE_DEFAULT_QUALITY if script.test_mode else "hd"),
39
31
  size=(BLUE_ASSISTANT_IMAGE_DEFAULT_SIZE if script.test_mode else "1792x1024"),
40
32
  sign_with_prompt=False,
@@ -44,7 +36,8 @@ def generate_image(
44
36
  script.nodes[node_name]["prompt"],
45
37
  )
46
38
  ],
47
- )[0]
39
+ verbose=script.verbose,
40
+ )
48
41
 
49
42
  if success:
50
43
  script.nodes[node_name]["filename"] = filename
@@ -1,15 +1,13 @@
1
1
  from typing import List
2
- from openai import OpenAI
3
- import pprint
4
2
 
5
3
  from blueness import module
6
- from openai_commands.env import OPENAI_API_KEY
4
+ from openai_commands.text_generation import api
7
5
 
8
6
  from blue_assistant import NAME
9
7
  from blue_assistant.script.repository.base.classes import BaseScript
10
8
  from blue_assistant.env import (
11
9
  BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
12
- BLUE_ASSISTANT_TEXT_MAX_TOKEN,
10
+ BLUE_ASSISTANT_TEXT_MAX_TOKENS,
13
11
  )
14
12
  from blue_assistant.logger import logger
15
13
 
@@ -21,14 +19,10 @@ def generate_text(
21
19
  script: BaseScript,
22
20
  node_name: str,
23
21
  ) -> bool:
24
- if not OPENAI_API_KEY:
25
- logger.error("OPENAI_API_KEY is not set.")
26
- return False
27
-
28
22
  logger.info(f"{NAME}: {script} @ {node_name} ...")
29
23
 
30
24
  messages: List = []
31
- list_of_context_nodes = script.get_history(node_name)
25
+ list_of_context_nodes = script.get_context(node_name)
32
26
  logger.info("node context: {}".format(" <- ".join(list_of_context_nodes)))
33
27
  for context_node in reversed(list_of_context_nodes):
34
28
  messages += [
@@ -56,29 +50,15 @@ def generate_text(
56
50
  }
57
51
  ]
58
52
 
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
53
+ success, output, _ = api.generate_text(
54
+ messages=messages,
55
+ model=BLUE_ASSISTANT_TEXT_DEFAULT_MODEL,
56
+ max_tokens=BLUE_ASSISTANT_TEXT_MAX_TOKENS,
57
+ verbose=script.verbose,
58
+ )
59
+ if not success:
60
+ return success
80
61
 
81
- output = response.choices[0].message.content
82
62
  logger.info(f"🗣️ output: {output}")
83
63
  script.nodes[node_name]["output"] = output
84
64
 
@@ -81,13 +81,13 @@ class BaseScript:
81
81
 
82
82
  return self.save_graph()
83
83
 
84
- def get_history(
84
+ def get_context(
85
85
  self,
86
86
  node_name: str,
87
87
  ) -> List[str]:
88
88
  return reduce(
89
89
  lambda x, y: x + y,
90
- [self.get_history(successor) for successor in self.G.successors(node_name)],
90
+ [self.get_context(successor) for successor in self.G.successors(node_name)],
91
91
  [node_name],
92
92
  )
93
93
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.137.1
3
+ Version: 4.142.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -76,4 +76,4 @@ graph LR
76
76
 
77
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)
78
78
 
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).
79
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.142.1`](https://github.com/kamangir/blue-assistant).
@@ -1,8 +1,8 @@
1
1
  blue_assistant/README.py,sha256=aB7xoxE3SpI_QbXzJRqh9R-QSWFJSfX3JG-ZY5nfDD4,1503
2
- blue_assistant/__init__.py,sha256=ah6uFi0CCkvh6f_cyoIYiWwK5fRvvR3d7-ne585JBlw,311
2
+ blue_assistant/__init__.py,sha256=dR1gRga50p7ATJUZqjToyki00k-bUoT6VR9PDwi-MQ0,311
3
3
  blue_assistant/__main__.py,sha256=URtal70XZc0--3FDTYWcLtnGOqBYjMX9gt-L1k8hDXI,361
4
- blue_assistant/config.env,sha256=gjGYkDkmzpwgy7_J-i9RclTKZsKtaAibn7mavD9l4u8,210
5
- blue_assistant/env.py,sha256=h2goHjsspOLjZ44yFHqHLB7wPl_GCodg3D6yfSE5FfM,732
4
+ blue_assistant/config.env,sha256=PUR0GHwzmpm7xNdWHjIv8DzlMAesOAa1NEnYDsIUTs8,211
5
+ blue_assistant/env.py,sha256=e3YPPpMCrKoTcOX8QmzndEwDnM-nC-hFTSUvhnaKpSc,737
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
@@ -29,13 +29,13 @@ blue_assistant/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
29
29
  blue_assistant/script/__main__.py,sha256=eOSOo5yYTPMwIXZ0GkuWkmOcsDWrZtHvClyJizXSk2w,1657
30
30
  blue_assistant/script/load.py,sha256=JsDY9T3HTM9vXngvKsA0Mt_erxAnRR_jI62-JhrOBMU,831
31
31
  blue_assistant/script/actions/__init__.py,sha256=W0PisTP1H0RRqivzwiaXlN-kvE3m1xlJtn5WGZ-PFtg,625
32
- blue_assistant/script/actions/generate_image.py,sha256=1OtDAXcFijTXUwZqfpw0375pCTQ3ooFvD2dYJxwFJSg,1513
33
- blue_assistant/script/actions/generate_text.py,sha256=xenvUISPKoq3rkzrBZIlRhQh7s7PTkchTTMdcyybe24,2394
32
+ blue_assistant/script/actions/generate_image.py,sha256=PgvOspDV8n2M7ZmgVOdZzJwQ1tnJNJ6V8gV94P74ksA,1336
33
+ blue_assistant/script/actions/generate_text.py,sha256=nD30y8hoFbYoDT2QsrhKCvUfJUrOubiiLl3OjabtASg,1881
34
34
  blue_assistant/script/actions/generic.py,sha256=ET1RaKcUABM8HdIv8JecSpUFasYqmwHacL-5LjF-8NM,355
35
35
  blue_assistant/script/actions/skip.py,sha256=G9gbGBbOLiCqcsmEUobdoxkB6wohFYmyi1arQGorZSg,352
36
36
  blue_assistant/script/repository/__init__.py,sha256=zVI3cubRqM9H6WgF0EUP9idILVLCumPFmJgKPM7iVlM,604
37
37
  blue_assistant/script/repository/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- blue_assistant/script/repository/base/classes.py,sha256=xYF-6W0TV_AfZHvRcB9lK-O5-Z45uPu6ETOIzxXWwvw,3717
38
+ blue_assistant/script/repository/base/classes.py,sha256=-G81it3Beb3fbhE5H6g0BPJwvZKn3qELiBaqRWXP4OY,3717
39
39
  blue_assistant/script/repository/blue_amo/__init__.py,sha256=WjL9GIlN-DBnbUMJ8O_FxTp0rcVGlsIS3H9YtXEefTk,76
40
40
  blue_assistant/script/repository/blue_amo/classes.py,sha256=vWQ_qMdJ2LmpEjDGFnSxOMZPd34yj-DX4UUTnx5aMtY,2082
41
41
  blue_assistant/script/repository/blue_amo/actions/__init__.py,sha256=je2S21KvYB3QkbABs71parwUh8MCh2mdlNZfLx_QuDg,430
@@ -49,8 +49,8 @@ blue_assistant/script/repository/orbital_data_explorer/__init__.py,sha256=yy5FtC
49
49
  blue_assistant/script/repository/orbital_data_explorer/classes.py,sha256=i4cVCR6ge8FhipPs-H1HZ_5xcok4mzxrqwRr_hLz_UI,657
50
50
  blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py,sha256=RcrFUAwnvhuwNh3gC65w9G26vd_cIa7LV1lFvGFcigk,370
51
51
  blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py,sha256=Wb8sU9UmdRRhHUhNj7_VQ74_Bio20xGajzeGz4HJqZQ,369
52
- blue_assistant-4.137.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
53
- blue_assistant-4.137.1.dist-info/METADATA,sha256=Yi8WBxMoH0hJxHnRo5RuWMuDHd4X5004aASCU6LaoBA,3578
54
- blue_assistant-4.137.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
55
- blue_assistant-4.137.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
56
- blue_assistant-4.137.1.dist-info/RECORD,,
52
+ blue_assistant-4.142.1.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
53
+ blue_assistant-4.142.1.dist-info/METADATA,sha256=ifohOQ1zpJdsKWyUNHlE3Yke1DbnTbFon2EfpwilPRg,3578
54
+ blue_assistant-4.142.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
55
+ blue_assistant-4.142.1.dist-info/top_level.txt,sha256=ud0BkBbdOVze13bNqHuhZj1rwCztaBtDf5ChEYzASOs,15
56
+ blue_assistant-4.142.1.dist-info/RECORD,,