waldiez 0.4.7__py3-none-any.whl → 0.4.8__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 (244) hide show
  1. waldiez/__init__.py +5 -5
  2. waldiez/_version.py +1 -1
  3. waldiez/cli.py +112 -73
  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} +16 -15
  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 +419 -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 +114 -49
  175. waldiez/running/__init__.py +1 -1
  176. waldiez/running/environment.py +49 -68
  177. waldiez/running/gen_seq_diagram.py +16 -14
  178. waldiez/running/running.py +53 -34
  179. waldiez/utils/__init__.py +0 -4
  180. waldiez/utils/cli_extras/jupyter.py +5 -3
  181. waldiez/utils/cli_extras/runner.py +6 -4
  182. waldiez/utils/cli_extras/studio.py +6 -4
  183. waldiez/utils/conflict_checker.py +15 -9
  184. waldiez/utils/flaml_warnings.py +5 -5
  185. {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/METADATA +235 -91
  186. waldiez-0.4.8.dist-info/RECORD +200 -0
  187. waldiez/exporting/agent/agent_exporter.py +0 -297
  188. waldiez/exporting/agent/utils/__init__.py +0 -23
  189. waldiez/exporting/agent/utils/captain_agent.py +0 -263
  190. waldiez/exporting/agent/utils/code_execution.py +0 -65
  191. waldiez/exporting/agent/utils/group_manager.py +0 -220
  192. waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
  193. waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
  194. waldiez/exporting/agent/utils/reasoning.py +0 -36
  195. waldiez/exporting/agent/utils/swarm_agent.py +0 -469
  196. waldiez/exporting/agent/utils/teachability.py +0 -41
  197. waldiez/exporting/agent/utils/termination_message.py +0 -44
  198. waldiez/exporting/base/__init__.py +0 -25
  199. waldiez/exporting/base/agent_position.py +0 -75
  200. waldiez/exporting/base/base_exporter.py +0 -118
  201. waldiez/exporting/base/export_position.py +0 -48
  202. waldiez/exporting/base/import_position.py +0 -23
  203. waldiez/exporting/base/mixin.py +0 -137
  204. waldiez/exporting/base/utils/__init__.py +0 -18
  205. waldiez/exporting/base/utils/comments.py +0 -96
  206. waldiez/exporting/base/utils/path_check.py +0 -68
  207. waldiez/exporting/base/utils/to_string.py +0 -84
  208. waldiez/exporting/chats/chats_exporter.py +0 -240
  209. waldiez/exporting/chats/utils/swarm.py +0 -210
  210. waldiez/exporting/flow/flow_exporter.py +0 -528
  211. waldiez/exporting/flow/utils/agent_utils.py +0 -204
  212. waldiez/exporting/flow/utils/chat_utils.py +0 -71
  213. waldiez/exporting/flow/utils/def_main.py +0 -77
  214. waldiez/exporting/flow/utils/flow_content.py +0 -202
  215. waldiez/exporting/flow/utils/flow_names.py +0 -116
  216. waldiez/exporting/flow/utils/importing_utils.py +0 -227
  217. waldiez/exporting/models/models_exporter.py +0 -199
  218. waldiez/exporting/models/utils.py +0 -174
  219. waldiez/exporting/skills/__init__.py +0 -9
  220. waldiez/exporting/skills/skills_exporter.py +0 -176
  221. waldiez/exporting/skills/utils.py +0 -369
  222. waldiez/models/agents/agent/teachability.py +0 -70
  223. waldiez/models/agents/rag_user/rag_user.py +0 -60
  224. waldiez/models/agents/swarm_agent/__init__.py +0 -50
  225. waldiez/models/agents/swarm_agent/after_work.py +0 -179
  226. waldiez/models/agents/swarm_agent/on_condition.py +0 -105
  227. waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
  228. waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
  229. waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
  230. waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
  231. waldiez/models/flow/utils.py +0 -232
  232. waldiez/models/skill/__init__.py +0 -16
  233. waldiez/models/skill/extra_requirements.py +0 -36
  234. waldiez/models/skill/skill_data.py +0 -53
  235. waldiez/models/skill/skill_type.py +0 -8
  236. waldiez/utils/pysqlite3_checker.py +0 -308
  237. waldiez/utils/rdps_checker.py +0 -122
  238. waldiez-0.4.7.dist-info/RECORD +0 -149
  239. /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
  240. /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
  241. {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/WHEEL +0 -0
  242. {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
  243. {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
  244. {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
@@ -0,0 +1,244 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Singleton context for exporters."""
4
+
5
+ import threading
6
+ from dataclasses import dataclass
7
+ from typing import Any, Optional
8
+
9
+ from waldiez.logger import WaldiezLogger
10
+
11
+ from .extras.path_resolver import DefaultPathResolver
12
+ from .extras.serializer import DefaultSerializer
13
+ from .protocols import ExportingLogger, PathResolver, Serializer, Validator
14
+ from .types import ExportConfig
15
+
16
+
17
+ @dataclass
18
+ class ExporterContext:
19
+ """Context object containing common exporter dependencies."""
20
+
21
+ serializer: Optional[Serializer] = None
22
+ path_resolver: Optional[PathResolver] = None
23
+ validator: Optional[Validator] = None
24
+ config: Optional[ExportConfig] = None
25
+ logger: Optional[ExportingLogger] = None
26
+
27
+ def get_serializer(self) -> Serializer:
28
+ """Get serializer or raise if not set.
29
+
30
+ Returns
31
+ -------
32
+ Serializer
33
+ The serializer instance.
34
+ """
35
+ return self.serializer or DefaultSerializer()
36
+
37
+ def get_path_resolver(self) -> PathResolver:
38
+ """Get path resolver or return default.
39
+
40
+ Returns
41
+ -------
42
+ PathResolver
43
+ The path resolver instance.
44
+ """
45
+ return self.path_resolver or DefaultPathResolver()
46
+
47
+ def get_config(
48
+ self,
49
+ name: Optional[str] = None,
50
+ description: Optional[str] = None,
51
+ requirements: Optional[list[str]] = None,
52
+ tags: Optional[list[str]] = None,
53
+ output_extension: Optional[str] = None,
54
+ is_async: bool = False,
55
+ output_directory: Optional[str] = None,
56
+ cache_seed: Optional[int] = None,
57
+ ) -> ExportConfig:
58
+ """Get export config or return default.
59
+
60
+ Parameters
61
+ ----------
62
+ name : Optional[str], optional
63
+ The name of the export, by default None
64
+ description : Optional[str], optional
65
+ A brief description of the export, by default None
66
+ requirements : Optional[list[str]], optional
67
+ A list of requirements for the export, by default None
68
+ tags : Optional[list[str]], optional
69
+ A list of tags associated with the export, by default None
70
+ output_extension : Optional[str], optional
71
+ The file extension for the output, by default None
72
+ is_async : bool, optional
73
+ Whether the export is asynchronous, by default False
74
+ output_directory : Optional[str], optional
75
+ The directory where the output will be saved, by default None
76
+ cache_seed : Optional[int], optional
77
+ The seed for caching, by default None
78
+
79
+ Returns
80
+ -------
81
+ ExportConfig
82
+ The export configuration.
83
+ """
84
+ kwargs: dict[str, Any] = {
85
+ "requirements": requirements or [],
86
+ "tags": tags or [],
87
+ "is_async": self.config.is_async if self.config else is_async,
88
+ }
89
+ if output_extension is not None:
90
+ kwargs["output_extension"] = output_extension
91
+ if output_directory is not None:
92
+ kwargs["output_directory"] = output_directory
93
+ if cache_seed is not None:
94
+ kwargs["cache_seed"] = cache_seed
95
+ if name is not None:
96
+ kwargs["name"] = name
97
+ if description is not None:
98
+ kwargs["description"] = description
99
+ if self.config is not None:
100
+ self.config.update(**kwargs)
101
+ else:
102
+ self.config = ExportConfig.create(**kwargs)
103
+ return self.config
104
+
105
+ def set_config(self, config: ExportConfig) -> None:
106
+ """Set the export configuration.
107
+
108
+ Parameters
109
+ ----------
110
+ config : ExportConfig
111
+ The export configuration to set.
112
+ """
113
+ self.config = config
114
+
115
+ def get_logger(self) -> ExportingLogger:
116
+ """Get logger or create a default one.
117
+
118
+ Returns
119
+ -------
120
+ ExportingLogger
121
+ The logger instance.
122
+ """
123
+ return self.logger or WaldiezLogger()
124
+
125
+
126
+ # pylint: disable=too-few-public-methods
127
+ class DefaultExporterContext(ExporterContext):
128
+ """Singleton context for exporters.
129
+
130
+ Provides a default configuration with standard serializer and escaper.
131
+ Access via get_default_exporter_context() for proper initialization.
132
+
133
+ Note
134
+ ----
135
+ This is a singleton - only one instance exists per application.
136
+ Direct instantiation may not behave as expected.
137
+ """
138
+
139
+ _instance: Optional["DefaultExporterContext"] = None
140
+ _lock = threading.Lock()
141
+
142
+ def __new__(cls, *args: Any, **kwargs: Any) -> "DefaultExporterContext":
143
+ """Create a new instance of DefaultExporterContext.
144
+
145
+ Parameters
146
+ ----------
147
+ cls : type
148
+ The class type for which the instance is being created.
149
+ *args : Any
150
+ Positional arguments for the constructor.
151
+ **kwargs : Any
152
+ Keyword arguments for the constructor.
153
+
154
+ Returns
155
+ -------
156
+ DefaultExporterContext
157
+ The singleton instance of DefaultExporterContext.
158
+ """
159
+ if cls._instance is None:
160
+ with cls._lock:
161
+ if cls._instance is None: # Double-check
162
+ cls._instance = super().__new__(cls)
163
+ return cls._instance
164
+
165
+ def __init__(
166
+ self,
167
+ serializer: Optional[Serializer] = None,
168
+ validator: Optional[Validator] = None,
169
+ path_resolver: Optional[PathResolver] = None,
170
+ logger: Optional[ExportingLogger] = None,
171
+ config: Optional[ExportConfig] = None,
172
+ ) -> None:
173
+ if hasattr(self, "_initialized"):
174
+ return
175
+ super().__init__(
176
+ serializer=serializer or DefaultSerializer(),
177
+ path_resolver=path_resolver or DefaultPathResolver(),
178
+ logger=logger or WaldiezLogger(),
179
+ validator=validator,
180
+ config=config,
181
+ )
182
+ self._initialized = True
183
+
184
+
185
+ def get_default_exporter_context(
186
+ config: Optional[ExportConfig] = None,
187
+ logger: Optional[ExportingLogger] = None,
188
+ ) -> ExporterContext:
189
+ """Get the default exporter context.
190
+
191
+ Parameters
192
+ ----------
193
+ config : Optional[ExportConfig], optional
194
+ The export configuration, by default None
195
+ logger : Optional[ExportingLogger], optional
196
+ The logger instance, by default None
197
+
198
+ Returns
199
+ -------
200
+ ExporterContext
201
+ The default exporter context.
202
+ """
203
+ return DefaultExporterContext(
204
+ serializer=DefaultSerializer(),
205
+ path_resolver=DefaultPathResolver(),
206
+ logger=logger or WaldiezLogger(),
207
+ config=config,
208
+ )
209
+
210
+
211
+ def create_exporter_context(
212
+ serializer: Optional[Serializer] = None,
213
+ validator: Optional[Validator] = None,
214
+ path_resolver: Optional[PathResolver] = None,
215
+ config: Optional[ExportConfig] = None,
216
+ logger: Optional[ExportingLogger] = None,
217
+ ) -> ExporterContext:
218
+ """Create an exporter context with the given components.
219
+
220
+ Parameters
221
+ ----------
222
+ serializer : Optional[Serializer], optional
223
+ The serializer component, by default None
224
+ path_resolver : Optional[PathResolver], optional
225
+ The path resolver component, by default None
226
+ validator : Optional[Validator], optional
227
+ The validator component, by default None
228
+ config : Optional[ExportConfig], optional
229
+ The export configuration, by default None
230
+ logger : Optional[ExportingLogger], optional
231
+ The logger instance, by default None
232
+
233
+ Returns
234
+ -------
235
+ ExporterContext
236
+ The created context.
237
+ """
238
+ return ExporterContext(
239
+ serializer=serializer or DefaultSerializer(),
240
+ path_resolver=path_resolver or DefaultPathResolver(),
241
+ validator=validator,
242
+ logger=logger or WaldiezLogger(),
243
+ config=config,
244
+ )
@@ -0,0 +1,89 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Enums for Waldiez exporting core."""
4
+
5
+ from enum import Enum
6
+
7
+
8
+ # Position Enums
9
+ class ImportPosition(Enum):
10
+ """Position for import statements in the generated code."""
11
+
12
+ BUILTINS = 0 # Built-in imports (os, sys, etc.)
13
+ THIRD_PARTY = 1 # Third-party imports (autogen, openai, etc.)
14
+ LOCAL = 2 # Local/relative imports
15
+
16
+
17
+ class ExportPosition(Enum):
18
+ """Position for content in the exported code.
19
+
20
+ Attributes
21
+ ----------
22
+ TOP : int
23
+ Position at the top of the file, typically for comments or metadata.
24
+ IMPORTS : int
25
+ Position for import statements.
26
+ TOOLS : int
27
+ Position for tool definitions.
28
+ MODELS : int
29
+ Position for model configurations (llm_config).
30
+ AGENTS : int
31
+ Position for agent definitions.
32
+ CHATS : int
33
+ Position for chat/connection definitions.
34
+ BOTTOM : int
35
+ Position at the bottom of the file,
36
+ typically for main execution or final code.
37
+ """
38
+
39
+ TOP = 0 # Top of file (comments, metadata)
40
+ IMPORTS = 1 # Import statements section
41
+ TOOLS = 2 # Tool definitions
42
+ MODELS = 3 # Model configurations (llm_config)
43
+ AGENTS = 4 # Agent definitions
44
+ CHATS = 5 # Chat/connection definitions
45
+ BOTTOM = 6 # Bottom of file (main execution, etc.)
46
+
47
+
48
+ class AgentPosition(Enum):
49
+ """Position relative to a specific agent."""
50
+
51
+ BEFORE_ALL = 0 # Before all agents are defined
52
+ BEFORE = 1 # Before this specific agent
53
+ AS_ARGUMENT = 2 # As part of agent's initialization arguments
54
+ AFTER = 3 # After this specific agent
55
+ AFTER_ALL = 4 # After all agents are defined
56
+
57
+
58
+ # Content Order Enums
59
+ class ContentOrder(Enum):
60
+ """Standard ordering for positioned content."""
61
+
62
+ EARLY_SETUP = -100
63
+ SETUP = -50
64
+ PRE_CONTENT = -10
65
+ MAIN_CONTENT = 0 # Default
66
+ POST_CONTENT = 10
67
+ CLEANUP = 50
68
+ LATE_CLEANUP = 100
69
+
70
+
71
+ # Content Type Markers
72
+ class ContentType(Enum):
73
+ """Type of content being exported."""
74
+
75
+ AGENT_DEFINITION = 0
76
+ MODEL_CONFIG = 1
77
+ TOOL_DEFINITION = 2
78
+ CHAT_DEFINITION = 3
79
+ FLOW_SETUP = 4
80
+ UTILITY_FUNCTION = 5
81
+ IMPORT_STATEMENT = 6
82
+ ENVIRONMENT_SETUP = 7
83
+
84
+
85
+ class GroupManagerStrategy(Enum):
86
+ """Strategy for group manager agent."""
87
+
88
+ PATTERN = "pattern" # Use AG2 Pattern system
89
+ TRADITIONAL = "traditional" # Use traditional GroupChat + GroupChatManager
@@ -0,0 +1,19 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Exporter core exceptions module."""
4
+
5
+
6
+ class ExporterError(Exception):
7
+ """Base exception for exporter errors."""
8
+
9
+
10
+ class ExporterInitializationError(ExporterError):
11
+ """Exception raised when exporter initialization fails."""
12
+
13
+
14
+ class ExporterValidationError(ExporterError):
15
+ """Exception raised when export validation fails."""
16
+
17
+
18
+ class ExporterContentError(ExporterError):
19
+ """Exception raised when content generation fails."""