waldiez 0.5.2__py3-none-any.whl → 0.5.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.
Potentially problematic release.
This version of waldiez might be problematic. Click here for more details.
- waldiez/_version.py +1 -1
- waldiez/cli.py +5 -27
- waldiez/exporter.py +0 -13
- waldiez/exporting/agent/exporter.py +38 -0
- waldiez/exporting/agent/extras/__init__.py +2 -0
- waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
- waldiez/exporting/agent/extras/group_member_extras.py +3 -2
- waldiez/exporting/agent/processor.py +113 -15
- waldiez/exporting/chats/processor.py +2 -21
- waldiez/exporting/chats/utils/common.py +66 -1
- waldiez/exporting/chats/utils/group.py +6 -3
- waldiez/exporting/chats/utils/nested.py +1 -1
- waldiez/exporting/chats/utils/sequential.py +25 -9
- waldiez/exporting/chats/utils/single.py +8 -6
- waldiez/exporting/core/context.py +0 -12
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
- waldiez/exporting/core/extras/base.py +20 -17
- waldiez/exporting/core/extras/path_resolver.py +39 -41
- waldiez/exporting/core/extras/serializer.py +16 -1
- waldiez/exporting/core/protocols.py +17 -0
- waldiez/exporting/core/types.py +6 -9
- waldiez/exporting/flow/execution_generator.py +56 -21
- waldiez/exporting/flow/exporter.py +1 -4
- waldiez/exporting/flow/factory.py +0 -9
- waldiez/exporting/flow/file_generator.py +6 -0
- waldiez/exporting/flow/orchestrator.py +27 -21
- waldiez/exporting/flow/utils/__init__.py +0 -2
- waldiez/exporting/flow/utils/common.py +15 -96
- waldiez/exporting/flow/utils/importing.py +4 -0
- waldiez/io/mqtt.py +33 -14
- waldiez/io/redis.py +18 -13
- waldiez/io/structured.py +9 -4
- waldiez/io/utils.py +32 -0
- waldiez/io/ws.py +8 -2
- waldiez/models/__init__.py +6 -0
- waldiez/models/agents/__init__.py +8 -0
- waldiez/models/agents/agent/agent.py +136 -38
- waldiez/models/agents/agent/agent_type.py +3 -2
- waldiez/models/agents/agents.py +10 -0
- waldiez/models/agents/doc_agent/__init__.py +13 -0
- waldiez/models/agents/doc_agent/doc_agent.py +126 -0
- waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
- waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
- waldiez/models/chat/chat_message.py +1 -1
- waldiez/models/flow/flow.py +13 -2
- waldiez/models/model/__init__.py +2 -2
- waldiez/models/model/_aws.py +75 -0
- waldiez/models/model/_llm.py +516 -0
- waldiez/models/model/_price.py +30 -0
- waldiez/models/model/model.py +45 -2
- waldiez/models/model/model_data.py +2 -83
- waldiez/models/tool/predefined/_duckduckgo.py +123 -0
- waldiez/models/tool/predefined/_google.py +31 -9
- waldiez/models/tool/predefined/_perplexity.py +161 -0
- waldiez/models/tool/predefined/_searxng.py +152 -0
- waldiez/models/tool/predefined/_tavily.py +46 -9
- waldiez/models/tool/predefined/_wikipedia.py +26 -6
- waldiez/models/tool/predefined/_youtube.py +36 -8
- waldiez/models/tool/predefined/registry.py +6 -0
- waldiez/models/waldiez.py +12 -0
- waldiez/runner.py +184 -382
- waldiez/running/__init__.py +2 -4
- waldiez/running/base_runner.py +136 -118
- waldiez/running/environment.py +61 -17
- waldiez/running/post_run.py +70 -14
- waldiez/running/pre_run.py +42 -0
- waldiez/running/protocol.py +42 -48
- waldiez/running/run_results.py +5 -5
- waldiez/running/standard_runner.py +429 -0
- waldiez/running/timeline_processor.py +1166 -0
- waldiez/utils/version.py +12 -1
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/METADATA +61 -63
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/RECORD +77 -66
- waldiez/running/import_runner.py +0 -424
- waldiez/running/subprocess_runner.py +0 -100
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/WHEEL +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.2.dist-info → waldiez-0.5.4.dist-info}/licenses/NOTICE.md +0 -0
waldiez/runner.py
CHANGED
|
@@ -14,444 +14,205 @@ variables specified in the waldiez file are set.
|
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
16
|
from pathlib import Path
|
|
17
|
-
from typing import TYPE_CHECKING, Union
|
|
17
|
+
from typing import TYPE_CHECKING, Any, Union
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Literal
|
|
18
20
|
|
|
19
21
|
from .models.waldiez import Waldiez
|
|
20
22
|
from .running import (
|
|
21
23
|
WaldiezBaseRunner,
|
|
22
|
-
|
|
23
|
-
WaldiezSubprocessRunner,
|
|
24
|
+
WaldiezStandardRunner,
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
if TYPE_CHECKING:
|
|
27
|
-
from autogen import
|
|
28
|
+
from autogen.io.run_response import ( # type: ignore[import-untyped]
|
|
29
|
+
AsyncRunResponseProtocol,
|
|
30
|
+
RunResponseProtocol,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def create_runner(
|
|
35
|
+
waldiez: Waldiez,
|
|
36
|
+
# mode: Literal["standard", "debug"] = "standard",
|
|
37
|
+
mode: Literal["standard"] = "standard",
|
|
38
|
+
output_path: str | Path | None = None,
|
|
39
|
+
uploads_root: str | Path | None = None,
|
|
40
|
+
structured_io: bool = False,
|
|
41
|
+
**kwargs: Any,
|
|
42
|
+
) -> WaldiezBaseRunner:
|
|
43
|
+
"""Create a Waldiez runner of the specified type.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
waldiez : Waldiez
|
|
48
|
+
The waldiez flow to run.
|
|
49
|
+
mode : str, optional
|
|
50
|
+
Runner mode: "standard", "debug", by default "standard"
|
|
51
|
+
output_path : str | Path | None, optional
|
|
52
|
+
Output path for results, by default None
|
|
53
|
+
uploads_root : str | Path | None, optional
|
|
54
|
+
Uploads root directory, by default None
|
|
55
|
+
structured_io : bool, optional
|
|
56
|
+
Use structured I/O, by default False
|
|
57
|
+
**kwargs
|
|
58
|
+
Additional arguments for specific runner types
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
WaldiezBaseRunner
|
|
63
|
+
The configured runner instance
|
|
64
|
+
|
|
65
|
+
Raises
|
|
66
|
+
------
|
|
67
|
+
ValueError
|
|
68
|
+
If unknown runner mode is specified
|
|
69
|
+
"""
|
|
70
|
+
runners: dict[str, type[WaldiezBaseRunner]] = {
|
|
71
|
+
"standard": WaldiezStandardRunner,
|
|
72
|
+
# "debug": WaldiezDebugRunner,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if mode not in runners:
|
|
76
|
+
available = ", ".join(runners.keys())
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"Unknown runner mode '{mode}'. Available: {available}"
|
|
79
|
+
)
|
|
28
80
|
|
|
81
|
+
runner_class = runners[mode]
|
|
82
|
+
return runner_class(
|
|
83
|
+
waldiez=waldiez,
|
|
84
|
+
output_path=output_path,
|
|
85
|
+
uploads_root=uploads_root,
|
|
86
|
+
structured_io=structured_io,
|
|
87
|
+
**kwargs,
|
|
88
|
+
)
|
|
29
89
|
|
|
30
|
-
class WaldiezRunner(WaldiezBaseRunner):
|
|
31
|
-
"""Waldiez runner class."""
|
|
32
90
|
|
|
33
|
-
|
|
91
|
+
class WaldiezRunner(WaldiezBaseRunner):
|
|
92
|
+
"""Factory class for creating Waldiez runners."""
|
|
34
93
|
|
|
94
|
+
# pylint: disable=super-init-not-called
|
|
35
95
|
def __init__(
|
|
36
96
|
self,
|
|
37
97
|
waldiez: Waldiez,
|
|
98
|
+
# mode: Literal["standard", "debug"] = "standard",
|
|
99
|
+
mode: Literal["standard"] = "standard",
|
|
38
100
|
output_path: str | Path | None = None,
|
|
39
101
|
uploads_root: str | Path | None = None,
|
|
40
102
|
structured_io: bool = False,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
) -> None:
|
|
45
|
-
"""Create a new Waldiez runner.
|
|
103
|
+
**kwargs: Any,
|
|
104
|
+
):
|
|
105
|
+
"""Create a runner instance.
|
|
46
106
|
|
|
47
107
|
Parameters
|
|
48
108
|
----------
|
|
49
109
|
waldiez : Waldiez
|
|
50
110
|
The waldiez flow to run.
|
|
111
|
+
mode : Literal["standard", "debug"], optional
|
|
112
|
+
Runner mode: "standard", "debug", by default "standard"
|
|
51
113
|
output_path : str | Path | None, optional
|
|
52
|
-
|
|
53
|
-
If None, a temporary directory will be used.
|
|
114
|
+
Output path for results, by default None
|
|
54
115
|
uploads_root : str | Path | None, optional
|
|
55
|
-
|
|
56
|
-
directory will be used.
|
|
116
|
+
Uploads root directory, by default None
|
|
57
117
|
structured_io : bool, optional
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
If True, the flow will be run in an isolated subprocess.
|
|
62
|
-
Defaults to False.
|
|
63
|
-
threaded : bool, optional
|
|
64
|
-
If True, the flow will be run in a threaded manner.
|
|
65
|
-
Defaults to False.
|
|
66
|
-
skip_patch_io : bool, optional
|
|
67
|
-
If True, the IO patching will be skipped.
|
|
68
|
-
Defaults to True.
|
|
118
|
+
Use structured I/O, by default False
|
|
119
|
+
**kwargs
|
|
120
|
+
Additional arguments for specific runner types
|
|
69
121
|
|
|
70
|
-
Returns
|
|
71
|
-
-------
|
|
72
|
-
WaldiezBaseRunner
|
|
73
|
-
The runner instance that will execute the flow.
|
|
74
122
|
"""
|
|
75
|
-
|
|
76
|
-
waldiez,
|
|
123
|
+
self._runner = create_runner(
|
|
124
|
+
waldiez=waldiez,
|
|
125
|
+
mode=mode,
|
|
77
126
|
output_path=output_path,
|
|
78
127
|
uploads_root=uploads_root,
|
|
79
128
|
structured_io=structured_io,
|
|
80
|
-
|
|
81
|
-
threaded=threaded,
|
|
82
|
-
skip_patch_io=skip_patch_io,
|
|
129
|
+
**kwargs,
|
|
83
130
|
)
|
|
84
|
-
if isolated:
|
|
85
|
-
self._implementation = WaldiezSubprocessRunner(
|
|
86
|
-
waldiez,
|
|
87
|
-
output_path=output_path,
|
|
88
|
-
uploads_root=uploads_root,
|
|
89
|
-
structured_io=structured_io,
|
|
90
|
-
isolated=True,
|
|
91
|
-
threaded=threaded,
|
|
92
|
-
skip_patch_io=skip_patch_io,
|
|
93
|
-
)
|
|
94
|
-
else:
|
|
95
|
-
self._implementation = WaldiezImportRunner(
|
|
96
|
-
waldiez,
|
|
97
|
-
output_path=output_path,
|
|
98
|
-
uploads_root=uploads_root,
|
|
99
|
-
structured_io=structured_io,
|
|
100
|
-
isolated=False,
|
|
101
|
-
threaded=threaded,
|
|
102
|
-
skip_patch_io=skip_patch_io,
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
@classmethod
|
|
106
|
-
def load(
|
|
107
|
-
cls,
|
|
108
|
-
waldiez_file: str | Path,
|
|
109
|
-
name: str | None = None,
|
|
110
|
-
description: str | None = None,
|
|
111
|
-
tags: list[str] | None = None,
|
|
112
|
-
requirements: list[str] | None = None,
|
|
113
|
-
output_path: str | Path | None = None,
|
|
114
|
-
uploads_root: str | Path | None = None,
|
|
115
|
-
structured_io: bool = False,
|
|
116
|
-
isolated: bool = False,
|
|
117
|
-
threaded: bool = False,
|
|
118
|
-
skip_patch_io: bool = True,
|
|
119
|
-
) -> "WaldiezRunner":
|
|
120
|
-
"""Load a waldiez flow from a file and create a runner.
|
|
121
131
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
waldiez_file : str | Path
|
|
125
|
-
The path to the waldiez file.
|
|
126
|
-
name : str | None, optional
|
|
127
|
-
The name of the flow.
|
|
128
|
-
If None, the name from the waldiez file will be used.
|
|
129
|
-
description : str | None, optional
|
|
130
|
-
The description of the flow.
|
|
131
|
-
If None, the description from the waldiez file will be used.
|
|
132
|
-
tags : list[str] | None, optional
|
|
133
|
-
The tags for the flow. If None, no tags will be set.
|
|
134
|
-
requirements : list[str] | None, optional
|
|
135
|
-
The requirements for the flow. If None, no requirements will be set.
|
|
136
|
-
output_path : str | Path | None, optional
|
|
137
|
-
The path to the output directory where the results will be stored.
|
|
138
|
-
If None, a temporary directory will be used.
|
|
139
|
-
uploads_root : str | Path | None, optional
|
|
140
|
-
The root directory for uploads. If None, the default uploads
|
|
141
|
-
directory will be used.
|
|
142
|
-
structured_io : bool, optional
|
|
143
|
-
If True, the flow will use
|
|
144
|
-
structured IO instead of the default 'input/print'.
|
|
145
|
-
isolated : bool, optional
|
|
146
|
-
If True, the flow will be run in an isolated subprocess.
|
|
147
|
-
Defaults to False.
|
|
148
|
-
threaded : bool, optional
|
|
149
|
-
If True, the flow will be run in a threaded manner.
|
|
150
|
-
Defaults to False.
|
|
151
|
-
skip_patch_io : bool, optional
|
|
152
|
-
If True, the IO patching will be skipped.
|
|
153
|
-
Defaults to True.
|
|
132
|
+
def __repr__(self) -> str:
|
|
133
|
+
"""Get the string representation of the runner.
|
|
154
134
|
|
|
155
135
|
Returns
|
|
156
136
|
-------
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
str
|
|
138
|
+
A string representation of the WaldiezRunner instance.
|
|
159
139
|
"""
|
|
160
|
-
|
|
161
|
-
waldiez_file,
|
|
162
|
-
name=name,
|
|
163
|
-
description=description,
|
|
164
|
-
tags=tags,
|
|
165
|
-
requirements=requirements,
|
|
166
|
-
)
|
|
167
|
-
return cls(
|
|
168
|
-
waldiez,
|
|
169
|
-
output_path=output_path,
|
|
170
|
-
uploads_root=uploads_root,
|
|
171
|
-
structured_io=structured_io,
|
|
172
|
-
isolated=isolated,
|
|
173
|
-
threaded=threaded,
|
|
174
|
-
skip_patch_io=skip_patch_io,
|
|
175
|
-
)
|
|
140
|
+
return f"WaldiezRunner({type(self._runner).__name__})"
|
|
176
141
|
|
|
177
|
-
def
|
|
178
|
-
|
|
179
|
-
output_file: Path,
|
|
180
|
-
uploads_root: Path | None,
|
|
181
|
-
) -> Path:
|
|
182
|
-
"""Actions to perform before running the flow.
|
|
183
|
-
|
|
184
|
-
Parameters
|
|
185
|
-
----------
|
|
186
|
-
output_file : Path
|
|
187
|
-
The output file.
|
|
188
|
-
uploads_root : Path | None
|
|
189
|
-
The runtime uploads root.
|
|
190
|
-
"""
|
|
191
|
-
return self._implementation._before_run(
|
|
192
|
-
output_file=output_file,
|
|
193
|
-
uploads_root=uploads_root,
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
async def _a_before_run(
|
|
197
|
-
self,
|
|
198
|
-
output_file: Path,
|
|
199
|
-
uploads_root: Path | None,
|
|
200
|
-
) -> Path:
|
|
201
|
-
"""Asynchronously perform actions before running the flow.
|
|
142
|
+
def __getattr__(self, name: str) -> Any:
|
|
143
|
+
"""Delegate attribute access to the underlying runner.
|
|
202
144
|
|
|
203
145
|
Parameters
|
|
204
146
|
----------
|
|
205
|
-
|
|
206
|
-
The
|
|
207
|
-
uploads_root : Path | None
|
|
208
|
-
The runtime uploads root.
|
|
147
|
+
name : str
|
|
148
|
+
The name of the attribute to access.
|
|
209
149
|
|
|
210
150
|
Returns
|
|
211
151
|
-------
|
|
212
|
-
|
|
213
|
-
The
|
|
152
|
+
Any
|
|
153
|
+
The value of the attribute from the underlying runner.
|
|
214
154
|
"""
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
)
|
|
155
|
+
if hasattr(self._runner, name):
|
|
156
|
+
return getattr(self._runner, name)
|
|
157
|
+
raise AttributeError(f"{type(self).__name__} has no attribute '{name}'")
|
|
218
158
|
|
|
219
159
|
def _run(
|
|
220
160
|
self,
|
|
221
161
|
temp_dir: Path,
|
|
222
162
|
output_file: Path,
|
|
223
163
|
uploads_root: Path | None,
|
|
224
|
-
skip_mmd: bool
|
|
164
|
+
skip_mmd: bool,
|
|
165
|
+
skip_timeline: bool,
|
|
166
|
+
**kwargs: Any,
|
|
225
167
|
) -> Union[
|
|
226
|
-
"
|
|
227
|
-
list["
|
|
228
|
-
dict[int, "ChatResult"],
|
|
168
|
+
list["RunResponseProtocol"],
|
|
169
|
+
list["AsyncRunResponseProtocol"],
|
|
229
170
|
]:
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
Parameters
|
|
233
|
-
----------
|
|
234
|
-
temp_dir : Path
|
|
235
|
-
The path to the temporary directory created for the run.
|
|
236
|
-
output_file : Path
|
|
237
|
-
The output file.
|
|
238
|
-
uploads_root : Path | None
|
|
239
|
-
The runtime uploads root.
|
|
240
|
-
skip_mmd : bool
|
|
241
|
-
Whether to skip generating the mermaid diagram.
|
|
242
|
-
|
|
243
|
-
Returns
|
|
244
|
-
-------
|
|
245
|
-
ChatResult | list[ChatResult] | dict[int, ChatResult]
|
|
246
|
-
The result of the run, which can be a single ChatResult,
|
|
247
|
-
a list of ChatResults,
|
|
248
|
-
or a dictionary mapping indices to ChatResults.
|
|
249
|
-
"""
|
|
250
|
-
return self._implementation._run(
|
|
171
|
+
return self._runner._run(
|
|
251
172
|
temp_dir=temp_dir,
|
|
252
173
|
output_file=output_file,
|
|
253
174
|
uploads_root=uploads_root,
|
|
254
175
|
skip_mmd=skip_mmd,
|
|
176
|
+
skip_timeline=skip_timeline,
|
|
177
|
+
**kwargs,
|
|
255
178
|
)
|
|
256
179
|
|
|
257
|
-
|
|
180
|
+
def _start(
|
|
258
181
|
self,
|
|
259
182
|
temp_dir: Path,
|
|
260
183
|
output_file: Path,
|
|
261
184
|
uploads_root: Path | None,
|
|
262
185
|
skip_mmd: bool,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
]: # pyright: ignore
|
|
268
|
-
"""Asynchronously run the flow.
|
|
269
|
-
|
|
270
|
-
Parameters
|
|
271
|
-
----------
|
|
272
|
-
temp_dir : Path
|
|
273
|
-
The path to the temporary directory created for the run.
|
|
274
|
-
output_file : Path
|
|
275
|
-
The output file.
|
|
276
|
-
uploads_root : Path | None
|
|
277
|
-
The runtime uploads root.
|
|
278
|
-
skip_mmd : bool
|
|
279
|
-
Whether to skip generating the mermaid diagram.
|
|
280
|
-
|
|
281
|
-
Returns
|
|
282
|
-
-------
|
|
283
|
-
Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
|
|
284
|
-
The result of the run, which can be a single ChatResult,
|
|
285
|
-
a list of ChatResults,
|
|
286
|
-
or a dictionary mapping indices to ChatResults.
|
|
287
|
-
"""
|
|
288
|
-
return await self._implementation._a_run(
|
|
186
|
+
skip_timeline: bool,
|
|
187
|
+
) -> None:
|
|
188
|
+
"""Start the workflow in a non-blocking way."""
|
|
189
|
+
self._runner._start(
|
|
289
190
|
temp_dir=temp_dir,
|
|
290
191
|
output_file=output_file,
|
|
291
192
|
uploads_root=uploads_root,
|
|
292
193
|
skip_mmd=skip_mmd,
|
|
194
|
+
skip_timeline=skip_timeline,
|
|
293
195
|
)
|
|
294
196
|
|
|
295
|
-
def
|
|
296
|
-
self
|
|
297
|
-
results: Union[
|
|
298
|
-
"ChatResult",
|
|
299
|
-
list["ChatResult"],
|
|
300
|
-
dict[int, "ChatResult"],
|
|
301
|
-
],
|
|
302
|
-
output_file: Path,
|
|
303
|
-
uploads_root: Path | None,
|
|
304
|
-
temp_dir: Path,
|
|
305
|
-
skip_mmd: bool,
|
|
306
|
-
) -> None:
|
|
307
|
-
"""Actions to perform after running the flow.
|
|
308
|
-
|
|
309
|
-
Parameters
|
|
310
|
-
----------
|
|
311
|
-
results : Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
|
|
312
|
-
The results of the run, which can be a single ChatResult,
|
|
313
|
-
a list of ChatResults,
|
|
314
|
-
or a dictionary mapping indices to ChatResults.
|
|
315
|
-
output_file : Path
|
|
316
|
-
The path to the output file.
|
|
317
|
-
uploads_root : Path | None
|
|
318
|
-
The runtime uploads root.
|
|
319
|
-
structured_io : bool
|
|
320
|
-
Whether to use structured IO instead of the default 'input/print'.
|
|
321
|
-
temp_dir : Path
|
|
322
|
-
The path to the temporary directory created for the run.
|
|
323
|
-
skip_mmd : bool
|
|
324
|
-
Whether to skip generating the mermaid diagram.
|
|
325
|
-
"""
|
|
326
|
-
self._implementation._after_run(
|
|
327
|
-
results,
|
|
328
|
-
output_file,
|
|
329
|
-
uploads_root,
|
|
330
|
-
temp_dir,
|
|
331
|
-
skip_mmd,
|
|
332
|
-
)
|
|
333
|
-
|
|
334
|
-
async def _a_after_run(
|
|
335
|
-
self,
|
|
336
|
-
results: Union[
|
|
337
|
-
"ChatResult",
|
|
338
|
-
list["ChatResult"],
|
|
339
|
-
dict[int, "ChatResult"],
|
|
340
|
-
],
|
|
341
|
-
output_file: Path,
|
|
342
|
-
uploads_root: Path | None,
|
|
343
|
-
temp_dir: Path,
|
|
344
|
-
skip_mmd: bool,
|
|
345
|
-
) -> None:
|
|
346
|
-
"""Asynchronously perform actions after running the flow.
|
|
347
|
-
|
|
348
|
-
Parameters
|
|
349
|
-
----------
|
|
350
|
-
output_file : Path
|
|
351
|
-
The path to the output file.
|
|
352
|
-
uploads_root : Path | None
|
|
353
|
-
The runtime uploads root.
|
|
354
|
-
structured_io : bool
|
|
355
|
-
Whether to use structured IO instead of the default 'input/print'.
|
|
356
|
-
temp_dir : Path
|
|
357
|
-
The path to the temporary directory created for the run.
|
|
358
|
-
skip_mmd : bool
|
|
359
|
-
Whether to skip generating the mermaid diagram.
|
|
360
|
-
"""
|
|
361
|
-
await self._implementation._a_after_run(
|
|
362
|
-
results,
|
|
363
|
-
output_file,
|
|
364
|
-
uploads_root,
|
|
365
|
-
temp_dir,
|
|
366
|
-
skip_mmd,
|
|
367
|
-
)
|
|
368
|
-
|
|
369
|
-
def start(
|
|
370
|
-
self,
|
|
371
|
-
output_path: str | Path | None,
|
|
372
|
-
uploads_root: str | Path | None,
|
|
373
|
-
structured_io: bool | None = None,
|
|
374
|
-
skip_patch_io: bool | None = None,
|
|
375
|
-
skip_mmd: bool = False,
|
|
376
|
-
) -> None:
|
|
377
|
-
"""Start the flow.
|
|
378
|
-
|
|
379
|
-
Parameters
|
|
380
|
-
----------
|
|
381
|
-
output_path : str | Path | None
|
|
382
|
-
The output path, by default None.
|
|
383
|
-
uploads_root : str | Path | None
|
|
384
|
-
The runtime uploads root.
|
|
385
|
-
structured_io : bool | None
|
|
386
|
-
Whether to use structured IO instead of the default 'input/print'.
|
|
387
|
-
If None, it will use the value from the context.
|
|
388
|
-
skip_patch_io : bool | None = None
|
|
389
|
-
Whether to skip patching I/O, by default None.
|
|
390
|
-
If None, it will use the value from the context.
|
|
391
|
-
skip_mmd : bool = False
|
|
392
|
-
Whether to skip generating the mermaid diagram.
|
|
393
|
-
"""
|
|
394
|
-
self._implementation.start(
|
|
395
|
-
output_path=output_path,
|
|
396
|
-
uploads_root=uploads_root,
|
|
397
|
-
structured_io=structured_io,
|
|
398
|
-
skip_patch_io=skip_patch_io,
|
|
399
|
-
)
|
|
197
|
+
def _stop(self) -> None:
|
|
198
|
+
self._runner._stop()
|
|
400
199
|
|
|
401
|
-
def
|
|
200
|
+
async def _a_run(
|
|
402
201
|
self,
|
|
403
202
|
temp_dir: Path,
|
|
404
203
|
output_file: Path,
|
|
405
204
|
uploads_root: Path | None,
|
|
406
205
|
skip_mmd: bool,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
----------
|
|
412
|
-
output_file : Path
|
|
413
|
-
The output file.
|
|
414
|
-
uploads_root : Path | None
|
|
415
|
-
The runtime uploads root.
|
|
416
|
-
skip_mmd : bool
|
|
417
|
-
Whether to skip generating the mermaid diagram.
|
|
418
|
-
"""
|
|
419
|
-
self._implementation._start(
|
|
206
|
+
skip_timeline: bool,
|
|
207
|
+
**kwargs: Any,
|
|
208
|
+
) -> Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]:
|
|
209
|
+
return await self._runner._a_run(
|
|
420
210
|
temp_dir=temp_dir,
|
|
421
211
|
output_file=output_file,
|
|
422
212
|
uploads_root=uploads_root,
|
|
423
213
|
skip_mmd=skip_mmd,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
async def a_start(
|
|
427
|
-
self,
|
|
428
|
-
output_path: str | Path | None,
|
|
429
|
-
uploads_root: str | Path | None,
|
|
430
|
-
structured_io: bool | None = None,
|
|
431
|
-
skip_patch_io: bool | None = None,
|
|
432
|
-
skip_mmd: bool = False,
|
|
433
|
-
) -> None:
|
|
434
|
-
"""Asynchronously start the flow.
|
|
435
|
-
|
|
436
|
-
Parameters
|
|
437
|
-
----------
|
|
438
|
-
output_path : str | Path | None
|
|
439
|
-
The output path, by default None.
|
|
440
|
-
uploads_root : str | Path | None
|
|
441
|
-
The runtime uploads root.
|
|
442
|
-
structured_io : bool | None
|
|
443
|
-
Whether to use structured IO instead of the default 'input/print'.
|
|
444
|
-
skip_patch_io : bool | None = None
|
|
445
|
-
Whether to skip patching I/O, by default None.
|
|
446
|
-
skip_mmd : bool = False
|
|
447
|
-
Whether to skip generating the mermaid diagram, by default False.
|
|
448
|
-
"""
|
|
449
|
-
await self._implementation.a_start(
|
|
450
|
-
output_path=output_path,
|
|
451
|
-
uploads_root=uploads_root,
|
|
452
|
-
structured_io=structured_io,
|
|
453
|
-
skip_patch_io=skip_patch_io,
|
|
454
|
-
skip_mmd=skip_mmd,
|
|
214
|
+
skip_timeline=skip_timeline,
|
|
215
|
+
**kwargs,
|
|
455
216
|
)
|
|
456
217
|
|
|
457
218
|
async def _a_start(
|
|
@@ -460,37 +221,78 @@ class WaldiezRunner(WaldiezBaseRunner):
|
|
|
460
221
|
output_file: Path,
|
|
461
222
|
uploads_root: Path | None,
|
|
462
223
|
skip_mmd: bool,
|
|
224
|
+
skip_timeline: bool,
|
|
463
225
|
) -> None:
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
Parameters
|
|
467
|
-
----------
|
|
468
|
-
temp_dir : Path
|
|
469
|
-
The path to the temporary directory created for the run.
|
|
470
|
-
output_file : Path
|
|
471
|
-
The output file.
|
|
472
|
-
uploads_root : Path | None
|
|
473
|
-
The runtime uploads root.
|
|
474
|
-
skip_mmd : bool
|
|
475
|
-
Whether to skip generating the mermaid diagram.
|
|
476
|
-
"""
|
|
477
|
-
await self._implementation._a_start(
|
|
226
|
+
return await self._runner._a_start(
|
|
478
227
|
temp_dir=temp_dir,
|
|
479
228
|
output_file=output_file,
|
|
480
229
|
uploads_root=uploads_root,
|
|
481
230
|
skip_mmd=skip_mmd,
|
|
231
|
+
skip_timeline=skip_timeline,
|
|
482
232
|
)
|
|
483
233
|
|
|
484
|
-
def
|
|
485
|
-
|
|
234
|
+
async def _a_stop(self) -> None:
|
|
235
|
+
return await self._runner._a_stop()
|
|
486
236
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
237
|
+
@classmethod
|
|
238
|
+
def load(
|
|
239
|
+
cls,
|
|
240
|
+
waldiez_file: str | Path,
|
|
241
|
+
name: str | None = None,
|
|
242
|
+
description: str | None = None,
|
|
243
|
+
tags: list[str] | None = None,
|
|
244
|
+
requirements: list[str] | None = None,
|
|
245
|
+
output_path: str | Path | None = None,
|
|
246
|
+
uploads_root: str | Path | None = None,
|
|
247
|
+
structured_io: bool = False,
|
|
248
|
+
**kwargs: Any,
|
|
249
|
+
) -> "WaldiezRunner":
|
|
250
|
+
"""Load a waldiez flow and create a runner.
|
|
490
251
|
|
|
491
|
-
|
|
492
|
-
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
waldiez_file : str | Path
|
|
255
|
+
Path to the waldiez flow file.
|
|
256
|
+
name : str | None, optional
|
|
257
|
+
Name of the flow, by default None
|
|
258
|
+
description : str | None, optional
|
|
259
|
+
Description of the flow, by default None
|
|
260
|
+
tags : list[str] | None, optional
|
|
261
|
+
Tags for the flow, by default None
|
|
262
|
+
requirements : list[str] | None, optional
|
|
263
|
+
Requirements for the flow, by default None
|
|
264
|
+
output_path : str | Path | None, optional
|
|
265
|
+
Output path for results, by default None
|
|
266
|
+
uploads_root : str | Path | None, optional
|
|
267
|
+
Uploads root directory, by default None
|
|
268
|
+
structured_io : bool, optional
|
|
269
|
+
Use structured I/O, by default False
|
|
270
|
+
**kwargs
|
|
271
|
+
Additional arguments for specific runner types
|
|
493
272
|
|
|
494
|
-
|
|
273
|
+
Returns
|
|
274
|
+
-------
|
|
275
|
+
WaldiezRunner
|
|
276
|
+
The configured runner instance
|
|
495
277
|
"""
|
|
496
|
-
|
|
278
|
+
waldiez = Waldiez.load(
|
|
279
|
+
waldiez_file,
|
|
280
|
+
name=name,
|
|
281
|
+
description=description,
|
|
282
|
+
tags=tags,
|
|
283
|
+
requirements=requirements,
|
|
284
|
+
)
|
|
285
|
+
mode = kwargs.pop("mode", "standard")
|
|
286
|
+
# Ensure mode is set correctly, defaulting to "standard" if not provided
|
|
287
|
+
if not mode or mode not in ["standard", "debug"]:
|
|
288
|
+
# Default to "standard" if mode is not specified or invalid
|
|
289
|
+
# This ensures backward compatibility and avoids errors
|
|
290
|
+
mode = "standard"
|
|
291
|
+
return cls(
|
|
292
|
+
waldiez=waldiez,
|
|
293
|
+
mode=mode,
|
|
294
|
+
output_path=output_path,
|
|
295
|
+
uploads_root=uploads_root,
|
|
296
|
+
structured_io=structured_io,
|
|
297
|
+
**kwargs,
|
|
298
|
+
)
|
waldiez/running/__init__.py
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
"""Running related functions."""
|
|
4
4
|
|
|
5
5
|
from .base_runner import WaldiezBaseRunner
|
|
6
|
-
from .
|
|
7
|
-
from .subprocess_runner import WaldiezSubprocessRunner
|
|
6
|
+
from .standard_runner import WaldiezStandardRunner
|
|
8
7
|
|
|
9
8
|
__all__ = [
|
|
10
9
|
"WaldiezBaseRunner",
|
|
11
|
-
"
|
|
12
|
-
"WaldiezSubprocessRunner",
|
|
10
|
+
"WaldiezStandardRunner",
|
|
13
11
|
]
|