waldiez 0.6.0__py3-none-any.whl → 0.6.1__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 (188) hide show
  1. waldiez/__init__.py +1 -1
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +18 -7
  4. waldiez/cli_extras/jupyter.py +3 -0
  5. waldiez/cli_extras/runner.py +3 -1
  6. waldiez/cli_extras/studio.py +3 -1
  7. waldiez/exporter.py +9 -3
  8. waldiez/exporting/agent/exporter.py +9 -10
  9. waldiez/exporting/agent/extras/captain_agent_extras.py +6 -6
  10. waldiez/exporting/agent/extras/doc_agent_extras.py +6 -6
  11. waldiez/exporting/agent/extras/group_manager_agent_extas.py +34 -23
  12. waldiez/exporting/agent/extras/group_member_extras.py +6 -5
  13. waldiez/exporting/agent/extras/handoffs/after_work.py +1 -1
  14. waldiez/exporting/agent/extras/handoffs/available.py +1 -1
  15. waldiez/exporting/agent/extras/handoffs/condition.py +3 -2
  16. waldiez/exporting/agent/extras/handoffs/handoff.py +1 -1
  17. waldiez/exporting/agent/extras/handoffs/target.py +6 -4
  18. waldiez/exporting/agent/extras/rag/chroma_extras.py +27 -19
  19. waldiez/exporting/agent/extras/rag/mongo_extras.py +8 -8
  20. waldiez/exporting/agent/extras/rag/pgvector_extras.py +5 -5
  21. waldiez/exporting/agent/extras/rag/qdrant_extras.py +5 -4
  22. waldiez/exporting/agent/extras/rag/vector_db_extras.py +1 -1
  23. waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +5 -7
  24. waldiez/exporting/agent/extras/reasoning_agent_extras.py +3 -5
  25. waldiez/exporting/chats/exporter.py +4 -4
  26. waldiez/exporting/chats/processor.py +1 -2
  27. waldiez/exporting/chats/utils/common.py +89 -48
  28. waldiez/exporting/chats/utils/group.py +9 -9
  29. waldiez/exporting/chats/utils/nested.py +7 -7
  30. waldiez/exporting/chats/utils/sequential.py +1 -1
  31. waldiez/exporting/chats/utils/single.py +2 -2
  32. waldiez/exporting/core/content.py +7 -7
  33. waldiez/exporting/core/context.py +5 -3
  34. waldiez/exporting/core/exporter.py +5 -3
  35. waldiez/exporting/core/exporters.py +2 -2
  36. waldiez/exporting/core/extras/agent_extras/captain_extras.py +2 -2
  37. waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +2 -2
  38. waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +2 -2
  39. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -8
  40. waldiez/exporting/core/extras/base.py +7 -5
  41. waldiez/exporting/core/extras/flow_extras.py +4 -5
  42. waldiez/exporting/core/extras/model_extras.py +2 -2
  43. waldiez/exporting/core/extras/path_resolver.py +1 -2
  44. waldiez/exporting/core/extras/serializer.py +2 -2
  45. waldiez/exporting/core/protocols.py +6 -5
  46. waldiez/exporting/core/result.py +25 -28
  47. waldiez/exporting/core/types.py +10 -10
  48. waldiez/exporting/core/utils/llm_config.py +2 -2
  49. waldiez/exporting/core/validation.py +10 -11
  50. waldiez/exporting/flow/execution_generator.py +98 -10
  51. waldiez/exporting/flow/exporter.py +2 -2
  52. waldiez/exporting/flow/factory.py +2 -2
  53. waldiez/exporting/flow/file_generator.py +4 -2
  54. waldiez/exporting/flow/merger.py +5 -3
  55. waldiez/exporting/flow/orchestrator.py +72 -2
  56. waldiez/exporting/flow/utils/common.py +5 -5
  57. waldiez/exporting/flow/utils/importing.py +6 -7
  58. waldiez/exporting/flow/utils/linting.py +25 -9
  59. waldiez/exporting/flow/utils/logging.py +2 -2
  60. waldiez/exporting/models/exporter.py +8 -8
  61. waldiez/exporting/models/processor.py +5 -5
  62. waldiez/exporting/tools/exporter.py +2 -2
  63. waldiez/exporting/tools/processor.py +7 -4
  64. waldiez/io/__init__.py +8 -4
  65. waldiez/io/_ws.py +10 -6
  66. waldiez/io/models/constants.py +10 -10
  67. waldiez/io/models/content/audio.py +1 -0
  68. waldiez/io/models/content/base.py +20 -18
  69. waldiez/io/models/content/file.py +1 -0
  70. waldiez/io/models/content/image.py +1 -0
  71. waldiez/io/models/content/text.py +1 -0
  72. waldiez/io/models/content/video.py +1 -0
  73. waldiez/io/models/user_input.py +10 -5
  74. waldiez/io/models/user_response.py +17 -16
  75. waldiez/io/mqtt.py +18 -31
  76. waldiez/io/redis.py +18 -22
  77. waldiez/io/structured.py +52 -53
  78. waldiez/io/utils.py +3 -0
  79. waldiez/io/ws.py +5 -1
  80. waldiez/logger.py +16 -3
  81. waldiez/models/agents/__init__.py +3 -0
  82. waldiez/models/agents/agent/agent.py +23 -16
  83. waldiez/models/agents/agent/agent_data.py +25 -22
  84. waldiez/models/agents/agent/code_execution.py +9 -11
  85. waldiez/models/agents/agent/termination_message.py +10 -12
  86. waldiez/models/agents/agent/update_system_message.py +2 -4
  87. waldiez/models/agents/agents.py +8 -8
  88. waldiez/models/agents/assistant/assistant.py +6 -3
  89. waldiez/models/agents/assistant/assistant_data.py +2 -2
  90. waldiez/models/agents/captain/captain_agent.py +7 -4
  91. waldiez/models/agents/captain/captain_agent_data.py +5 -7
  92. waldiez/models/agents/doc_agent/doc_agent.py +7 -4
  93. waldiez/models/agents/doc_agent/doc_agent_data.py +9 -10
  94. waldiez/models/agents/doc_agent/rag_query_engine.py +10 -12
  95. waldiez/models/agents/extra_requirements.py +3 -3
  96. waldiez/models/agents/group_manager/group_manager.py +12 -7
  97. waldiez/models/agents/group_manager/group_manager_data.py +13 -12
  98. waldiez/models/agents/group_manager/speakers.py +17 -19
  99. waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +7 -4
  100. waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +4 -1
  101. waldiez/models/agents/rag_user_proxy/retrieve_config.py +69 -63
  102. waldiez/models/agents/rag_user_proxy/vector_db_config.py +19 -19
  103. waldiez/models/agents/reasoning/reasoning_agent.py +7 -4
  104. waldiez/models/agents/reasoning/reasoning_agent_data.py +3 -2
  105. waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +8 -8
  106. waldiez/models/agents/user_proxy/user_proxy.py +6 -3
  107. waldiez/models/agents/user_proxy/user_proxy_data.py +1 -1
  108. waldiez/models/chat/chat.py +27 -20
  109. waldiez/models/chat/chat_data.py +22 -19
  110. waldiez/models/chat/chat_message.py +9 -9
  111. waldiez/models/chat/chat_nested.py +9 -9
  112. waldiez/models/chat/chat_summary.py +6 -6
  113. waldiez/models/common/__init__.py +2 -0
  114. waldiez/models/common/ag2_version.py +2 -0
  115. waldiez/models/common/dict_utils.py +8 -6
  116. waldiez/models/common/handoff.py +18 -17
  117. waldiez/models/common/method_utils.py +7 -7
  118. waldiez/models/common/naming.py +49 -0
  119. waldiez/models/flow/flow.py +11 -6
  120. waldiez/models/flow/flow_data.py +23 -17
  121. waldiez/models/flow/info.py +3 -3
  122. waldiez/models/flow/naming.py +2 -1
  123. waldiez/models/model/_aws.py +11 -13
  124. waldiez/models/model/_llm.py +5 -0
  125. waldiez/models/model/_price.py +2 -4
  126. waldiez/models/model/extra_requirements.py +1 -3
  127. waldiez/models/model/model.py +2 -2
  128. waldiez/models/model/model_data.py +21 -21
  129. waldiez/models/tool/extra_requirements.py +2 -4
  130. waldiez/models/tool/predefined/_duckduckgo.py +1 -0
  131. waldiez/models/tool/predefined/_email.py +1 -0
  132. waldiez/models/tool/predefined/_google.py +1 -0
  133. waldiez/models/tool/predefined/_perplexity.py +1 -0
  134. waldiez/models/tool/predefined/_searxng.py +1 -0
  135. waldiez/models/tool/predefined/_tavily.py +1 -0
  136. waldiez/models/tool/predefined/_wikipedia.py +1 -0
  137. waldiez/models/tool/predefined/_youtube.py +1 -0
  138. waldiez/models/tool/tool.py +8 -5
  139. waldiez/models/tool/tool_data.py +2 -2
  140. waldiez/models/waldiez.py +152 -4
  141. waldiez/runner.py +11 -5
  142. waldiez/running/async_utils.py +192 -0
  143. waldiez/running/base_runner.py +117 -264
  144. waldiez/running/dir_utils.py +52 -0
  145. waldiez/running/environment.py +10 -44
  146. waldiez/running/events_mixin.py +252 -0
  147. waldiez/running/exceptions.py +20 -0
  148. waldiez/running/gen_seq_diagram.py +18 -15
  149. waldiez/running/io_utils.py +216 -0
  150. waldiez/running/protocol.py +11 -5
  151. waldiez/running/requirements_mixin.py +65 -0
  152. waldiez/running/results_mixin.py +926 -0
  153. waldiez/running/standard_runner.py +22 -25
  154. waldiez/running/step_by_step/breakpoints_mixin.py +192 -60
  155. waldiez/running/step_by_step/command_handler.py +3 -0
  156. waldiez/running/step_by_step/events_processor.py +194 -14
  157. waldiez/running/step_by_step/step_by_step_models.py +110 -43
  158. waldiez/running/step_by_step/step_by_step_runner.py +107 -57
  159. waldiez/running/subprocess_runner/__base__.py +9 -1
  160. waldiez/running/subprocess_runner/_async_runner.py +5 -3
  161. waldiez/running/subprocess_runner/_sync_runner.py +6 -2
  162. waldiez/running/subprocess_runner/runner.py +39 -23
  163. waldiez/running/timeline_processor.py +1 -1
  164. waldiez/utils/__init__.py +2 -0
  165. waldiez/utils/conflict_checker.py +4 -4
  166. waldiez/utils/python_manager.py +415 -0
  167. waldiez/ws/_file_handler.py +18 -18
  168. waldiez/ws/_mock.py +2 -1
  169. waldiez/ws/cli.py +36 -12
  170. waldiez/ws/client_manager.py +35 -27
  171. waldiez/ws/errors.py +3 -0
  172. waldiez/ws/models.py +43 -52
  173. waldiez/ws/reloader.py +12 -4
  174. waldiez/ws/server.py +85 -55
  175. waldiez/ws/session_manager.py +8 -9
  176. waldiez/ws/session_stats.py +1 -1
  177. waldiez/ws/utils.py +4 -1
  178. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/METADATA +82 -93
  179. waldiez-0.6.1.dist-info/RECORD +254 -0
  180. waldiez/running/post_run.py +0 -186
  181. waldiez/running/pre_run.py +0 -281
  182. waldiez/running/run_results.py +0 -14
  183. waldiez/running/utils.py +0 -625
  184. waldiez-0.6.0.dist-info/RECORD +0 -251
  185. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/WHEEL +0 -0
  186. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/entry_points.txt +0 -0
  187. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/licenses/LICENSE +0 -0
  188. {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/licenses/NOTICE.md +0 -0
waldiez/__init__.py CHANGED
@@ -9,7 +9,7 @@ from .utils import check_conflicts
9
9
 
10
10
  # flake8: noqa: F401
11
11
  # pylint: disable=import-error,line-too-long
12
- # pyright: reportMissingImports=false
12
+ # pyright: reportMissingImports=false,reportUnknownVariableType=false
13
13
  try:
14
14
  # noqa: I001
15
15
  from ._version import __version__ # type: ignore[unused-ignore, unused-import, import-not-found, import-untyped] # noqa
waldiez/_version.py CHANGED
@@ -5,4 +5,4 @@
5
5
  This file is automatically generated by Hatchling.
6
6
  Do not edit this file directly.
7
7
  """
8
- __version__ = VERSION = "0.6.0"
8
+ __version__ = VERSION = "0.6.1"
waldiez/cli.py CHANGED
@@ -3,13 +3,15 @@
3
3
  # flake8: noqa: E501
4
4
  # pylint: disable=missing-function-docstring, missing-param-doc, missing-raises-doc
5
5
  # pylint: disable=line-too-long, import-outside-toplevel
6
+ # pyright: reportUnknownArgumentType=false,reportCallInDefaultInitializer=false
7
+ # pyright: reportUnusedCallResult=false,reportAny=false
6
8
  """Command line interface to convert or run a waldiez file."""
7
9
 
8
10
  import json
9
11
  import os
10
12
  import sys
11
13
  from pathlib import Path
12
- from typing import TYPE_CHECKING, Literal, Optional
14
+ from typing import TYPE_CHECKING, Literal
13
15
 
14
16
  import anyio
15
17
  import typer
@@ -81,7 +83,7 @@ def run(
81
83
  resolve_path=True,
82
84
  ),
83
85
  ],
84
- output: Optional[Path] = typer.Option( # noqa: B008
86
+ output: Path | None = typer.Option( # noqa: B008
85
87
  None,
86
88
  help=(
87
89
  "Path to the output (.py) file. "
@@ -91,7 +93,7 @@ def run(
91
93
  dir_okay=False,
92
94
  resolve_path=True,
93
95
  ),
94
- uploads_root: Optional[Path] = typer.Option( # noqa: B008
96
+ uploads_root: Path | None = typer.Option( # noqa: B008
95
97
  None,
96
98
  help=(
97
99
  "Path to the uploads root directory. "
@@ -104,15 +106,15 @@ def run(
104
106
  structured: bool = typer.Option( # noqa: B008
105
107
  False,
106
108
  help=(
107
- "If set, the output will be structured as a directory with "
108
- "the flow file and any additional generated files in it."
109
+ "If set, structured messages will be used for I/O when "
110
+ "using print and/or input"
109
111
  ),
110
112
  ),
111
113
  force: bool = typer.Option( # noqa: B008
112
114
  False,
113
115
  help="Override the output file if it already exists.",
114
116
  ),
115
- env_file: Optional[Path] = typer.Option( # noqa: B008
117
+ env_file: Path | None = typer.Option( # noqa: B008
116
118
  None,
117
119
  "--env-file",
118
120
  "-e",
@@ -136,6 +138,14 @@ def run(
136
138
  is_eager=True,
137
139
  rich_help_panel="Debug",
138
140
  ),
141
+ breakpoints: list[str] = typer.Option( # noqa: B008
142
+ ...,
143
+ "--breakpoints",
144
+ "-b",
145
+ default_factory=list,
146
+ help="Optional list with initial breakpoints (if using step mode).",
147
+ rich_help_panel="Debug",
148
+ ),
139
149
  subprocess: bool = typer.Option(
140
150
  False,
141
151
  "--subprocess",
@@ -171,6 +181,7 @@ def run(
171
181
  dot_env=env_file,
172
182
  subprocess_mode=subprocess_mode,
173
183
  waldiez_file=file,
184
+ breakpoints=breakpoints,
174
185
  )
175
186
  except FileNotFoundError as error:
176
187
  typer.echo(f"File not found: {file}")
@@ -271,7 +282,7 @@ def check(
271
282
  LOG.success("Waldiez flow seems valid.")
272
283
 
273
284
 
274
- def _get_output_path(output: Optional[Path], force: bool) -> Optional[Path]:
285
+ def _get_output_path(output: Path | None, force: bool) -> Path | None:
275
286
  if output is not None:
276
287
  output = Path(output).resolve()
277
288
  if output is not None and not output.parent.exists():
@@ -2,6 +2,9 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: skip-file
4
4
  # isort: skip_file
5
+ # pyright: reportMissingImports=false,reportUnusedImport=false
6
+ # pyright: reportCallInDefaultInitializer=false,reportPrivateImportUsage=false
7
+ # pyright: reportUnknownVariableType=false
5
8
  # flake8: noqa: E501
6
9
  """Waldiez-jupyter extra typer commands for CLI."""
7
10
 
@@ -3,6 +3,8 @@
3
3
  # pylint: skip-file
4
4
  # isort: skip_file
5
5
  # flake8: noqa: E501,E402
6
+ # pyright: reportMissingImports=false,reportUnusedImport=false
7
+ # pyright: reportUnknownVariableType=false
6
8
  """Waldiez-runner extra typer commands for CLI."""
7
9
 
8
10
  from typing import Any, Callable
@@ -18,7 +20,7 @@ runner_app: Callable[..., Any] | None = None
18
20
  try:
19
21
  from waldiez_runner.cli import run # type: ignore[unused-ignore, import-not-found, import-untyped]
20
22
 
21
- runner_app = run # pyright: ignore
23
+ runner_app = run
22
24
 
23
25
  _have_runner = True
24
26
  except BaseException:
@@ -3,6 +3,8 @@
3
3
  # pylint: skip-file
4
4
  # isort: skip_file
5
5
  # flake8: noqa: E501,E402
6
+ # pyright: reportMissingImports=false,reportUnusedImport=false
7
+ # pyright: reportUnknownVariableType=false
6
8
  """Waldiez-studio extra typer commands for CLI."""
7
9
 
8
10
  from typing import Any, Callable
@@ -18,7 +20,7 @@ studio_app: Callable[..., Any] | None = None
18
20
  try:
19
21
  from waldiez_studio.cli import run # type: ignore[unused-ignore, import-not-found, import-untyped]
20
22
 
21
- studio_app = run # pyright: ignore
23
+ studio_app = run
22
24
 
23
25
  _have_studio = True
24
26
  except BaseException:
waldiez/exporter.py CHANGED
@@ -1,5 +1,9 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportMissingTypeStubs=false,reportUnknownMemberType=false
5
+ # pyright: reportUnknownVariableType=false,reportAny=false
6
+ # pyright: reportUnusedCallResult=false
3
7
  """
4
8
  Waldiez exporter class.
5
9
 
@@ -29,7 +33,8 @@ class WaldiezExporter:
29
33
  waldiez (Waldiez): The Waldiez instance.
30
34
  """
31
35
 
32
- flow_extras: FlowExtras
36
+ flow_extras: FlowExtras | None
37
+ waldiez: Waldiez
33
38
 
34
39
  def __init__(self, waldiez: Waldiez) -> None:
35
40
  """Initialize the Waldiez exporter.
@@ -40,6 +45,7 @@ class WaldiezExporter:
40
45
  The Waldiez instance.
41
46
  """
42
47
  self.waldiez = waldiez
48
+ self.flow_extras = None
43
49
 
44
50
  @classmethod
45
51
  def load(cls, file_path: Path) -> "WaldiezExporter":
@@ -173,13 +179,13 @@ class WaldiezExporter:
173
179
  cell_metadata_filter="-all",
174
180
  )
175
181
  with open(py_path, "r", encoding="utf-8") as py_out:
176
- jp_content = jupytext.read( # pyright: ignore
182
+ jp_content = jupytext.read(
177
183
  py_out,
178
184
  fmt="py:percent",
179
185
  config=config,
180
186
  )
181
187
  ipynb_path = str(py_path).replace(".tmp.py", ".tmp.ipynb")
182
- jupytext.write( # pyright: ignore
188
+ jupytext.write(
183
189
  jp_content,
184
190
  ipynb_path,
185
191
  fmt="ipynb",
@@ -2,10 +2,11 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=too-many-arguments,too-many-positional-arguments
4
4
  # pylint: disable=too-many-return-statements,too-many-instance-attributes
5
+ # pyright: reportUnusedParameter=false
5
6
  """Export agents."""
6
7
 
7
8
  from pathlib import Path
8
- from typing import Any, Callable, Optional, Union
9
+ from typing import Any, Callable
9
10
 
10
11
  from waldiez.models import (
11
12
  WaldiezAgent,
@@ -45,14 +46,12 @@ class AgentExporter(Exporter[StandardExtras]):
45
46
  tool_names: dict[str, str],
46
47
  is_async: bool = False,
47
48
  for_notebook: bool = False,
48
- cache_seed: Optional[int] = None,
49
- initial_chats: Optional[list[WaldiezAgentConnection]] = None,
50
- group_chat_members: Optional[list[WaldiezAgent]] = None,
51
- arguments_resolver: Optional[
52
- Callable[[WaldiezAgent], list[str]]
53
- ] = None,
54
- output_dir: Optional[Union[str, Path]] = None,
55
- context: Optional[ExporterContext] = None,
49
+ cache_seed: int | None = None,
50
+ initial_chats: list[WaldiezAgentConnection] | None = None,
51
+ group_chat_members: list[WaldiezAgent] | None = None,
52
+ arguments_resolver: Callable[[WaldiezAgent], list[str]] | None = None,
53
+ output_dir: str | Path | None = None,
54
+ context: ExporterContext | None = None,
56
55
  **kwargs: Any,
57
56
  ):
58
57
  """Initialize the agent exporter.
@@ -336,7 +335,7 @@ class AgentExporter(Exporter[StandardExtras]):
336
335
 
337
336
  return reason_extras
338
337
 
339
- def generate_main_content(self) -> Optional[str]:
338
+ def generate_main_content(self) -> str | None:
340
339
  """Generate the main agent definition.
341
340
 
342
341
  Returns
@@ -10,7 +10,7 @@ import os
10
10
  import uuid
11
11
  from datetime import datetime, timezone
12
12
  from pathlib import Path
13
- from typing import Any, Optional
13
+ from typing import Any
14
14
 
15
15
  from waldiez.models import (
16
16
  WaldiezAgent,
@@ -37,8 +37,8 @@ class CaptainAgentProcessor:
37
37
  agent: WaldiezAgent,
38
38
  agent_names: dict[str, str],
39
39
  all_models: list[WaldiezModel],
40
- serializer: Optional[Serializer] = None,
41
- output_dir: Optional[Path] = None,
40
+ serializer: Serializer | None = None,
41
+ output_dir: Path | None = None,
42
42
  ):
43
43
  self.agent = agent
44
44
  self.agent_names = agent_names
@@ -48,9 +48,9 @@ class CaptainAgentProcessor:
48
48
 
49
49
  def process(
50
50
  self,
51
- code_execution_config: Optional[CodeExecutionConfig] = None,
52
- termination_config: Optional[TerminationConfig] = None,
53
- system_message_config: Optional[SystemMessageConfig] = None,
51
+ code_execution_config: CodeExecutionConfig | None = None,
52
+ termination_config: TerminationConfig | None = None,
53
+ system_message_config: SystemMessageConfig | None = None,
54
54
  ) -> CaptainExtras:
55
55
  """Process group manager and return extras.
56
56
 
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=too-few-public-methods,no-self-use
4
+ # pyright: reportUninitializedInstanceVariable=false
4
5
 
5
6
  # before agent: query engine initialization
6
7
  # agent extra args:
@@ -13,7 +14,6 @@
13
14
  # import shutil
14
15
  import shutil
15
16
  from pathlib import Path
16
- from typing import Optional
17
17
 
18
18
  from waldiez.exporting.core.extras.path_resolver import DefaultPathResolver
19
19
  from waldiez.exporting.core.protocols import PathResolver
@@ -49,10 +49,10 @@ class DocAgentProcessor:
49
49
  agent_names: dict[str, str],
50
50
  model_names: dict[str, str],
51
51
  all_models: list[WaldiezModel],
52
- cache_seed: Optional[int] = None,
52
+ cache_seed: int | None = None,
53
53
  serializer: Serializer | None = None,
54
54
  path_resolver: PathResolver | None = None,
55
- output_dir: Optional[Path] = None,
55
+ output_dir: Path | None = None,
56
56
  ):
