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
@@ -1,5 +1,8 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportArgumentType=false,reportIncompatibleVariableOverride=false
5
+
3
6
  """User proxy agent model."""
4
7
 
5
8
  from pydantic import Field
@@ -24,7 +27,7 @@ class WaldiezUserProxy(WaldiezAgent):
24
27
  The user proxy agent's data
25
28
  """
26
29
 
27
- agent_type: Annotated[ # pyright: ignore
30
+ agent_type: Annotated[
28
31
  Literal["user", "user_proxy"],
29
32
  Field(
30
33
  "user_proxy",
@@ -37,11 +40,11 @@ class WaldiezUserProxy(WaldiezAgent):
37
40
  alias="agentType",
38
41
  ),
39
42
  ]
40
- data: Annotated[ # pyright: ignore
43
+ data: Annotated[
41
44
  WaldiezUserProxyData,
42
45
  Field(
43
46
  title="Data",
44
47
  description="The user proxy agent's data",
45
- default_factory=WaldiezUserProxyData, # pyright: ignore
48
+ default_factory=WaldiezUserProxyData,
46
49
  ),
47
50
  ]
@@ -29,4 +29,4 @@ class WaldiezUserProxyData(WaldiezAgentData):
29
29
  description="The human input mode, Defaults to `ALWAYS`",
30
30
  alias="humanInputMode",
31
31
  ),
32
- ] = "ALWAYS"
32
+ ]
@@ -1,13 +1,16 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportDeprecated=false,reportUnknownMemberType=false
5
+ # pyright: reportAttributeAccessIssue=false,reportUnknownVariableType=false
6
+
3
7
  """Waldiez chat model."""
4
8
 
5
- from typing import Any, Optional
9
+ from typing import TYPE_CHECKING, Any, Optional
6
10
 
7
11
  from pydantic import Field, model_validator
8
12
  from typing_extensions import Annotated, Literal, Self
9
13
 
10
- from ..agents import WaldiezAgent, WaldiezRagUserProxy
11
14
  from ..common import (
12
15
  WaldiezAgentTarget,
13
16
  WaldiezBase,
@@ -34,6 +37,9 @@ from .chat_nested import (
34
37
  WaldiezChatNested,
35
38
  )
36
39
 
40
+ if TYPE_CHECKING:
41
+ from ..agents import WaldiezAgent
42
+
37
43
  WaldiezChatType = Literal["chat", "nested", "group", "hidden"]
38
44
  """Possible chat types: "chat", "nested", "group", "hidden"."""
39
45
 
@@ -61,7 +67,7 @@ class WaldiezChat(WaldiezBase):
61
67
  The nested chat message/reply if any.
62
68
  message : WaldiezChatMessage
63
69
  The chat message.
64
- message_content : Optional[str]
70
+ message_content : str | None
65
71
  The chat message content if any. If method, the method's body.
66
72
 
67
73
  Functions
@@ -146,12 +152,12 @@ class WaldiezChat(WaldiezBase):
146
152
  return self.data.message
147
153
 
148
154
  @property
149
- def message_content(self) -> Optional[str]:
155
+ def message_content(self) -> str | None:
150
156
  """Get the message content."""
151
157
  return self.data.message_content
152
158
 
153
159
  @property
154
- def max_turns(self) -> Optional[int]:
160
+ def max_turns(self) -> int | None:
155
161
  """Get the max rounds for the chat."""
156
162
  return self.data.max_turns
157
163
 
@@ -227,8 +233,8 @@ class WaldiezChat(WaldiezBase):
227
233
 
228
234
  def get_message_function(
229
235
  self,
230
- name_prefix: Optional[str] = None,
231
- name_suffix: Optional[str] = None,
236
+ name_prefix: str | None = None,
237
+ name_suffix: str | None = None,
232
238
  is_rag: bool = False,
233
239
  ) -> tuple[str, str]:
234
240
  """Get the message function.
@@ -281,10 +287,10 @@ class WaldiezChat(WaldiezBase):
281
287
 
282
288
  @staticmethod
