waldiez 0.5.10__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 (192) hide show
  1. waldiez/__init__.py +1 -1
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +19 -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 +15 -16
  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 +40 -24
  12. waldiez/exporting/agent/extras/group_member_extras.py +6 -5
  13. waldiez/exporting/agent/extras/handoffs/after_work.py +2 -1
  14. waldiez/exporting/agent/extras/handoffs/available.py +2 -1
  15. waldiez/exporting/agent/extras/handoffs/condition.py +3 -2
  16. waldiez/exporting/agent/extras/handoffs/handoff.py +2 -1
  17. waldiez/exporting/agent/extras/handoffs/target.py +7 -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/agent/termination.py +1 -0
  26. waldiez/exporting/chats/exporter.py +4 -4
  27. waldiez/exporting/chats/processor.py +1 -2
  28. waldiez/exporting/chats/utils/common.py +89 -48
  29. waldiez/exporting/chats/utils/group.py +9 -9
  30. waldiez/exporting/chats/utils/nested.py +7 -7
  31. waldiez/exporting/chats/utils/sequential.py +1 -1
  32. waldiez/exporting/chats/utils/single.py +2 -2
  33. waldiez/exporting/core/constants.py +3 -1
  34. waldiez/exporting/core/content.py +7 -7
  35. waldiez/exporting/core/context.py +5 -3
  36. waldiez/exporting/core/exporter.py +5 -3
  37. waldiez/exporting/core/exporters.py +2 -2
  38. waldiez/exporting/core/extras/agent_extras/captain_extras.py +2 -2
  39. waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +2 -2
  40. waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +2 -2
  41. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -8
  42. waldiez/exporting/core/extras/base.py +7 -5
  43. waldiez/exporting/core/extras/flow_extras.py +4 -5
  44. waldiez/exporting/core/extras/model_extras.py +2 -2
  45. waldiez/exporting/core/extras/path_resolver.py +1 -2
  46. waldiez/exporting/core/extras/serializer.py +13 -11
  47. waldiez/exporting/core/protocols.py +6 -5
  48. waldiez/exporting/core/result.py +25 -28
  49. waldiez/exporting/core/types.py +11 -10
  50. waldiez/exporting/core/utils/llm_config.py +4 -4
  51. waldiez/exporting/core/validation.py +10 -11
  52. waldiez/exporting/flow/execution_generator.py +99 -10
  53. waldiez/exporting/flow/exporter.py +2 -2
  54. waldiez/exporting/flow/factory.py +2 -2
  55. waldiez/exporting/flow/file_generator.py +4 -2
  56. waldiez/exporting/flow/merger.py +5 -3
  57. waldiez/exporting/flow/orchestrator.py +72 -2
  58. waldiez/exporting/flow/utils/common.py +6 -6
  59. waldiez/exporting/flow/utils/importing.py +7 -8
  60. waldiez/exporting/flow/utils/linting.py +25 -9
  61. waldiez/exporting/flow/utils/logging.py +5 -77
  62. waldiez/exporting/models/exporter.py +8 -8
  63. waldiez/exporting/models/processor.py +5 -5
  64. waldiez/exporting/tools/exporter.py +2 -2
  65. waldiez/exporting/tools/processor.py +7 -4
  66. waldiez/io/__init__.py +11 -5
  67. waldiez/io/_ws.py +12 -6
  68. waldiez/io/models/constants.py +10 -10
  69. waldiez/io/models/content/audio.py +1 -0
  70. waldiez/io/models/content/base.py +20 -18
  71. waldiez/io/models/content/file.py +1 -0
  72. waldiez/io/models/content/image.py +1 -0
  73. waldiez/io/models/content/text.py +1 -0
  74. waldiez/io/models/content/video.py +1 -0
  75. waldiez/io/models/user_input.py +10 -5
  76. waldiez/io/models/user_response.py +17 -16
  77. waldiez/io/mqtt.py +18 -31
  78. waldiez/io/redis.py +18 -22
  79. waldiez/io/structured.py +122 -70
  80. waldiez/io/utils.py +19 -10
  81. waldiez/io/ws.py +7 -3
  82. waldiez/logger.py +16 -3
  83. waldiez/models/agents/__init__.py +3 -0
  84. waldiez/models/agents/agent/agent.py +25 -17
  85. waldiez/models/agents/agent/agent_data.py +25 -22
  86. waldiez/models/agents/agent/code_execution.py +9 -11
  87. waldiez/models/agents/agent/termination_message.py +10 -12
  88. waldiez/models/agents/agent/update_system_message.py +2 -4
  89. waldiez/models/agents/agents.py +8 -8
  90. waldiez/models/agents/assistant/assistant.py +6 -3
  91. waldiez/models/agents/assistant/assistant_data.py +2 -2
  92. waldiez/models/agents/captain/captain_agent.py +7 -4
  93. waldiez/models/agents/captain/captain_agent_data.py +5 -7
  94. waldiez/models/agents/doc_agent/doc_agent.py +7 -4
  95. waldiez/models/agents/doc_agent/doc_agent_data.py +9 -10
  96. waldiez/models/agents/doc_agent/rag_query_engine.py +10 -12
  97. waldiez/models/agents/extra_requirements.py +3 -3
  98. waldiez/models/agents/group_manager/group_manager.py +12 -7
  99. waldiez/models/agents/group_manager/group_manager_data.py +13 -12
  100. waldiez/models/agents/group_manager/speakers.py +17 -19
  101. waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +7 -4
  102. waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +4 -1
  103. waldiez/models/agents/rag_user_proxy/retrieve_config.py +69 -63
  104. waldiez/models/agents/rag_user_proxy/vector_db_config.py +19 -19
  105. waldiez/models/agents/reasoning/reasoning_agent.py +7 -4
  106. waldiez/models/agents/reasoning/reasoning_agent_data.py +3 -2
  107. waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +8 -8
  108. waldiez/models/agents/user_proxy/user_proxy.py +6 -3
  109. waldiez/models/agents/user_proxy/user_proxy_data.py +1 -1
  110. waldiez/models/chat/chat.py +28 -20
  111. waldiez/models/chat/chat_data.py +22 -21
  112. waldiez/models/chat/chat_message.py +9 -9
  113. waldiez/models/chat/chat_nested.py +9 -9
  114. waldiez/models/chat/chat_summary.py +6 -6
  115. waldiez/models/common/__init__.py +2 -0
  116. waldiez/models/common/ag2_version.py +2 -0
  117. waldiez/models/common/base.py +2 -0
  118. waldiez/models/common/dict_utils.py +8 -6
  119. waldiez/models/common/handoff.py +20 -17
  120. waldiez/models/common/method_utils.py +9 -7
  121. waldiez/models/common/naming.py +49 -0
  122. waldiez/models/flow/flow.py +11 -6
  123. waldiez/models/flow/flow_data.py +23 -17
  124. waldiez/models/flow/info.py +3 -3
  125. waldiez/models/flow/naming.py +2 -1
  126. waldiez/models/model/_aws.py +11 -13
  127. waldiez/models/model/_llm.py +8 -0
  128. waldiez/models/model/_price.py +2 -4
  129. waldiez/models/model/extra_requirements.py +1 -3
  130. waldiez/models/model/model.py +2 -2
  131. waldiez/models/model/model_data.py +21 -21
  132. waldiez/models/tool/extra_requirements.py +2 -4
  133. waldiez/models/tool/predefined/_duckduckgo.py +1 -0
  134. waldiez/models/tool/predefined/_email.py +4 -0
  135. waldiez/models/tool/predefined/_google.py +1 -0
  136. waldiez/models/tool/predefined/_perplexity.py +2 -1
  137. waldiez/models/tool/predefined/_searxng.py +2 -1
  138. waldiez/models/tool/predefined/_tavily.py +1 -0
  139. waldiez/models/tool/predefined/_wikipedia.py +2 -1
  140. waldiez/models/tool/predefined/_youtube.py +1 -0
  141. waldiez/models/tool/tool.py +8 -5
  142. waldiez/models/tool/tool_data.py +2 -2
  143. waldiez/models/waldiez.py +152 -4
  144. waldiez/runner.py +11 -5
  145. waldiez/running/async_utils.py +192 -0
  146. waldiez/running/base_runner.py +155 -241
  147. waldiez/running/dir_utils.py +52 -0
  148. waldiez/running/environment.py +10 -44
  149. waldiez/running/events_mixin.py +252 -0
  150. waldiez/running/exceptions.py +20 -0
  151. waldiez/running/gen_seq_diagram.py +18 -15
  152. waldiez/running/io_utils.py +216 -0
  153. waldiez/running/protocol.py +11 -5
  154. waldiez/running/requirements_mixin.py +65 -0
  155. waldiez/running/results_mixin.py +926 -0
  156. waldiez/running/standard_runner.py +24 -27
  157. waldiez/running/step_by_step/breakpoints_mixin.py +503 -47
  158. waldiez/running/step_by_step/command_handler.py +154 -0
  159. waldiez/running/step_by_step/events_processor.py +379 -0
  160. waldiez/running/step_by_step/step_by_step_models.py +425 -41
  161. waldiez/running/step_by_step/step_by_step_runner.py +437 -382
  162. waldiez/running/subprocess_runner/__base__.py +13 -8
  163. waldiez/running/subprocess_runner/_async_runner.py +6 -4
  164. waldiez/running/subprocess_runner/_sync_runner.py +11 -6
  165. waldiez/running/subprocess_runner/runner.py +48 -23
  166. waldiez/running/timeline_processor.py +1 -1
  167. waldiez/utils/__init__.py +2 -0
  168. waldiez/utils/conflict_checker.py +4 -4
  169. waldiez/utils/python_manager.py +415 -0
  170. waldiez/ws/__init__.py +8 -7
  171. waldiez/ws/_file_handler.py +18 -20
  172. waldiez/ws/_mock.py +75 -0
  173. waldiez/ws/cli.py +58 -10
  174. waldiez/ws/client_manager.py +77 -53
  175. waldiez/ws/errors.py +3 -0
  176. waldiez/ws/models.py +61 -53
  177. waldiez/ws/reloader.py +33 -4
  178. waldiez/ws/server.py +121 -52
  179. waldiez/ws/session_manager.py +8 -9
  180. waldiez/ws/session_stats.py +1 -1
  181. waldiez/ws/utils.py +33 -5
  182. {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/METADATA +107 -109
  183. waldiez-0.6.1.dist-info/RECORD +254 -0
  184. waldiez/running/post_run.py +0 -180
  185. waldiez/running/pre_run.py +0 -159
  186. waldiez/running/run_results.py +0 -14
  187. waldiez/running/utils.py +0 -511
  188. waldiez-0.5.10.dist-info/RECORD +0 -248
  189. {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/WHEEL +0 -0
  190. {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/entry_points.txt +0 -0
  191. {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/licenses/LICENSE +0 -0
  192. {waldiez-0.5.10.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
 
@@ -194,6 +200,7 @@ class WaldiezChat(WaldiezBase):
194
200
  WaldiezHandoff
195
201
  The handoff representation of the chat.
196
202
  """
203
+ # noinspection PyTypeHints
197
204
  target: WaldiezTransitionTarget = WaldiezAgentTarget(
198
205
  target_type="AgentTarget",
199
206
  value=[self.target],
@@ -226,8 +233,8 @@ class WaldiezChat(WaldiezBase):
226
233
 
227
234
  def get_message_function(
228
235
  self,
229
- name_prefix: Optional[str] = None,
230
- name_suffix: Optional[str] = None,
236
+ name_prefix: str | None = None,
237
+ name_suffix: str | None = None,
231
238
  is_rag: bool = False,
232
239
  ) -> tuple[str, str]:
233
240
  """Get the message function.
@@ -280,10 +287,10 @@ class WaldiezChat(WaldiezBase):
280
287
 
281
288
  @staticmethod
282
289
  def _get_nested_chat_function(
283
- content: Optional[str],
290
+ content: str | None,
284
291
  function_name_base: str,
285
- name_prefix: Optional[str] = None,
286
- name_suffix: Optional[str] = None,
292
+ name_prefix: str | None = None,
293
+ name_suffix: str | None = None,
287
294
  ) -> tuple[str, str]:
288
295
  """Get the nested chat function.
289
296
 
@@ -322,16 +329,16 @@ class WaldiezChat(WaldiezBase):
322
329
 
323
330
  def get_nested_chat_message_function(
324
331
  self,
325
- name_prefix: Optional[str] = None,
326
- name_suffix: Optional[str] = None,
332
+ name_prefix: str | None = None,
333
+ name_suffix: str | None = None,
327
334
  ) -> tuple[str, str]:
328
335
  """Get the nested chat message function.
329
336
 
330
337
  Parameters
331
338
  ----------
332
- name_prefix : str
339
+ name_prefix : str | None
333
340
  The function name prefix.
334
- name_suffix : str
341
+ name_suffix : str | None
335
342
  The function name suffix.
336
343
 
337
344
  Returns
@@ -357,16 +364,16 @@ class WaldiezChat(WaldiezBase):
357
364
 
358
365
  def get_nested_chat_reply_function(
359
366
  self,
360
- name_prefix: Optional[str] = None,
361
- name_suffix: Optional[str] = None,
367
+ name_prefix: str | None = None,
368
+ name_suffix: str | None = None,
362
369
  ) -> tuple[str, str]:
363
370
  """Get the nested chat reply function.
364
371
 
365
372
  Parameters
366
373
  ----------
367
- name_prefix : str
374
+ name_prefix : str | None
368
375
  The function name prefix.
369
- name_suffix : str
376
+ name_suffix : str | None
370
377
  The function name suffix.
371
378
 
372
379
  Returns
@@ -393,7 +400,7 @@ class WaldiezChat(WaldiezBase):
393
400
  def get_chat_args(
394
401
  self,
395
402
  for_queue: bool,
396
- sender: Optional[WaldiezAgent] = None,
403
+ sender: Optional["WaldiezAgent"] = None,
397
404
  ) -> dict[str, Any]:
398
405
  """Get the chat arguments to use in autogen.
399
406
 
@@ -411,9 +418,10 @@ class WaldiezChat(WaldiezBase):
411
418
  """
412
419
  args_dict = self.data.get_chat_args(for_queue)
413
420
  if (
414
- isinstance(sender, WaldiezRagUserProxy)
421
+ sender
415
422
  and sender.is_rag_user
416
423
  and self.message.type == "rag_message_generator"
424
+ and hasattr(sender.data, "retrieve_config")
417
425
  ):
418
426
  # check for n_results in agent data, to add in context
419
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
@@ -55,8 +58,6 @@ class WaldiezChatData(WaldiezBase):
55
58
  The maximum number of turns for the chat, by default None (no limit).
56
59
  silent : bool, optional
57
60
  Whether to run the chat silently, by default False (not silent).
58
- summary_args : Optional[dict[str, Any]]
59
- The summary args to use in autogen.
60
61
  real_source : Optional[str]
61
62
  The real source of the chat (overrides the source).
62
63
  real_target : Optional[str]
@@ -73,7 +74,7 @@ class WaldiezChatData(WaldiezBase):
73
74
  title="Description",
74
75
  description="The description of the chat.",
75
76
  ),
76
- ] = "A new chat"
77
+ ]
77
78
  position: Annotated[
78
79
  int,
79
80
  Field(
@@ -81,7 +82,7 @@ class WaldiezChatData(WaldiezBase):
81
82
  title="Position",
82
83
  description="The position of the chat in the flow (Ignored).",
83
84
  ),
84
- ] = -1
85
+ ]
85
86
  order: Annotated[
86
87
  int,
87
88
  Field(
@@ -89,7 +90,7 @@ class WaldiezChatData(WaldiezBase):
89
90
  title="Order",
90
91
  description="The order of the chat in the flow.",
91
92
  ),
92
- ] = -1
93
+ ]
93
94
  clear_history: Annotated[
94
95
  bool,
95
96
  Field(
@@ -98,9 +99,9 @@ class WaldiezChatData(WaldiezBase):
98
99
  title="Clear History",
99
100
  description="Whether to clear the chat history.",
100
101
  ),
101
- ] = True
102
+ ]
102
103
  message: Annotated[
103
- Union[str, WaldiezChatMessage],
104
+ str | WaldiezChatMessage,
104
105
  Field(
105
106
  title="Message",
106
107
  description="The message of the chat.",
@@ -125,14 +126,14 @@ class WaldiezChatData(WaldiezBase):
125
126
  ),
126
127
  ]
127
128
  max_turns: Annotated[
128
- Optional[int],
129
+ int | None,
129
130
  Field(
130
131
  default=None,
131
132
  alias="maxTurns",
132
133
  title="Max Turns",
133
134
  description="The maximum number of turns for the chat.",
134
135
  ),
135
- ] = None
136
+ ]
136
137
  prerequisites: Annotated[
137
138
  list[str],
138
139
  Field(
@@ -140,7 +141,7 @@ class WaldiezChatData(WaldiezBase):
140
141
  description="The prerequisites (chat ids) for the chat (if async).",
141
142
  default_factory=list,
142
143
  ),
143
- ] = []
144
+ ]
144
145
  silent: Annotated[
145
146
  bool,
146
147
  Field(
@@ -148,25 +149,25 @@ class WaldiezChatData(WaldiezBase):
148
149
  title="Silent",
149
150
  description="Whether to run the chat silently.",
150
151
  ),
151
- ] = False
152
+ ]
152
153
  real_source: Annotated[
153
- Optional[str],
154
+ str | None,
154
155
  Field(
155
156
  default=None,
156
157
  alias="realSource",
157
158
  title="Real Source",
158
159
  description="The real source of the chat (overrides the source).",
159
160
  ),
160
- ] = None
161
+ ]
161
162
  real_target: Annotated[
162
- Optional[str],
163
+ str | None,
163
164
  Field(
164
165
  default=None,
165
166
  alias="realTarget",
166
167
  title="Real Target",
167
168
  description="The real target of the chat (overrides the target).",
168
169
  ),
169
- ] = None
170
+ ]
170
171
  source_type: Annotated[
171
172
  WaldiezAgentType,
172
173
  Field(
@@ -203,7 +204,7 @@ class WaldiezChatData(WaldiezBase):
203
204
  ),
204
205
  ]
205
206
  after_work: Annotated[
206
- Optional[WaldiezHandoffTransition],
207
+ WaldiezHandoffTransition | None,
207
208
  Field(
208
209
  None,
209
210
  title="After Work",
@@ -213,13 +214,13 @@ class WaldiezChatData(WaldiezBase):
213
214
  ),
214
215
  alias="afterWork",
215
216
  ),
216
- ] = None
217
- _message_content: Optional[str] = None
217
+ ]
218
+ _message_content: str | None = None
218
219
  _chat_id: int = 0
219
220
  _prerequisites: list[int] = []
220
221
 
221
222
  @property
222
- def message_content(self) -> Optional[str]:
223
+ def message_content(self) -> str | None:
223
224
  """Get the message content."""
224
225
  return self._message_content
225
226
 
@@ -336,7 +337,7 @@ class WaldiezChatData(WaldiezBase):
336
337
  return value
337
338
 
338
339
  @property
339
- def summary_args(self) -> Optional[dict[str, Any]]:
340
+ def summary_args(self) -> dict[str, Any] | None:
340
341
  """Get the summary args."""
341
342
  if self.summary.method not in (
342
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
@@ -58,6 +58,7 @@ class WaldiezBase(BaseModel):
58
58
  mode = "json"
59
59
  if by_alias is None: # pragma: no branch
60
60
  by_alias = True
61
+ # noinspection PyUnreachableCode
61
62
  if not isinstance(by_alias, bool):
62
63
  by_alias = True
63
64
  return super().model_dump(by_alias=by_alias, mode=mode, **kwargs)
@@ -92,6 +93,7 @@ class WaldiezBase(BaseModel):
92
93
  by_alias = kwargs.pop("by_alias", None)
93
94
  if by_alias is None:
94
95
  by_alias = True
96
+ # noinspection PyUnreachableCode
95
97
  if not isinstance(by_alias, bool):
96
98
  by_alias = True
97
99
  return super().model_dump_json(by_alias=by_alias, **kwargs)
@@ -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