57
57
  self.agent = agent
58
58
  self.agent_name = agent_names.get(agent.id, agent.name)
@@ -65,9 +65,9 @@ class DocAgentProcessor:
65
65
 
66
66
  def process(
67
67
  self,
68
- code_execution_config: Optional[CodeExecutionConfig] = None,
69
- termination_config: Optional[TerminationConfig] = None,
70
- system_message_config: Optional[SystemMessageConfig] = None,
68
+ code_execution_config: CodeExecutionConfig | None = None,
69
+ termination_config: TerminationConfig | None = None,
70
+ system_message_config: SystemMessageConfig | None = None,
71
71
  ) -> StandardExtras:
72
72
  """Process the document agent configuration.
73
73
 
@@ -3,7 +3,7 @@
3
3
  # pylint: disable=no-self-use,too-few-public-methods
4
4
  """Group manager agent configuration processor."""
5
5
 
6
- from typing import Callable, Optional
6
+ from typing import Callable
7
7
 
8
8
  from waldiez.models import (
9
9
  WaldiezAgent,
@@ -35,7 +35,8 @@ class GroupManagerProcessor:
35
35
  model_names: dict[str, str],
36
36
  all_models: list[WaldiezModel],
37
37
  serializer: Callable[..., str],
38
- cache_seed: Optional[int] = None,
38
+ cache_seed: int | None = None,
39
+ strategy: GroupManagerStrategy | None = None,
39
40
  ):
40
41
  """Initialize the group manager processor.