283
289
  def _get_nested_chat_function(
284
- content: Optional[str],
290
+ content: str | None,
285
291
  function_name_base: str,
286
- name_prefix: Optional[str] = None,
287
- name_suffix: Optional[str] = None,
292
+ name_prefix: str | None = None,
293
+ name_suffix: str | None = None,
288
294
  ) -> tuple[str, str]:
289
295
  """Get the nested chat function.
290
296
 
@@ -323,16 +329,16 @@ class WaldiezChat(WaldiezBase):
323
329
 
324
330
  def get_nested_chat_message_function(
325
331
  self,
326
- name_prefix: Optional[str] = None,
327
- name_suffix: Optional[str] = None,
332
+ name_prefix: str | None = None,
333
+ name_suffix: str | None = None,
328
334
  ) -> tuple[str, str]:
329
335
  """Get the nested chat message function.
330
336
 
331
337
  Parameters
332
338
  ----------
333
- name_prefix : str
339
+ name_prefix : str | None
334
340
  The function name prefix.
335
- name_suffix : str
341
+ name_suffix : str | None
336
342
  The function name suffix.
337
343
 
338
344
  Returns
@@ -358,16 +364,16 @@ class WaldiezChat(WaldiezBase):
358
364
 
359
365
  def get_nested_chat_reply_function(
360
366
  self,
361
- name_prefix: Optional[str] = None,
362
- name_suffix: Optional[str] = None,
367
+ name_prefix: str | None = None,
368
+ name_suffix: str | None = None,
363
369
  ) -> tuple[str, str]:
364
370
  """Get the nested chat reply function.
365
371
 
366
372
  Parameters
367
373
  ----------
368
- name_prefix : str
374
+ name_prefix : str | None
369
375
  The function name prefix.
370
- name_suffix : str
376
+ name_suffix : str | None
371
377
  The function name suffix.
372
378
 
373
379
  Returns
@@ -394,7 +400,7 @@ class WaldiezChat(WaldiezBase):
394
400
  def get_chat_args(
395
401
  self,
396
402
  for_queue: bool,
397
- sender: Optional[WaldiezAgent] = None,
403
+ sender: Optional["WaldiezAgent"] = None,
398
404
  ) -> dict[str, Any]:
399
405
  """Get the chat arguments to use in autogen.
400
406
 
