waldiez 0.5.3__py3-none-any.whl → 0.5.5__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.

Files changed (76) hide show
  1. waldiez/_version.py +1 -1
  2. waldiez/cli.py +3 -27
  3. waldiez/exporter.py +0 -13
  4. waldiez/exporting/agent/exporter.py +38 -0
  5. waldiez/exporting/agent/extras/__init__.py +2 -0
  6. waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
  7. waldiez/exporting/agent/extras/group_member_extras.py +3 -2
  8. waldiez/exporting/agent/processor.py +113 -15
  9. waldiez/exporting/chats/processor.py +2 -21
  10. waldiez/exporting/chats/utils/common.py +66 -1
  11. waldiez/exporting/chats/utils/group.py +6 -3
  12. waldiez/exporting/chats/utils/nested.py +1 -1
  13. waldiez/exporting/chats/utils/sequential.py +25 -9
  14. waldiez/exporting/chats/utils/single.py +8 -6
  15. waldiez/exporting/core/context.py +0 -12
  16. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
  17. waldiez/exporting/core/extras/base.py +20 -17
  18. waldiez/exporting/core/extras/path_resolver.py +39 -41
  19. waldiez/exporting/core/extras/serializer.py +16 -1
  20. waldiez/exporting/core/protocols.py +17 -0
  21. waldiez/exporting/core/types.py +6 -9
  22. waldiez/exporting/flow/execution_generator.py +56 -21
  23. waldiez/exporting/flow/exporter.py +1 -4
  24. waldiez/exporting/flow/factory.py +0 -9
  25. waldiez/exporting/flow/file_generator.py +6 -0
  26. waldiez/exporting/flow/orchestrator.py +27 -21
  27. waldiez/exporting/flow/utils/__init__.py +0 -2
  28. waldiez/exporting/flow/utils/common.py +15 -96
  29. waldiez/exporting/flow/utils/importing.py +4 -0
  30. waldiez/io/mqtt.py +33 -14
  31. waldiez/io/redis.py +18 -13
  32. waldiez/io/structured.py +9 -4
  33. waldiez/io/utils.py +32 -0
  34. waldiez/io/ws.py +8 -2
  35. waldiez/models/__init__.py +6 -0
  36. waldiez/models/agents/__init__.py +8 -0
  37. waldiez/models/agents/agent/agent.py +136 -38
  38. waldiez/models/agents/agent/agent_type.py +3 -2
  39. waldiez/models/agents/agents.py +10 -0
  40. waldiez/models/agents/doc_agent/__init__.py +13 -0
  41. waldiez/models/agents/doc_agent/doc_agent.py +126 -0
  42. waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
  43. waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
  44. waldiez/models/flow/flow.py +13 -2
  45. waldiez/models/model/__init__.py +2 -2
  46. waldiez/models/model/_aws.py +75 -0
  47. waldiez/models/model/_llm.py +516 -0
  48. waldiez/models/model/_price.py +30 -0
  49. waldiez/models/model/model.py +45 -2
  50. waldiez/models/model/model_data.py +2 -83
  51. waldiez/models/tool/predefined/_duckduckgo.py +123 -0
  52. waldiez/models/tool/predefined/_google.py +31 -9
  53. waldiez/models/tool/predefined/_perplexity.py +161 -0
  54. waldiez/models/tool/predefined/_searxng.py +152 -0
  55. waldiez/models/tool/predefined/_tavily.py +46 -9
  56. waldiez/models/tool/predefined/_wikipedia.py +26 -6
  57. waldiez/models/tool/predefined/_youtube.py +36 -8
  58. waldiez/models/tool/predefined/registry.py +6 -0
  59. waldiez/models/waldiez.py +12 -0
  60. waldiez/runner.py +177 -408
  61. waldiez/running/__init__.py +2 -4
  62. waldiez/running/base_runner.py +100 -112
  63. waldiez/running/environment.py +29 -4
  64. waldiez/running/post_run.py +0 -1
  65. waldiez/running/protocol.py +36 -48
  66. waldiez/running/run_results.py +5 -5
  67. waldiez/running/standard_runner.py +429 -0
  68. waldiez/running/timeline_processor.py +0 -82
  69. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/METADATA +59 -62
  70. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/RECORD +74 -64
  71. waldiez/running/import_runner.py +0 -437
  72. waldiez/running/subprocess_runner.py +0 -104
  73. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/WHEEL +0 -0
  74. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/entry_points.txt +0 -0
  75. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/LICENSE +0 -0
  76. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/NOTICE.md +0 -0