41
42
 
@@ -57,6 +58,8 @@ class GroupManagerProcessor:
57
58
  Function to serialize data into a string format.
58
59
  cache_seed : Optional[int], optional
59
60
  Seed for caching purposes, by default None.
61
+ strategy : Optional[GroupManagerStrategy]
62
+ Optional strategy to force (pattern based or traditional)
60
63
  """
61
64
  self.agent = agent
62
65
  self.initial_chats = initial_chats
@@ -66,12 +69,13 @@ class GroupManagerProcessor:
66
69
  self.all_models = all_models
67
70
  self.serializer = serializer
68
71
  self.cache_seed = cache_seed
72
+ self.strategy = strategy
69
73
 
70
74
  def process(
71
75
  self,
72
- code_execution_config: Optional[CodeExecutionConfig] = None,
73
- termination_config: Optional[TerminationConfig] = None,
74
- system_message_config: Optional[SystemMessageConfig] = None,
76
+ code_execution_config: CodeExecutionConfig | None = None,
77
+ termination_config: TerminationConfig | None = None,
78
+ system_message_config: SystemMessageConfig | None = None,
75
79
  ) -> GroupManagerExtras:
76
80
  """Process group manager and return extras.
77
81
 
@@ -133,6 +137,8 @@ class GroupManagerProcessor:
133
137
 
