waldiez 0.4.7__py3-none-any.whl → 0.4.9__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 (248) hide show
  1. waldiez/__init__.py +5 -5
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +97 -102
  4. waldiez/exporter.py +61 -19
  5. waldiez/exporting/__init__.py +25 -6
  6. waldiez/exporting/agent/__init__.py +7 -3
  7. waldiez/exporting/agent/code_execution.py +114 -0
  8. waldiez/exporting/agent/exporter.py +354 -0
  9. waldiez/exporting/agent/extras/__init__.py +15 -0
  10. waldiez/exporting/agent/extras/captain_agent_extras.py +315 -0
  11. waldiez/exporting/agent/extras/group/target.py +178 -0
  12. waldiez/exporting/agent/extras/group_manager_agent_extas.py +500 -0
  13. waldiez/exporting/agent/extras/group_member_extras.py +181 -0
  14. waldiez/exporting/agent/extras/handoffs/__init__.py +19 -0
  15. waldiez/exporting/agent/extras/handoffs/after_work.py +78 -0
  16. waldiez/exporting/agent/extras/handoffs/available.py +74 -0
  17. waldiez/exporting/agent/extras/handoffs/condition.py +158 -0
  18. waldiez/exporting/agent/extras/handoffs/handoff.py +171 -0
  19. waldiez/exporting/agent/extras/handoffs/target.py +189 -0
  20. waldiez/exporting/agent/extras/rag/__init__.py +10 -0
  21. waldiez/exporting/agent/{utils/rag_user/chroma_utils.py → extras/rag/chroma_extras.py} +37 -24
  22. waldiez/exporting/agent/{utils/rag_user/mongo_utils.py → extras/rag/mongo_extras.py} +10 -10
  23. waldiez/exporting/agent/{utils/rag_user/pgvector_utils.py → extras/rag/pgvector_extras.py} +13 -13
  24. waldiez/exporting/agent/{utils/rag_user/qdrant_utils.py → extras/rag/qdrant_extras.py} +13 -13
  25. waldiez/exporting/agent/{utils/rag_user/vector_db.py → extras/rag/vector_db_extras.py} +59 -46
  26. waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +245 -0
  27. waldiez/exporting/agent/extras/reasoning_agent_extras.py +88 -0
  28. waldiez/exporting/agent/factory.py +95 -0
  29. waldiez/exporting/agent/processor.py +150 -0
  30. waldiez/exporting/agent/system_message.py +36 -0
  31. waldiez/exporting/agent/termination.py +50 -0
  32. waldiez/exporting/chats/__init__.py +7 -3
  33. waldiez/exporting/chats/exporter.py +97 -0
  34. waldiez/exporting/chats/factory.py +65 -0
  35. waldiez/exporting/chats/processor.py +226 -0
  36. waldiez/exporting/chats/utils/__init__.py +6 -5
  37. waldiez/exporting/chats/utils/common.py +11 -45
  38. waldiez/exporting/chats/utils/group.py +55 -0
  39. waldiez/exporting/chats/utils/nested.py +37 -52
  40. waldiez/exporting/chats/utils/sequential.py +72 -61
  41. waldiez/exporting/chats/utils/{single_chat.py → single.py} +48 -50
  42. waldiez/exporting/core/__init__.py +196 -0
  43. waldiez/exporting/core/constants.py +17 -0
  44. waldiez/exporting/core/content.py +69 -0
  45. waldiez/exporting/core/context.py +244 -0
  46. waldiez/exporting/core/enums.py +89 -0
  47. waldiez/exporting/core/errors.py +19 -0
  48. waldiez/exporting/core/exporter.py +390 -0
  49. waldiez/exporting/core/exporters.py +67 -0
  50. waldiez/exporting/core/extras/__init__.py +39 -0
  51. waldiez/exporting/core/extras/agent_extras/__init__.py +27 -0
  52. waldiez/exporting/core/extras/agent_extras/captain_extras.py +57 -0
  53. waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +102 -0
  54. waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +53 -0
  55. waldiez/exporting/core/extras/agent_extras/reasoning_extras.py +68 -0
  56. waldiez/exporting/core/extras/agent_extras/standard_extras.py +263 -0
  57. waldiez/exporting/core/extras/base.py +241 -0
  58. waldiez/exporting/core/extras/chat_extras.py +118 -0
  59. waldiez/exporting/core/extras/flow_extras.py +70 -0
  60. waldiez/exporting/core/extras/model_extras.py +73 -0
  61. waldiez/exporting/core/extras/path_resolver.py +93 -0
  62. waldiez/exporting/core/extras/serializer.py +138 -0
  63. waldiez/exporting/core/extras/tool_extras.py +82 -0
  64. waldiez/exporting/core/protocols.py +259 -0
  65. waldiez/exporting/core/result.py +705 -0
  66. waldiez/exporting/core/types.py +329 -0
  67. waldiez/exporting/core/utils/__init__.py +11 -0
  68. waldiez/exporting/core/utils/comment.py +33 -0
  69. waldiez/exporting/core/utils/llm_config.py +117 -0
  70. waldiez/exporting/core/validation.py +96 -0
  71. waldiez/exporting/flow/__init__.py +6 -2
  72. waldiez/exporting/flow/execution_generator.py +193 -0
  73. waldiez/exporting/flow/exporter.py +107 -0
  74. waldiez/exporting/flow/factory.py +94 -0
  75. waldiez/exporting/flow/file_generator.py +214 -0
  76. waldiez/exporting/flow/merger.py +387 -0
  77. waldiez/exporting/flow/orchestrator.py +411 -0
  78. waldiez/exporting/flow/utils/__init__.py +9 -36
  79. waldiez/exporting/flow/utils/common.py +206 -0
  80. waldiez/exporting/flow/utils/importing.py +373 -0
  81. waldiez/exporting/flow/utils/linting.py +200 -0
  82. waldiez/exporting/flow/utils/{logging_utils.py → logging.py} +23 -9
  83. waldiez/exporting/models/__init__.py +3 -1
  84. waldiez/exporting/models/exporter.py +233 -0
  85. waldiez/exporting/models/factory.py +66 -0
  86. waldiez/exporting/models/processor.py +139 -0
  87. waldiez/exporting/tools/__init__.py +11 -0
  88. waldiez/exporting/tools/exporter.py +207 -0
  89. waldiez/exporting/tools/factory.py +57 -0
  90. waldiez/exporting/tools/processor.py +248 -0
  91. waldiez/exporting/tools/registration.py +133 -0
  92. waldiez/io/__init__.py +128 -0
  93. waldiez/io/_ws.py +199 -0
  94. waldiez/io/models/__init__.py +60 -0
  95. waldiez/io/models/base.py +66 -0
  96. waldiez/io/models/constants.py +78 -0
  97. waldiez/io/models/content/__init__.py +23 -0
  98. waldiez/io/models/content/audio.py +43 -0
  99. waldiez/io/models/content/base.py +45 -0
  100. waldiez/io/models/content/file.py +43 -0
  101. waldiez/io/models/content/image.py +96 -0
  102. waldiez/io/models/content/text.py +37 -0
  103. waldiez/io/models/content/video.py +43 -0
  104. waldiez/io/models/user_input.py +269 -0
  105. waldiez/io/models/user_response.py +215 -0
  106. waldiez/io/mqtt.py +681 -0
  107. waldiez/io/redis.py +782 -0
  108. waldiez/io/structured.py +439 -0
  109. waldiez/io/utils.py +184 -0
  110. waldiez/io/ws.py +298 -0
  111. waldiez/logger.py +481 -0
  112. waldiez/models/__init__.py +108 -51
  113. waldiez/models/agents/__init__.py +34 -70
  114. waldiez/models/agents/agent/__init__.py +10 -4
  115. waldiez/models/agents/agent/agent.py +466 -65
  116. waldiez/models/agents/agent/agent_data.py +119 -47
  117. waldiez/models/agents/agent/agent_type.py +13 -2
  118. waldiez/models/agents/agent/code_execution.py +12 -12
  119. waldiez/models/agents/agent/human_input_mode.py +8 -0
  120. waldiez/models/agents/agent/{linked_skill.py → linked_tool.py} +7 -7
  121. waldiez/models/agents/agent/nested_chat.py +35 -7
  122. waldiez/models/agents/agent/termination_message.py +30 -22
  123. waldiez/models/agents/{swarm_agent → agent}/update_system_message.py +22 -22
  124. waldiez/models/agents/agents.py +58 -63
  125. waldiez/models/agents/assistant/assistant.py +4 -4
  126. waldiez/models/agents/assistant/assistant_data.py +13 -1
  127. waldiez/models/agents/{captain_agent → captain}/captain_agent.py +5 -5
  128. waldiez/models/agents/{captain_agent → captain}/captain_agent_data.py +5 -5
  129. waldiez/models/agents/extra_requirements.py +11 -16
  130. waldiez/models/agents/group_manager/group_manager.py +103 -13
  131. waldiez/models/agents/group_manager/group_manager_data.py +36 -14
  132. waldiez/models/agents/group_manager/speakers.py +77 -24
  133. waldiez/models/agents/{rag_user → rag_user_proxy}/__init__.py +16 -16
  134. waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +64 -0
  135. waldiez/models/agents/{rag_user/rag_user_data.py → rag_user_proxy/rag_user_proxy_data.py} +6 -5
  136. waldiez/models/agents/{rag_user → rag_user_proxy}/retrieve_config.py +182 -114
  137. waldiez/models/agents/{rag_user → rag_user_proxy}/vector_db_config.py +13 -13
  138. waldiez/models/agents/reasoning/reasoning_agent.py +6 -6
  139. waldiez/models/agents/reasoning/reasoning_agent_data.py +110 -63
  140. waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +38 -10
  141. waldiez/models/agents/user_proxy/user_proxy.py +11 -7
  142. waldiez/models/agents/user_proxy/user_proxy_data.py +2 -2
  143. waldiez/models/chat/__init__.py +2 -1
  144. waldiez/models/chat/chat.py +166 -87
  145. waldiez/models/chat/chat_data.py +99 -136
  146. waldiez/models/chat/chat_message.py +33 -23
  147. waldiez/models/chat/chat_nested.py +31 -30
  148. waldiez/models/chat/chat_summary.py +10 -8
  149. waldiez/models/common/__init__.py +52 -2
  150. waldiez/models/common/ag2_version.py +1 -1
  151. waldiez/models/common/base.py +38 -7
  152. waldiez/models/common/dict_utils.py +42 -17
  153. waldiez/models/common/handoff.py +459 -0
  154. waldiez/models/common/id_generator.py +19 -0
  155. waldiez/models/common/method_utils.py +130 -68
  156. waldiez/{exporting/base/utils → models/common}/naming.py +38 -61
  157. waldiez/models/common/waldiez_version.py +37 -0
  158. waldiez/models/flow/__init__.py +9 -2
  159. waldiez/models/flow/connection.py +18 -0
  160. waldiez/models/flow/flow.py +311 -215
  161. waldiez/models/flow/flow_data.py +207 -40
  162. waldiez/models/flow/info.py +85 -0
  163. waldiez/models/flow/naming.py +131 -0
  164. waldiez/models/model/__init__.py +7 -1
  165. waldiez/models/model/extra_requirements.py +3 -12
  166. waldiez/models/model/model.py +76 -21
  167. waldiez/models/model/model_data.py +108 -20
  168. waldiez/models/tool/__init__.py +16 -0
  169. waldiez/models/tool/extra_requirements.py +36 -0
  170. waldiez/models/{skill/skill.py → tool/tool.py} +88 -88
  171. waldiez/models/tool/tool_data.py +51 -0
  172. waldiez/models/tool/tool_type.py +8 -0
  173. waldiez/models/waldiez.py +97 -80
  174. waldiez/runner.py +115 -61
  175. waldiez/running/__init__.py +13 -7
  176. waldiez/running/environment.py +49 -68
  177. waldiez/running/gen_seq_diagram.py +16 -14
  178. waldiez/running/post_run.py +119 -0
  179. waldiez/running/pre_run.py +149 -0
  180. waldiez/running/util.py +134 -0
  181. waldiez/utils/__init__.py +2 -4
  182. waldiez/utils/cli_extras/jupyter.py +5 -3
  183. waldiez/utils/cli_extras/runner.py +6 -4
  184. waldiez/utils/cli_extras/studio.py +6 -4
  185. waldiez/utils/conflict_checker.py +15 -9
  186. waldiez/utils/flaml_warnings.py +5 -5
  187. waldiez/utils/version.py +47 -0
  188. {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/METADATA +235 -91
  189. waldiez-0.4.9.dist-info/RECORD +203 -0
  190. waldiez/exporting/agent/agent_exporter.py +0 -297
  191. waldiez/exporting/agent/utils/__init__.py +0 -23
  192. waldiez/exporting/agent/utils/captain_agent.py +0 -263
  193. waldiez/exporting/agent/utils/code_execution.py +0 -65
  194. waldiez/exporting/agent/utils/group_manager.py +0 -220
  195. waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
  196. waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
  197. waldiez/exporting/agent/utils/reasoning.py +0 -36
  198. waldiez/exporting/agent/utils/swarm_agent.py +0 -469
  199. waldiez/exporting/agent/utils/teachability.py +0 -41
  200. waldiez/exporting/agent/utils/termination_message.py +0 -44
  201. waldiez/exporting/base/__init__.py +0 -25
  202. waldiez/exporting/base/agent_position.py +0 -75
  203. waldiez/exporting/base/base_exporter.py +0 -118
  204. waldiez/exporting/base/export_position.py +0 -48
  205. waldiez/exporting/base/import_position.py +0 -23
  206. waldiez/exporting/base/mixin.py +0 -137
  207. waldiez/exporting/base/utils/__init__.py +0 -18
  208. waldiez/exporting/base/utils/comments.py +0 -96
  209. waldiez/exporting/base/utils/path_check.py +0 -68
  210. waldiez/exporting/base/utils/to_string.py +0 -84
  211. waldiez/exporting/chats/chats_exporter.py +0 -240
  212. waldiez/exporting/chats/utils/swarm.py +0 -210
  213. waldiez/exporting/flow/flow_exporter.py +0 -528
  214. waldiez/exporting/flow/utils/agent_utils.py +0 -204
  215. waldiez/exporting/flow/utils/chat_utils.py +0 -71
  216. waldiez/exporting/flow/utils/def_main.py +0 -77
  217. waldiez/exporting/flow/utils/flow_content.py +0 -202
  218. waldiez/exporting/flow/utils/flow_names.py +0 -116
  219. waldiez/exporting/flow/utils/importing_utils.py +0 -227
  220. waldiez/exporting/models/models_exporter.py +0 -199
  221. waldiez/exporting/models/utils.py +0 -174
  222. waldiez/exporting/skills/__init__.py +0 -9
  223. waldiez/exporting/skills/skills_exporter.py +0 -176
  224. waldiez/exporting/skills/utils.py +0 -369
  225. waldiez/models/agents/agent/teachability.py +0 -70
  226. waldiez/models/agents/rag_user/rag_user.py +0 -60
  227. waldiez/models/agents/swarm_agent/__init__.py +0 -50
  228. waldiez/models/agents/swarm_agent/after_work.py +0 -179
  229. waldiez/models/agents/swarm_agent/on_condition.py +0 -105
  230. waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
  231. waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
  232. waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
  233. waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
  234. waldiez/models/flow/utils.py +0 -232
  235. waldiez/models/skill/__init__.py +0 -16
  236. waldiez/models/skill/extra_requirements.py +0 -36
  237. waldiez/models/skill/skill_data.py +0 -53
  238. waldiez/models/skill/skill_type.py +0 -8
  239. waldiez/running/running.py +0 -369
  240. waldiez/utils/pysqlite3_checker.py +0 -308
  241. waldiez/utils/rdps_checker.py +0 -122
  242. waldiez-0.4.7.dist-info/RECORD +0 -149
  243. /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
  244. /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
  245. {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/WHEEL +0 -0
  246. {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/entry_points.txt +0 -0
  247. {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/licenses/LICENSE +0 -0
  248. {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/licenses/NOTICE.md +0 -0
@@ -0,0 +1,390 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ # pylint: disable=too-few-public-methods
4
+ """Base exporter classes."""
5
+
6
+ import abc
7
+ from typing import Any, Generic, Optional
8
+
9
+ from .constants import DEFAULT_IMPORT_POSITION
10
+ from .content import PositionedContent
11
+ from .context import DefaultExporterContext, ExporterContext
12
+ from .enums import (
13
+ AgentPosition,
14
+ ContentOrder,
15
+ ExportPosition,
16
+ ImportPosition,
17
+ )
18
+ from .protocols import ExportContributor
19
+ from .result import ExportResult, ExportResultBuilder
20
+ from .types import (
21
+ EnvironmentVariable,
22
+ ExportConfig,
23
+ Extras,
24
+ ImportStatement,
25
+ )
26
+
27
+
28
+ class Exporter(abc.ABC, Generic[Extras]):
29
+ """Exporter base class with structured extras and clean interface."""
30
+
31
+ def __init__(
32
+ self,
33
+ context: Optional[ExporterContext] = None,
34
+ **kwargs: Any,
35
+ ):
36
+ """Initialize the exporter.
37
+
38
+ Parameters
39
+ ----------
40
+ context : Optional[ExporterContext], optional
41
+ The exporter context with dependencies, by default None
42
+ **kwargs : Any
43
+ Additional keyword arguments for subclasses.
44
+ """
45
+ self._context = context or DefaultExporterContext(
46
+ config=ExportConfig.create(**kwargs)
47
+ )
48
+ config = self._context.get_config()
49
+ config.update(**kwargs)
50
+ self._context.set_config(config)
51
+ self._result = ExportResult()
52
+ self._initialized = False
53
+ self._builder = ExportResultBuilder()
54
+ self.config = self._context.get_config()
55
+
56
+ # Allow subclasses to handle additional kwargs
57
+ self._handle_kwargs(**kwargs)
58
+
59
+ def _handle_kwargs(self, **kwargs: Any) -> None:
60
+ """Handle additional keyword arguments.
61
+
62
+ Override in subclasses to handle specific arguments.
63
+
64
+ Parameters
65
+ ----------
66
+ **kwargs : Any
67
+ Additional keyword arguments.
68
+ """
69
+
70
+ @property
71
+ def context(self) -> ExporterContext:
72
+ """Get the exporter context.
73
+
74
+ Returns
75
+ -------
76
+ ExporterContext
77
+ The exporter context.
78
+ """
79
+ return self._context
80
+
81
+ @property
82
+ @abc.abstractmethod
83
+ def extras(self) -> Extras:
84
+ """Get the structured extras for this exporter.
85
+
86
+ Returns
87
+ -------
88
+ Extras
89
+ The extras instance.
90
+ """
91
+
92
+ @abc.abstractmethod
93
+ def generate_main_content(self) -> Optional[str]:
94
+ """Generate the main export content.
95
+
96
+ Returns
97
+ -------
98
+ Optional[str]
99
+ The main content, or None if no content should be generated.
100
+ """
101
+
102
+ def _ensure_initialized(self) -> None:
103
+ """Ensure the exporter is properly initialized."""
104
+ if not self._initialized:
105
+ self._initialize_export()
106
+ self._initialized = True
107
+
108
+ def _initialize_export(self) -> None:
109
+ """Initialize the export with content from extras and main content."""
110
+ # Let extras contribute their content first
111
+ if isinstance(self.extras, ExportContributor):
112
+ self.extras.contribute_to_export(self._result)
113
+
114
+ # Generate and set main content
115
+ main_content = self.generate_main_content()
116
+ if main_content:
117
+ self._result.main_content = main_content
118
+
119
+ # Add default imports if available
120
+ self._add_default_imports()
121
+
122
+ # Allow subclasses to add additional content
123
+ self._add_additional_content()
124
+
125
+ # Validate if validator is available
126
+ self._validate_result()
127
+
128
+ def _add_default_imports(self) -> None:
129
+ """Add default imports for this exporter type.
130
+
131
+ Override in subclasses to add type-specific imports.
132
+ """
133
+
134
+ def _add_additional_content(self) -> None:
135
+ """Additional content (subclasses hook).
136
+
137
+ This is called after extras contribution and main content generation.
138
+ """
139
+
140
+ def _validate_result(self) -> None:
141
+ """Validate the export result if validator is available."""
142
+ if self._context.validator:
143
+ validation_result = self._context.validator.validate(self._result)
144
+ self._result.validation_result = validation_result
145
+
146
+ # Convenience methods for adding content
147
+
148
+ def add_import(
149
+ self,
150
+ statement: str,
151
+ position: ImportPosition = DEFAULT_IMPORT_POSITION,
152
+ ) -> None:
153
+ """Add an import statement.
154
+
155
+ Parameters
156
+ ----------
157
+ statement : str
158
+ The import statement to add.
159
+ position : ImportPosition, optional
160
+ The position of the import, by default THIRD_PARTY
161
+ """
162
+ self._result.add_import(statement, position)
163
+
164
+ def add_imports(
165
+ self,
166
+ statements: set[str],
167
+ position: ImportPosition = DEFAULT_IMPORT_POSITION,
168
+ ) -> None:
169
+ """Add multiple import statements.
170
+
171
+ Parameters
172
+ ----------
173
+ statements : Set[str]
174
+ The import statements to add.
175
+ position : ImportPosition, optional
176
+ The position of the imports, by default THIRD_PARTY
177
+ """
178
+ self._result.add_imports(statements, position)
179
+
180
+ def add_content(
181
+ self,
182
+ content: str,
183
+ position: ExportPosition,
184
+ order: ContentOrder = ContentOrder.MAIN_CONTENT,
185
+ agent_id: Optional[str] = None,
186
+ agent_position: Optional[AgentPosition] = None,
187
+ skip_strip: bool | None = None,
188
+ **metadata: Any,
189
+ ) -> None:
190
+ """Add positioned content.
191
+
192
+ Parameters
193
+ ----------
194
+ content : str
195
+ The content to add.
196
+ position : ExportPosition
197
+ The position of the content.
198
+ order : int, optional
199
+ The order within the position, by default 0
200
+ agent_id : Optional[str], optional
201
+ Agent ID for agent-relative positioning, by default None
202
+ agent_position : Optional[AgentPosition], optional
203
+ Position relative to agent, by default None
204
+ skip_strip : bool | None, optional
205
+ Whether to skip stripping whitespace, by default None
206
+ If None, defaults to True for CHATS position (keep identation),
207
+ **metadata : Any
208
+ Additional metadata for the content.
209
+ """
210
+ if skip_strip is None:
211
+ skip_strip = position == ExportPosition.CHATS
212
+ self._result.add_content(
213
+ content=content,
214
+ position=position,
215
+ order=order,
216
+ agent_id=agent_id,
217
+ agent_position=agent_position,
218
+ skip_strip=skip_strip,
219
+ **metadata,
220
+ )
221
+
222
+ def add_env_var(
223
+ self,
224
+ name: str,
225
+ value: str,
226
+ description: Optional[str] = None,
227
+ required: bool = True,
228
+ ) -> None:
229
+ """Add environment variable.
230
+
231
+ Parameters
232
+ ----------
233
+ name : str
234
+ The name of the environment variable.
235
+ value : str
236
+ The value of the environment variable.
237
+ description : Optional[str], optional
238
+ Description of the variable, by default None
239
+ required : bool, optional
240
+ Whether the variable is required, by default True
241
+ """
242
+ self._result.add_env_var(name, value, description, required)
243
+
244
+ def set_metadata(self, key: str, value: Any) -> None:
245
+ """Set metadata on the export result.
246
+
247
+ Parameters
248
+ ----------
249
+ key : str
250
+ The metadata key.
251
+ value : Any
252
+ The metadata value.
253
+ """
254
+ self._result.metadata[key] = value
255
+
256
+ def get_metadata(self, key: str, default: Any = None) -> Any:
257
+ """Get metadata from the export result.
258
+
259
+ Parameters
260
+ ----------
261
+ key : str
262
+ The metadata key.
263
+ default : Any, optional
264
+ Default value if key not found, by default None
265
+
266
+ Returns
267
+ -------
268
+ Any
269
+ The metadata value or default.
270
+ """
271
+ return self._result.metadata.get(key, default)
272
+
273
+ # Public interface methods
274
+
275
+ def export(self) -> ExportResult:
276
+ """Export and return the complete result.
277
+
278
+ Returns
279
+ -------
280
+ ExportResult
281
+ The complete export result.
282
+ """
283
+ self._ensure_initialized()
284
+ return self._result
285
+
286
+ def get_imports(self) -> list[ImportStatement]:
287
+ """Get sorted imports.
288
+
289
+ Returns
290
+ -------
291
+ List[ImportStatement]
292
+ Sorted list of import statements.
293
+ """
294
+ self._ensure_initialized()
295
+ return self._result.get_sorted_imports()
296
+
297
+ def get_content_by_position(
298
+ self, position: ExportPosition
299
+ ) -> list[PositionedContent]:
300
+ """Get content for a specific position.
301
+
302
+ Parameters
303
+ ----------
304
+ position : ExportPosition
305
+ The position to filter by.
306
+
307
+ Returns
308
+ -------
309
+ List[PositionedContent]
310
+ List of content for the specified position.
311
+ """
312
+ self._ensure_initialized()
313
+ return self._result.get_content_by_position(position)
314
+
315
+ def get_main_content(self) -> Optional[str]:
316
+ """Get the main content.
317
+
318
+ Returns
319
+ -------
320
+ Optional[str]
321
+ The main content.
322
+ """
323
+ self._ensure_initialized()
324
+ return self._result.main_content
325
+
326
+ def get_environment_variables(self) -> list[EnvironmentVariable]:
327
+ """Get environment variables.
328
+
329
+ Returns
330
+ -------
331
+ List[EnvironmentVariable]
332
+ List of environment variables.
333
+ """
334
+ self._ensure_initialized()
335
+ return self._result.environment_variables
336
+
337
+ def has_content(self) -> bool:
338
+ """Check if the exporter has any content.
339
+
340
+ Returns
341
+ -------
342
+ bool
343
+ True if there's any content.
344
+ """
345
+ self._ensure_initialized()
346
+ return self._result.has_content()
347
+
348
+ def has_errors(self) -> bool:
349
+ """Check if there are validation errors.
350
+
351
+ Returns
352
+ -------
353
+ bool
354
+ True if there are validation errors.
355
+ """
356
+ self._ensure_initialized()
357
+ return self._result.has_errors()
358
+
359
+ def has_warnings(self) -> bool:
360
+ """Check if there are validation warnings.
361
+
362
+ Returns
363
+ -------
364
+ bool
365
+ True if there are validation warnings.
366
+ """
367
+ self._ensure_initialized()
368
+ return self._result.has_warnings()
369
+
370
+ def get_statistics(self) -> dict[str, int]:
371
+ """Get statistics about the export.
372
+
373
+ Returns
374
+ -------
375
+ Dict[str, int]
376
+ Dictionary with export statistics.
377
+ """
378
+ self._ensure_initialized()
379
+ return self._result.get_statistics()
380
+
381
+ def clear(self) -> None:
382
+ """Clear all export content and reset initialization state."""
383
+ self._result.clear()
384
+ self._initialized = False
385
+
386
+ def reset(self) -> None:
387
+ """Reset the exporter to initial state."""
388
+ self._result = ExportResult()
389
+ self._initialized = False
390
+ self._builder = ExportResultBuilder()
@@ -0,0 +1,67 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ """Exporters for Waldiez."""
5
+
6
+ from typing import Any, Optional
7
+
8
+ from .exporter import Exporter
9
+ from .types import Extras
10
+
11
+
12
+ class SimpleExporter(Exporter[None]):
13
+ """Simple exporter that doesn't use extras system."""
14
+
15
+ @property
16
+ def extras(self) -> None:
17
+ """Simple exporters don't have extras."""
18
+ return None
19
+
20
+ def _add_additional_content(self) -> None:
21
+ """Override this for custom content in simple exporters."""
22
+
23
+
24
+ class ConfigurableExporter(Exporter[Extras]):
25
+ """Exporter with configuration support."""
26
+
27
+ def __init__(self, config: Optional[dict[str, Any]] = None, **kwargs: Any):
28
+ """Initialize with configuration.
29
+
30
+ Parameters
31
+ ----------
32
+ config : Optional[Dict[str, Any]], optional
33
+ Configuration dictionary, by default None
34
+ **kwargs : Any
35
+ Additional keyword arguments.
36
+ """
37
+ super().__init__(**kwargs)
38
+ self._config = config or {}
39
+
40
+ def get_config_value(self, key: str, default: Any = None) -> Any:
41
+ """Get a configuration value.
42
+
43
+ Parameters
44
+ ----------
45
+ key : str
46
+ The configuration key.
47
+ default : Any, optional
48
+ Default value if key not found, by default None
49
+
50
+ Returns
51
+ -------
52
+ Any
53
+ The configuration value or default.
54
+ """
55
+ return self._config.get(key, default)
56
+
57
+ def set_config_value(self, key: str, value: Any) -> None:
58
+ """Set a configuration value.
59
+
60
+ Parameters
61
+ ----------
62
+ key : str
63
+ The configuration key.
64
+ value : Any
65
+ The configuration value.
66
+ """
67
+ self._config[key] = value
@@ -0,0 +1,39 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Extras for Waldiez exporting core module."""
4
+
5
+ from .agent_extras import (
6
+ CaptainExtras,
7
+ CodeExecutionConfig,
8
+ GroupManagerExtras,
9
+ RAGUserExtras,
10
+ ReasoningExtras,
11
+ StandardExtras,
12
+ SystemMessageConfig,
13
+ TerminationConfig,
14
+ )
15
+ from .base import BaseExtras
16
+ from .chat_extras import ChatExtras
17
+ from .flow_extras import FlowExtras
18
+ from .model_extras import ModelExtras
19
+ from .path_resolver import DefaultPathResolver
20
+ from .serializer import DefaultSerializer
21
+ from .tool_extras import ToolExtras
22
+
23
+ __all__ = [
24
+ "BaseExtras",
25
+ "ChatExtras",
26
+ "FlowExtras",
27
+ "ModelExtras",
28
+ "DefaultPathResolver",
29
+ "DefaultSerializer",
30
+ "ToolExtras",
31
+ "StandardExtras",
32
+ "CaptainExtras",
33
+ "CodeExecutionConfig",
34
+ "SystemMessageConfig",
35
+ "TerminationConfig",
36
+ "RAGUserExtras",
37
+ "ReasoningExtras",
38
+ "GroupManagerExtras",
39
+ ]
@@ -0,0 +1,27 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ # pylint: disable=too-few-public-methods
4
+ """Agent specific extras module."""
5
+
6
+ from .captain_extras import CaptainExtras
7
+ from .group_manager_extras import GroupManagerExtras
8
+ from .rag_user_extras import RAGUserExtras
9
+ from .reasoning_extras import ReasoningExtras
10
+ from .standard_extras import (
11
+ CodeExecutionConfig,
12
+ StandardExtras,
13
+ SystemMessageConfig,
14
+ TerminationConfig,
15
+ )
16
+
17
+ __all__ = [
18
+ "StandardExtras",
19
+ "CaptainExtras",
20
+ "StandardExtras",
21
+ "RAGUserExtras",
22
+ "ReasoningExtras",
23
+ "GroupManagerExtras",
24
+ "CodeExecutionConfig",
25
+ "SystemMessageConfig",
26
+ "TerminationConfig",
27
+ ]
@@ -0,0 +1,57 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Captain agent extras module."""
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Any, Optional
7
+
8
+ from waldiez.exporting.core.result import ExportResult
9
+
10
+ from .standard_extras import StandardExtras
11
+
12
+
13
+ @dataclass
14
+ class CaptainExtras(StandardExtras):
15
+ """Extras for captain agents."""
16
+
17
+ nested_config: Optional[dict[str, Any]] = None
18
+
19
+ def _contribute_specific_content(self, result: ExportResult) -> None:
20
+ """Contribute captain specific content to the export result.
21
+
22
+ Parameters
23
+ ----------
24
+ result : ExportResult
25
+ The export result to contribute to.
26
+ """
27
+ super()._contribute_specific_content(result)
28
+ if self.extra_args:
29
+ for arg in self.extra_args:
30
+ result.add_instance_argument(
31
+ name=arg.name,
32
+ value=arg.value,
33
+ instance_id=arg.instance_id,
34
+ tabs=arg.tabs,
35
+ )
36
+
37
+ def set_nested_config(self, config: dict[str, Any]) -> None:
38
+ """Set the nested configuration.
39
+
40
+ Parameters
41
+ ----------
42
+ config : Dict[str, Any]
43
+ The nested configuration.
44
+ """
45
+ self.nested_config = config
46
+
47
+ def has_specific_content(self) -> bool:
48
+ """Check for captain specific content.
49
+
50
+ Returns
51
+ -------
52
+ bool
53
+ True if there's captain specific content.
54
+ """
55
+ if not super().has_specific_content():
56
+ return bool(self.extra_args or self.nested_config)
57
+ return True
@@ -0,0 +1,102 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+
4
+ """Group manager agent specific extras module."""
5
+
6
+ from dataclasses import dataclass, field
7
+
8
+ from ...enums import (
9
+ AgentPosition,
10
+ ContentOrder,
11
+ ExportPosition,
12
+ GroupManagerStrategy,
13
+ ImportPosition,
14
+ )
15
+ from ...result import ExportResult
16
+ from .standard_extras import StandardExtras
17
+
18
+
19
+ @dataclass
20
+ class GroupManagerExtras(StandardExtras):
21
+ """Extras for group manager agents."""
22
+
23
+ # Strategy determination
24
+ strategy: GroupManagerStrategy = GroupManagerStrategy.PATTERN
25
+
26
+ # Pattern-based content
27
+ pattern_definition: str = ""
28
+ pattern_class_name: str = "AutoPattern"
29
+ pattern_imports: set[str] = field(default_factory=set[str])
30
+
31
+ # Traditional GroupChat content
32
+ group_chat_definition: str = ""
33
+ group_chat_name: str = ""
34
+ group_chat_argument: str = ""
35
+ custom_speaker_selection: str = ""
36
+
37
+ # Shared content
38
+ context_variables_content: str = ""
39
+ after_work_content: str = ""
40
+
41
+ def has_specific_content(self) -> bool:
42
+ """Check if group manager has specific content.
43
+
44
+ Returns
45
+ -------
46
+ bool
47
+ True if there is specific content for the group manager,
48
+ """
49
+ if not super().has_specific_content():
50
+ return bool(
51
+ self.pattern_definition.strip()
52
+ or self.group_chat_definition.strip()
53
+ or self.custom_speaker_selection.strip()
54
+ )
55
+ return True
56
+
57
+ def _contribute_specific_content(self, result: ExportResult) -> None:
58
+ """Contribute group manager content to export.
59
+
60
+ Parameters
61
+ ----------
62
+ result : ExportResult
63
+ The export result to contribute to.
64
+ """
65
+ super()._contribute_specific_content(result)
66
+ # Add pattern imports
67
+ for import_stmt in self.pattern_imports:
68
+ result.add_import(import_stmt, position=ImportPosition.THIRD_PARTY)
69
+
70
+ # Add pattern definition or group chat definition
71
+ if (
72
+ self.strategy == GroupManagerStrategy.PATTERN
73
+ and self.pattern_definition
74
+ ):
75
+ result.add_content(
76
+ self.pattern_definition,
77
+ ExportPosition.AGENTS,
78
+ agent_position=AgentPosition.AFTER_ALL,
79
+ order=ContentOrder.LATE_CLEANUP,
80
+ )
81
+ elif self.strategy == GroupManagerStrategy.TRADITIONAL:
82
+ # Add custom speaker selection function first
83
+ if self.custom_speaker_selection:
84
+ result.add_content(
85
+ self.custom_speaker_selection,
86
+ ExportPosition.AGENTS,
87
+ agent_position=AgentPosition.AFTER_ALL,
88
+ order=ContentOrder.LATE_CLEANUP,
89
+ )
90
+
91
+ # Add grop chat argument if specified
92
+ if self.group_chat_argument:
93
+ self.add_arg(self.group_chat_argument, tabs=1)
94
+
95
+ # Add group chat definition
96
+ if self.group_chat_definition:
97
+ result.add_content(
98
+ self.group_chat_definition,
99
+ ExportPosition.AGENTS,
100
+ agent_position=AgentPosition.AFTER_ALL,
101
+ order=ContentOrder.LATE_CLEANUP.value - 1,
102
+ )