@@ -412,9 +418,10 @@ class WaldiezChat(WaldiezBase):
412
418
  """
413
419
  args_dict = self.data.get_chat_args(for_queue)
414
420
  if (
415
- isinstance(sender, WaldiezRagUserProxy)
421
+ sender
416
422
  and sender.is_rag_user
417
423
  and self.message.type == "rag_message_generator"
424
+ and hasattr(sender.data, "retrieve_config")
418
425
  ):
419
426
  # check for n_results in agent data, to add in context
420
427
  n_results = sender.data.retrieve_config.n_results
@@ -1,8 +1,11 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportArgumentType=false
5
+
3
6
  """Chat data model."""
4
7
 
5
- from typing import Any, Optional, Union
8
+ from typing import Any
6
9
 
7
10
  from pydantic import Field, field_validator, model_validator
8
11
  from typing_extensions import Annotated, Self
@@ -71,7 +74,7 @@ class WaldiezChatData(WaldiezBase):
71
74
  title="Description",
72
75
  description="The description of the chat.",
73
76
  ),
74
- ] = "A new chat"
77
+ ]
75
78
  position: Annotated[
76
79
  int,
77
80
  Field(
@@ -79,7 +82,7 @@ class WaldiezChatData(WaldiezBase):
79
82
  title="Position",
80
83
  description="The position of the chat in the flow (Ignored).",
81
84
  ),
82
- ] = -1
85
+ ]
83
86
  order: Annotated[
84
87
  int,
85
88
  Field(
@@ -87,7 +90,7 @@ class WaldiezChatData(WaldiezBase):
87
90
  title="Order",
88
91
  description="The order of the chat in the flow.",
89
92
  ),
90
- ] = -1
93
+ ]
91
94
  clear_history: Annotated[
92
95
  bool,
93
96
  Field(
@@ -96,9 +99,9 @@ class WaldiezChatData(WaldiezBase):
96
99
  title="Clear History",
97
100
  description="Whether to clear the chat history.",
98
101
  ),
99
- ] = True
102
+ ]
100
103
  message: Annotated[
101
- Union[str, WaldiezChatMessage],
104
+ str | WaldiezChatMessage,
102
105
  Field(
103
106
  title="Message",
104
107
  description="The message of the chat.",
@@ -123,14 +126,14 @@ class WaldiezChatData(WaldiezBase):
123
126
  ),
124
127
  ]
125
128
  max_turns: Annotated[
126
- Optional[int],
129
+ int | None,
127
130
  Field(
128
131
  default=None,
129
132
  alias="maxTurns",
130
133
  title="Max Turns",
131
134
  description="The maximum number of turns for the chat.",
132
135
  ),
133
- ] = None
136
+ ]
134
137
  prerequisites: Annotated[
135
138
  list[str],
136
139
  Field(
@@ -138,7 +141,7 @@ class WaldiezChatData(WaldiezBase):
138
141
  description="The prerequisites (chat ids) for the chat (if async).",
139
142
  default_factory=list,
140
143
  ),
141
- ] = []
144
+ ]
142
145
  silent: Annotated[
143
146
  bool,
144
147
  Field(
@@ -146,25 +149,25 @@ class WaldiezChatData(WaldiezBase):
146
149
  title="Silent",
147
150
  description="Whether to run the chat silently.",
148
151
  ),
149
- ] = False
152
+ ]
150
153
  real_source: Annotated[
151
- Optional[str],
154
+ str | None,
152
155
  Field(
153
156
  default=None,
154
157
  alias="realSource",
155
158
  title="Real Source",
156
159
  description="The real source of the chat (overrides the source).",
157
160
  ),
158
- ] = None
161
+ ]
159
162
  real_target: Annotated[
160
- Optional[str],
163
+ str | None,
161
164
  Field(
162
165
  default=None,
163
166
  alias="realTarget",
164
167
  title="Real Target",
165
168
  description="The real target of the chat (overrides the target).",
166
169
  ),
167
- ] = None
170
+ ]
168
171
  source_type: Annotated[
169
172
  WaldiezAgentType,
170
173
  Field(
@@ -201,7 +204,7 @@ class WaldiezChatData(WaldiezBase):
201
204
  ),
202
205
  ]
203
206
  after_work: Annotated[
204
- Optional[WaldiezHandoffTransition],
207
+ WaldiezHandoffTransition | None,
205
208
  Field(
206
209
  None,
207
210
  title="After Work",
@@ -211,13 +214,13 @@ class WaldiezChatData(WaldiezBase):
211
214
  ),
212
215
  alias="afterWork",
213
216
  ),
214
- ] = None
215
- _message_content: Optional[str] = None
217
+ ]
218
+ _message_content: str | None = None
216
219
  _chat_id: int = 0
217
220
  _prerequisites: list[int] = []
218
221
 
219
222
  @property
220
- def message_content(self) -> Optional[str]:
223
+ def message_content(self) -> str | None:
221
224
  """Get the message content."""
222
225
  return self._message_content
223
226
 
@@ -334,7 +337,7 @@ class WaldiezChatData(WaldiezBase):
334
337
  return value
335
338
 
336
339
  @property
337
- def summary_args(self) -> Optional[dict[str, Any]]:
340
+ def summary_args(self) -> dict[str, Any] | None:
338
341
  """Get the summary args."""
339
342
  if self.summary.method not in (
340
343
  "reflection_with_llm",
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez Message Model."""
4
4
 
5
- from typing import Any, Optional
5
+ from typing import Any
6
6
 
7
7
  from pydantic import Field, model_validator
8
8
  from typing_extensions import Annotated, Literal, Self
@@ -72,7 +72,7 @@ class WaldiezChatMessage(WaldiezBase):
72
72
  "the `sender.message_generator` method will be used."