134
138
  def _determine_strategy(self) -> GroupManagerStrategy:
135
139
  """Determine which strategy to use for this group manager."""
140
+ if self.strategy is not None:
141
+ return self.strategy
136
142
  if self.is_pattern_strategy(self.initial_chats):
137
143
  # Use AG2 Pattern system
138
144
  return GroupManagerStrategy.PATTERN
@@ -145,10 +151,11 @@ class GroupManagerProcessor:
145
151
  extras.pattern_class_name = self._get_pattern_class_name()
146
152
 
147
153
  # Add required imports
148
- extras.pattern_imports.add(
154
+ pattern_import = (
149
155
  "from autogen.agentchat.group.patterns import "
150
156
  f"{extras.pattern_class_name}"
151
157
  )
158
+ extras.pattern_imports.add(pattern_import)
152
159
 
153
160
  # Get user agent if applicable
154
161
  user_agent = None
@@ -222,7 +229,7 @@ class GroupManagerProcessor:
222
229
  return pattern_map.get(selection_method, "AutoPattern")
223
230
 
224
231
  def _generate_pattern_definition(
225
- self, pattern_class: str, user_agent: Optional[WaldiezAgent]
232
+ self, pattern_class: str, user_agent: WaldiezAgent | None
226
233
  ) -> str:
227
234
  """Generate the pattern definition string."""
228
235
  if not isinstance(self.agent, WaldiezGroupManager):
@@ -253,12 +260,13 @@ class GroupManagerProcessor:
253
260
  as_dict=True,
254
261
  )
