zrb 1.15.17__py3-none-any.whl → 1.15.19__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/chat_session.py +3 -3
- zrb/builtin/llm/llm_ask.py +17 -2
- zrb/builtin/llm/tool/sub_agent.py +2 -2
- zrb/config/config.py +6 -2
- zrb/config/llm_config.py +5 -5
- zrb/task/any_task.py +6 -1
- zrb/task/base/context.py +2 -2
- zrb/task/base_task.py +37 -23
- zrb/task/llm/agent.py +7 -7
- zrb/task/llm/config.py +19 -10
- zrb/task/llm/tool_wrapper.py +16 -9
- zrb/task/llm_task.py +17 -6
- zrb/util/attr.py +9 -9
- zrb/util/string/conversion.py +1 -1
- {zrb-1.15.17.dist-info → zrb-1.15.19.dist-info}/METADATA +1 -1
- {zrb-1.15.17.dist-info → zrb-1.15.19.dist-info}/RECORD +18 -18
- {zrb-1.15.17.dist-info → zrb-1.15.19.dist-info}/WHEEL +0 -0
- {zrb-1.15.17.dist-info → zrb-1.15.19.dist-info}/entry_points.txt +0 -0
zrb/builtin/llm/chat_session.py
CHANGED
@@ -106,7 +106,7 @@ def _show_info(ctx: AnyContext):
|
|
106
106
|
_show_command("/modes", "Show current modes"),
|
107
107
|
_show_subcommand("<mode1,mode2,..>", "Set current modes"),
|
108
108
|
_show_command("/yolo", "Get current YOLO mode"),
|
109
|
-
_show_subcommand("<true|false>", "Set YOLO mode
|
109
|
+
_show_subcommand("<true|false|list-of-tools>", "Set YOLO mode"),
|
110
110
|
_show_command("/help", "Show this message"),
|
111
111
|
]
|
112
112
|
),
|
@@ -179,7 +179,7 @@ async def _trigger_ask_and_wait_for_result(
|
|
179
179
|
ctx: AnyContext,
|
180
180
|
user_prompt: str,
|
181
181
|
modes: str,
|
182
|
-
yolo_mode: bool,
|
182
|
+
yolo_mode: bool | str,
|
183
183
|
previous_session_name: str | None = None,
|
184
184
|
start_new: bool = False,
|
185
185
|
) -> str | None:
|
@@ -239,7 +239,7 @@ async def _trigger_ask(
|
|
239
239
|
ctx: AnyContext,
|
240
240
|
user_prompt: str,
|
241
241
|
modes: str,
|
242
|
-
yolo_mode: bool,
|
242
|
+
yolo_mode: bool | str,
|
243
243
|
previous_session_name: str | None = None,
|
244
244
|
start_new: bool = False,
|
245
245
|
):
|
zrb/builtin/llm/llm_ask.py
CHANGED
@@ -24,11 +24,13 @@ from zrb.builtin.llm.tool.web import (
|
|
24
24
|
from zrb.callback.callback import Callback
|
25
25
|
from zrb.config.config import CFG
|
26
26
|
from zrb.config.llm_config import llm_config
|
27
|
+
from zrb.context.any_context import AnyContext
|
27
28
|
from zrb.input.bool_input import BoolInput
|
28
29
|
from zrb.input.str_input import StrInput
|
29
30
|
from zrb.input.text_input import TextInput
|
30
31
|
from zrb.task.base_trigger import BaseTrigger
|
31
32
|
from zrb.task.llm_task import LLMTask
|
33
|
+
from zrb.util.string.conversion import to_boolean
|
32
34
|
|
33
35
|
_llm_ask_inputs = [
|
34
36
|
StrInput(
|
@@ -82,7 +84,7 @@ _llm_ask_inputs = [
|
|
82
84
|
allow_positional_parsing=False,
|
83
85
|
always_prompt=False,
|
84
86
|
),
|
85
|
-
|
87
|
+
StrInput(
|
86
88
|
"yolo",
|
87
89
|
description="YOLO mode (LLM Agent will start in YOLO Mode)",
|
88
90
|
prompt="YOLO mode (LLM Agent will start in YOLO Mode)",
|
@@ -101,6 +103,19 @@ _llm_ask_inputs = [
|
|
101
103
|
),
|
102
104
|
]
|
103
105
|
|
106
|
+
|
107
|
+
def _render_yolo_mode_input(ctx: AnyContext) -> list[str] | bool | None:
|
108
|
+
if ctx.input.yolo.strip() == "":
|
109
|
+
return None
|
110
|
+
elements = ctx.input.yolo.split(",")
|
111
|
+
if len(elements) == 0:
|
112
|
+
try:
|
113
|
+
return to_boolean(elements[0])
|
114
|
+
except Exception:
|
115
|
+
pass
|
116
|
+
return elements
|
117
|
+
|
118
|
+
|
104
119
|
llm_ask: LLMTask = llm_group.add_task(
|
105
120
|
LLMTask(
|
106
121
|
name="llm-ask",
|
@@ -122,7 +137,7 @@ llm_ask: LLMTask = llm_group.add_task(
|
|
122
137
|
None if ctx.input.modes.strip() == "" else ctx.input.modes.split(",")
|
123
138
|
),
|
124
139
|
message="{ctx.input.message}",
|
125
|
-
|
140
|
+
yolo_mode=_render_yolo_mode_input,
|
126
141
|
retries=0,
|
127
142
|
),
|
128
143
|
alias="ask",
|
@@ -25,7 +25,7 @@ def create_sub_agent_tool(
|
|
25
25
|
model_settings: "ModelSettings | None" = None,
|
26
26
|
tools: "list[ToolOrCallable]" = [],
|
27
27
|
toolsets: list["AbstractToolset[Agent]"] = [],
|
28
|
-
|
28
|
+
yolo_mode: bool | list[str] | None = None,
|
29
29
|
log_indent_level: int = 2,
|
30
30
|
) -> Callable[[AnyContext, str], Coroutine[Any, Any, str]]:
|
31
31
|
"""
|
@@ -99,7 +99,7 @@ def create_sub_agent_tool(
|
|
99
99
|
model_settings=resolved_model_settings,
|
100
100
|
tools=tools,
|
101
101
|
toolsets=toolsets,
|
102
|
-
|
102
|
+
yolo_mode=yolo_mode,
|
103
103
|
)
|
104
104
|
|
105
105
|
sub_agent_run = None
|
zrb/config/config.py
CHANGED
@@ -304,8 +304,12 @@ class Config:
|
|
304
304
|
return float(self._getenv("LLM_THROTTLE_SLEEP", "1.0"))
|
305
305
|
|
306
306
|
@property
|
307
|
-
def LLM_YOLO_MODE(self) -> bool:
|
308
|
-
|
307
|
+
def LLM_YOLO_MODE(self) -> bool | list[str]:
|
308
|
+
str_val = self._getenv("LLM_YOLO_MODE", "false")
|
309
|
+
try:
|
310
|
+
return to_boolean(str_val)
|
311
|
+
except Exception:
|
312
|
+
return [val.strip() for val in str_val.split(",") if val.strip() != ""]
|
309
313
|
|
310
314
|
@property
|
311
315
|
def LLM_SUMMARIZE_HISTORY(self) -> bool:
|
zrb/config/llm_config.py
CHANGED
@@ -26,7 +26,7 @@ class LLMConfig:
|
|
26
26
|
default_model: "Model | None" = None,
|
27
27
|
default_model_settings: "ModelSettings | None" = None,
|
28
28
|
default_model_provider: "Provider | None" = None,
|
29
|
-
default_yolo_mode: bool | None = None,
|
29
|
+
default_yolo_mode: bool | list[str] | None = None,
|
30
30
|
):
|
31
31
|
self.__internal_default_prompt: dict[str, str] = {}
|
32
32
|
self._default_model_name = default_model_name
|
@@ -153,9 +153,9 @@ class LLMConfig:
|
|
153
153
|
model_name = self.default_model_name
|
154
154
|
if model_name is None:
|
155
155
|
return "openai:gpt-4o"
|
156
|
-
from pydantic_ai.models.openai import
|
156
|
+
from pydantic_ai.models.openai import OpenAIChatModel
|
157
157
|
|
158
|
-
return
|
158
|
+
return OpenAIChatModel(
|
159
159
|
model_name=model_name,
|
160
160
|
provider=self.default_model_provider,
|
161
161
|
)
|
@@ -175,7 +175,7 @@ class LLMConfig:
|
|
175
175
|
)
|
176
176
|
|
177
177
|
@property
|
178
|
-
def default_yolo_mode(self) -> bool:
|
178
|
+
def default_yolo_mode(self) -> bool | list[str]:
|
179
179
|
return self._get_property(
|
180
180
|
self._default_yolo_mode, CFG.LLM_YOLO_MODE, lambda: False
|
181
181
|
)
|
@@ -236,7 +236,7 @@ class LLMConfig:
|
|
236
236
|
def set_default_model_settings(self, model_settings: "ModelSettings"):
|
237
237
|
self._default_model_settings = model_settings
|
238
238
|
|
239
|
-
def set_default_yolo_mode(self, yolo_mode: bool):
|
239
|
+
def set_default_yolo_mode(self, yolo_mode: bool | list[str]):
|
240
240
|
self._default_yolo_mode = yolo_mode
|
241
241
|
|
242
242
|
|
zrb/task/any_task.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from __future__ import annotations # Enables forward references
|
2
2
|
|
3
3
|
from abc import ABC, abstractmethod
|
4
|
-
from typing import TYPE_CHECKING, Any
|
4
|
+
from typing import TYPE_CHECKING, Any, Callable
|
5
5
|
|
6
6
|
from zrb.env.any_env import AnyEnv
|
7
7
|
from zrb.input.any_input import AnyInput
|
@@ -211,3 +211,8 @@ class AnyTask(ABC):
|
|
211
211
|
session (AnySession): The shared session.
|
212
212
|
"""
|
213
213
|
pass
|
214
|
+
|
215
|
+
@abstractmethod
|
216
|
+
def to_function(self) -> Callable[..., Any]:
|
217
|
+
"""Turn a task into a function"""
|
218
|
+
pass
|
zrb/task/base/context.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import os
|
2
|
-
from typing import TYPE_CHECKING
|
2
|
+
from typing import TYPE_CHECKING, Any
|
3
3
|
|
4
4
|
from zrb.context.any_context import AnyContext
|
5
5
|
from zrb.context.any_shared_context import AnySharedContext
|
@@ -29,7 +29,7 @@ def fill_shared_context_inputs(
|
|
29
29
|
shared_ctx: AnySharedContext,
|
30
30
|
task: AnyTask,
|
31
31
|
str_kwargs: dict[str, str] | None = None,
|
32
|
-
kwargs: dict[str,
|
32
|
+
kwargs: dict[str, Any] | None = None,
|
33
33
|
):
|
34
34
|
"""
|
35
35
|
Populates the shared context with input values provided via str_kwargs.
|
zrb/task/base_task.py
CHANGED
@@ -21,6 +21,7 @@ from zrb.task.base.execution import (
|
|
21
21
|
)
|
22
22
|
from zrb.task.base.lifecycle import execute_root_tasks, run_and_cleanup, run_task_async
|
23
23
|
from zrb.task.base.operators import handle_lshift, handle_rshift
|
24
|
+
from zrb.util.string.conversion import to_snake_case
|
24
25
|
|
25
26
|
|
26
27
|
class BaseTask(AnyTask):
|
@@ -219,7 +220,7 @@ class BaseTask(AnyTask):
|
|
219
220
|
self,
|
220
221
|
session: AnySession | None = None,
|
221
222
|
str_kwargs: dict[str, str] | None = None,
|
222
|
-
kwargs: dict[str,
|
223
|
+
kwargs: dict[str, Any] | None = None,
|
223
224
|
) -> Any:
|
224
225
|
"""
|
225
226
|
Synchronously runs the task and its dependencies, handling async setup and cleanup.
|
@@ -286,47 +287,60 @@ class BaseTask(AnyTask):
|
|
286
287
|
# Add definition location to the error
|
287
288
|
if hasattr(e, "add_note"):
|
288
289
|
e.add_note(additional_error_note)
|
289
|
-
|
290
|
+
elif hasattr(e, "__notes__"):
|
290
291
|
# fallback: use the __notes__ attribute directly
|
291
292
|
e.__notes__ = getattr(e, "__notes__", []) + [additional_error_note]
|
292
293
|
raise e
|
293
294
|
|
294
|
-
def
|
295
|
-
# NOTE: Non documented feature, untested
|
296
|
-
from inspect import Parameter, Signature
|
297
|
-
|
295
|
+
def to_function(self) -> Callable[..., Any]:
|
298
296
|
from zrb.context.shared_context import SharedContext
|
299
297
|
from zrb.session.session import Session
|
300
298
|
|
301
|
-
def task_runner_fn(**kwargs):
|
302
|
-
|
299
|
+
def task_runner_fn(**kwargs) -> Any:
|
300
|
+
task_kwargs = self._get_func_kwargs(kwargs)
|
303
301
|
shared_ctx = SharedContext()
|
304
302
|
session = Session(shared_ctx=shared_ctx)
|
305
|
-
return self.run(session=session,
|
303
|
+
return self.run(session=session, kwargs=task_kwargs)
|
304
|
+
|
305
|
+
task_runner_fn.__doc__ = self._create_fn_docstring()
|
306
|
+
task_runner_fn.__signature__ = self._create_fn_signature()
|
307
|
+
task_runner_fn.__name__ = self.name
|
308
|
+
return task_runner_fn
|
309
|
+
|
310
|
+
def _get_func_kwargs(self, kwargs: dict[str, Any]) -> dict[str, Any]:
|
311
|
+
fn_kwargs = {}
|
312
|
+
for inp in self.inputs:
|
313
|
+
snake_input_name = to_snake_case(inp.name)
|
314
|
+
if snake_input_name in kwargs:
|
315
|
+
fn_kwargs[inp.name] = kwargs[snake_input_name]
|
316
|
+
return fn_kwargs
|
306
317
|
|
318
|
+
def _create_fn_docstring(self) -> str:
|
319
|
+
from zrb.context.shared_context import SharedContext
|
320
|
+
|
321
|
+
stub_shared_ctx = SharedContext()
|
322
|
+
str_input_default_values = {}
|
323
|
+
for inp in self.inputs:
|
324
|
+
str_input_default_values[inp.name] = inp.get_default_str(stub_shared_ctx)
|
307
325
|
# Create docstring
|
308
326
|
doc = f"{self.description}\n\n"
|
309
327
|
if len(self.inputs) > 0:
|
310
328
|
doc += "Args:\n"
|
311
329
|
for inp in self.inputs:
|
312
|
-
|
313
|
-
|
314
|
-
|
330
|
+
str_input_default = str_input_default_values.get(inp.name, "")
|
331
|
+
doc += (
|
332
|
+
f" {inp.name}: {inp.description} (default: {str_input_default})"
|
333
|
+
)
|
315
334
|
doc += "\n"
|
316
|
-
|
335
|
+
return doc
|
317
336
|
|
318
|
-
|
337
|
+
def _create_fn_signature(self) -> inspect.Signature:
|
319
338
|
params = []
|
320
339
|
for inp in self.inputs:
|
321
340
|
params.append(
|
322
|
-
Parameter(
|
323
|
-
name=inp.name,
|
324
|
-
kind=Parameter.POSITIONAL_OR_KEYWORD,
|
325
|
-
default=inp.default if inp.default is not None else Parameter.empty,
|
341
|
+
inspect.Parameter(
|
342
|
+
name=to_snake_case(inp.name),
|
343
|
+
kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
326
344
|
)
|
327
345
|
)
|
328
|
-
|
329
|
-
task_runner_fn.__signature__ = sig
|
330
|
-
task_runner_fn.__name__ = self.name
|
331
|
-
|
332
|
-
return task_runner_fn
|
346
|
+
return inspect.Signature(params)
|
zrb/task/llm/agent.py
CHANGED
@@ -30,14 +30,14 @@ def create_agent_instance(
|
|
30
30
|
tools: "list[ToolOrCallable]" = [],
|
31
31
|
toolsets: list["AbstractToolset[Agent]"] = [],
|
32
32
|
retries: int = 3,
|
33
|
-
|
33
|
+
yolo_mode: bool | list[str] | None = None,
|
34
34
|
) -> "Agent":
|
35
35
|
"""Creates a new Agent instance with configured tools and servers."""
|
36
36
|
from pydantic_ai import Agent, Tool
|
37
37
|
from pydantic_ai.tools import GenerateToolJsonSchema
|
38
38
|
|
39
|
-
if
|
40
|
-
|
39
|
+
if yolo_mode is None:
|
40
|
+
yolo_mode = False
|
41
41
|
# Normalize tools
|
42
42
|
tool_list = []
|
43
43
|
for tool_or_callable in tools:
|
@@ -47,7 +47,7 @@ def create_agent_instance(
|
|
47
47
|
tool = tool_or_callable
|
48
48
|
tool_list.append(
|
49
49
|
Tool(
|
50
|
-
function=wrap_func(tool.function, ctx,
|
50
|
+
function=wrap_func(tool.function, ctx, yolo_mode),
|
51
51
|
takes_ctx=tool.takes_ctx,
|
52
52
|
max_retries=tool.max_retries,
|
53
53
|
name=tool.name,
|
@@ -61,7 +61,7 @@ def create_agent_instance(
|
|
61
61
|
)
|
62
62
|
else:
|
63
63
|
# Turn function into tool
|
64
|
-
tool_list.append(wrap_tool(tool_or_callable, ctx,
|
64
|
+
tool_list.append(wrap_tool(tool_or_callable, ctx, yolo_mode))
|
65
65
|
# Return Agent
|
66
66
|
return Agent(
|
67
67
|
model=model,
|
@@ -86,7 +86,7 @@ def get_agent(
|
|
86
86
|
toolsets_attr: "list[AbstractToolset[Agent]] | Callable[[AnySharedContext], list[AbstractToolset[Agent]]]", # noqa
|
87
87
|
additional_toolsets: "list[AbstractToolset[Agent]]",
|
88
88
|
retries: int = 3,
|
89
|
-
|
89
|
+
yolo_mode: bool | list[str] | None = None,
|
90
90
|
) -> "Agent":
|
91
91
|
"""Retrieves the configured Agent instance or creates one if necessary."""
|
92
92
|
from pydantic_ai import Agent
|
@@ -118,7 +118,7 @@ def get_agent(
|
|
118
118
|
toolsets=tool_sets,
|
119
119
|
model_settings=model_settings,
|
120
120
|
retries=retries,
|
121
|
-
|
121
|
+
yolo_mode=yolo_mode,
|
122
122
|
)
|
123
123
|
|
124
124
|
|
zrb/task/llm/config.py
CHANGED
@@ -8,20 +8,29 @@ from zrb.attr.type import BoolAttr, StrAttr, fstring
|
|
8
8
|
from zrb.config.llm_config import LLMConfig, llm_config
|
9
9
|
from zrb.context.any_context import AnyContext
|
10
10
|
from zrb.context.any_shared_context import AnySharedContext
|
11
|
-
from zrb.util.attr import get_attr, get_bool_attr
|
11
|
+
from zrb.util.attr import get_attr, get_bool_attr, get_str_list_attr
|
12
12
|
|
13
13
|
|
14
|
-
def
|
14
|
+
def get_yolo_mode(
|
15
15
|
ctx: AnyContext,
|
16
|
-
|
16
|
+
yolo_mode_attr: BoolAttr | StrAttr | None = None,
|
17
17
|
render_yolo_mode: bool = True,
|
18
|
-
):
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
) -> bool | list[str]:
|
19
|
+
if yolo_mode_attr is None:
|
20
|
+
return llm_config.default_yolo_mode
|
21
|
+
try:
|
22
|
+
return get_bool_attr(
|
23
|
+
ctx,
|
24
|
+
yolo_mode_attr,
|
25
|
+
False,
|
26
|
+
auto_render=render_yolo_mode,
|
27
|
+
)
|
28
|
+
except Exception:
|
29
|
+
return get_str_list_attr(
|
30
|
+
ctx,
|
31
|
+
yolo_mode_attr,
|
32
|
+
auto_render=render_yolo_mode,
|
33
|
+
)
|
25
34
|
|
26
35
|
|
27
36
|
def get_model_settings(
|
zrb/task/llm/tool_wrapper.py
CHANGED
@@ -26,23 +26,27 @@ class ToolExecutionCancelled(ValueError):
|
|
26
26
|
pass
|
27
27
|
|
28
28
|
|
29
|
-
def wrap_tool(func: Callable, ctx: AnyContext,
|
29
|
+
def wrap_tool(func: Callable, ctx: AnyContext, yolo_mode: bool | list[str]) -> "Tool":
|
30
30
|
"""Wraps a tool function to handle exceptions and context propagation."""
|
31
31
|
from pydantic_ai import RunContext, Tool
|
32
32
|
|
33
33
|
original_sig = inspect.signature(func)
|
34
34
|
needs_run_context_for_pydantic = _has_context_parameter(original_sig, RunContext)
|
35
|
-
wrapper = wrap_func(func, ctx,
|
35
|
+
wrapper = wrap_func(func, ctx, yolo_mode)
|
36
36
|
return Tool(wrapper, takes_ctx=needs_run_context_for_pydantic)
|
37
37
|
|
38
38
|
|
39
|
-
def wrap_func(func: Callable, ctx: AnyContext,
|
39
|
+
def wrap_func(func: Callable, ctx: AnyContext, yolo_mode: bool | list[str]) -> Callable:
|
40
40
|
original_sig = inspect.signature(func)
|
41
41
|
needs_any_context_for_injection = _has_context_parameter(original_sig, AnyContext)
|
42
42
|
takes_no_args = len(original_sig.parameters) == 0
|
43
43
|
# Pass individual flags to the wrapper creator
|
44
44
|
wrapper = _create_wrapper(
|
45
|
-
func,
|
45
|
+
func=func,
|
46
|
+
original_sig=original_sig,
|
47
|
+
ctx=ctx,
|
48
|
+
needs_any_context_for_injection=needs_any_context_for_injection,
|
49
|
+
yolo_mode=yolo_mode,
|
46
50
|
)
|
47
51
|
_adjust_signature(wrapper, original_sig, takes_no_args)
|
48
52
|
return wrapper
|
@@ -82,7 +86,7 @@ def _create_wrapper(
|
|
82
86
|
original_sig: inspect.Signature,
|
83
87
|
ctx: AnyContext,
|
84
88
|
needs_any_context_for_injection: bool,
|
85
|
-
|
89
|
+
yolo_mode: bool | list[str],
|
86
90
|
) -> Callable:
|
87
91
|
"""Creates the core wrapper function."""
|
88
92
|
|
@@ -110,10 +114,13 @@ def _create_wrapper(
|
|
110
114
|
if "_dummy" in kwargs and "_dummy" not in original_sig.parameters:
|
111
115
|
del kwargs["_dummy"]
|
112
116
|
try:
|
113
|
-
if not
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
+
if not ctx.is_web_mode and ctx.is_tty:
|
118
|
+
if (
|
119
|
+
isinstance(yolo_mode, list) and func.__name__ not in yolo_mode
|
120
|
+
) or not yolo_mode:
|
121
|
+
approval, reason = await _ask_for_approval(ctx, func, args, kwargs)
|
122
|
+
if not approval:
|
123
|
+
raise ToolExecutionCancelled(f"User disapproving: {reason}")
|
117
124
|
return await run_async(func(*args, **kwargs))
|
118
125
|
except KeyboardInterrupt as e:
|
119
126
|
raise e
|
zrb/task/llm_task.py
CHANGED
@@ -12,9 +12,9 @@ from zrb.task.any_task import AnyTask
|
|
12
12
|
from zrb.task.base_task import BaseTask
|
13
13
|
from zrb.task.llm.agent import get_agent, run_agent_iteration
|
14
14
|
from zrb.task.llm.config import (
|
15
|
-
get_is_yolo_mode,
|
16
15
|
get_model,
|
17
16
|
get_model_settings,
|
17
|
+
get_yolo_mode,
|
18
18
|
)
|
19
19
|
from zrb.task.llm.conversation_history import (
|
20
20
|
inject_conversation_history_notes,
|
@@ -107,7 +107,8 @@ class LLMTask(BaseTask):
|
|
107
107
|
execute_condition: bool | str | Callable[[AnySharedContext], bool] = True,
|
108
108
|
retries: int = 2,
|
109
109
|
retry_period: float = 0,
|
110
|
-
|
110
|
+
yolo_mode: StrListAttr | BoolAttr | None = None,
|
111
|
+
is_yolo_mode: BoolAttr | None = None,
|
111
112
|
render_yolo_mode: bool = True,
|
112
113
|
readiness_check: list[AnyTask] | AnyTask | None = None,
|
113
114
|
readiness_check_delay: float = 0.5,
|
@@ -184,7 +185,11 @@ class LLMTask(BaseTask):
|
|
184
185
|
)
|
185
186
|
self._max_call_iteration = max_call_iteration
|
186
187
|
self._conversation_context = conversation_context
|
187
|
-
self.
|
188
|
+
self._yolo_mode = yolo_mode
|
189
|
+
if is_yolo_mode is not None:
|
190
|
+
print("[DEPRECATED] use `yolo_mode` instead of `is_yolo_mode`")
|
191
|
+
if self._yolo_mode is None:
|
192
|
+
self._yolo_mode = is_yolo_mode
|
188
193
|
self._render_yolo_mode = render_yolo_mode
|
189
194
|
self._attachment = attachment
|
190
195
|
|
@@ -210,6 +215,12 @@ class LLMTask(BaseTask):
|
|
210
215
|
):
|
211
216
|
self._history_summarization_token_threshold = summarization_token_threshold
|
212
217
|
|
218
|
+
def set_modes(self, modes: StrListAttr):
|
219
|
+
self._modes = modes
|
220
|
+
|
221
|
+
def set_yolo_mode(self, yolo_mode: StrListAttr | BoolAttr):
|
222
|
+
self._yolo_mode = yolo_mode
|
223
|
+
|
213
224
|
async def _exec_action(self, ctx: AnyContext) -> Any:
|
214
225
|
# Get dependent configurations first
|
215
226
|
model_settings = get_model_settings(ctx, self._model_settings)
|
@@ -222,9 +233,9 @@ class LLMTask(BaseTask):
|
|
222
233
|
model_api_key_attr=self._model_api_key,
|
223
234
|
render_model_api_key=self._render_model_api_key,
|
224
235
|
)
|
225
|
-
|
236
|
+
yolo_mode = get_yolo_mode(
|
226
237
|
ctx=ctx,
|
227
|
-
|
238
|
+
yolo_mode_attr=self._yolo_mode,
|
228
239
|
render_yolo_mode=self._render_yolo_mode,
|
229
240
|
)
|
230
241
|
summarization_prompt = get_summarization_system_prompt(
|
@@ -269,7 +280,7 @@ class LLMTask(BaseTask):
|
|
269
280
|
additional_tools=self._additional_tools,
|
270
281
|
toolsets_attr=self._toolsets,
|
271
282
|
additional_toolsets=self._additional_toolsets,
|
272
|
-
|
283
|
+
yolo_mode=yolo_mode,
|
273
284
|
)
|
274
285
|
# 4. Run the agent iteration and save the results/history
|
275
286
|
result = await self._execute_agent(
|
zrb/util/attr.py
CHANGED
@@ -96,9 +96,9 @@ def get_bool_attr(
|
|
96
96
|
bool: The boolean attribute value.
|
97
97
|
"""
|
98
98
|
val = get_attr(shared_ctx, attr, default, auto_render)
|
99
|
-
if isinstance(val,
|
100
|
-
return
|
101
|
-
return val
|
99
|
+
if isinstance(val, bool):
|
100
|
+
return val
|
101
|
+
return to_boolean(val)
|
102
102
|
|
103
103
|
|
104
104
|
def get_int_attr(
|
@@ -120,9 +120,9 @@ def get_int_attr(
|
|
120
120
|
int: The integer attribute value.
|
121
121
|
"""
|
122
122
|
val = get_attr(shared_ctx, attr, default, auto_render)
|
123
|
-
if isinstance(val,
|
124
|
-
return
|
125
|
-
return val
|
123
|
+
if isinstance(val, int):
|
124
|
+
return val
|
125
|
+
return int(val)
|
126
126
|
|
127
127
|
|
128
128
|
def get_float_attr(
|
@@ -144,9 +144,9 @@ def get_float_attr(
|
|
144
144
|
float | None: The float attribute value.
|
145
145
|
"""
|
146
146
|
val = get_attr(shared_ctx, attr, default, auto_render)
|
147
|
-
if isinstance(val,
|
148
|
-
return
|
149
|
-
return val
|
147
|
+
if isinstance(val, (int, float)):
|
148
|
+
return val
|
149
|
+
return float(val)
|
150
150
|
|
151
151
|
|
152
152
|
def get_attr(
|
zrb/util/string/conversion.py
CHANGED
@@ -9,10 +9,10 @@ zrb/builtin/git_subtree.py,sha256=7BKwOkVTWDrR0DXXQ4iJyHqeR6sV5VYRt8y_rEB0EHg,35
|
|
9
9
|
zrb/builtin/group.py,sha256=t008xLM4_fgbjfZrPoi_fQAnSHIo6MOiQSCHBO4GDYU,2379
|
10
10
|
zrb/builtin/http.py,sha256=L6RE73c65wWwG5iHFN-tpOhyh56KsrgVskDd3c3YXtk,4246
|
11
11
|
zrb/builtin/jwt.py,sha256=3M5uaQhJZbKQLjTUft1OwPz_JxtmK-xtkjxWjciOQho,2859
|
12
|
-
zrb/builtin/llm/chat_session.py,sha256=
|
12
|
+
zrb/builtin/llm/chat_session.py,sha256=p0giSVYuQMQ5H1hbQzl7cMb49XZqWG0SF7X-ixB5EBU,10203
|
13
13
|
zrb/builtin/llm/history.py,sha256=LDOrL0p7r_AHLa5L8Dp7bHNsOALugmJd7OguXRWGnm4,3087
|
14
14
|
zrb/builtin/llm/input.py,sha256=Nw-26uTWp2QhUgKJcP_IMHmtk-b542CCSQ_vCOjhvhM,877
|
15
|
-
zrb/builtin/llm/llm_ask.py,sha256=
|
15
|
+
zrb/builtin/llm/llm_ask.py,sha256=BuZdQKw4oXCdZyFYr-pKKMKGMG3XDQKa9aaCGOoSsHM,6015
|
16
16
|
zrb/builtin/llm/previous-session.js,sha256=xMKZvJoAbrwiyHS0OoPrWuaKxWYLoyR5sguePIoCjTY,816
|
17
17
|
zrb/builtin/llm/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
zrb/builtin/llm/tool/api.py,sha256=vMEiZhhTZ3o2jRBxWcJ62b0M85wd_w4W0X4Hx23NXto,2380
|
@@ -20,7 +20,7 @@ zrb/builtin/llm/tool/cli.py,sha256=8rugrKaNPEatHjr7nN4OIRLRT2TcF-oylEZGbLI9Brs,1
|
|
20
20
|
zrb/builtin/llm/tool/code.py,sha256=fr9FbmtfwizQTyTztvuvwAb9MD_auRZhPZfoJVBlKT4,8777
|
21
21
|
zrb/builtin/llm/tool/file.py,sha256=eXFGGFxxpdpWGVw0svyQNQc03I5M7wotSsA_HjkXw7c,23670
|
22
22
|
zrb/builtin/llm/tool/rag.py,sha256=Ab8_ZljnG_zfkwxPezImvorshuz3Fi4CmSzNOtU1a-g,9770
|
23
|
-
zrb/builtin/llm/tool/sub_agent.py,sha256=
|
23
|
+
zrb/builtin/llm/tool/sub_agent.py,sha256=qJTJ2GSH-2Cma2QyHEJm8l_VuDHMHwhAWGls217YA6A,5078
|
24
24
|
zrb/builtin/llm/tool/web.py,sha256=Hc9ikgBWZMgLB2O5lX-P9k8jvNSZeyUufqHXa_n_v4I,7653
|
25
25
|
zrb/builtin/md5.py,sha256=690RV2LbW7wQeTFxY-lmmqTSVEEZv3XZbjEUW1Q3XpE,1480
|
26
26
|
zrb/builtin/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -217,7 +217,7 @@ zrb/callback/callback.py,sha256=PFhCqzfxdk6IAthmXcZ13DokT62xtBzJr_ciLw6I8Zg,4030
|
|
217
217
|
zrb/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
218
218
|
zrb/cmd/cmd_result.py,sha256=L8bQJzWCpcYexIxHBNsXj2pT3BtLmWex0iJSMkvimOA,597
|
219
219
|
zrb/cmd/cmd_val.py,sha256=7Doowyg6BK3ISSGBLt-PmlhzaEkBjWWm51cED6fAUOQ,1014
|
220
|
-
zrb/config/config.py,sha256=
|
220
|
+
zrb/config/config.py,sha256=afsH-a7yTPT5hhvnmxGarAiU5yRUcUbua3Y_hRgltEg,14326
|
221
221
|
zrb/config/default_prompt/file_extractor_system_prompt.md,sha256=42Co-uNiL1Wn_KtH-7vjvNA0nja-xM0Sh2HpZF9OFU8,3880
|
222
222
|
zrb/config/default_prompt/interactive_system_prompt.md,sha256=XvXI51dMpQmuuYah_LEWUwJzvWHxNTz8XqbdMsF6qdI,2555
|
223
223
|
zrb/config/default_prompt/persona.md,sha256=GfUJ4-Mlf_Bm1YTzxFNkPkdVbAi06ZDVYh-iIma3NOs,253
|
@@ -225,7 +225,7 @@ zrb/config/default_prompt/repo_extractor_system_prompt.md,sha256=EGZ-zj78RlMEg2j
|
|
225
225
|
zrb/config/default_prompt/repo_summarizer_system_prompt.md,sha256=RNy37Wg7ibXj3DlsFKaYvgMpMS-lyXlM1LZlc59_4ic,2009
|
226
226
|
zrb/config/default_prompt/summarization_prompt.md,sha256=vbxzJGeH7uCdgnfbVt3GYOjY-BygmeRfJ6tnzXmFdoY,1698
|
227
227
|
zrb/config/default_prompt/system_prompt.md,sha256=gEb6N-cFg6VvOV-7ZffNwVt39DavAGesMqn9u0epbRc,2282
|
228
|
-
zrb/config/llm_config.py,sha256=
|
228
|
+
zrb/config/llm_config.py,sha256=9I_msAibvTY-ADG6lXCBXQ0EshaA-GQzJym9EZKsetw,8901
|
229
229
|
zrb/config/llm_context/config.py,sha256=TPQX_kU772r0AHmVFeo1WGLDAidacT-qDyuMWxY_avg,5878
|
230
230
|
zrb/config/llm_context/config_parser.py,sha256=h95FbOjvVobhrsfGtG_BY3hxS-OLzQj-9F5vGZuehkY,1473
|
231
231
|
zrb/config/llm_rate_limitter.py,sha256=_iQRv3d6kUPeRvmUYZX_iwCE7iDSEK1oKa4bQ9GROho,5261
|
@@ -334,20 +334,20 @@ zrb/session_state_logger/any_session_state_logger.py,sha256=T_-aJv63HwoTeiDOmXKH
|
|
334
334
|
zrb/session_state_logger/file_session_state_logger.py,sha256=NMyj_g2ImQc6ZRM9f35EpA-CM1UO-ZgoDnPkN1DSi9U,3915
|
335
335
|
zrb/session_state_logger/session_state_logger_factory.py,sha256=_oT1UIqm25nMwKhsUvXehnCdDvNqxCyuN8GLdv2D_U4,188
|
336
336
|
zrb/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
337
|
-
zrb/task/any_task.py,sha256=
|
337
|
+
zrb/task/any_task.py,sha256=JZOEYaSZ9XL2dQvNhrstcxF9D_jf95Bz6d0JcVzE8kE,6213
|
338
338
|
zrb/task/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
339
|
-
zrb/task/base/context.py,sha256=
|
339
|
+
zrb/task/base/context.py,sha256=ptz9-Am1s4yq6EHZUpnSrB0Ps3k7BgyakVbE-ZpiBzc,3923
|
340
340
|
zrb/task/base/execution.py,sha256=scDLfNYBe8Bc8Ct1LCIKmFtjpPxm7FjqZ2bJXIQAzv8,11042
|
341
341
|
zrb/task/base/lifecycle.py,sha256=c2v977pUm7S4EqrTMcUJKhnYOWugACVwU3qORDKiLXQ,7639
|
342
342
|
zrb/task/base/monitoring.py,sha256=UAOEcPiYNtZR4FFxzWCosuOEFE_P3c4GT5vAhQmohqI,5663
|
343
343
|
zrb/task/base/operators.py,sha256=uAMFqpZJsPnCrojgOl1FUDXTS15mtOa_IqiAXltyYRU,1576
|
344
|
-
zrb/task/base_task.py,sha256=
|
344
|
+
zrb/task/base_task.py,sha256=upwuqAfwNDXTYM-uRDJhgZqqqARI03T6ksUbFHHLEH0,13321
|
345
345
|
zrb/task/base_trigger.py,sha256=WSGcmBcGAZw8EzUXfmCjqJQkz8GEmi1RzogpF6A1V4s,6902
|
346
346
|
zrb/task/cmd_task.py,sha256=myM8WZm6NrUD-Wv0Vb5sTOrutrAVZLt5LVsSBKwX6SM,10860
|
347
347
|
zrb/task/http_check.py,sha256=Gf5rOB2Se2EdizuN9rp65HpGmfZkGc-clIAlHmPVehs,2565
|
348
348
|
zrb/task/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
349
|
-
zrb/task/llm/agent.py,sha256
|
350
|
-
zrb/task/llm/config.py,sha256=
|
349
|
+
zrb/task/llm/agent.py,sha256=uI0X_injDrxq-IhYuZsAMdoq9AXy-gnipozGuZ72QIs,8990
|
350
|
+
zrb/task/llm/config.py,sha256=zOPf4NpdWPuBc_R8d-kljYcOKfUAypDxiSjRDrxV66M,4059
|
351
351
|
zrb/task/llm/conversation_history.py,sha256=oMdKUV2__mBZ4znnA-prl-gfyoleKC8Nj5KNpmLQJ4o,6764
|
352
352
|
zrb/task/llm/conversation_history_model.py,sha256=kk-7niTl29Rm2EUIhTHzPXgZ5tp4IThMnIB3dS-1OdU,3062
|
353
353
|
zrb/task/llm/default_workflow/coding.md,sha256=2uythvPsnBpYfIhiIH1cCinQXX0i0yUqsL474Zpemw0,2484
|
@@ -358,9 +358,9 @@ zrb/task/llm/history_summarization.py,sha256=UIT8bpdT3hy1xn559waDLFWZlNtIqdIpIvR
|
|
358
358
|
zrb/task/llm/history_summarization_tool.py,sha256=Wazi4WMr3k1WJ1v7QgjAPbuY1JdBpHUsTWGt3DSTsLc,1706
|
359
359
|
zrb/task/llm/print_node.py,sha256=si619OvCUZJYTUSUpoOqVAgLSu1BGw-dlBq02MSD7FE,8096
|
360
360
|
zrb/task/llm/prompt.py,sha256=FGXWYHecWtrNNkPnjg-uhnkqp7fYt8V91-AjFM_5fpA,11550
|
361
|
-
zrb/task/llm/tool_wrapper.py,sha256=
|
361
|
+
zrb/task/llm/tool_wrapper.py,sha256=AsRzVAZtuAMsutLHGetpsPPncu6pcd4LrwxYRZxsp7c,9933
|
362
362
|
zrb/task/llm/typing.py,sha256=c8VAuPBw_4A3DxfYdydkgedaP-LU61W9_wj3m3CAX1E,58
|
363
|
-
zrb/task/llm_task.py,sha256=
|
363
|
+
zrb/task/llm_task.py,sha256=OxJ9QpqjEyeOI1_zqzNZHtQlRHi0ANOvL9FYaWLzO3Y,14913
|
364
364
|
zrb/task/make_task.py,sha256=PD3b_aYazthS8LHeJsLAhwKDEgdurQZpymJDKeN60u0,2265
|
365
365
|
zrb/task/rsync_task.py,sha256=WfqNSaicJgYWpunNU34eYxXDqHDHOftuDHyWJKjqwg0,6365
|
366
366
|
zrb/task/scaffolder.py,sha256=rME18w1HJUHXgi9eTYXx_T2G4JdqDYzBoNOkdOOo5-o,6806
|
@@ -370,7 +370,7 @@ zrb/task/tcp_check.py,sha256=P_QgGqwd5dXDaud3oQRxe_WuxyxG4s7CTY2wDk9Qcu0,2511
|
|
370
370
|
zrb/task_status/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
371
371
|
zrb/task_status/task_status.py,sha256=blZ8dxg9g_8MuViq-t7yJRLoE7yGUf5srgHf-PCsXNc,3069
|
372
372
|
zrb/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
373
|
-
zrb/util/attr.py,sha256=
|
373
|
+
zrb/util/attr.py,sha256=PdN5Jt0fGLQkTpfiziVMYXq22f56nwnaMHxLO063qCI,5369
|
374
374
|
zrb/util/callable.py,sha256=b6OFXbCXp2twow3wh2E_h5hNHLs2pXaLfGQz4iVyiQc,771
|
375
375
|
zrb/util/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
376
376
|
zrb/util/cli/markdown.py,sha256=Uhuw8XR-jAG9AG3oNK8VHJpYOdU40Q_8yVN74uu0RJ8,384
|
@@ -401,7 +401,7 @@ zrb/util/llm/prompt.py,sha256=HMpKby27DE8lJWpytYKylp7Iw9ENwsYQI0nMMKCCi54,2190
|
|
401
401
|
zrb/util/load.py,sha256=DK0KYSlu48HCoGPqnW1IxnE3pHrZSPCstfz8Fjyqqv8,2140
|
402
402
|
zrb/util/run.py,sha256=vu-mcSWDP_WuuvIKqM_--Gk3WkABO1oTXiHmBRTvVQk,546
|
403
403
|
zrb/util/string/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
404
|
-
zrb/util/string/conversion.py,sha256=
|
404
|
+
zrb/util/string/conversion.py,sha256=ovSQtogMCt2hQcyh1neSp_XdbFx4WX-Mw5xoUlyOnRQ,6271
|
405
405
|
zrb/util/string/format.py,sha256=MwWGAwSdtOgR_2uz-JCXlg_q-uRYUUI-G8CGkfdgqik,1198
|
406
406
|
zrb/util/string/name.py,sha256=SXEfxJ1-tDOzHqmSV8kvepRVyMqs2XdV_vyoh_9XUu0,1584
|
407
407
|
zrb/util/todo.py,sha256=r9_KYF2-hLKMNjsp6AFK9zivykMrywd-kJ4bCwfdafI,19323
|
@@ -409,7 +409,7 @@ zrb/util/todo_model.py,sha256=hhzAX-uFl5rsg7iVX1ULlJOfBtblwQ_ieNUxBWfc-Os,1670
|
|
409
409
|
zrb/util/truncate.py,sha256=eSzmjBpc1Qod3lM3M73snNbDOcARHukW_tq36dWdPvc,921
|
410
410
|
zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
411
411
|
zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
|
412
|
-
zrb-1.15.
|
413
|
-
zrb-1.15.
|
414
|
-
zrb-1.15.
|
415
|
-
zrb-1.15.
|
412
|
+
zrb-1.15.19.dist-info/METADATA,sha256=xqYaEjMc-itju0TLC9dhhS5WWIHa9nEzYDrJyPcnpns,9892
|
413
|
+
zrb-1.15.19.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
414
|
+
zrb-1.15.19.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
|
415
|
+
zrb-1.15.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|