73
73
  ),
74
74
  ),
75
- ] = "none"
75
+ ]
76
76
  use_carryover: Annotated[
77
77
  bool,
78
78
  Field(
@@ -80,15 +80,15 @@ class WaldiezChatMessage(WaldiezBase):
80
80
  title="Use Carryover",
81
81
  description="Use the carryover from the context.",
82
82
  ),
83
- ] = False
83
+ ]
84
84
  content: Annotated[
85
- Optional[str],
85
+ str | None,
86
86
  Field(
87
87
  default=None,
88
88
  title="Content",
89
89
  description="The content of the message (string or method).",
90
90
  ),
91
- ] = None
91
+ ]
92
92
  context: Annotated[
93
93
  dict[str, Any],
94
94
  Field(
@@ -96,9 +96,9 @@ class WaldiezChatMessage(WaldiezBase):
96
96
  title="Context",
97
97
  description="Extra context of the message.",
98
98
  ),
99
- ] = {}
99
+ ]
100
100
 
101
- _content_body: Optional[str] = None
101
+ _content_body: str | None = None
102
102
 
103
103
  def is_method(self) -> bool:
104
104
  """Check if the message is a method.
@@ -111,7 +111,7 @@ class WaldiezChatMessage(WaldiezBase):
111
111
  return self.type in ("method", "rag_message_generator")
112
112
 
113
113
  @property
114
- def content_body(self) -> Optional[str]:
114
+ def content_body(self) -> str | None:
115
115
  """Get the content body."""
116
116
  return self._content_body
117
117
 
@@ -141,7 +141,7 @@ class WaldiezChatMessage(WaldiezBase):
141
141
  ValueError
142
142
  If the content is invalid.
143
143
  """
144
- content: Optional[str] = None
144
+ content: str | None = None
145
145
  if self.type == "none":
146
146
  content = "None"
147
147
  if self.type == "method":
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Nested chat model."""
4
4
 
5
- from typing import Any, Optional
5
+ from typing import Any
6
6
 
7
7
  from pydantic import Field, field_validator, model_validator
8
8
  from typing_extensions import Annotated, Self
@@ -36,32 +36,32 @@ class WaldiezChatNested(WaldiezBase):
36
36
  """
37
37
 
38
38
  message: Annotated[
39
- Optional[WaldiezChatMessage],
39
+ WaldiezChatMessage | None,
40
40
  Field(
41
41
  default=None,
42
42
  title="Message",
43
43
  description="The message in a nested chat (sender -> recipient).",
44
44
  ),
45
- ] = None
45
+ ]
46
46
  reply: Annotated[
47
- Optional[WaldiezChatMessage],
47
+ WaldiezChatMessage | None,
48
48
  Field(
49
49
  default=None,
50
50
  title="Reply",
51
51
  description="The reply in a nested chat (recipient -> sender).",
52
52
  ),
53
- ] = None
53
+ ]
54
54
 
55
- _message_content: Optional[str] = None
56
- _reply_content: Optional[str] = None
55
+ _message_content: str | None = None
56
+ _reply_content: str | None = None
57
57
 
58
58
  @property
59
- def message_content(self) -> Optional[str]:
59
+ def message_content(self) -> str | None:
60
60
  """Get the message content."""
61
61
  return self._message_content
62
62
 
63
63
  @property
64
- def reply_content(self) -> Optional[str]:
64
+ def reply_content(self) -> str | None:
65
65
  """Get the reply content."""
66
66
  return self._reply_content
67
67
 
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez chat summary options."""
4
4
 
5
- from typing import Any, Optional
5
+ from typing import Any
6
6
 
7
7
  from pydantic import (
8
8
  Field,
@@ -37,13 +37,13 @@ class WaldiezChatSummary(WaldiezBase):
37
37
  """
38
38
 