255
262
  manager_name = self.agent_names[self.agent.id]
256
- pattern_lines.append(
263
+ pattern_line = (
257
264
  " group_manager_args={\n"
258
265
  f"{llm_config_arg}"
259
266
  f' "name": "{manager_name}",\n'
260
267
  " },"
261
268
  )
269
+ pattern_lines.append(pattern_line)
262
270
 
263
271
  # Add context variables if present
264
272
  if self.agent.data.context_variables:
@@ -339,7 +347,7 @@ class GroupManagerProcessor:
339
347
 
340
348
  def _generate_speakers_configuration(
341
349
  self,
342
- ) -> tuple[list[str], Optional[str]]:
350
+ ) -> tuple[list[str], str | None]:
343
351
  """Generate speakers configuration for traditional group chat."""
344
352
  if not isinstance(self.agent, WaldiezGroupManager):
345
353
  return [], None
@@ -350,10 +358,11 @@ class GroupManagerProcessor:
350
358
 
351
359
  # Max retries
352
360
  if speakers.max_retries_for_selecting is not None:
353
- config_lines.append(
361
+ config_line = (
354
362
  " max_retries_for_selecting_speaker="
355
363
  f"{speakers.max_retries_for_selecting},"
356
364
  )
365
+ config_lines.append(config_line)
357
366
 
358
367
  # Selection method
359
368
  if speakers.selection_method != "custom":
@@ -394,7 +403,7 @@ class GroupManagerProcessor:
394
403
 
395
404
  if isinstance(allow_repeat, bool):
396
405
  lines.append(f" allow_repeat_speaker={allow_repeat},")
397
- else:
406
+ elif allow_repeat is not None:
398
407
  # List of agent names
399
408
  agent_names = ", ".join(
400
409
  self.agent_names[agent_id] for agent_id in allow_repeat
@@ -425,15 +434,14 @@ class GroupManagerProcessor:
425
434
  # Serialize transitions
426
435
  transitions_str = self.serializer(transitions_dict, tabs=1)
427
436
  transitions_str = transitions_str.replace('"', "").replace("'", "")
428
-
429
- lines.extend(
430
- [
431
- " allowed_or_disallowed_speaker_transitions="
432
- f"{transitions_str},",
433
- ' speaker_transitions_type="'
434
- f'"{self.agent.data.speakers.transitions_type}",',
435
- ]
437
+ allowed_or_disallowed_line = (
438
+ f" allowed_or_disallowed_speaker_transitions={transitions_str},"
436
439
  )
440
+ transition_type_line = (
441
+ ' speaker_transitions_type="'
442
+ f'"{self.agent.data.speakers.transitions_type}",'
443
+ )
444
+ lines.extend([allowed_or_disallowed_line, transition_type_line])
437
445
 
438
446
  return lines
439
447
 
@@ -475,8 +483,8 @@ class GroupManagerProcessor:
475
483
  ),
476
484
  "GroupManagerTarget": (
477
485
  "GroupManagerTarget()",
478
- f"{import_prefix}.targets.group_manager_target "
479
- "import GroupManagerTarget",
486
+ # pylint: disable=line-too-long
487
+ f"{import_prefix}.targets.group_manager_target import GroupManagerTarget", # noqa: E501
480
488
  ),
481
489
  }
482
490
 
@@ -501,10 +509,13 @@ class GroupManagerProcessor:
501
509
  for agent in self.group_chat_members
502
510
  ]