waldiez/runner.py CHANGED
@@ -14,285 +14,179 @@ 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
- WaldiezImportRunner,
23
- WaldiezSubprocessRunner,
24
+ WaldiezStandardRunner,
24
25
  )
25
26
 
26
27
  if TYPE_CHECKING:
27
- from autogen import ChatResult # type: ignore
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
- _implementation: WaldiezBaseRunner
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
- isolated: bool = False,
42
- threaded: bool = False,
43
- skip_patch_io: bool = True,
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
- The path to the output directory where the results will be stored.
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
- The root directory for uploads. If None, the default uploads
56
- directory will be used.
116
+ Uploads root directory, by default None
57
117
  structured_io : bool, optional
58
- If True, the flow will use
59
- structured IO instead of the default 'input/print'.
60
- isolated : bool, optional
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
- super().__init__(
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
- isolated=isolated,
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
131
 
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
-
122
- Parameters
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
- WaldiezBaseRunner
158
- The runner instance that will execute the flow.
159
- """
160
- waldiez = Waldiez.load(
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
- )
176
-
177
- def _before_run(
178
- self,
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.
137
+ str
138
+ A string representation of the WaldiezRunner instance.
190
139
  """
191
- return self._implementation._before_run(
192
- output_file=output_file,
193
- uploads_root=uploads_root,
194
- )
140
+ return f"WaldiezRunner({type(self._runner).__name__})"
195
141
 
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
- output_file : str | Path
206
- The output file.
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
- Path
213
- The path to the temporary directory created for the run.
152
+ Any
153
+ The value of the attribute from the underlying runner.
214
154
  """
215
- return await self._implementation._a_before_run(
216
- output_file, uploads_root
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 = False,
225
- skip_timeline: bool = False,
164
+ skip_mmd: bool,
165
+ skip_timeline: bool,
166
+ **kwargs: Any,
226
167
  ) -> Union[
227
- "ChatResult",
228
- list["ChatResult"],
229
- dict[int, "ChatResult"],
168
+ list["RunResponseProtocol"],
169
+ list["AsyncRunResponseProtocol"],
230
170
  ]:
231
- """Run the flow.
232
-
233
- Parameters
234
- ----------
235
- temp_dir : Path
236
- The path to the temporary directory created for the run.
237
- output_file : Path
238
- The output file.
239
- uploads_root : Path | None
240
- The runtime uploads root.
241
- skip_mmd : bool
242
- Whether to skip generating the mermaid diagram.
243
- skip_timeline : bool
244
- Whether to skip generating the timeline JSON.
245
-
246
- Returns
247
- -------
248
- ChatResult | list[ChatResult] | dict[int, ChatResult]
249
- The result of the run, which can be a single ChatResult,
250
- a list of ChatResults,
251
- or a dictionary mapping indices to ChatResults.
252
- """
253
- return self._implementation._run(
171
+ return self._runner._run(
254
172
  temp_dir=temp_dir,
255
173
  output_file=output_file,
256
174
  uploads_root=uploads_root,
257
175
  skip_mmd=skip_mmd,
258
176
  skip_timeline=skip_timeline,
177
+ **kwargs,
259
178
  )
260
179
 
261
- async def _a_run(
180
+ def _start(
262
181
  self,
263
182
  temp_dir: Path,
264
183
  output_file: Path,
265
184
  uploads_root: Path | None,
266
185
  skip_mmd: bool,
267
186
  skip_timeline: bool,
268
- ) -> Union[
269
- "ChatResult",
270
- list["ChatResult"],
271
- dict[int, "ChatResult"],
272
- ]: # pyright: ignore
273
- """Asynchronously run the flow.
274
-
275
- Parameters
276
- ----------
277
- temp_dir : Path
278
- The path to the temporary directory created for the run.
279
- output_file : Path
280
- The output file.
281
- uploads_root : Path | None
282
- The runtime uploads root.
283
- skip_mmd : bool
284
- Whether to skip generating the mermaid diagram.
285
- skip_timeline : bool
286
- Whether to skip generating the timeline JSON.
287
-
288
- Returns
289
- -------
290
- Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
291
- The result of the run, which can be a single ChatResult,
292
- a list of ChatResults,
293
- or a dictionary mapping indices to ChatResults.
294
- """
295
- return await self._implementation._a_run(
187
+ ) -> None:
188
+ """Start the workflow in a non-blocking way."""
189
+ self._runner._start(
296
190
  temp_dir=temp_dir,
297
191
  output_file=output_file,
298
192
  uploads_root=uploads_root,
@@ -300,126 +194,28 @@ class WaldiezRunner(WaldiezBaseRunner):
300
194
  skip_timeline=skip_timeline,
301
195
  )
302
196
 
303
- def _after_run(
304
- self,
305
- results: Union[
306
- "ChatResult",
307
- list["ChatResult"],
308
- dict[int, "ChatResult"],
309
- ],
310
- output_file: Path,
311
- uploads_root: Path | None,
312
- temp_dir: Path,
313
- skip_mmd: bool,
314
- skip_timeline: bool,
315
- ) -> None:
316
- """Actions to perform after running the flow.
317
-
318
- Parameters
319
- ----------
320
- results : Union[ChatResult, list[ChatResult], dict[int, ChatResult]]
321
- The results of the run, which can be a single ChatResult,
322
- a list of ChatResults,
323
- or a dictionary mapping indices to ChatResults.
324
- output_file : Path
325
- The path to the output file.
326
- uploads_root : Path | None
327
- The runtime uploads root.
328
- structured_io : bool
329
- Whether to use structured IO instead of the default 'input/print'.
330
- temp_dir : Path
331
- The path to the temporary directory created for the run.
332
- skip_mmd : bool
333
- Whether to skip generating the mermaid diagram.
334
- skip_timeline : bool
335
- Whether to skip generating the timeline JSON.
336
- """
337
- self._implementation._after_run(
338
- results,
339
- output_file,
340
- uploads_root,
341
- temp_dir,
342
- skip_mmd=skip_mmd,
343
- skip_timeline=skip_timeline,
344
- )
197
+ def _stop(self) -> None:
198
+ self._runner._stop()
345
199
 
346
- async def _a_after_run(
200
+ async def _a_run(
347
201
  self,
348
- results: Union[
349
- "ChatResult",
350
- list["ChatResult"],
351
- dict[int, "ChatResult"],
352
- ],
202
+ temp_dir: Path,
353
203
  output_file: Path,
354
204
  uploads_root: Path | None,
355
- temp_dir: Path,
356
205
  skip_mmd: bool,
357
206
  skip_timeline: bool,
358
- ) -> None:
359
- """Asynchronously perform actions after running the flow.
360
-
361
- Parameters
362
- ----------
363
- output_file : Path
364
- The path to the output file.
365
- uploads_root : Path | None
366
- The runtime uploads root.
367
- structured_io : bool
368
- Whether to use structured IO instead of the default 'input/print'.
369
- temp_dir : Path
370
- The path to the temporary directory created for the run.
371
- skip_mmd : bool
372
- Whether to skip generating the mermaid diagram.
373
- skip_timeline : bool
374
- Whether to skip generating the timeline JSON.
375
- """
376
- await self._implementation._a_after_run(
377
- results,
378
- output_file,
379
- uploads_root,
380
- temp_dir,
381
- skip_mmd=skip_mmd,
382
- skip_timeline=skip_timeline,
383
- )
384
-
385
- def start(
386
- self,
387
- output_path: str | Path | None,
388
- uploads_root: str | Path | None,
389
- structured_io: bool | None = None,
390
- skip_patch_io: bool | None = None,
391
- skip_mmd: bool = False,
392
- skip_timeline: bool = False,
393
- ) -> None:
394
- """Start the flow.
395
-
396
- Parameters
397
- ----------
398
- output_path : str | Path | None
399
- The output path, by default None.
400
- uploads_root : str | Path | None
401
- The runtime uploads root.
402
- structured_io : bool | None
403
- Whether to use structured IO instead of the default 'input/print'.
404
- If None, it will use the value from the context.
405
- skip_patch_io : bool | None = None
406
- Whether to skip patching I/O, by default None.
407
- If None, it will use the value from the context.
408
- skip_mmd : bool = False
409
- Whether to skip generating the mermaid diagram.
410
- skip_timeline : bool = False
411
- Whether to skip generating the timeline JSON.
412
- """
413
- self._implementation.start(
414
- output_path=output_path,
207
+ **kwargs: Any,
208
+ ) -> Union[list["RunResponseProtocol"], list["AsyncRunResponseProtocol"]]:
209
+ return await self._runner._a_run(
210
+ temp_dir=temp_dir,
211
+ output_file=output_file,
415
212
  uploads_root=uploads_root,
416
- structured_io=structured_io,
417
- skip_patch_io=skip_patch_io,
418
213
  skip_mmd=skip_mmd,
419
214
  skip_timeline=skip_timeline,
215
+ **kwargs,
420
216
  )
421
217
 
422
- def _start(
218
+ async def _a_start(
423
219
  self,
424
220
  temp_dir: Path,
425
221
  output_file: Path,
@@ -427,20 +223,7 @@ class WaldiezRunner(WaldiezBaseRunner):
427
223
  skip_mmd: bool,
428
224
  skip_timeline: bool,
429
225
  ) -> None:
430
- """Start the flow.
431
-
432
- Parameters
433
- ----------
434
- output_file : Path
435
- The output file.
436
- uploads_root : Path | None
437
- The runtime uploads root.
438
- skip_mmd : bool
439
- Whether to skip generating the mermaid diagram.
440
- skip_timeline : bool
441
- Whether to skip generating the timeline JSON.
442
- """
443
- self._implementation._start(
226
+ return await self._runner._a_start(
444
227
  temp_dir=temp_dir,
445
228
  output_file=output_file,
446
229
  uploads_root=uploads_root,
@@ -448,82 +231,68 @@ class WaldiezRunner(WaldiezBaseRunner):
448
231
  skip_timeline=skip_timeline,
449
232
  )
450
233
 
451
- async def a_start(
452
- self,
453
- output_path: str | Path | None,
454
- uploads_root: str | Path | None,
455
- structured_io: bool | None = None,
456
- skip_patch_io: bool | None = None,
457
- skip_mmd: bool = False,
458
- skip_timeline: bool = False,
459
- ) -> None:
460
- """Asynchronously start the flow.
234
+ async def _a_stop(self) -> None:
235
+ return await self._runner._a_stop()
236
+
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.
461
251
 
462
252
  Parameters
463
253
  ----------
464
- output_path : str | Path | None
465
- The output path, by default None.
466
- uploads_root : str | Path | None
467
- The runtime uploads root.
468
- structured_io : bool | None
469
- Whether to use structured IO instead of the default 'input/print'.
470
- skip_patch_io : bool | None = None
471
- Whether to skip patching I/O, by default None.
472
- skip_mmd : bool = False
473
- Whether to skip generating the mermaid diagram, by default False.
474
- skip_timeline : bool = False
475
- Whether to skip generating the timeline JSON, by default False.
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
272
+
273
+ Returns
274
+ -------
275
+ WaldiezRunner
276
+ The configured runner instance
476
277
  """
477
- await self._implementation.a_start(
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,
478
294
  output_path=output_path,
479
295
  uploads_root=uploads_root,
480
296
  structured_io=structured_io,
481
- skip_patch_io=skip_patch_io,
482
- skip_mmd=skip_mmd,
483
- skip_timeline=skip_timeline,
297
+ **kwargs,
484
298
  )
485
-
486
- async def _a_start(
487
- self,
488
- temp_dir: Path,
489
- output_file: Path,
490
- uploads_root: Path | None,
491
- skip_mmd: bool,
492
- skip_timeline: bool = False,
493
- ) -> None:
494
- """Asynchronously start the flow.
495
-
496
- Parameters
497
- ----------
498
- temp_dir : Path
499
- The path to the temporary directory created for the run.
500
- output_file : Path
501
- The output file.
502
- uploads_root : Path | None
503
- The runtime uploads root.
504
- skip_mmd : bool
505
- Whether to skip generating the mermaid diagram.
506
- skip_timeline : bool, optional
507
- Whether to skip generating the timeline JSON, by default False.
508
- """
509
- await self._implementation._a_start(
510
- temp_dir=temp_dir,
511
- output_file=output_file,
512
- uploads_root=uploads_root,
513
- skip_mmd=skip_mmd,
514
- skip_timeline=skip_timeline,
515
- )
516
-
517
- def _stop(self) -> None:
518
- """Actions to perform when stopping the flow.
519
-
520
- This method should be overridden in subclasses if needed.
521
- """
522
- self._implementation._stop()
523
-
524
- async def _a_stop(self) -> None:
525
- """Asynchronously perform actions when stopping the flow.
526
-
527
- This method should be overridden in subclasses if needed.
528
- """
529
- await self._implementation._a_stop()