blue-assistant 4.137.1__tar.gz → 4.154.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {blue_assistant-4.137.1/blue_assistant.egg-info → blue_assistant-4.154.1}/PKG-INFO +10 -3
  2. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/README.md +8 -2
  3. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/tests/help.sh +3 -0
  4. blue_assistant-4.154.1/blue_assistant/.abcli/tests/web_crawl.sh +12 -0
  5. blue_assistant-4.154.1/blue_assistant/.abcli/web/crawl.sh +26 -0
  6. blue_assistant-4.154.1/blue_assistant/.abcli/web.sh +15 -0
  7. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/__init__.py +1 -1
  8. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/config.env +1 -1
  9. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/env.py +3 -3
  10. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/help/functions.py +2 -0
  11. blue_assistant-4.154.1/blue_assistant/help/web.py +33 -0
  12. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/actions/__init__.py +1 -3
  13. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/actions/generate_image.py +7 -14
  14. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/actions/generate_text.py +11 -31
  15. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/base/classes.py +2 -2
  16. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/blue_amo/classes.py +1 -1
  17. blue_assistant-4.154.1/blue_assistant/web/__init__.py +0 -0
  18. blue_assistant-4.154.1/blue_assistant/web/__main__.py +60 -0
  19. blue_assistant-4.154.1/blue_assistant/web/crawl.py +82 -0
  20. {blue_assistant-4.137.1 → blue_assistant-4.154.1/blue_assistant.egg-info}/PKG-INFO +10 -3
  21. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant.egg-info/SOURCES.txt +8 -2
  22. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant.egg-info/requires.txt +1 -0
  23. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/requirements.txt +1 -0
  24. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/setup.py +1 -0
  25. blue_assistant-4.137.1/blue_assistant/script/actions/skip.py +0 -15
  26. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/LICENSE +0 -0
  27. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/MANIFEST.in +0 -0
  28. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/abcli.sh +0 -0
  29. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/actions.sh +0 -0
  30. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/alias.sh +0 -0
  31. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  32. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/browse.sh +0 -0
  33. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/script/list.sh +0 -0
  34. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/script/run.sh +0 -0
  35. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/script.sh +0 -0
  36. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  37. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  38. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/tests/script_run.sh +0 -0
  39. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  40. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/README.py +0 -0
  41. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/__main__.py +0 -0
  42. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/functions.py +0 -0
  43. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/help/__init__.py +0 -0
  44. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/help/__main__.py +0 -0
  45. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/help/script.py +0 -0
  46. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/host.py +0 -0
  47. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/logger.py +0 -0
  48. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/sample.env +0 -0
  49. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/__init__.py +0 -0
  50. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/__main__.py +0 -0
  51. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/actions/generic.py +0 -0
  52. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/load.py +0 -0
  53. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/__init__.py +0 -0
  54. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/base/__init__.py +0 -0
  55. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  56. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/blue_amo/actions/__init__.py +0 -0
  57. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/blue_amo/actions/slicing_into_frames.py +0 -0
  58. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +0 -0
  59. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/generic/__init__.py +0 -0
  60. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/generic/classes.py +0 -0
  61. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/hue/__init__.py +0 -0
  62. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/hue/classes.py +0 -0
  63. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/orbital_data_explorer/__init__.py +0 -0
  64. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py +0 -0
  65. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py +0 -0
  66. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/script/repository/orbital_data_explorer/classes.py +0 -0
  67. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant/urls.py +0 -0
  68. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  69. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/blue_assistant.egg-info/top_level.txt +0 -0
  70. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/pyproject.toml +0 -0
  71. {blue_assistant-4.137.1 → blue_assistant-4.154.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.137.1
3
+ Version: 4.154.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -30,6 +30,7 @@ Requires-Dist: pylint
30
30
  Requires-Dist: pytest
31
31
  Requires-Dist: python-dotenv[cli]
32
32
  Requires-Dist: tqdm
33
+ Requires-Dist: beautifulsoup4
33
34
  Requires-Dist: networkx
34
35
  Requires-Dist: pydot
35
36
  Dynamic: author
@@ -44,7 +45,7 @@ Dynamic: summary
44
45
 
45
46
  # 🧠 blue-assistant
46
47
 
47
- 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
48
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations.
48
49
 
49
50
  | | |
50
51
  | --- | --- |
@@ -59,7 +60,10 @@ graph LR
59
60
  assistant_script_list["@assistant<br>script<br>list"]
60
61
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
61
62
 
63
+ assistant_web_crawl["@assistant<br>web<br>crawl -<br>&lt;url-1&gt;+&lt;url-2&gt;+&lt;url-3&gt;<br>&lt;object-name&gt;"]
64
+
62
65
  script["📜 script"]:::folder
66
+ url["🔗 url"]:::folder
63
67
  object["📂 object"]:::folder
64
68
 
65
69
  script --> assistant_script_list
@@ -68,6 +72,9 @@ graph LR
68
72
  object --> assistant_script_run
69
73
  assistant_script_run --> object
70
74
 
75
+ url --> assistant_web_crawl
76
+ assistant_web_crawl --> object
77
+
71
78
  classDef folder fill:#999,stroke:#333,stroke-width:2px;
72
79
  ```
73
80
 
@@ -76,4 +83,4 @@ graph LR
76
83
 
77
84
  [![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
85
 
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).
86
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.154.1`](https://github.com/kamangir/blue-assistant).
@@ -1,6 +1,6 @@
1
1
  # 🧠 blue-assistant
2
2
 
3
- 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
3
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations.
4
4
 
5
5
  | | |
6
6
  | --- | --- |
@@ -15,7 +15,10 @@ graph LR
15
15
  assistant_script_list["@assistant<br>script<br>list"]
16
16
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
17
17
 
18
+ assistant_web_crawl["@assistant<br>web<br>crawl -<br>&lt;url-1&gt;+&lt;url-2&gt;+&lt;url-3&gt;<br>&lt;object-name&gt;"]
19
+
18
20
  script["📜 script"]:::folder
21
+ url["🔗 url"]:::folder
19
22
  object["📂 object"]:::folder
20
23
 
21
24
  script --> assistant_script_list
@@ -24,6 +27,9 @@ graph LR
24
27
  object --> assistant_script_run
25
28
  assistant_script_run --> object
26
29
 
30
+ url --> assistant_web_crawl
31
+ assistant_web_crawl --> object
32
+
27
33
  classDef folder fill:#999,stroke:#333,stroke-width:2px;
28
34
  ```
29
35
 
@@ -32,4 +38,4 @@ graph LR
32
38
 
33
39
  [![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)
34
40
 
35
- built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.137.1`](https://github.com/kamangir/blue-assistant).
41
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.154.1`](https://github.com/kamangir/blue-assistant).
@@ -23,6 +23,9 @@ function test_blue_assistant_help() {
23
23
  "@assistant script list" \
24
24
  "@assistant script run" \
25
25
  \
26
+ "@assistant web" \
27
+ "@assistant web crawl" \
28
+ \
26
29
  "blue_assistant"; do
27
30
  abcli_eval ,$options \
28
31
  abcli_help $module
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_blue_assistant_web_crawl() {
4
+ local options=$1
5
+
6
+ abcli_eval ,$options \
7
+ blue_assistant_web_crawl \
8
+ ~upload \
9
+ https://ode.rsl.wustl.edu/+https://oderest.rsl.wustl.edu/ \
10
+ test_blue_assistant_web_crawl-$(abcli_string_timestamp_short) \
11
+ --max_iterations 3
12
+ }
@@ -0,0 +1,26 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function blue_assistant_web_crawl() {
4
+ local options=$1
5
+ local do_dryrun=$(abcli_option_int "$options" dryrun 0)
6
+ local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun))
7
+
8
+ local seed_urls=${2:-void}
9
+
10
+ local object_name=$(abcli_clarify_object $3 web-crawl-$(abcli_string_timestamp_short))
11
+
12
+ abcli_log "crawling $seed_urls -> $object_name ..."
13
+
14
+ abcli_eval dryrun=$do_dryrun \
15
+ python3 -m blue_assistant.web \
16
+ crawl \
17
+ --seed_urls $seed_urls \
18
+ --object_name $object_name \
19
+ "${@:4}"
20
+ [[ $? -ne 0 ]] && return 1
21
+
22
+ [[ "$do_upload" == 1 ]] &&
23
+ abcli_upload - $object_name
24
+
25
+ return 0
26
+ }
@@ -0,0 +1,15 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function blue_assistant_web() {
4
+ local task=$(abcli_unpack_keyword $1 help)
5
+
6
+ local function_name=blue_assistant_web_$task
7
+ if [[ $(type -t $function_name) == "function" ]]; then
8
+ $function_name "${@:2}"
9
+ return
10
+ fi
11
+
12
+ python3 -m blue_assistant.web "$@"
13
+ }
14
+
15
+ abcli_source_caller_suffix_path /web
@@ -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.154.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -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
@@ -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(
@@ -5,6 +5,7 @@ from abcli.help.generic import help_functions as generic_help_functions
5
5
 
6
6
  from blue_assistant import ALIAS
7
7
  from blue_assistant.help.script import help_functions as help_script
8
+ from blue_assistant.help.web import help_functions as help_web
8
9
 
9
10
 
10
11
  def help_browse(
@@ -30,5 +31,6 @@ help_functions.update(
30
31
  {
31
32
  "browse": help_browse,
32
33
  "script": help_script,
34
+ "web": help_web,
33
35
  }
34
36
  )
@@ -0,0 +1,33 @@
1
+ from typing import List
2
+
3
+ from blue_options.terminal import show_usage, xtra
4
+
5
+
6
+ def help_crawl(
7
+ tokens: List[str],
8
+ mono: bool,
9
+ ) -> str:
10
+ options = xtra("dryrun,~upload", mono=mono)
11
+
12
+ args = [
13
+ "[--max_iterations <100000>]",
14
+ ]
15
+
16
+ return show_usage(
17
+ [
18
+ "@assistant",
19
+ "web",
20
+ "crawl",
21
+ f"[{options}]",
22
+ "<url-1>+<url-2>+<url-3>",
23
+ "[-|<object-name>]",
24
+ ]
25
+ + args,
26
+ "crawl the web.",
27
+ mono=mono,
28
+ )
29
+
30
+
31
+ help_functions = {
32
+ "crawl": help_crawl,
33
+ }
@@ -4,13 +4,11 @@ from blue_assistant.script.repository.base.classes import BaseScript
4
4
  from blue_assistant.script.actions.generic import generic_action
5
5
  from blue_assistant.script.actions.generate_image import generate_image
6
6
  from blue_assistant.script.actions.generate_text import generate_text
7
- from blue_assistant.script.actions.skip import skip_action
8
7
  from blue_assistant.logger import logger
9
8
 
10
9
 
11
10
  dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
12
- "generic_action": generic_action,
11
+ "generic": generic_action,
13
12
  "generate_image": generate_image,
14
13
  "generate_text": generate_text,
15
- "skip": skip_action,
16
14
  }
@@ -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
 
@@ -44,7 +44,7 @@ class BlueAmoScript(GenericScript):
44
44
 
45
45
  reduce_node = "stitching_the_frames"
46
46
  self.G.add_node(reduce_node)
47
- self.nodes[reduce_node] = {"action": "skip"}
47
+ self.nodes[reduce_node] = {"action": "generic"}
48
48
 
49
49
  for index in range(self.vars["frame_count"]):
50
50
  node_name = f"generating_frame_{index+1:03d}"
File without changes
@@ -0,0 +1,60 @@
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.web.crawl import crawl_list_of_urls
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="crawl",
17
+ )
18
+ parser.add_argument(
19
+ "--max_iterations",
20
+ type=int,
21
+ default=10,
22
+ )
23
+ parser.add_argument(
24
+ "--verbose",
25
+ type=int,
26
+ default=0,
27
+ help="0 | 1",
28
+ )
29
+ parser.add_argument(
30
+ "--seed_urls",
31
+ type=str,
32
+ )
33
+ parser.add_argument(
34
+ "--object_name",
35
+ type=str,
36
+ )
37
+ args = parser.parse_args()
38
+
39
+ success = False
40
+ if args.task == "crawl":
41
+ success = True
42
+
43
+ output = crawl_list_of_urls(
44
+ seed_urls=args.seed_urls.split("+"),
45
+ object_name=args.object_name,
46
+ max_iterations=args.max_iterations,
47
+ )
48
+
49
+ if args.verbose == 1:
50
+ logger.info(f"{len(output)} url(s)")
51
+ for index, (url, content) in enumerate(output.items()):
52
+ logger.info(f"#{index: 4} - {url}: {content[:200]}...\n")
53
+ if index > 10:
54
+ logger.info("...")
55
+ break
56
+
57
+ else:
58
+ success = None
59
+
60
+ sys_exit(logger, NAME, args.task, success)
@@ -0,0 +1,82 @@
1
+ from typing import List, Dict, Set
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+ from urllib.parse import urljoin, urlparse
5
+
6
+ from blueness import module
7
+
8
+
9
+ from blue_assistant import NAME
10
+ from blue_assistant.logger import logger
11
+
12
+ NAME = module.name(__file__, NAME)
13
+
14
+
15
+ def fetch_links_and_content(url, base_url, original_path):
16
+ try:
17
+ response = requests.get(url, timeout=5)
18
+ response.raise_for_status()
19
+ except requests.RequestException:
20
+ return set(), ""
21
+
22
+ soup = BeautifulSoup(response.text, "html.parser")
23
+ links = set()
24
+
25
+ for a_tag in soup.find_all("a", href=True):
26
+ full_url = urljoin(base_url, a_tag["href"])
27
+ parsed_url = urlparse(full_url)
28
+
29
+ # Ensure link is from the same domain and in the same directory tree
30
+ if parsed_url.netloc == urlparse(
31
+ base_url
32
+ ).netloc and parsed_url.path.startswith(original_path):
33
+ links.add(full_url)
34
+
35
+ plain_text = soup.get_text(separator=" ", strip=True)
36
+
37
+ return links, plain_text
38
+
39
+
40
+ def crawl_list_of_urls(
41
+ seed_urls: List[str],
42
+ object_name: str,
43
+ max_iterations: int = 10,
44
+ ) -> Dict[str, str]:
45
+ logger.info(
46
+ "{}.crawl_list_of_urls({}): {} -> {}".format(
47
+ NAME,
48
+ len(seed_urls),
49
+ ", ".join(seed_urls),
50
+ object_name,
51
+ )
52
+ )
53
+
54
+ visited: Dict[str, str] = {}
55
+ queue: Set[str] = set(seed_urls)
56
+ base_url = urlparse(seed_urls[0]).scheme + "://" + urlparse(seed_urls[0]).netloc
57
+ original_path = (
58
+ urlparse(seed_urls[0]).path.rsplit("/", 1)[0] + "/"
59
+ ) # Get base directory
60
+
61
+ iteration: int = 0
62
+ while queue:
63
+ current_url = queue.pop()
64
+ if current_url in visited:
65
+ continue
66
+
67
+ logger.info(f"🔗 {current_url} ...")
68
+ new_links, content = fetch_links_and_content(
69
+ current_url, base_url, original_path
70
+ )
71
+ visited[current_url] = content
72
+ queue.update(new_links - visited.keys())
73
+
74
+ iteration += 1
75
+ if max_iterations != -1 and iteration >= max_iterations:
76
+ logger.warning(f"max iteration of {max_iterations} reached.")
77
+ break
78
+
79
+ if queue:
80
+ logger.warning(f"queue: {len(queue)}")
81
+
82
+ return visited
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.137.1
3
+ Version: 4.154.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -30,6 +30,7 @@ Requires-Dist: pylint
30
30
  Requires-Dist: pytest
31
31
  Requires-Dist: python-dotenv[cli]
32
32
  Requires-Dist: tqdm
33
+ Requires-Dist: beautifulsoup4
33
34
  Requires-Dist: networkx
34
35
  Requires-Dist: pydot
35
36
  Dynamic: author
@@ -44,7 +45,7 @@ Dynamic: summary
44
45
 
45
46
  # 🧠 blue-assistant
46
47
 
47
- 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations, such as below,
48
+ 🧠 `@assistant` runs AI scripts; DAGs that combine deterministic and AI operations.
48
49
 
49
50
  | | |
50
51
  | --- | --- |
@@ -59,7 +60,10 @@ graph LR
59
60
  assistant_script_list["@assistant<br>script<br>list"]
60
61
  assistant_script_run["@assistant<br>script<br>run -<br>&lt;script&gt;<br>&lt;object-name&gt;"]
61
62
 
63
+ assistant_web_crawl["@assistant<br>web<br>crawl -<br>&lt;url-1&gt;+&lt;url-2&gt;+&lt;url-3&gt;<br>&lt;object-name&gt;"]
64
+
62
65
  script["📜 script"]:::folder
66
+ url["🔗 url"]:::folder
63
67
  object["📂 object"]:::folder
64
68
 
65
69
  script --> assistant_script_list
@@ -68,6 +72,9 @@ graph LR
68
72
  object --> assistant_script_run
69
73
  assistant_script_run --> object
70
74
 
75
+ url --> assistant_web_crawl
76
+ assistant_web_crawl --> object
77
+
71
78
  classDef folder fill:#999,stroke:#333,stroke-width:2px;
72
79
  ```
73
80
 
@@ -76,4 +83,4 @@ graph LR
76
83
 
77
84
  [![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
85
 
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).
86
+ built by 🌀 [`blue_options-4.207.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.154.1`](https://github.com/kamangir/blue-assistant).
@@ -25,6 +25,7 @@ blue_assistant/.abcli/alias.sh
25
25
  blue_assistant/.abcli/blue_assistant.sh
26
26
  blue_assistant/.abcli/browse.sh
27
27
  blue_assistant/.abcli/script.sh
28
+ blue_assistant/.abcli/web.sh
28
29
  blue_assistant/.abcli/script/list.sh
29
30
  blue_assistant/.abcli/script/run.sh
30
31
  blue_assistant/.abcli/tests/README.sh
@@ -32,10 +33,13 @@ blue_assistant/.abcli/tests/help.sh
32
33
  blue_assistant/.abcli/tests/script_list.sh
33
34
  blue_assistant/.abcli/tests/script_run.sh
34
35
  blue_assistant/.abcli/tests/version.sh
36
+ blue_assistant/.abcli/tests/web_crawl.sh
37
+ blue_assistant/.abcli/web/crawl.sh
35
38
  blue_assistant/help/__init__.py
36
39
  blue_assistant/help/__main__.py
37
40
  blue_assistant/help/functions.py
38
41
  blue_assistant/help/script.py
42
+ blue_assistant/help/web.py
39
43
  blue_assistant/script/__init__.py
40
44
  blue_assistant/script/__main__.py
41
45
  blue_assistant/script/load.py
@@ -43,7 +47,6 @@ blue_assistant/script/actions/__init__.py
43
47
  blue_assistant/script/actions/generate_image.py
44
48
  blue_assistant/script/actions/generate_text.py
45
49
  blue_assistant/script/actions/generic.py
46
- blue_assistant/script/actions/skip.py
47
50
  blue_assistant/script/repository/__init__.py
48
51
  blue_assistant/script/repository/base/__init__.py
49
52
  blue_assistant/script/repository/base/classes.py
@@ -59,4 +62,7 @@ blue_assistant/script/repository/hue/classes.py
59
62
  blue_assistant/script/repository/orbital_data_explorer/__init__.py
60
63
  blue_assistant/script/repository/orbital_data_explorer/classes.py
61
64
  blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py
62
- blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py
65
+ blue_assistant/script/repository/orbital_data_explorer/actions/researching_the_questions.py
66
+ blue_assistant/web/__init__.py
67
+ blue_assistant/web/__main__.py
68
+ blue_assistant/web/crawl.py
@@ -16,5 +16,6 @@ pylint
16
16
  pytest
17
17
  python-dotenv[cli]
18
18
  tqdm
19
+ beautifulsoup4
19
20
  networkx
20
21
  pydot
@@ -17,6 +17,7 @@ pylint
17
17
  pytest
18
18
  python-dotenv[cli]
19
19
  tqdm
20
+ beautifulsoup4
20
21
 
21
22
  networkx
22
23
  pydot
@@ -20,6 +20,7 @@ setup(
20
20
  f"{NAME}.script.repository.hue",
21
21
  f"{NAME}.script.repository.orbital_data_explorer",
22
22
  f"{NAME}.script.repository.orbital_data_explorer.actions",
23
+ f"{NAME}.web",
23
24
  ],
24
25
  include_package_data=True,
25
26
  package_data={
@@ -1,15 +0,0 @@
1
- from blueness import module
2
-
3
- from blue_assistant import NAME
4
- from blue_assistant.script.repository.base.classes import BaseScript
5
- from blue_assistant.logger import logger
6
-
7
- NAME = module.name(__file__, NAME)
8
-
9
-
10
- def skip_action(
11
- script: BaseScript,
12
- node_name: str,
13
- ) -> bool:
14
- logger.info(f"{NAME}: {script} @ {node_name} ...")
15
- return True