503
511
  target_names_str = ", ".join(target_names)
512
+ import_line = (
513
+ f"{import_prefix}.targets.transition_target "
514
+ "import RandomAgentTarget"
515
+ )
504
516
  return (
505
517
  f"RandomAgentTarget(agents=[{target_names_str}])",
506
- f"{import_prefix}.targets.transition_target "
507
- "import RandomAgentTarget",
518
+ import_line,
508
519
  )
509
520
 
510
521
  return "", ""
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=no-self-use,too-few-public-methods
4
+ # pyright: reportUninitializedInstanceVariable=false
4
5
  """Group member agent configuration processor."""
5
6
 
6
7
  from dataclasses import dataclass, field
@@ -26,10 +27,10 @@ class GroupMemberProcessorResult:
26
27
  before_agent: str = ""
27
28
  after_agent: str = ""
28
29
  extra_arguments: list[InstanceArgument] = field(
29
- default_factory=list[InstanceArgument]
30
+ default_factory=list,
30
31
  )
31
32
  extra_imports: set[ImportStatement] = field(
32
- default_factory=set[ImportStatement]
33
+ default_factory=set,
33
34
  )
34
35
 
35
36
 
@@ -108,10 +109,10 @@ class GroupMemberAgentProcessor:
108
109
  tab = " "