39
39
  method: Annotated[
40
- Optional[WaldiezChatSummaryMethod],
40
+ WaldiezChatSummaryMethod | None,
41
41
  Field(
42
42
  default="last_msg",
43
43
  title="Method",
44
44
  description="The method to use for the LLM summary.",
45
45
  ),
46
- ] = "last_msg"
46
+ ]
47
47
  prompt: Annotated[
48
48
  str,
49
49
  Field(
@@ -51,7 +51,7 @@ class WaldiezChatSummary(WaldiezBase):
51
51
  title="Prompt",
52
52
  description="The prompt for the LLM summary method.",
53
53
  ),
54
- ] = "Summarize the conversation."
54
+ ]
55
55
  args: Annotated[
56
56
  dict[str, str],
57
57
  Field(
@@ -59,13 +59,13 @@ class WaldiezChatSummary(WaldiezBase):
59
59
  description="The additional arguments for the LLM summary method.",
60
60
  default_factory=dict,
61
61
  ),
62
- ] = {}
62
+ ]
63
63
 
64
64
  # noinspection PyNestedDecorators
65
65
  @field_validator("method", mode="before")
66
66
  @classmethod
67
67
  def validate_summary_method(
68
- cls, value: Optional[WaldiezChatSummaryMethod]
68
+ cls, value: WaldiezChatSummaryMethod | None
69
69
  ) -> WaldiezChatSummaryMethod | None:
70
70
  """Validate the summary method.
71
71
 
@@ -38,6 +38,7 @@ from .naming import (
38
38
  MAX_VARIABLE_LENGTH,
39
39
  get_valid_instance_name,
40
40
  get_valid_python_variable_name,
41
+ safe_filename,
41
42
  )
42
43
  from .waldiez_version import get_waldiez_version
43
44
 
@@ -56,6 +57,7 @@ __all__ = [
56
57
  "generate_function",
57
58
  "now",
58
59
  "parse_code_string",
60
+ "safe_filename",
59
61
  "WaldiezDefaultCondition",
60
62
  "WaldiezAgentTarget",
61
63
  "WaldiezContextBasedCondition",
@@ -1,5 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportMissingTypeStubs=false
3
5
  """Get the autogen version."""
4
6
 
5
7
  import warnings
@@ -1,11 +1,13 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pyright: reportUnknownVariableType=false
3
5
  """Dictionary related utilities."""
4
6
 
5
7
  import ast
6
8
  import json
7
9
  import re
8
- from typing import Any, Union
10
+ from typing import Any
9
11
 
10
12
  BOOL_VALUES = {"true", "false"}
11
13
  NULL_VALUES = {"none", "null", "nil", "undefined"}
@@ -21,7 +23,7 @@ def _strip_outer_quotes(value: str) -> str:
21
23
  return value_stripped
22
24
 
23
25
 
24
- def _detect_null_or_boolean(value: str) -> Union[None, bool, str]:
26
+ def _detect_null_or_boolean(value: str) -> bool | str | None:
25
27
  """
26
28
  Detect null values or booleans.
27
29
 
@@ -45,7 +47,7 @@ def _detect_null_or_boolean(value: str) -> Union[None, bool, str]:
45
47
  return value
46
48
 
47
49
 
48
- def _detect_numeric_type(value: str) -> Union[int, float, str]:
50
+ def _detect_numeric_type(value: str) -> int | float | str:
49
51
  """
50
52
  Detect if string represents an integer or float.
51
53
 
@@ -72,7 +74,7 @@ def _detect_numeric_type(value: str) -> Union[int, float, str]:
72
74
 
73
75
  def _detect_container_type(
74
76
  value: str,
75
- ) -> Union[dict[str, Any], list[Any], tuple[Any], set[Any], str]:
77
+ ) -> dict[str, Any] | list[Any] | tuple[Any] | set[Any] | str:
76
78
  """
77
79
  Detect if string represents a container type (dict, list, tuple, set).
78
80
 
