zrb 1.17.3__py3-none-any.whl → 1.17.4__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.
- zrb/builtin/llm/tool/web.py +28 -4
- zrb/config/config.py +28 -0
- zrb/task/rsync_task.py +24 -10
- zrb/util/attr.py +5 -1
- {zrb-1.17.3.dist-info → zrb-1.17.4.dist-info}/METADATA +1 -1
- {zrb-1.17.3.dist-info → zrb-1.17.4.dist-info}/RECORD +8 -8
- {zrb-1.17.3.dist-info → zrb-1.17.4.dist-info}/WHEEL +0 -0
- {zrb-1.17.3.dist-info → zrb-1.17.4.dist-info}/entry_points.txt +0 -0
zrb/builtin/llm/tool/web.py
CHANGED
|
@@ -52,18 +52,41 @@ def create_search_internet_tool() -> Callable:
|
|
|
52
52
|
"""
|
|
53
53
|
import requests
|
|
54
54
|
|
|
55
|
-
if
|
|
55
|
+
if (
|
|
56
|
+
CFG.SEARCH_INTERNET_METHOD.strip().lower() == "serpapi"
|
|
57
|
+
and CFG.SERPAPI_KEY != ""
|
|
58
|
+
):
|
|
56
59
|
response = requests.get(
|
|
57
60
|
"https://serpapi.com/search",
|
|
58
61
|
headers={"User-Agent": _DEFAULT_USER_AGENT},
|
|
59
62
|
params={
|
|
60
63
|
"q": query,
|
|
61
64
|
"start": (page - 1) * 10,
|
|
62
|
-
"hl":
|
|
63
|
-
"safe":
|
|
65
|
+
"hl": CFG.SERPAPI_LANG,
|
|
66
|
+
"safe": CFG.SERPAPI_SAFE,
|
|
64
67
|
"api_key": CFG.SERPAPI_KEY,
|
|
65
68
|
},
|
|
66
69
|
)
|
|
70
|
+
elif (
|
|
71
|
+
CFG.SEARCH_INTERNET_METHOD.strip().lower() == "brave"
|
|
72
|
+
and CFG.BRAVE_API_KEY != ""
|
|
73
|
+
):
|
|
74
|
+
response = requests.get(
|
|
75
|
+
"https://api.search.brave.com/res/v1/web/search",
|
|
76
|
+
headers={
|
|
77
|
+
"User-Agent": _DEFAULT_USER_AGENT,
|
|
78
|
+
"Accept": "application/json",
|
|
79
|
+
"x-subscription-token": CFG.BRAVE_API_KEY,
|
|
80
|
+
},
|
|
81
|
+
params={
|
|
82
|
+
"q": query,
|
|
83
|
+
"count": "10",
|
|
84
|
+
"offset": (page - 1) * 10,
|
|
85
|
+
"safesearch": CFG.BRAVE_API_SAFE,
|
|
86
|
+
"search_lang": CFG.BRAVE_API_LANG,
|
|
87
|
+
"summary": "true",
|
|
88
|
+
},
|
|
89
|
+
)
|
|
67
90
|
else:
|
|
68
91
|
response = requests.get(
|
|
69
92
|
url=f"{CFG.SEARXNG_BASE_URL}/search",
|
|
@@ -72,7 +95,8 @@ def create_search_internet_tool() -> Callable:
|
|
|
72
95
|
"q": query,
|
|
73
96
|
"format": "json",
|
|
74
97
|
"pageno": page,
|
|
75
|
-
"safesearch":
|
|
98
|
+
"safesearch": CFG.SEARXNG_SAFE,
|
|
99
|
+
"language": CFG.SEARXNG_LANG,
|
|
76
100
|
},
|
|
77
101
|
)
|
|
78
102
|
if response.status_code != 200:
|
zrb/config/config.py
CHANGED
|
@@ -442,10 +442,30 @@ class Config:
|
|
|
442
442
|
"""Either serpapi or searxng"""
|
|
443
443
|
return self._getenv("SEARCH_INTERNET_METHOD", "serpapi")
|
|
444
444
|
|
|
445
|
+
@property
|
|
446
|
+
def BRAVE_API_KEY(self) -> str:
|
|
447
|
+
return os.getenv("BRAVE_API_KEY", "")
|
|
448
|
+
|
|
449
|
+
@property
|
|
450
|
+
def BRAVE_API_SAFE(self) -> str:
|
|
451
|
+
return self._getenv("BRAVE_API_SAFE", "off")
|
|
452
|
+
|
|
453
|
+
@property
|
|
454
|
+
def BRAVE_API_LANG(self) -> str:
|
|
455
|
+
return self._getenv("BRAVE_API_LANG", "en")
|
|
456
|
+
|
|
445
457
|
@property
|
|
446
458
|
def SERPAPI_KEY(self) -> str:
|
|
447
459
|
return os.getenv("SERPAPI_KEY", "")
|
|
448
460
|
|
|
461
|
+
@property
|
|
462
|
+
def SERPAPI_SAFE(self) -> str:
|
|
463
|
+
return self._getenv("SERPAPI_SAFE", "off")
|
|
464
|
+
|
|
465
|
+
@property
|
|
466
|
+
def SERPAPI_LANG(self) -> str:
|
|
467
|
+
return self._getenv("SERPAPI_LANG", "en")
|
|
468
|
+
|
|
449
469
|
@property
|
|
450
470
|
def SEARXNG_PORT(self) -> int:
|
|
451
471
|
return int(self._getenv("SEARXNG_PORT", "8080"))
|
|
@@ -454,6 +474,14 @@ class Config:
|
|
|
454
474
|
def SEARXNG_BASE_URL(self) -> str:
|
|
455
475
|
return self._getenv("SEARXNG_BASE_URL", f"http://localhost:{self.SEARXNG_PORT}")
|
|
456
476
|
|
|
477
|
+
@property
|
|
478
|
+
def SEARXNG_SAFE(self) -> int:
|
|
479
|
+
return int(self._getenv("SEARXNG_SAFE", "0"))
|
|
480
|
+
|
|
481
|
+
@property
|
|
482
|
+
def SEARXNG_LANG(self) -> int:
|
|
483
|
+
return int(self._getenv("SEARXNG_LANG", "en"))
|
|
484
|
+
|
|
457
485
|
@property
|
|
458
486
|
def BANNER(self) -> str:
|
|
459
487
|
return fstring_format(
|
zrb/task/rsync_task.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
3
|
-
from zrb.attr.type import IntAttr, StrAttr
|
|
1
|
+
from zrb.attr.type import BoolAttr, IntAttr, StrAttr
|
|
4
2
|
from zrb.context.any_context import AnyContext
|
|
5
3
|
from zrb.env.any_env import AnyEnv
|
|
6
4
|
from zrb.input.any_input import AnyInput
|
|
@@ -17,8 +15,8 @@ class RsyncTask(CmdTask):
|
|
|
17
15
|
icon: str | None = None,
|
|
18
16
|
description: str | None = None,
|
|
19
17
|
cli_only: bool = False,
|
|
20
|
-
input: list[AnyInput] | AnyInput | None = None,
|
|
21
|
-
env: list[AnyEnv] | AnyEnv | None = None,
|
|
18
|
+
input: list[AnyInput | None] | AnyInput | None = None,
|
|
19
|
+
env: list[AnyEnv | None] | AnyEnv | None = None,
|
|
22
20
|
shell: StrAttr | None = None,
|
|
23
21
|
auto_render_shell: bool = True,
|
|
24
22
|
remote_host: StrAttr | None = None,
|
|
@@ -39,12 +37,14 @@ class RsyncTask(CmdTask):
|
|
|
39
37
|
render_local_source_path: bool = True,
|
|
40
38
|
local_destination_path: StrAttr | None = None,
|
|
41
39
|
render_local_destination_path: bool = True,
|
|
40
|
+
exclude_from: StrAttr | None = None,
|
|
41
|
+
render_exclude_from: bool = True,
|
|
42
42
|
cwd: str | None = None,
|
|
43
43
|
render_cwd: bool = True,
|
|
44
44
|
plain_print: bool = False,
|
|
45
45
|
max_output_line: int = 1000,
|
|
46
46
|
max_error_line: int = 1000,
|
|
47
|
-
execute_condition:
|
|
47
|
+
execute_condition: BoolAttr = True,
|
|
48
48
|
retries: int = 2,
|
|
49
49
|
retry_period: float = 0,
|
|
50
50
|
readiness_check: list[AnyTask] | AnyTask | None = None,
|
|
@@ -93,6 +93,8 @@ class RsyncTask(CmdTask):
|
|
|
93
93
|
self._render_local_source_path = render_local_source_path
|
|
94
94
|
self._local_destination_path = local_destination_path
|
|
95
95
|
self._render_local_destination_path = render_local_destination_path
|
|
96
|
+
self._exclude_from = exclude_from
|
|
97
|
+
self._render_exclude_from = render_exclude_from
|
|
96
98
|
|
|
97
99
|
def _get_source_path(self, ctx: AnyContext) -> str:
|
|
98
100
|
local_source_path = self._get_local_source_path(ctx)
|
|
@@ -144,16 +146,28 @@ class RsyncTask(CmdTask):
|
|
|
144
146
|
auto_render=self._render_local_destination_path,
|
|
145
147
|
)
|
|
146
148
|
|
|
149
|
+
def _get_exclude_from_param(self, ctx: AnyContext) -> str:
|
|
150
|
+
exclude_from = get_str_attr(
|
|
151
|
+
ctx,
|
|
152
|
+
self._exclude_from,
|
|
153
|
+
"",
|
|
154
|
+
auto_render=self._render_exclude_from,
|
|
155
|
+
).strip()
|
|
156
|
+
if exclude_from == "":
|
|
157
|
+
return ""
|
|
158
|
+
return f"--exclude-from='{exclude_from}'"
|
|
159
|
+
|
|
147
160
|
def _get_cmd_script(self, ctx: AnyContext) -> str:
|
|
148
161
|
port = self._get_remote_port(ctx)
|
|
149
162
|
password = self._get_remote_password(ctx)
|
|
150
163
|
key = self._get_remote_ssh_key(ctx)
|
|
151
164
|
src = self._get_source_path(ctx)
|
|
152
165
|
dst = self._get_destination_path(ctx)
|
|
166
|
+
exclude_from = self._get_exclude_from_param(ctx)
|
|
153
167
|
if key != "" and password != "":
|
|
154
|
-
return f'sshpass -p "$_ZRB_SSH_PASSWORD" rsync --mkpath -avz -e "ssh -i {key} -p {port}" {src} {dst}' # noqa
|
|
168
|
+
return f'sshpass -p "$_ZRB_SSH_PASSWORD" rsync --mkpath -avz -e "ssh -i {key} -p {port}" {exclude_from} {src} {dst}' # noqa
|
|
155
169
|
if key != "":
|
|
156
|
-
return f'rsync --mkpath -avz -e "ssh -i {key} -p {port}" {src} {dst}'
|
|
170
|
+
return f'rsync --mkpath -avz -e "ssh -i {key} -p {port}" {exclude_from} {src} {dst}'
|
|
157
171
|
if password != "":
|
|
158
|
-
return f'sshpass -p "$_ZRB_SSH_PASSWORD" rsync --mkpath -avz -e "ssh -p {port}" {src} {dst}' # noqa
|
|
159
|
-
return f'rsync --mkpath -avz -e "ssh -p {port}" {src} {dst}'
|
|
172
|
+
return f'sshpass -p "$_ZRB_SSH_PASSWORD" rsync --mkpath -avz -e "ssh -p {port}" {exclude_from} {src} {dst}' # noqa
|
|
173
|
+
return f'rsync --mkpath -avz -e "ssh -p {port}" {exclude_from} {src} {dst}'
|
zrb/util/attr.py
CHANGED
|
@@ -27,9 +27,11 @@ def get_str_list_attr(
|
|
|
27
27
|
Returns:
|
|
28
28
|
list[str]: A list of string attributes.
|
|
29
29
|
"""
|
|
30
|
+
if attr is None:
|
|
31
|
+
return []
|
|
30
32
|
if callable(attr):
|
|
31
33
|
return attr(shared_ctx)
|
|
32
|
-
return
|
|
34
|
+
return [get_str_attr(shared_ctx, val, "", auto_render) for val in attr]
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
def get_str_dict_attr(
|
|
@@ -46,6 +48,8 @@ def get_str_dict_attr(
|
|
|
46
48
|
Returns:
|
|
47
49
|
dict[str, Any]: A dictionary of string attributes.
|
|
48
50
|
"""
|
|
51
|
+
if attr is None:
|
|
52
|
+
return {}
|
|
49
53
|
if callable(attr):
|
|
50
54
|
return attr(shared_ctx)
|
|
51
55
|
return {
|
|
@@ -23,7 +23,7 @@ zrb/builtin/llm/tool/file.py,sha256=Pa-2Vy3M9EKcngPXnzA5GwSbeZYPDE94ZAuiagGZqks,
|
|
|
23
23
|
zrb/builtin/llm/tool/note.py,sha256=7H1PK2NJRAF5BqVNwh6d0I27zUIKvkiyPS1xzVxlcZY,2298
|
|
24
24
|
zrb/builtin/llm/tool/rag.py,sha256=aN8D8ZqzGXWCP_1F1LbN0QgfyzaK9CKrjfTPorDIYjw,9824
|
|
25
25
|
zrb/builtin/llm/tool/sub_agent.py,sha256=nYluPfc8FlSobpP_4vnBIqkPARrDHq_SwKkmlh_ATUI,5067
|
|
26
|
-
zrb/builtin/llm/tool/web.py,sha256=
|
|
26
|
+
zrb/builtin/llm/tool/web.py,sha256=BrohIKRO3tF66Ut5hx28nerRnLc4fEtznV8DyK9ozUc,6680
|
|
27
27
|
zrb/builtin/md5.py,sha256=690RV2LbW7wQeTFxY-lmmqTSVEEZv3XZbjEUW1Q3XpE,1480
|
|
28
28
|
zrb/builtin/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
zrb/builtin/project/add/fastapp/fastapp_input.py,sha256=MKlWR_LxWhM_DcULCtLfL_IjTxpDnDBkn9KIqNmajFs,310
|
|
@@ -221,7 +221,7 @@ zrb/callback/callback.py,sha256=PFhCqzfxdk6IAthmXcZ13DokT62xtBzJr_ciLw6I8Zg,4030
|
|
|
221
221
|
zrb/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
222
222
|
zrb/cmd/cmd_result.py,sha256=L8bQJzWCpcYexIxHBNsXj2pT3BtLmWex0iJSMkvimOA,597
|
|
223
223
|
zrb/cmd/cmd_val.py,sha256=7Doowyg6BK3ISSGBLt-PmlhzaEkBjWWm51cED6fAUOQ,1014
|
|
224
|
-
zrb/config/config.py,sha256=
|
|
224
|
+
zrb/config/config.py,sha256=XuNtEkPQACuqXhnr1rgFkFjltG8fVTOCMxZVxk8X9n8,15880
|
|
225
225
|
zrb/config/default_prompt/file_extractor_system_prompt.md,sha256=dNBWy4O4mfCqGkqaRQHDo18hDCengU0IZ0vQMSDwbyY,3821
|
|
226
226
|
zrb/config/default_prompt/interactive_system_prompt.md,sha256=5wE_E1WiMwbXY_jaRoQzDM9esnOxmlsD3BShGx8HyEc,2702
|
|
227
227
|
zrb/config/default_prompt/persona.md,sha256=GfUJ4-Mlf_Bm1YTzxFNkPkdVbAi06ZDVYh-iIma3NOs,253
|
|
@@ -366,7 +366,7 @@ zrb/task/llm/tool_wrapper.py,sha256=DCqRNw-7lul1PL4E11vi5cjb6uyjZ9_vUN5KKlcf0yI,
|
|
|
366
366
|
zrb/task/llm/typing.py,sha256=c8VAuPBw_4A3DxfYdydkgedaP-LU61W9_wj3m3CAX1E,58
|
|
367
367
|
zrb/task/llm_task.py,sha256=onQlUnOIBxXa6gSurgXcpmQ4BsIxDH6G4PnuEImLZPU,15994
|
|
368
368
|
zrb/task/make_task.py,sha256=PD3b_aYazthS8LHeJsLAhwKDEgdurQZpymJDKeN60u0,2265
|
|
369
|
-
zrb/task/rsync_task.py,sha256=
|
|
369
|
+
zrb/task/rsync_task.py,sha256=n3MBjx5nj3PO2ntLS4m4wqaU9mo0imHmxez_WRbOfAk,6958
|
|
370
370
|
zrb/task/scaffolder.py,sha256=rME18w1HJUHXgi9eTYXx_T2G4JdqDYzBoNOkdOOo5-o,6806
|
|
371
371
|
zrb/task/scheduler.py,sha256=lPsemHq40QrYiw3QNJwoWG9fc28qDrhvwVYnQ797_7Q,3133
|
|
372
372
|
zrb/task/task.py,sha256=KCrCaWYOQQvv1RJsYtHDeo9RBFmlXQ28oKyEFU4Q7pA,73
|
|
@@ -374,7 +374,7 @@ zrb/task/tcp_check.py,sha256=P_QgGqwd5dXDaud3oQRxe_WuxyxG4s7CTY2wDk9Qcu0,2511
|
|
|
374
374
|
zrb/task_status/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
375
375
|
zrb/task_status/task_status.py,sha256=blZ8dxg9g_8MuViq-t7yJRLoE7yGUf5srgHf-PCsXNc,3069
|
|
376
376
|
zrb/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
377
|
-
zrb/util/attr.py,sha256
|
|
377
|
+
zrb/util/attr.py,sha256=-tNDm3cwke3zEEXL8gV1ChzHFCVEJ90gM1P07l20SwI,5447
|
|
378
378
|
zrb/util/callable.py,sha256=b6OFXbCXp2twow3wh2E_h5hNHLs2pXaLfGQz4iVyiQc,771
|
|
379
379
|
zrb/util/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
380
380
|
zrb/util/cli/markdown.py,sha256=Uhuw8XR-jAG9AG3oNK8VHJpYOdU40Q_8yVN74uu0RJ8,384
|
|
@@ -414,7 +414,7 @@ zrb/util/todo_model.py,sha256=hhzAX-uFl5rsg7iVX1ULlJOfBtblwQ_ieNUxBWfc-Os,1670
|
|
|
414
414
|
zrb/util/truncate.py,sha256=eSzmjBpc1Qod3lM3M73snNbDOcARHukW_tq36dWdPvc,921
|
|
415
415
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
416
416
|
zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
|
|
417
|
-
zrb-1.17.
|
|
418
|
-
zrb-1.17.
|
|
419
|
-
zrb-1.17.
|
|
420
|
-
zrb-1.17.
|
|
417
|
+
zrb-1.17.4.dist-info/METADATA,sha256=yGeh5HqVoHrvwPed4JUHEe_Igc4GV6brmB0jUddSClU,9893
|
|
418
|
+
zrb-1.17.4.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
419
|
+
zrb-1.17.4.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
|
420
|
+
zrb-1.17.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|