blue-assistant 4.307.1__tar.gz → 4.319.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 (84) hide show
  1. {blue_assistant-4.307.1/blue_assistant.egg-info → blue_assistant-4.319.1}/PKG-INFO +2 -2
  2. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/README.md +1 -1
  3. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/__init__.py +1 -1
  4. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/script.py +1 -0
  5. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/__main__.py +10 -1
  6. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/web_crawl.py +4 -3
  7. blue_assistant-4.319.1/blue_assistant/script/repository/base/classes.py +21 -0
  8. blue_assistant-4.307.1/blue_assistant/script/repository/base/classes.py → blue_assistant-4.319.1/blue_assistant/script/repository/base/root.py +40 -15
  9. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/classes.py +2 -11
  10. blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py +11 -0
  11. blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/actions/expanding_the_extractions.py +109 -0
  12. blue_assistant-4.319.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +15 -0
  13. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/web/crawl.py +5 -5
  14. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/web/fetch.py +2 -2
  15. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/web/functions.py +11 -0
  16. {blue_assistant-4.307.1 → blue_assistant-4.319.1/blue_assistant.egg-info}/PKG-INFO +2 -2
  17. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/SOURCES.txt +2 -0
  18. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/setup.py +1 -0
  19. blue_assistant-4.307.1/blue_assistant/script/repository/base/root.py +0 -5
  20. blue_assistant-4.307.1/blue_assistant/script/repository/orbital_data_explorer/classes.py +0 -7
  21. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/LICENSE +0 -0
  22. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/MANIFEST.in +0 -0
  23. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/abcli.sh +0 -0
  24. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/actions.sh +0 -0
  25. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/alias.sh +0 -0
  26. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/blue_assistant.sh +0 -0
  27. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/browse.sh +0 -0
  28. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/create_user.sh +0 -0
  29. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/list.sh +0 -0
  30. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue/set.sh +0 -0
  31. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/hue.sh +0 -0
  32. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script/list.sh +0 -0
  33. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script/run.sh +0 -0
  34. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/script.sh +0 -0
  35. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/README.sh +0 -0
  36. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/help.sh +0 -0
  37. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/script_list.sh +0 -0
  38. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/script_run.sh +0 -0
  39. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/version.sh +0 -0
  40. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/web_crawl.sh +0 -0
  41. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/tests/web_fetch.sh +0 -0
  42. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web/crawl.sh +0 -0
  43. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web/fetch.sh +0 -0
  44. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/.abcli/web.sh +0 -0
  45. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/README.py +0 -0
  46. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/__main__.py +0 -0
  47. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/config.env +0 -0
  48. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/env.py +0 -0
  49. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/functions.py +0 -0
  50. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/__init__.py +0 -0
  51. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/__main__.py +0 -0
  52. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/functions.py +0 -0
  53. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/hue.py +0 -0
  54. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/help/web.py +0 -0
  55. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/host.py +0 -0
  56. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/logger.py +0 -0
  57. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/sample.env +0 -0
  58. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/__init__.py +0 -0
  59. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/__init__.py +0 -0
  60. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_image.py +0 -0
  61. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generate_text.py +0 -0
  62. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/actions/generic.py +0 -0
  63. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/load.py +0 -0
  64. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/__init__.py +0 -0
  65. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/base/__init__.py +0 -0
  66. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/__init__.py +0 -0
  67. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/actions/__init__.py +0 -0
  68. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/actions/setting_frame_prompts.py +0 -0
  69. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/blue_amo/actions/stitching_the_frames.py +0 -0
  70. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/__init__.py +0 -0
  71. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/__main__.py +0 -0
  72. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/api.py +0 -0
  73. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/classes.py +0 -0
  74. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/hue/colors.py +0 -0
  75. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/script/repository/orbital_data_explorer/__init__.py +0 -0
  76. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/urls.py +0 -0
  77. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/web/__init__.py +0 -0
  78. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant/web/__main__.py +0 -0
  79. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/dependency_links.txt +0 -0
  80. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/requires.txt +0 -0
  81. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/blue_assistant.egg-info/top_level.txt +0 -0
  82. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/pyproject.toml +0 -0
  83. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/requirements.txt +0 -0
  84. {blue_assistant-4.307.1 → blue_assistant-4.319.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.307.1
3
+ Version: 4.319.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -124,4 +124,4 @@ Also home to [`@web`](https://raw.githubusercontent.com/kamangir/blue-assistant/
124
124
 
125
125
  [![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)
126
126
 
127
- built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.1`](https://github.com/kamangir/blue-assistant).
127
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.319.1`](https://github.com/kamangir/blue-assistant).
@@ -79,4 +79,4 @@ Also home to [`@web`](./blue_assistant/web/)
79
79
 
80
80
  [![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)
81
81
 
82
- built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.1`](https://github.com/kamangir/blue-assistant).
82
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.319.1`](https://github.com/kamangir/blue-assistant).
@@ -4,7 +4,7 @@ ICON = "🧠"
4
4
 
5
5
  DESCRIPTION = f"{ICON} An AI Assistant."
6
6
 
7
- VERSION = "4.307.1"
7
+ VERSION = "4.319.1"
8
8
 
9
9
  REPO_NAME = "blue-assistant"
10
10
 
@@ -37,6 +37,7 @@ def help_run(
37
37
  args = [
38
38
  "[--test_mode 1]",
39
39
  "[--verbose 1]",
40
+ "[--runnable <~node_1,~node_2>]",
40
41
  ]
41
42
 
42
43
  return show_usage(
@@ -48,6 +48,13 @@ parser.add_argument(
48
48
  default=1,
49
49
  help="0 | 1",
50
50
  )
51
+ parser.add_argument(
52
+ "--runnable",
53
+ type=str,
54
+ default="",
55
+ help="~node_1,~node_2",
56
+ )
57
+
51
58
  args = parser.parse_args()
52
59
 
53
60
  delim = " " if args.delim == "space" else args.delim
@@ -70,7 +77,9 @@ elif args.task == "run":
70
77
  )
71
78
 
72
79
  if success:
73
- success = script.run()
80
+ success = script.run(
81
+ runnable=args.runnable,
82
+ )
74
83
  else:
75
84
  success = None
76
85
 
@@ -4,6 +4,7 @@ from blue_options.logger import log_list
4
4
 
5
5
  from blue_assistant import NAME
6
6
  from blue_assistant.web.crawl import crawl_list_of_urls
7
+ from blue_assistant.web.functions import normalize_url
7
8
  from blue_assistant.script.repository.base.root import RootScript
8
9
  from blue_assistant.logger import logger
9
10
 
@@ -32,16 +33,16 @@ def web_crawl(
32
33
  if seed_url_var_name not in script.vars:
33
34
  logger.error(f"{node_name}: {seed_url_var_name}: seed_urls not found in vars.")
34
35
  return False
35
- seed_urls = script.vars[seed_url_var_name]
36
+ seed_urls = list({normalize_url(url) for url in script.vars[seed_url_var_name]})
36
37
  log_list(logger, "using", seed_urls, "seed url(s)")
37
38
 
38
- success, _ = crawl_list_of_urls(
39
+ success, crawl_cache = crawl_list_of_urls(
39
40
  seed_urls=seed_urls,
40
41
  object_name=script.object_name,
41
42
  max_iterations=script.nodes[node_name]["max_iterations"],
42
43
  cache_prefix=node_name,
43
44
  )
44
45
 
45
- script.nodes[node_name]["output"] = success
46
+ script.nodes[node_name]["output"] = crawl_cache
46
47
 
47
48
  return success
@@ -0,0 +1,21 @@
1
+ import copy
2
+
3
+ from blueness import module
4
+ from blue_objects import file, path
5
+
6
+ from blue_assistant import NAME
7
+ from blue_assistant.script.repository.base.root import RootScript
8
+ from blue_assistant.script.actions import dict_of_actions
9
+ from blue_assistant.logger import logger
10
+
11
+
12
+ NAME = module.name(__file__, NAME)
13
+
14
+
15
+ class BaseScript(RootScript):
16
+ name = path.name(file.path(__file__))
17
+
18
+ def __init__(self, **kwargs):
19
+ super().__init__(**kwargs)
20
+
21
+ self.dict_of_actions = copy.deepcopy(dict_of_actions)
@@ -1,25 +1,18 @@
1
- from typing import Dict, List, Callable
2
1
  import os
3
- import networkx as nx
2
+ from typing import Dict, List
4
3
  from functools import reduce
4
+ import networkx as nx
5
5
  from tqdm import tqdm
6
- import copy
7
6
 
8
- from blueness import module
9
- from blue_objects import file, objects, path
7
+ from blue_options.options import Options
8
+ from blue_objects import file, path, objects
10
9
  from blue_objects.metadata import post_to_object
11
10
  from blueflow.workflow import dot_file
12
11
 
13
- from blue_assistant import NAME
14
- from blue_assistant.script.repository.base.root import RootScript
15
- from blue_assistant.script.actions import dict_of_actions
16
12
  from blue_assistant.logger import logger
17
13
 
18
14
 
19
- NAME = module.name(__file__, NAME)
20
-
21
-
22
- class BaseScript(RootScript):
15
+ class RootScript:
23
16
  name = path.name(file.path(__file__))
24
17
 
25
18
  def __init__(
@@ -28,13 +21,15 @@ class BaseScript(RootScript):
28
21
  test_mode: bool = False,
29
22
  verbose: bool = False,
30
23
  ):
24
+ self.nodes_changed = False
25
+
31
26
  self.object_name = object_name
32
27
 
33
28
  self.test_mode = test_mode
34
29
 
35
30
  self.verbose = verbose
36
31
 
37
- self.dict_of_actions = copy.deepcopy(dict_of_actions)
32
+ self.dict_of_actions = {}
38
33
 
39
34
  metadata_filename = os.path.join(
40
35
  file.path(__file__),
@@ -115,7 +110,9 @@ class BaseScript(RootScript):
115
110
  text = text.replace(f":::{var_name}", str(var_value))
116
111
 
117
112
  for node_name, node in self.nodes.items():
118
- text = text.replace(f":::{node_name}", node.get("output", ""))
113
+ node_output = node.get("output", "")
114
+ if isinstance(node_output, str):
115
+ text = text.replace(f":::{node_name}", node_output)
119
116
 
120
117
  return text
121
118
 
@@ -174,14 +171,26 @@ class BaseScript(RootScript):
174
171
  logger.error(f"{action_name}: action not found.")
175
172
  return False
176
173
 
177
- def run(self) -> bool:
174
+ def run(
175
+ self,
176
+ runnable: str = "",
177
+ ) -> bool:
178
178
  logger.info(f"{self.name}.run -> {self.object_name}")
179
179
 
180
+ if runnable:
181
+ logger.info(f"applying runnables: {runnable}")
182
+ runnable_options = Options(runnable)
183
+ for node_name, node_is_runnable in runnable_options.items():
184
+ logger.info(f"{node_name}.runnable={node_is_runnable}")
185
+ self.nodes[node_name]["runnable"] = node_is_runnable
186
+
180
187
  success: bool = True
181
188
  while (
182
189
  not all(self.nodes[node].get("completed", False) for node in self.nodes)
183
190
  and success
184
191
  ):
192
+ self.nodes_changed = False
193
+
185
194
  for node_name in tqdm(self.nodes):
186
195
  if self.nodes[node_name].get("completed", False):
187
196
  continue
@@ -212,6 +221,22 @@ class BaseScript(RootScript):
212
221
 
213
222
  self.nodes[node_name]["completed"] = True
214
223
 
224
+ cache_filename = self.nodes[node_name].get("cache", "")
225
+ if cache_filename:
226
+ if not file.save_text(
227
+ objects.path_of(
228
+ object_name=self.object_name,
229
+ filename=cache_filename,
230
+ ),
231
+ [self.nodes[node_name].get("output", "")],
232
+ ):
233
+ success = False
234
+ break
235
+
236
+ if self.nodes_changed:
237
+ logger.info("🪄 nodes changed.")
238
+ break
239
+
215
240
  if not post_to_object(
216
241
  self.object_name,
217
242
  "output",
@@ -14,17 +14,8 @@ NAME = module.name(__file__, NAME)
14
14
  class BlueAmoScript(BaseScript):
15
15
  name = path.name(file.path(__file__))
16
16
 
17
- def __init__(
18
- self,
19
- object_name: str,
20
- test_mode: bool = False,
21
- verbose: bool = False,
22
- ):
23
- super().__init__(
24
- object_name=object_name,
25
- test_mode=test_mode,
26
- verbose=verbose,
27
- )
17
+ def __init__(self, **kwargs):
18
+ super().__init__(**kwargs)
28
19
 
29
20
  self.dict_of_actions.update(dict_of_actions)
30
21
 
@@ -0,0 +1,11 @@
1
+ from typing import Dict, Callable
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+ from blue_assistant.script.repository.orbital_data_explorer.actions import (
5
+ expanding_the_extractions,
6
+ )
7
+
8
+
9
+ dict_of_actions: Dict[str, Callable[[BaseScript, str], bool]] = {
10
+ "expanding_the_extractions": expanding_the_extractions.expanding_the_extractions,
11
+ }
@@ -0,0 +1,109 @@
1
+ import copy
2
+ from typing import Dict
3
+
4
+ from blueness import module
5
+ from blue_options.logger import log_dict, log_list
6
+ from blue_objects import file, objects
7
+ from blue_objects.metadata import get_from_object
8
+
9
+ from blue_assistant import NAME
10
+ from blue_assistant.script.repository.base.classes import BaseScript
11
+ from blue_assistant.web.functions import url_to_filename
12
+ from blue_assistant.logger import logger
13
+
14
+ NAME = module.name(__file__, NAME)
15
+
16
+
17
+ def expanding_the_extractions(
18
+ script: BaseScript,
19
+ node_name: str,
20
+ ) -> bool:
21
+ map_node_name = "extraction"
22
+
23
+ crawl_cache: Dict[str, str] = get_from_object(
24
+ script.object_name,
25
+ "web_crawl_cache",
26
+ {},
27
+ )
28
+ log_dict(logger, "using", crawl_cache, "crawled url(s)")
29
+
30
+ list_of_urls = [
31
+ url
32
+ for url, content_type in crawl_cache.items()
33
+ if "html" in content_type
34
+ and not file.exists(
35
+ objects.path_of(
36
+ object_name=script.object_name,
37
+ filename="{}_cache/{}.txt".format(
38
+ map_node_name,
39
+ url_to_filename(url),
40
+ ),
41
+ )
42
+ )
43
+ ]
44
+ log_list(logger, "using", list_of_urls, "crawled unextracted html(s).")
45
+
46
+ max_nodes = min(
47
+ len(list_of_urls),
48
+ script.nodes[node_name]["max_nodes"],
49
+ )
50
+ logger.info(
51
+ "{}: expanding {} X {}...".format(
52
+ NAME,
53
+ map_node_name,
54
+ max_nodes,
55
+ )
56
+ )
57
+
58
+ map_node = script.nodes[map_node_name]
59
+ del script.nodes[map_node_name]
60
+ script.G.remove_node(map_node_name)
61
+
62
+ reduce_node_name = "generating_summary"
63
+ for index in range(max_nodes):
64
+ url = list_of_urls[index]
65
+ index_node_name = f"{map_node_name}_{index+1:03d}"
66
+
67
+ success, url_content = file.load_yaml(
68
+ filename=objects.path_of(
69
+ object_name=script.object_name,
70
+ filename="web_crawl_cache/{}.yaml".format(
71
+ url_to_filename(url),
72
+ ),
73
+ ),
74
+ )
75
+ if not success:
76
+ logger.warning(f"{url}: failed to load url content.")
77
+ continue
78
+ if "text" not in url_content:
79
+ logger.warning(f"{url}: no text found in url content.")
80
+ continue
81
+
82
+ logger.info(f"{url} -{map_node_name}-> {index_node_name}")
83
+
84
+ script.nodes[index_node_name] = copy.deepcopy(map_node)
85
+
86
+ script.nodes[index_node_name]["prompt"] = map_node["prompt"].replace(
87
+ ":::url_content",
88
+ url_content["text"],
89
+ )
90
+
91
+ script.nodes[index_node_name]["url"] = url
92
+ script.nodes[index_node_name]["cache"] = "{}_cache/{}.txt".format(
93
+ map_node_name,
94
+ url_to_filename(url),
95
+ )
96
+
97
+ script.G.add_node(index_node_name)
98
+ script.G.add_edge(
99
+ index_node_name,
100
+ node_name,
101
+ )
102
+ script.G.add_edge(
103
+ reduce_node_name,
104
+ index_node_name,
105
+ )
106
+
107
+ script.nodes_changed = True
108
+
109
+ return script.save_graph()
@@ -0,0 +1,15 @@
1
+ from blue_objects import file, path
2
+
3
+ from blue_assistant.script.repository.base.classes import BaseScript
4
+ from blue_assistant.script.repository.orbital_data_explorer.actions import (
5
+ dict_of_actions,
6
+ )
7
+
8
+
9
+ class OrbitalDataExplorerScript(BaseScript):
10
+ name = path.name(file.path(__file__))
11
+
12
+ def __init__(self, **kwargs):
13
+ super().__init__(**kwargs)
14
+
15
+ self.dict_of_actions.update(dict_of_actions)
@@ -35,7 +35,7 @@ def crawl_list_of_urls(
35
35
  seed_urls
36
36
  + get_from_object(
37
37
  object_name,
38
- f"{cache_prefix}_crawl_queue",
38
+ f"{cache_prefix}_queue",
39
39
  [],
40
40
  )
41
41
  )
@@ -44,7 +44,7 @@ def crawl_list_of_urls(
44
44
 
45
45
  crawl_cache: Dict[str, str] = get_from_object(
46
46
  object_name,
47
- f"{cache_prefix}_crawl_cache",
47
+ f"{cache_prefix}_cache",
48
48
  {},
49
49
  )
50
50
  log_dict(logger, "loaded cache:", crawl_cache, "url(s)")
@@ -75,7 +75,7 @@ def crawl_list_of_urls(
75
75
  if not file.save_yaml(
76
76
  filename=objects.path_of(
77
77
  object_name=object_name,
78
- filename="{}_crawl_cache/{}.yaml".format(
78
+ filename="{}_cache/{}.yaml".format(
79
79
  cache_prefix,
80
80
  url_to_filename(url),
81
81
  ),
@@ -108,12 +108,12 @@ def crawl_list_of_urls(
108
108
  if not (
109
109
  post_to_object(
110
110
  object_name,
111
- f"{cache_prefix}_crawl_cache",
111
+ f"{cache_prefix}_cache",
112
112
  crawl_cache,
113
113
  )
114
114
  and post_to_object(
115
115
  object_name,
116
- f"{cache_prefix}_crawl_queue",
116
+ f"{cache_prefix}_queue",
117
117
  queue,
118
118
  )
119
119
  ):
@@ -9,6 +9,7 @@ from blueness import module
9
9
  from blue_options.logger import log_long_text, log_list
10
10
 
11
11
  from blue_assistant import NAME
12
+ from blue_assistant.web.functions import normalize_url
12
13
  from blue_assistant.logger import logger
13
14
 
14
15
  warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
@@ -49,8 +50,7 @@ def fetch_links_and_text(
49
50
  for a_tag in soup.find_all("a", href=True):
50
51
  a_url = urljoin(url, a_tag["href"])
51
52
 
52
- if "#" in a_url:
53
- a_url = a_url.split("#", 1)[0]
53
+ a_url = normalize_url(a_url)
54
54
 
55
55
  if a_url.startswith(url):
56
56
  if url not in list_of_urls:
@@ -1,4 +1,15 @@
1
1
  import re
2
+ from urllib.parse import urlparse, urlunparse
3
+
4
+
5
+ # https://chatgpt.com/c/67d733a0-4be4-8005-bf52-fb9ba32487c2
6
+ def normalize_url(url: str) -> str:
7
+ return urlunparse(
8
+ urlparse(url)._replace(
9
+ query="",
10
+ fragment="",
11
+ ),
12
+ )
2
13
 
3
14
 
4
15
  def url_to_filename(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: blue_assistant
3
- Version: 4.307.1
3
+ Version: 4.319.1
4
4
  Summary: 🧠 An AI Assistant.
5
5
  Home-page: https://github.com/kamangir/blue-assistant
6
6
  Author: Arash Abadpour (Kamangir)
@@ -124,4 +124,4 @@ Also home to [`@web`](https://raw.githubusercontent.com/kamangir/blue-assistant/
124
124
 
125
125
  [![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)
126
126
 
127
- built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.307.1`](https://github.com/kamangir/blue-assistant).
127
+ built by 🌀 [`blue_options-4.240.1`](https://github.com/kamangir/awesome-bash-cli), based on 🧠 [`blue_assistant-4.319.1`](https://github.com/kamangir/blue-assistant).
@@ -71,6 +71,8 @@ blue_assistant/script/repository/hue/classes.py
71
71
  blue_assistant/script/repository/hue/colors.py
72
72
  blue_assistant/script/repository/orbital_data_explorer/__init__.py
73
73
  blue_assistant/script/repository/orbital_data_explorer/classes.py
74
+ blue_assistant/script/repository/orbital_data_explorer/actions/__init__.py
75
+ blue_assistant/script/repository/orbital_data_explorer/actions/expanding_the_extractions.py
74
76
  blue_assistant/web/__init__.py
75
77
  blue_assistant/web/__main__.py
76
78
  blue_assistant/web/crawl.py
@@ -18,6 +18,7 @@ setup(
18
18
  f"{NAME}.script.repository.blue_amo.actions",
19
19
  f"{NAME}.script.repository.hue",
20
20
  f"{NAME}.script.repository.orbital_data_explorer",
21
+ f"{NAME}.script.repository.orbital_data_explorer.actions",
21
22
  f"{NAME}.web",
22
23
  ],
23
24
  include_package_data=True,
@@ -1,5 +0,0 @@
1
- from blue_objects import file, objects, path
2
-
3
-
4
- class RootScript:
5
- name = path.name(file.path(__file__))
@@ -1,7 +0,0 @@
1
- from blue_objects import file, path
2
-
3
- from blue_assistant.script.repository.base.classes import BaseScript
4
-
5
-
6
- class OrbitalDataExplorerScript(BaseScript):
7
- name = path.name(file.path(__file__))