109
110
  arg_string = "["
110
111
 
111
- arcg_content = self._process_update_functions()
112
+ arg_content = self._process_update_functions()
112
113
 
113
- if arcg_content:
114
- arg_string += f"{arcg_content}\n{tab}"
114
+ if arg_content:
115
+ arg_string += f"{arg_content}\n{tab}"
115
116
  self.result.extra_imports.add(
116
117
  ImportStatement("from autogen import UpdateSystemMessage")
117
118
  )
@@ -27,7 +27,7 @@ class AfterWorkResult:
27
27
 
28
28
  content: str = ""
29
29
  before_content: str = ""
30
- extra_imports: set[str] = field(default_factory=set[str])
30
+ extra_imports: set[str] = field(default_factory=set)
31
31
 
32
32
 
33
33
  class AfterWorkProcessor:
@@ -14,7 +14,7 @@ class TransitionAvailableResult:
14
14
  """Result from processing transition availability."""
15
15
 
16
16
  content: str = ""
17
- extra_imports: set[str] = field(default_factory=set[str])
17
+ extra_imports: set[str] = field(default_factory=set)
18
18
 
19
19
 
20
20
  class TransitionAvailableProcessor:
@@ -1,6 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  # pylint: disable=too-few-public-methods
4
+ # pyright: reportUnnecessaryIsInstance=false,reportUnreachable=false
4
5
  """Handoff condition processing for Waldiez agents."""