@@ -97,7 +99,7 @@ def _detect_container_type(
97
99
  try:
98
100
  parsed = json.loads(value)
99
101
  if isinstance(parsed, (dict, list)):
100
- return parsed # pyright: ignore
102
+ return parsed
101
103
  except (json.JSONDecodeError, TypeError):
102
104
  pass
103
105
 
@@ -105,7 +107,7 @@ def _detect_container_type(
105
107
  try:
106
108
  parsed = ast.literal_eval(value)
107
109
  if isinstance(parsed, (dict, list, tuple, set)):
108
- return parsed # pyright: ignore
110
+ return parsed
109
111
  except (ValueError, SyntaxError):
110
112
  pass
111
113
 
@@ -1,8 +1,11 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ # pylint: disable=invalid-name
5
+
3
6
  """Waldiez Agent Handoff class."""
4
7
 
5
- from typing import Any, Union
8
+ from typing import Any
6
9
 
7
10
  from pydantic import Field
8
11
  from typing_extensions import Annotated, Literal
@@ -115,13 +118,13 @@ class WaldiezSimpleTarget(WaldiezBase):
115
118
  Field(
116
119
  "TerminateTarget", description="The type of the transition target."
117
120
  ),
118
- ] = "TerminateTarget"
121
+ ]
119
122
  value: Annotated[
120
123
  list[str],
121
124
  Field(
122
125
  default_factory=list,
123
126
  ),
124
- ] = [] # not actually used (just for consistency with other targets)
127
+ ] # not actually used (just for consistency with other targets)
125
128
 
126
129
 
127
130
  class WaldiezGroupOrNestedTarget(WaldiezBase):
@@ -157,12 +160,10 @@ class WaldiezGroupOrNestedTarget(WaldiezBase):
157
160
 
158
161
 
159
162
  WaldiezTransitionTarget = Annotated[
160
- Union[
161
- WaldiezAgentTarget,
162
- WaldiezRandomAgentTarget,
163
- WaldiezGroupOrNestedTarget,
164
- WaldiezSimpleTarget,
165
- ],
163
+ WaldiezAgentTarget
164
+ | WaldiezRandomAgentTarget
165
+ | WaldiezGroupOrNestedTarget
166
+ | WaldiezSimpleTarget,
166
167
  Field(discriminator="target_type"),
167
168
  ]
168
169
 
@@ -228,7 +229,7 @@ class WaldiezContextStrLLMCondition(WaldiezBase):
228
229
 
229
230
 
230
231
  WaldiezLLMBasedCondition = Annotated[
231
- Union[WaldiezStringLLMCondition, WaldiezContextStrLLMCondition],
232
+ WaldiezStringLLMCondition | WaldiezContextStrLLMCondition,
232
233
  Field(discriminator="condition_type"),
233
234
  ]
234
235
 
@@ -293,15 +294,15 @@ class WaldiezExpressionContextCondition(WaldiezBase):
293
294
 
294
295
 
295
296
  WaldiezContextBasedCondition = Annotated[
296
- Union[WaldiezStringContextCondition, WaldiezExpressionContextCondition],
297
+ WaldiezStringContextCondition | WaldiezExpressionContextCondition,
297
298
  Field(discriminator="condition_type"),
298
299
  ]
299
300
 
300
301
 
301
302
  # Union type for just the condition types (without targets)
302
- WaldiezHandoffCondition = Union[
303
- WaldiezLLMBasedCondition, WaldiezContextBasedCondition
304
- ]
303
+ WaldiezHandoffCondition = (
304
+ WaldiezLLMBasedCondition | WaldiezContextBasedCondition
305
+ )
305
306
 
306
307
 
307
308
  # pylint: disable=too-few-public-methods
@@ -362,9 +363,9 @@ class WaldiezContextBasedTransition(WaldiezBase):
362
363
 
363
364
 
364
365
  # Union type for complete transitions (condition + target)
365
- WaldiezHandoffTransition = Union[
366
- WaldiezLLMBasedTransition, WaldiezContextBasedTransition
367
- ]
366
+ WaldiezHandoffTransition = (
367
+ WaldiezLLMBasedTransition | WaldiezContextBasedTransition
368
+ )
368
369
 
369
370
 
370
371
  class WaldiezHandoff(WaldiezBase):