zrb 1.1.0__py3-none-any.whl → 1.2.0__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/git.py +8 -8
- zrb/builtin/llm/llm_chat.py +3 -3
- zrb/builtin/project/add/fastapp/fastapp_input.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py +3 -3
- zrb/builtin/project/create/project_task.py +2 -2
- zrb/builtin/random.py +3 -3
- zrb/builtin/setup/common_input.py +5 -5
- zrb/builtin/setup/tmux/tmux.py +1 -1
- zrb/builtin/setup/zsh/zsh.py +1 -1
- zrb/builtin/todo.py +4 -4
- zrb/input/base_input.py +17 -12
- zrb/input/bool_input.py +12 -5
- zrb/input/float_input.py +12 -5
- zrb/input/int_input.py +12 -5
- zrb/input/option_input.py +5 -5
- zrb/input/password_input.py +5 -5
- zrb/input/text_input.py +4 -4
- {zrb-1.1.0.dist-info → zrb-1.2.0.dist-info}/METADATA +1 -1
- {zrb-1.1.0.dist-info → zrb-1.2.0.dist-info}/RECORD +21 -22
- zrb/util/llm/tool.py +0 -87
- {zrb-1.1.0.dist-info → zrb-1.2.0.dist-info}/WHEEL +0 -0
- {zrb-1.1.0.dist-info → zrb-1.2.0.dist-info}/entry_points.txt +0 -0
zrb/builtin/git.py
CHANGED
@@ -24,31 +24,31 @@ from zrb.util.git import (
|
|
24
24
|
name="source",
|
25
25
|
description="Source branch/tag/commit",
|
26
26
|
prompt="Source branch/tag/commit",
|
27
|
-
|
27
|
+
default="main",
|
28
28
|
),
|
29
29
|
StrInput(
|
30
30
|
name="current",
|
31
31
|
description="Current branch/tag/commit",
|
32
32
|
prompt="Current branch/tag/commit",
|
33
|
-
|
33
|
+
default="HEAD",
|
34
34
|
),
|
35
35
|
BoolInput(
|
36
36
|
name="created",
|
37
37
|
description="Include created files",
|
38
38
|
prompt="Include created files",
|
39
|
-
|
39
|
+
default="True",
|
40
40
|
),
|
41
41
|
BoolInput(
|
42
42
|
name="removed",
|
43
43
|
description="Include removed files",
|
44
44
|
prompt="Include removed files",
|
45
|
-
|
45
|
+
default="True",
|
46
46
|
),
|
47
47
|
BoolInput(
|
48
48
|
name="updated",
|
49
49
|
description="Include updated files",
|
50
50
|
prompt="Include updated files",
|
51
|
-
|
51
|
+
default="True",
|
52
52
|
),
|
53
53
|
],
|
54
54
|
description="🔍 Get modified files",
|
@@ -109,7 +109,7 @@ async def prune_local_branches(ctx: AnyContext):
|
|
109
109
|
name="message",
|
110
110
|
description="Commit message",
|
111
111
|
prompt="Commit message",
|
112
|
-
|
112
|
+
default="Add feature/fix bug",
|
113
113
|
),
|
114
114
|
description="📝 Commit changes",
|
115
115
|
group=git_group,
|
@@ -131,7 +131,7 @@ async def git_commit(ctx: AnyContext):
|
|
131
131
|
name="remote",
|
132
132
|
description="Remote name",
|
133
133
|
prompt="Remote name",
|
134
|
-
|
134
|
+
default="origin",
|
135
135
|
),
|
136
136
|
upstream=git_commit,
|
137
137
|
group=git_group,
|
@@ -154,7 +154,7 @@ async def git_pull(ctx: AnyContext):
|
|
154
154
|
name="remote",
|
155
155
|
description="Remote name",
|
156
156
|
prompt="Remote name",
|
157
|
-
|
157
|
+
default="origin",
|
158
158
|
),
|
159
159
|
upstream=git_commit,
|
160
160
|
group=git_group,
|
zrb/builtin/llm/llm_chat.py
CHANGED
@@ -80,21 +80,21 @@ llm_chat: LLMTask = llm_group.add_task(
|
|
80
80
|
"model",
|
81
81
|
description="LLM Model",
|
82
82
|
prompt="LLM Model",
|
83
|
-
|
83
|
+
default=LLM_MODEL,
|
84
84
|
allow_positional_parsing=False,
|
85
85
|
),
|
86
86
|
TextInput(
|
87
87
|
"system-prompt",
|
88
88
|
description="System prompt",
|
89
89
|
prompt="System prompt",
|
90
|
-
|
90
|
+
default=LLM_SYSTEM_PROMPT,
|
91
91
|
allow_positional_parsing=False,
|
92
92
|
),
|
93
93
|
BoolInput(
|
94
94
|
"start-new",
|
95
95
|
description="Start new conversation (LLM will forget everything)",
|
96
96
|
prompt="Start new conversation (LLM will forget everything)",
|
97
|
-
|
97
|
+
default=False,
|
98
98
|
allow_positional_parsing=False,
|
99
99
|
),
|
100
100
|
TextInput("message", description="User message", prompt="Your message"),
|
@@ -8,7 +8,7 @@ run_env_input = OptionInput(
|
|
8
8
|
description="Running environment",
|
9
9
|
prompt="Running Environment",
|
10
10
|
options=["dev", "prod"],
|
11
|
-
|
11
|
+
default="prod",
|
12
12
|
)
|
13
13
|
|
14
14
|
new_module_input = StrInput(
|
@@ -37,14 +37,14 @@ plural_entity_input = StrInput(
|
|
37
37
|
name="plural",
|
38
38
|
description="Plural entity name",
|
39
39
|
prompt="Plural entity name",
|
40
|
-
|
40
|
+
default=lambda ctx: pluralize(ctx.input.entity),
|
41
41
|
)
|
42
42
|
|
43
43
|
new_entity_column_input = StrInput(
|
44
44
|
name="column",
|
45
45
|
description="Entity's column name",
|
46
46
|
prompt="New entity's column name",
|
47
|
-
|
47
|
+
default="name",
|
48
48
|
)
|
49
49
|
|
50
50
|
new_column_input = StrInput(
|
@@ -15,13 +15,13 @@ scaffold_project = Scaffolder(
|
|
15
15
|
name="project-dir",
|
16
16
|
description="Project directory",
|
17
17
|
prompt="Project directory",
|
18
|
-
|
18
|
+
default=lambda _: os.getcwd(),
|
19
19
|
),
|
20
20
|
StrInput(
|
21
21
|
name="project",
|
22
22
|
description="Project name",
|
23
23
|
prompt="Project name",
|
24
|
-
|
24
|
+
default=lambda ctx: os.path.basename(ctx.input.project_dir),
|
25
25
|
),
|
26
26
|
],
|
27
27
|
source_path=os.path.join(_DIR, "project-template"),
|
zrb/builtin/random.py
CHANGED
@@ -15,13 +15,13 @@ from zrb.task.make_task import make_task
|
|
15
15
|
name="side",
|
16
16
|
description="Number of sides",
|
17
17
|
prompt="How many sides (comma separated)",
|
18
|
-
|
18
|
+
default="6",
|
19
19
|
),
|
20
20
|
IntInput(
|
21
21
|
name="num-rolls",
|
22
22
|
description="Number of rolls",
|
23
23
|
prompt="How many rolls",
|
24
|
-
|
24
|
+
default="1",
|
25
25
|
),
|
26
26
|
],
|
27
27
|
retries=0,
|
@@ -48,7 +48,7 @@ def throw_dice(ctx: AnyContext) -> str:
|
|
48
48
|
name="values",
|
49
49
|
description="Value to be shuffled",
|
50
50
|
prompt="List of values (comma separated)",
|
51
|
-
|
51
|
+
default="🪙, 🪄, ⚔️, 🍷",
|
52
52
|
),
|
53
53
|
retries=0,
|
54
54
|
group=random_group,
|
@@ -6,30 +6,30 @@ package_manager_input = OptionInput(
|
|
6
6
|
description="Your package manager",
|
7
7
|
prompt="Your package manager",
|
8
8
|
options=["apt", "dnf", "pacman", "zypper", "pkg", "brew", "spack"],
|
9
|
-
|
9
|
+
default="apt",
|
10
10
|
)
|
11
11
|
|
12
12
|
use_sudo_input = BoolInput(
|
13
13
|
name="use-sudo",
|
14
14
|
description="Use sudo or not",
|
15
15
|
prompt="Need sudo",
|
16
|
-
|
16
|
+
default=True,
|
17
17
|
)
|
18
18
|
|
19
19
|
setup_bash_input = BoolInput(
|
20
20
|
name="setup-bash",
|
21
21
|
description="Setup bash",
|
22
22
|
prompt="Setup bash",
|
23
|
-
|
23
|
+
default=True,
|
24
24
|
)
|
25
25
|
|
26
26
|
setup_zsh_input = BoolInput(
|
27
|
-
name="setup-zsh", description="Setup zsh", prompt="Setup zsh",
|
27
|
+
name="setup-zsh", description="Setup zsh", prompt="Setup zsh", default=True
|
28
28
|
)
|
29
29
|
|
30
30
|
setup_powershell_input = BoolInput(
|
31
31
|
name="setup-powershell",
|
32
32
|
description="Setup powershell",
|
33
33
|
prompt="Setup powershell",
|
34
|
-
|
34
|
+
default=False,
|
35
35
|
)
|
zrb/builtin/setup/tmux/tmux.py
CHANGED
zrb/builtin/setup/zsh/zsh.py
CHANGED
zrb/builtin/todo.py
CHANGED
@@ -37,7 +37,7 @@ from zrb.util.todo import (
|
|
37
37
|
name="priority",
|
38
38
|
description="Task priority",
|
39
39
|
prompt="Task priority",
|
40
|
-
|
40
|
+
default="E",
|
41
41
|
),
|
42
42
|
StrInput(
|
43
43
|
name="project",
|
@@ -208,13 +208,13 @@ def archive_todo(ctx: AnyContext):
|
|
208
208
|
name="duration",
|
209
209
|
prompt="Working duration",
|
210
210
|
description="Working duration",
|
211
|
-
|
211
|
+
default="30m",
|
212
212
|
),
|
213
213
|
StrInput(
|
214
214
|
name="stop",
|
215
215
|
prompt="Working stop time (%Y-%m-%d %H:%M:%S)",
|
216
216
|
description="Working stop time",
|
217
|
-
|
217
|
+
default=lambda _: _get_default_stop_work_time_str(),
|
218
218
|
),
|
219
219
|
],
|
220
220
|
description="🕒 Log work todo",
|
@@ -293,7 +293,7 @@ def _get_default_stop_work_time_str() -> str:
|
|
293
293
|
name="text",
|
294
294
|
description="Todo.txt content",
|
295
295
|
prompt="Todo.txt content (will override existing)",
|
296
|
-
|
296
|
+
default=lambda _: _get_todo_txt_content(),
|
297
297
|
allow_positional_parsing=False,
|
298
298
|
),
|
299
299
|
],
|
zrb/input/base_input.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
from typing import Any
|
2
2
|
|
3
|
-
from zrb.attr.type import
|
3
|
+
from zrb.attr.type import AnyAttr
|
4
4
|
from zrb.context.any_shared_context import AnySharedContext
|
5
5
|
from zrb.input.any_input import AnyInput
|
6
|
-
from zrb.util.attr import
|
6
|
+
from zrb.util.attr import get_attr
|
7
7
|
from zrb.util.string.conversion import to_snake_case
|
8
8
|
|
9
9
|
|
@@ -13,7 +13,7 @@ class BaseInput(AnyInput):
|
|
13
13
|
name: str,
|
14
14
|
description: str | None = None,
|
15
15
|
prompt: str | None = None,
|
16
|
-
|
16
|
+
default: AnyAttr = "",
|
17
17
|
auto_render: bool = True,
|
18
18
|
allow_empty: bool = False,
|
19
19
|
allow_positional_parsing: bool = True,
|
@@ -21,7 +21,7 @@ class BaseInput(AnyInput):
|
|
21
21
|
self._name = name
|
22
22
|
self._description = description
|
23
23
|
self._prompt = prompt
|
24
|
-
self.
|
24
|
+
self._default_value = default
|
25
25
|
self._auto_render = auto_render
|
26
26
|
self._allow_empty = allow_empty
|
27
27
|
self._allow_positional_parsing = allow_positional_parsing
|
@@ -45,10 +45,10 @@ class BaseInput(AnyInput):
|
|
45
45
|
def allow_positional_parsing(self) -> bool:
|
46
46
|
return self._allow_positional_parsing
|
47
47
|
|
48
|
-
def to_html(self,
|
48
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
49
49
|
name = self.name
|
50
50
|
description = self.description
|
51
|
-
default = self.get_default_str(
|
51
|
+
default = self.get_default_str(shared_ctx)
|
52
52
|
return f'<input name="{name}" placeholder="{description}" value="{default}" />'
|
53
53
|
|
54
54
|
def update_shared_context(
|
@@ -74,6 +74,7 @@ class BaseInput(AnyInput):
|
|
74
74
|
return str_value
|
75
75
|
|
76
76
|
def prompt_cli_str(self, shared_ctx: AnySharedContext) -> str:
|
77
|
+
"""Prompting user to input the value"""
|
77
78
|
value = self._prompt_cli_str(shared_ctx)
|
78
79
|
while not self._allow_empty and value == "":
|
79
80
|
value = self._prompt_cli_str(shared_ctx)
|
@@ -81,16 +82,20 @@ class BaseInput(AnyInput):
|
|
81
82
|
|
82
83
|
def _prompt_cli_str(self, shared_ctx: AnySharedContext) -> str:
|
83
84
|
prompt_message = self.prompt_message
|
84
|
-
|
85
|
-
if
|
86
|
-
prompt_message = f"{prompt_message} [{
|
85
|
+
default_str = self.get_default_str(shared_ctx)
|
86
|
+
if default_str != "":
|
87
|
+
prompt_message = f"{prompt_message} [{default_str}]"
|
87
88
|
print(f"{prompt_message}: ", end="")
|
88
89
|
value = input()
|
89
90
|
if value.strip() == "":
|
90
|
-
value =
|
91
|
+
value = default_str
|
91
92
|
return value
|
92
93
|
|
93
94
|
def get_default_str(self, shared_ctx: AnySharedContext) -> str:
|
94
|
-
|
95
|
-
|
95
|
+
"""Get default value as str"""
|
96
|
+
default_value = get_attr(
|
97
|
+
shared_ctx, self._default_value, default="", auto_render=self._auto_render
|
96
98
|
)
|
99
|
+
if not isinstance(default_value, str):
|
100
|
+
return str(default_value)
|
101
|
+
return default_value
|
zrb/input/bool_input.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.attr.type import
|
1
|
+
from zrb.attr.type import BoolAttr
|
2
2
|
from zrb.context.any_shared_context import AnySharedContext
|
3
3
|
from zrb.input.base_input import BaseInput
|
4
|
+
from zrb.util.attr import get_bool_attr
|
4
5
|
from zrb.util.string.conversion import to_boolean
|
5
6
|
|
6
7
|
|
@@ -10,7 +11,7 @@ class BoolInput(BaseInput):
|
|
10
11
|
name: str,
|
11
12
|
description: str | None = None,
|
12
13
|
prompt: str | None = None,
|
13
|
-
|
14
|
+
default: BoolAttr = False,
|
14
15
|
auto_render: bool = True,
|
15
16
|
allow_empty: bool = False,
|
16
17
|
allow_positional_parsing: bool = True,
|
@@ -19,16 +20,16 @@ class BoolInput(BaseInput):
|
|
19
20
|
name=name,
|
20
21
|
description=description,
|
21
22
|
prompt=prompt,
|
22
|
-
|
23
|
+
default=default,
|
23
24
|
auto_render=auto_render,
|
24
25
|
allow_empty=allow_empty,
|
25
26
|
allow_positional_parsing=allow_positional_parsing,
|
26
27
|
)
|
27
28
|
|
28
|
-
def to_html(self,
|
29
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
29
30
|
name = self.name
|
30
31
|
description = self.description
|
31
|
-
default = to_boolean(self.get_default_str(
|
32
|
+
default = to_boolean(self.get_default_str(shared_ctx))
|
32
33
|
selected_true = "selected" if default else ""
|
33
34
|
selected_false = "selected" if not default else ""
|
34
35
|
return "\n".join(
|
@@ -40,5 +41,11 @@ class BoolInput(BaseInput):
|
|
40
41
|
]
|
41
42
|
)
|
42
43
|
|
44
|
+
def get_default_str(self, shared_ctx: AnySharedContext) -> str:
|
45
|
+
default_value = get_bool_attr(
|
46
|
+
shared_ctx, self._default_value, auto_render=self._auto_render
|
47
|
+
)
|
48
|
+
return f"{default_value}"
|
49
|
+
|
43
50
|
def _parse_str_value(self, str_value: str) -> bool:
|
44
51
|
return to_boolean(str_value)
|
zrb/input/float_input.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.attr.type import
|
1
|
+
from zrb.attr.type import FloatAttr
|
2
2
|
from zrb.context.any_shared_context import AnySharedContext
|
3
3
|
from zrb.input.base_input import BaseInput
|
4
|
+
from zrb.util.attr import get_float_attr
|
4
5
|
|
5
6
|
|
6
7
|
class FloatInput(BaseInput):
|
@@ -9,7 +10,7 @@ class FloatInput(BaseInput):
|
|
9
10
|
name: str,
|
10
11
|
description: str | None = None,
|
11
12
|
prompt: str | None = None,
|
12
|
-
|
13
|
+
default: FloatAttr = 0.0,
|
13
14
|
auto_render: bool = True,
|
14
15
|
allow_empty: bool = False,
|
15
16
|
allow_positional_parsing: bool = True,
|
@@ -18,17 +19,23 @@ class FloatInput(BaseInput):
|
|
18
19
|
name=name,
|
19
20
|
description=description,
|
20
21
|
prompt=prompt,
|
21
|
-
|
22
|
+
default=default,
|
22
23
|
auto_render=auto_render,
|
23
24
|
allow_empty=allow_empty,
|
24
25
|
allow_positional_parsing=allow_positional_parsing,
|
25
26
|
)
|
26
27
|
|
27
|
-
def to_html(self,
|
28
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
28
29
|
name = self.name
|
29
30
|
description = self.description
|
30
|
-
default = self.get_default_str(
|
31
|
+
default = self.get_default_str(shared_ctx)
|
31
32
|
return f'<input type="number" name="{name}" placeholder="{description}" value="{default}" step="any" />' # noqa
|
32
33
|
|
34
|
+
def get_default_str(self, shared_ctx: AnySharedContext) -> str:
|
35
|
+
default_value = get_float_attr(
|
36
|
+
shared_ctx, self._default_value, auto_render=self._auto_render
|
37
|
+
)
|
38
|
+
return f"{default_value}"
|
39
|
+
|
33
40
|
def _parse_str_value(self, str_value: str) -> float:
|
34
41
|
return float(str_value)
|
zrb/input/int_input.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.attr.type import
|
1
|
+
from zrb.attr.type import IntAttr
|
2
2
|
from zrb.context.any_shared_context import AnySharedContext
|
3
3
|
from zrb.input.base_input import BaseInput
|
4
|
+
from zrb.util.attr import get_int_attr
|
4
5
|
|
5
6
|
|
6
7
|
class IntInput(BaseInput):
|
@@ -9,7 +10,7 @@ class IntInput(BaseInput):
|
|
9
10
|
name: str,
|
10
11
|
description: str | None = None,
|
11
12
|
prompt: str | None = None,
|
12
|
-
|
13
|
+
default: IntAttr = 0,
|
13
14
|
auto_render: bool = True,
|
14
15
|
allow_empty: bool = False,
|
15
16
|
allow_positional_parsing: bool = True,
|
@@ -18,17 +19,23 @@ class IntInput(BaseInput):
|
|
18
19
|
name=name,
|
19
20
|
description=description,
|
20
21
|
prompt=prompt,
|
21
|
-
|
22
|
+
default=default,
|
22
23
|
auto_render=auto_render,
|
23
24
|
allow_empty=allow_empty,
|
24
25
|
allow_positional_parsing=allow_positional_parsing,
|
25
26
|
)
|
26
27
|
|
27
|
-
def to_html(self,
|
28
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
28
29
|
name = self.name
|
29
30
|
description = self.description
|
30
|
-
default = self.get_default_str(
|
31
|
+
default = self.get_default_str(shared_ctx)
|
31
32
|
return f'<input type="number" step="1" name="{name}" placeholder="{description}" value="{default}" />' # noqa
|
32
33
|
|
33
34
|
def _parse_str_value(self, str_value: str) -> int:
|
34
35
|
return int(str_value)
|
36
|
+
|
37
|
+
def get_default_str(self, shared_ctx: AnySharedContext) -> str:
|
38
|
+
default_value = get_int_attr(
|
39
|
+
shared_ctx, self._default_value, auto_render=self._auto_render
|
40
|
+
)
|
41
|
+
return f"{default_value}"
|
zrb/input/option_input.py
CHANGED
@@ -11,7 +11,7 @@ class OptionInput(BaseInput):
|
|
11
11
|
description: str | None = None,
|
12
12
|
prompt: str | None = None,
|
13
13
|
options: StrListAttr = [],
|
14
|
-
|
14
|
+
default: StrAttr = "",
|
15
15
|
auto_render: bool = True,
|
16
16
|
allow_empty: bool = False,
|
17
17
|
allow_positional_parsing: bool = True,
|
@@ -20,19 +20,19 @@ class OptionInput(BaseInput):
|
|
20
20
|
name=name,
|
21
21
|
description=description,
|
22
22
|
prompt=prompt,
|
23
|
-
|
23
|
+
default=default,
|
24
24
|
auto_render=auto_render,
|
25
25
|
allow_empty=allow_empty,
|
26
26
|
allow_positional_parsing=allow_positional_parsing,
|
27
27
|
)
|
28
28
|
self._options = options
|
29
29
|
|
30
|
-
def to_html(self,
|
30
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
31
31
|
name = self.name
|
32
32
|
description = self.description
|
33
|
-
default = self.get_default_str(
|
33
|
+
default = self.get_default_str(shared_ctx)
|
34
34
|
html = [f'<select name="{name}" placeholder="{description}">']
|
35
|
-
for value in get_str_list_attr(
|
35
|
+
for value in get_str_list_attr(shared_ctx, self._options, self._auto_render):
|
36
36
|
selected = "selected" if value == default else ""
|
37
37
|
html.append(f'<option value="{value}" {selected}>{value}</option>')
|
38
38
|
html.append("</select>")
|
zrb/input/password_input.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import getpass
|
2
|
-
from collections.abc import Callable
|
3
2
|
|
3
|
+
from zrb.attr.type import StrAttr
|
4
4
|
from zrb.context.any_shared_context import AnySharedContext
|
5
5
|
from zrb.input.base_input import BaseInput
|
6
6
|
|
@@ -11,7 +11,7 @@ class PasswordInput(BaseInput):
|
|
11
11
|
name: str,
|
12
12
|
description: str | None = None,
|
13
13
|
prompt: str | None = None,
|
14
|
-
|
14
|
+
default: StrAttr = "",
|
15
15
|
auto_render: bool = True,
|
16
16
|
allow_empty: bool = False,
|
17
17
|
allow_positional_parsing: bool = True,
|
@@ -20,17 +20,17 @@ class PasswordInput(BaseInput):
|
|
20
20
|
name=name,
|
21
21
|
description=description,
|
22
22
|
prompt=prompt,
|
23
|
-
|
23
|
+
default=default,
|
24
24
|
auto_render=auto_render,
|
25
25
|
allow_empty=allow_empty,
|
26
26
|
allow_positional_parsing=allow_positional_parsing,
|
27
27
|
)
|
28
28
|
self._is_secret = True
|
29
29
|
|
30
|
-
def to_html(self,
|
30
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
31
31
|
name = self.name
|
32
32
|
description = self.description
|
33
|
-
default = self.get_default_str(
|
33
|
+
default = self.get_default_str(shared_ctx)
|
34
34
|
return f'<input type="password" name="{name}" placeholder="{description}" value="{default}" />' # noqa
|
35
35
|
|
36
36
|
def _prompt_cli_str(self, shared_ctx: AnySharedContext) -> str:
|
zrb/input/text_input.py
CHANGED
@@ -15,7 +15,7 @@ class TextInput(BaseInput):
|
|
15
15
|
name: str,
|
16
16
|
description: str | None = None,
|
17
17
|
prompt: str | None = None,
|
18
|
-
|
18
|
+
default: str | Callable[[AnySharedContext], str] = "",
|
19
19
|
auto_render: bool = True,
|
20
20
|
allow_empty: bool = False,
|
21
21
|
allow_positional_parsing: bool = True,
|
@@ -28,7 +28,7 @@ class TextInput(BaseInput):
|
|
28
28
|
name=name,
|
29
29
|
description=description,
|
30
30
|
prompt=prompt,
|
31
|
-
|
31
|
+
default=default,
|
32
32
|
auto_render=auto_render,
|
33
33
|
allow_empty=allow_empty,
|
34
34
|
allow_positional_parsing=allow_positional_parsing,
|
@@ -56,10 +56,10 @@ class TextInput(BaseInput):
|
|
56
56
|
return " -->"
|
57
57
|
return ""
|
58
58
|
|
59
|
-
def to_html(self,
|
59
|
+
def to_html(self, shared_ctx: AnySharedContext) -> str:
|
60
60
|
name = self.name
|
61
61
|
description = self.description
|
62
|
-
default = self.get_default_str(
|
62
|
+
default = self.get_default_str(shared_ctx)
|
63
63
|
return "\n".join(
|
64
64
|
[
|
65
65
|
f'<textarea name="{name}" placeholder="{description}">',
|
@@ -4,10 +4,10 @@ zrb/attr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
zrb/attr/type.py,sha256=4TV5gPYMMrKh5V-yB6iRYKCbsXAH_AvGXMsjxKLHcUs,568
|
5
5
|
zrb/builtin/__init__.py,sha256=oXG4Zm_rIp3G81Y7hiSe38jeS2sGZAnADoP_yxxhYEc,1926
|
6
6
|
zrb/builtin/base64.py,sha256=1YnSwASp7OEAvQcsnHZGpJEvYoI1Z2zTIJ1bCDHfcPQ,921
|
7
|
-
zrb/builtin/git.py,sha256=
|
7
|
+
zrb/builtin/git.py,sha256=8_qVE_2lVQEVXQ9vhiw8Tn4Prj1VZB78ZjEJJS5Ab3M,5461
|
8
8
|
zrb/builtin/git_subtree.py,sha256=7BKwOkVTWDrR0DXXQ4iJyHqeR6sV5VYRt8y_rEB0EHg,3505
|
9
9
|
zrb/builtin/group.py,sha256=-phJfVpTX3_gUwS1u8-RbZUHe-X41kxDBSmrVh4rq8E,1682
|
10
|
-
zrb/builtin/llm/llm_chat.py,sha256=
|
10
|
+
zrb/builtin/llm/llm_chat.py,sha256=UVhfJR0APXRC3tEv5i5vYbEANWqi04QD_WsAiARJ7j4,4494
|
11
11
|
zrb/builtin/llm/previous-session.js,sha256=xMKZvJoAbrwiyHS0OoPrWuaKxWYLoyR5sguePIoCjTY,816
|
12
12
|
zrb/builtin/llm/tool/api.py,sha256=yQ3XV8O7Fx7hHssLSOcmiHDnevPhz9ktWi44HK7zTls,801
|
13
13
|
zrb/builtin/llm/tool/cli.py,sha256=to_IjkfrMGs6eLfG0cpVN9oyADWYsJQCtyluUhUdBww,253
|
@@ -15,7 +15,7 @@ zrb/builtin/llm/tool/rag.py,sha256=PawaLZL-ThctxtBtsQuP3XsgTxQKyCGFqrudCANPJKk,5
|
|
15
15
|
zrb/builtin/llm/tool/web.py,sha256=N2HYuXbKPUpjVAq_UnQMbUrTIE8u0Ut3TeQadZ7_NJc,2217
|
16
16
|
zrb/builtin/md5.py,sha256=0pNlrfZA0wlZlHvFHLgyqN0JZJWGKQIF5oXxO44_OJk,949
|
17
17
|
zrb/builtin/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
|
-
zrb/builtin/project/add/fastapp/fastapp_input.py,sha256=
|
18
|
+
zrb/builtin/project/add/fastapp/fastapp_input.py,sha256=MKlWR_LxWhM_DcULCtLfL_IjTxpDnDBkn9KIqNmajFs,310
|
19
19
|
zrb/builtin/project/add/fastapp/fastapp_task.py,sha256=mUMZjC413DhZSKqA6donPTxVbd_DnDFqSV_ZTqQnSHs,2697
|
20
20
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.coveragerc,sha256=MsTf0Vlt_pxV-j4mNh-TxSo7sTI_GaVS_oM4tksIykE,181
|
21
21
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.flake8,sha256=fgvHmuskgYiCvHZHaFtiyOWW0zasVrs0P-sFHOq3W5U,56
|
@@ -43,7 +43,7 @@ zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/templat
|
|
43
43
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/navigation_config_file.py,sha256=8dYj8GyvhTIr0lny_3aZec2BTHMBFTVRGLLH4OoWvCo,186
|
44
44
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/format_task.py,sha256=8YykCthDgjXT8MFvTrPSWYUXsfhafmoSMG9LH2ZiaD0,431
|
45
45
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/group.py,sha256=S0sKnnABSGy3YzaExH40xJjm4UsEX6AyDE1u94ewk6A,648
|
46
|
-
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py,sha256=
|
46
|
+
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py,sha256=_LagLs2R9Eao4xJ1d2i_Yj1ELu7uZGNJnK90ruvY0O8,1511
|
47
47
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_task.py,sha256=_1sJd91bViSfEbpxNgqeCE7gBHP7yH9i7uJbPu9OvtY,4058
|
48
48
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py,sha256=NtQX3F9vVGJAPkzt6VffXGru8ULh4gYWeDxNk1Qepek,8293
|
49
49
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/gateway/subroute/my_module.py,sha256=_5EgmEeATL5ZSX5MSJixkDgRQKGNTPG6watEuzv3eQI,418
|
@@ -181,18 +181,18 @@ zrb/builtin/project/add/fastapp/fastapp_util.py,sha256=UVzKfljUDLvlassnKy8pKH4hB
|
|
181
181
|
zrb/builtin/project/create/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
182
182
|
zrb/builtin/project/create/project-template/README.md,sha256=BHeWF_txdTDzKewWdWfGhO3YOTiW8E3YwTMnd0T1LVA,39
|
183
183
|
zrb/builtin/project/create/project-template/zrb_init.py,sha256=kY0x5MrkIVl3l1GtN2ROrYGNpsfN2dgRT84LCcSrGUs,44
|
184
|
-
zrb/builtin/project/create/project_task.py,sha256=
|
184
|
+
zrb/builtin/project/create/project_task.py,sha256=az-yd2FRDmGZ_7qxslmW11ryTeI3yttRmXtlFnZhF00,1132
|
185
185
|
zrb/builtin/python.py,sha256=e-yyVWovwlxCBLyXGsd9Ek3IAL_X-Q_hpNNOPoRjOgk,349
|
186
|
-
zrb/builtin/random.py,sha256=
|
186
|
+
zrb/builtin/random.py,sha256=p9kCvosSiSJyuGQrlrXuIQT8TRDGxXhfiUbsm3GFPd0,1793
|
187
187
|
zrb/builtin/setup/asdf/asdf.py,sha256=n_dWoyYa7vZ9tBCy8hgxmSWZ-XHltC1R70mIVZQhnXY,2419
|
188
188
|
zrb/builtin/setup/asdf/asdf_helper.py,sha256=6jARtyIAE1H82HKVQ84D25RrMAsAip_gD28X9ZlaTCk,1205
|
189
|
-
zrb/builtin/setup/common_input.py,sha256=
|
189
|
+
zrb/builtin/setup/common_input.py,sha256=zIVVsZsNlSoV2Fw8kyt7g5B8XAU8cWBsT865NPoddwo,848
|
190
190
|
zrb/builtin/setup/latex/ubuntu.py,sha256=er9wJAT4CpmghIaiIPFb3FvgqAn1aqU5UgX7GHL3FjA,577
|
191
|
-
zrb/builtin/setup/tmux/tmux.py,sha256=
|
191
|
+
zrb/builtin/setup/tmux/tmux.py,sha256=YaiZKQODsBDip2ya5pA02c2-lfLDU8VKGbeHwFWI43s,1403
|
192
192
|
zrb/builtin/setup/tmux/tmux_config.sh,sha256=wQCb4Q-mNkxIPOcvpN84X9RUWkGY16u3Vd-pOhVidgg,416
|
193
193
|
zrb/builtin/setup/tmux/tmux_helper.py,sha256=M03l0wfL25TzGGp6lnVfX40ayT_x7N2lz-nz2chO7PU,396
|
194
194
|
zrb/builtin/setup/ubuntu.py,sha256=oOSN7Eq7arEpY2i0vWHPR2owio6dqqOvceteYrgmbYw,1019
|
195
|
-
zrb/builtin/setup/zsh/zsh.py,sha256=
|
195
|
+
zrb/builtin/setup/zsh/zsh.py,sha256=b9_UDSJpOT246RiL5BNr6N1jqNHzoUQircZ_u6dkU5g,1820
|
196
196
|
zrb/builtin/setup/zsh/zsh_config.sh,sha256=SRkcXvVT3tdfS1UDT0-dSj2PKXPLohhyakY6tUEQPjc,4764
|
197
197
|
zrb/builtin/setup/zsh/zsh_helper.py,sha256=1zF1FH0oEPVAVhMA20tsdk1H0RPMCkLusYX8twsTbGI,393
|
198
198
|
zrb/builtin/shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -200,7 +200,7 @@ zrb/builtin/shell/autocomplete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
200
200
|
zrb/builtin/shell/autocomplete/bash.py,sha256=-7YDVV7txgJH9mAYSYN0jmvUEeDIzWFvVNY-cY0myF8,1181
|
201
201
|
zrb/builtin/shell/autocomplete/subcmd.py,sha256=WZI6cGWJcn80zSyxOHG7sCMO3Ucix3mZf4xm_xyB_Y0,606
|
202
202
|
zrb/builtin/shell/autocomplete/zsh.py,sha256=9hlq0Wt3fhRz326mAQTypEd4_4lZdrbBx_3A-Ti3mvw,1022
|
203
|
-
zrb/builtin/todo.py,sha256=
|
203
|
+
zrb/builtin/todo.py,sha256=zlMJhnlnhKhJ2v9arrakEfbqVrMsAPW3vMwiBKEeoZk,10824
|
204
204
|
zrb/callback/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
205
205
|
zrb/callback/any_callback.py,sha256=Yhdv5UWHAZSVzj5K2JdxcVQx8x8VX8aZJEivj3NTfZc,247
|
206
206
|
zrb/callback/callback.py,sha256=hKefB_Jd1XGjPSLQdMKDsGLHPzEGO2dqrIArLl_EmD0,848
|
@@ -228,14 +228,14 @@ zrb/group/any_group.py,sha256=1rNcsi5eu_86JAx_6Jy46SK4BTeppcb89MORynJd-4o,1115
|
|
228
228
|
zrb/group/group.py,sha256=JFmWVEQ9PVy2WCf5pUG74iwL2xcGxXaAjT-NArAeloM,1861
|
229
229
|
zrb/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
230
230
|
zrb/input/any_input.py,sha256=tvls3uJBVPLW5Oawxof9qWCX-lH1h_RErxjYNu1bwtY,899
|
231
|
-
zrb/input/base_input.py,sha256=
|
232
|
-
zrb/input/bool_input.py,sha256=
|
233
|
-
zrb/input/float_input.py,sha256=
|
234
|
-
zrb/input/int_input.py,sha256=
|
235
|
-
zrb/input/option_input.py,sha256=
|
236
|
-
zrb/input/password_input.py,sha256=
|
231
|
+
zrb/input/base_input.py,sha256=J1lvo96YieaceFeReNoon2N4bOgRK7lBrDfRoINLu9g,3599
|
232
|
+
zrb/input/bool_input.py,sha256=bxX2-T8XTlz5zq4gkk3LMHX8S93gdvTUsZ0I6DH56VU,1762
|
233
|
+
zrb/input/float_input.py,sha256=Mfl8CygKMkRFv1l6jM28FqQ6SIIB2ZpbaYoM-JMNyXU,1398
|
234
|
+
zrb/input/int_input.py,sha256=w5ewSxstUYv5LBAzvX_E0jIueXXdmnY2ehoQMTtg-EA,1380
|
235
|
+
zrb/input/option_input.py,sha256=IrpF0XvFbH5G-IEAnoQ4QOvq7gn2wyT4jKwAdMKwV0s,2058
|
236
|
+
zrb/input/password_input.py,sha256=Tu8TZx95717YsHICZ0zBzTUPKPf-K9vGlvRyaOTrFEM,1388
|
237
237
|
zrb/input/str_input.py,sha256=NevZHX9rf1g8eMatPyy-kUX3DglrVAQpzvVpKAzf7bA,81
|
238
|
-
zrb/input/text_input.py,sha256=
|
238
|
+
zrb/input/text_input.py,sha256=wSNiYAx2xYPtl09Dfh_uHws9WG2dRqkS0Jnlm9HvD3s,3145
|
239
239
|
zrb/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
240
240
|
zrb/runner/cli.py,sha256=G_ILZCFzpV-kRE3dm1kq6BorB51TLJ34Qmhgy5SIMlU,6734
|
241
241
|
zrb/runner/common_util.py,sha256=mjEBSmfdY2Sun2U5-8y8gGwF82OiRM8sgiYDOdW9NA4,1338
|
@@ -330,7 +330,6 @@ zrb/util/file.py,sha256=mgNobIKCr0eIQUlg6W2Yg1fvg943VyuOUF8WMFpJA5A,859
|
|
330
330
|
zrb/util/git.py,sha256=TShnMxPAk20Tglp25d_XPVZX-q0mvKeqdprVMeXQ5f0,4787
|
331
331
|
zrb/util/git_subtree.py,sha256=zyWl0aUEZJyUJKjfw1uglozB4R1kF9pWtfKjhu8DN44,2658
|
332
332
|
zrb/util/group.py,sha256=Bg7HrSycoK110U5s_Tca6-uUQuZ5CMgb8wxZSrvDQ98,2790
|
333
|
-
zrb/util/llm/tool.py,sha256=NkENrUlGxcqqU7jzHAH7DBXNcm_ndEo2dFnJ5nhvWmk,2991
|
334
333
|
zrb/util/load.py,sha256=m0e5DVLV7_RON6AZdjkquPym6BBrvYBbDMrllV44Y_k,1993
|
335
334
|
zrb/util/run.py,sha256=DGHUP9x1Q8V8UF3FbpmjLGuhVVCCLfjTH2teT8qXlNI,207
|
336
335
|
zrb/util/string/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -340,7 +339,7 @@ zrb/util/string/name.py,sha256=8picJfUBXNpdh64GNaHv3om23QHhUZux7DguFLrXHp8,1163
|
|
340
339
|
zrb/util/todo.py,sha256=1nDdwPc22oFoK_1ZTXyf3638Bg6sqE2yp_U4_-frHoc,16015
|
341
340
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
342
341
|
zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
|
343
|
-
zrb-1.
|
344
|
-
zrb-1.
|
345
|
-
zrb-1.
|
346
|
-
zrb-1.
|
342
|
+
zrb-1.2.0.dist-info/METADATA,sha256=DlgVxKkUzjjMmqfdqv1h2jqlZGprsQGYraHstWCkEU4,4307
|
343
|
+
zrb-1.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
344
|
+
zrb-1.2.0.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
345
|
+
zrb-1.2.0.dist-info/RECORD,,
|
zrb/util/llm/tool.py
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
import inspect
|
2
|
-
from collections.abc import Callable
|
3
|
-
from typing import Annotated, Any, Literal, get_type_hints
|
4
|
-
|
5
|
-
|
6
|
-
def callable_to_tool_schema(callable_obj: Callable) -> dict[str, Any]:
|
7
|
-
"""
|
8
|
-
Convert a callable into a tool schema dictionary by deriving the parameter schema.
|
9
|
-
|
10
|
-
:param callable_obj: The callable object (e.g., a function).
|
11
|
-
:return: A dictionary representing the tool schema.
|
12
|
-
"""
|
13
|
-
if not callable(callable_obj):
|
14
|
-
raise ValueError("Provided object is not callable")
|
15
|
-
# Derive name and description
|
16
|
-
name = callable_obj.__name__
|
17
|
-
description = (callable_obj.__doc__ or "").strip()
|
18
|
-
# Get function signature
|
19
|
-
sig = inspect.signature(callable_obj)
|
20
|
-
hints = get_type_hints(callable_obj)
|
21
|
-
# Build parameter schema
|
22
|
-
param_schema = {"type": "object", "properties": {}, "required": []}
|
23
|
-
for param_name, param in sig.parameters.items():
|
24
|
-
# Get the type hint or default to str
|
25
|
-
param_type = hints.get(param_name, str)
|
26
|
-
|
27
|
-
# Handle annotated types (e.g., Annotated[str, "description"])
|
28
|
-
json_type, param_metadata = _process_type_annotation(param_type)
|
29
|
-
param_schema["properties"][param_name] = param_metadata
|
30
|
-
|
31
|
-
# Mark required parameters
|
32
|
-
if param.default is inspect.Parameter.empty:
|
33
|
-
param_schema["required"].append(param_name)
|
34
|
-
return {
|
35
|
-
"type": "function",
|
36
|
-
"function": {
|
37
|
-
"name": name,
|
38
|
-
"description": description,
|
39
|
-
"parameters": param_schema,
|
40
|
-
},
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
def _process_type_annotation(py_type: Any) -> tuple[str, dict]:
|
45
|
-
"""
|
46
|
-
Process type annotations and return the JSON Schema type and metadata.
|
47
|
-
|
48
|
-
:param py_type: The type annotation.
|
49
|
-
:return: A tuple of (JSON type, parameter metadata).
|
50
|
-
"""
|
51
|
-
if hasattr(py_type, "__origin__") and py_type.__origin__ is Literal:
|
52
|
-
# Handle Literal (enum)
|
53
|
-
enum_values = list(py_type.__args__)
|
54
|
-
return "string", {"type": "string", "enum": enum_values}
|
55
|
-
|
56
|
-
if hasattr(py_type, "__origin__") and py_type.__origin__ is Annotated:
|
57
|
-
# Handle Annotated types
|
58
|
-
base_type = py_type.__args__[0]
|
59
|
-
description = py_type.__args__[1]
|
60
|
-
json_type = _python_type_to_json_type(base_type)
|
61
|
-
return json_type, {"type": json_type, "description": description}
|
62
|
-
|
63
|
-
# Fallback to basic type conversion
|
64
|
-
json_type = _python_type_to_json_type(py_type)
|
65
|
-
return json_type, {"type": json_type}
|
66
|
-
|
67
|
-
|
68
|
-
def _python_type_to_json_type(py_type):
|
69
|
-
"""
|
70
|
-
Map Python types to JSON Schema types.
|
71
|
-
"""
|
72
|
-
if py_type is str:
|
73
|
-
return "string"
|
74
|
-
elif py_type is int:
|
75
|
-
return "integer"
|
76
|
-
elif py_type is float:
|
77
|
-
return "number"
|
78
|
-
elif py_type is bool:
|
79
|
-
return "boolean"
|
80
|
-
elif py_type is list:
|
81
|
-
return "array"
|
82
|
-
elif py_type is dict:
|
83
|
-
return "object"
|
84
|
-
elif py_type in {None, type(None)}:
|
85
|
-
return "null"
|
86
|
-
else:
|
87
|
-
return "string" # Default to string for unsupported types
|
File without changes
|
File without changes
|