5
6
 
6
7
  from dataclasses import dataclass, field
@@ -30,7 +31,7 @@ class ConditionResult:
30
31
  """
31
32
 
32
33
  content: str = ""
33
- extra_imports: set[str] = field(default_factory=set[str])
34
+ extra_imports: set[str] = field(default_factory=set)
34
35
 
35
36
 
36
37
  class ConditionProcessor:
@@ -82,7 +83,7 @@ class ConditionProcessor:
82
83
  elif isinstance(
83
84
  condition,
84
85
  WaldiezExpressionContextCondition,
85
- ): # pyright: ignore
86
+ ):
86
87
  self._process_expression_context_condition(condition)
87
88
  else:
88
89
  raise ValueError(f"Unsupported condition type: {type(condition)}")
@@ -35,7 +35,7 @@ class HandoffResult:
35
35
  """
36
36
 
37
37
  after_agent: str = ""
38
- extra_imports: set[str] = field(default_factory=set[str])
38
+ extra_imports: set[str] = field(default_factory=set)
39
39
 
40
40
 
41
41
  class HandoffProcessor:
@@ -4,7 +4,7 @@
4
4
  """Transition target processor for Waldiez agents."""
5
5
 
6
6
  from dataclasses import dataclass, field
7
- from typing import Callable, Set
7
+ from typing import Callable
8
8
 
9
9
  from waldiez.exporting.chats.utils.nested import get_nested_chat_queue
10
10
  from waldiez.models import (
@@ -33,7 +33,7 @@ class TargetResult:
33
33
 
34
34
  content: str = ""
35
35
  before_content: str = ""
36
- extra_imports: Set[str] = field(default_factory=set) # pyright: ignore
36
+ extra_imports: set[str] = field(default_factory=set)
37
37
 
38
38
 
39
39
  # noinspection PyTypeHints
@@ -128,10 +128,11 @@ class TransitionTargetProcessor:
128
128
  ) -> str:
129
129
  """Process random agent target."""
130
130
  if not isinstance(target, WaldiezRandomAgentTarget):
131
- raise ValueError(
131
+ msg = (
132
132
  "Expected WaldiezRandomAgentTarget"
133
133
  " for random agent target processing."
134
134
  )
135
+ raise ValueError(msg)
135
136
  agent_vars = [self.agent_names[agent_id] for agent_id in target.value]
136
137
  agents_str = ", ".join(agent_vars)
137
138
  return f"RandomAgentTarget([{agents_str}])"
@@ -141,10 +142,11 @@ class TransitionTargetProcessor:
141
142
  ) -> str:
142
143
  """Process group chat target."""
143
144
  if not isinstance(target, WaldiezGroupOrNestedTarget):
144
- raise ValueError(
145
+ msg = (
145
146
  "Expected WaldiezGroupOrNestedTarget for group chat target "
146
147
  "processing."
147
148
  )
149
+ raise ValueError(msg)
148
150
  chat_name = self.chat_names[target.value[0]]
149
151
  return f"GroupChatTarget({chat_name})"
150
152