waldiez 0.4.6__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.6.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.6.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.6.dist-info → waldiez-0.4.8.dist-info}/WHEEL +0 -0
  242. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
  243. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
  244. {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
@@ -2,16 +2,32 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Waldiez flow data."""
4
4
 
5
- from typing import Any, Dict, List, Optional
5
+ from typing import Any, Optional
6
6
 
7
7
  from pydantic import Field, model_validator
8
8
  from typing_extensions import Annotated, Self
9
9
 
10
- from ..agents import WaldiezAgents
11
- from ..chat import WaldiezChat
12
- from ..common import WaldiezBase
10
+ from ..agents import (
11
+ WaldiezAgents,
12
+ WaldiezAgentTerminationMessage,
13
+ WaldiezAssistant,
14
+ WaldiezAssistantData,
15
+ )
16
+ from ..chat import (
17
+ WaldiezChat,
18
+ WaldiezChatData,
19
+ WaldiezChatMessage,
20
+ WaldiezChatNested,
21
+ WaldiezChatSummary,
22
+ )
23
+ from ..common import (
24
+ WaldiezBase,
25
+ WaldiezDefaultCondition,
26
+ WaldiezTransitionAvailability,
27
+ now,
28
+ )
13
29
  from ..model import WaldiezModel
14
- from ..skill import WaldiezSkill
30
+ from ..tool import WaldiezTool
15
31
 
16
32
 
17
33
  class WaldiezFlowData(WaldiezBase):
@@ -19,24 +35,24 @@ class WaldiezFlowData(WaldiezBase):
19
35
 
20
36
  Attributes
21
37
  ----------
22
- nodes : List[Dict[str, Any]]
38
+ nodes : list[dict[str, Any]]
23
39
  The nodes of the flow. We ignore this (UI-related)
24
- edges : List[Dict[str, Any]]
40
+ edges : list[dict[str, Any]]
25
41
  The edges of the flow. We ignore this (UI-related)
26
- viewport : Dict[str, Any]
42
+ viewport : dict[str, Any]
27
43
  The viewport of the flow. We ignore this (UI-related)
28
44
  agents : WaldiezAgents
29
45
  The agents of the flow:
30
- users: List[WaldiezUserProxy]
31
- assistants: List[WaldiezAssistant]
32
- managers: List[WaldiezGroupManager]
33
- rag_users : List[WaldiezRagUser]
46
+ users: list[WaldiezUserProxy]
47
+ assistants: list[WaldiezAssistant]
48
+ managers: list[WaldiezGroupManager]
49
+ rag_users : list[WaldiezRagUserProxy]
34
50
  See `WaldiezAgents` for more info.
35
- models : List[WaldiezModel]
51
+ models : list[WaldiezModel]
36
52
  The models of the flow. See `WaldiezModel`.
37
- skills : List[WaldiezSkill]
38
- The skills of the flow. See `WaldiezSkill`.
39
- chats : List[WaldiezChat]
53
+ tools : list[WaldiezTool]
54
+ The tools of the flow. See `WaldiezTool`.
55
+ chats : list[WaldiezChat]
40
56
  The chats of the flow. See `WaldiezChat`.
41
57
  is_async : bool
42
58
  Whether the flow is asynchronous or not.
@@ -44,32 +60,32 @@ class WaldiezFlowData(WaldiezBase):
44
60
  The seed for the cache. If None, the seed is not set. Default is 41.
45
61
  """
46
62
 
47
- # the ones below (nodes,edges, viewport) we ignore
63
+ # we ignore the three below (nodes, edges, viewport)
48
64
  # (they for graph connections, positions, etc.)
49
65
  nodes: Annotated[
50
- List[Dict[str, Any]],
66
+ list[dict[str, Any]],
51
67
  Field(
52
68
  default_factory=list,
53
69
  title="Nodes",
54
70
  description="The nodes of the flow",
55
71
  ),
56
- ]
72
+ ] = []
57
73
  edges: Annotated[
58
- List[Dict[str, Any]],
74
+ list[dict[str, Any]],
59
75
  Field(
60
76
  default_factory=list,
61
77
  title="Edges",
62
78
  description="The edges of the flow",
63
79
  ),
64
- ]
80
+ ] = []
65
81
  viewport: Annotated[
66
- Dict[str, Any],
82
+ dict[str, Any],
67
83
  Field(
68
84
  default_factory=dict,
69
85
  title="Viewport",
70
86
  description="The viewport of the flow",
71
87
  ),
72
- ]
88
+ ] = {}
73
89
  # these are the ones we use.
74
90
  agents: Annotated[
75
91
  WaldiezAgents,
@@ -80,49 +96,49 @@ class WaldiezFlowData(WaldiezBase):
80
96
  ),
81
97
  ]
82
98
  models: Annotated[
83
- List[WaldiezModel],
99
+ list[WaldiezModel],
84
100
  Field(
85
101
  description="The models of the flow",
86
102
  title="Models",
87
103
  default_factory=list,
88
104
  ),
89
- ]
90
- skills: Annotated[
91
- List[WaldiezSkill],
105
+ ] = []
106
+ tools: Annotated[
107
+ list[WaldiezTool],
92
108
  Field(
93
- description="The skills of the flow",
94
- title="Skills",
109
+ description="The tools of the flow",
110
+ title="Tools",
95
111
  default_factory=list,
96
112
  ),
97
- ]
113
+ ] = []
98
114
  chats: Annotated[
99
- List[WaldiezChat],
115
+ list[WaldiezChat],
100
116
  Field(
101
117
  description="The chats of the flow",
102
118
  title="Chats",
103
119
  default_factory=list,
104
120
  ),
105
- ]
121
+ ] = []
106
122
  is_async: Annotated[
107
123
  bool,
108
124
  Field(
109
- False,
125
+ default=False,
110
126
  description="Whether the flow is asynchronous or not",
111
127
  title="Is Async",
112
128
  ),
113
- ]
129
+ ] = False
114
130
  cache_seed: Annotated[
115
131
  Optional[int],
116
132
  Field(
117
- 41,
133
+ 42,
118
134
  alias="cacheSeed",
119
135
  description=(
120
136
  "The seed for the cache. If None, the seed is not set."
121
- "Default is 41."
137
+ "Default is 42."
122
138
  ),
123
139
  title="Cache Seed",
124
140
  ),
125
- ] = 41
141
+ ] = 42
126
142
 
127
143
  @model_validator(mode="after")
128
144
  def validate_flow_chats(self) -> Self:
@@ -138,7 +154,7 @@ class WaldiezFlowData(WaldiezBase):
138
154
  ValueError
139
155
  If there is a chat with a prerequisite that does not exist.
140
156
  """
141
- self.chats = sorted(self.chats, key=lambda x: x.order)
157
+ self.chats.sort(key=lambda x: x.order)
142
158
  # in async, ag2 uses the "chat_id" field (and it must be an int):
143
159
  # ```
144
160
  # prerequisites = []
@@ -156,7 +172,7 @@ class WaldiezFlowData(WaldiezBase):
156
172
  # prerequisites.append((chat_id, pre_chat_id))
157
173
  # return prerequisites
158
174
  # ```
159
- id_to_chat_id: Dict[str, int] = {}
175
+ id_to_chat_id: dict[str, int] = {}
160
176
  for index, chat in enumerate(self.chats):
161
177
  id_to_chat_id[chat.id] = index
162
178
  chat.set_chat_id(index)
@@ -165,7 +181,7 @@ class WaldiezFlowData(WaldiezBase):
165
181
  # also update the chat prerequisites (if async)
166
182
  # we have ids(str), not chat_ids(int)
167
183
  for chat in self.chats:
168
- chat_prerequisites = []
184
+ chat_prerequisites: list[int] = []
169
185
  for chat_id in chat.data.prerequisites:
170
186
  if chat_id not in id_to_chat_id: # pragma: no cover
171
187
  raise ValueError(
@@ -174,3 +190,154 @@ class WaldiezFlowData(WaldiezBase):
174
190
  chat_prerequisites.append(id_to_chat_id[chat_id])
175
191
  chat.set_prerequisites(chat_prerequisites)
176
192
  return self
193
+
194
+ @classmethod
195
+ def default(cls) -> "WaldiezFlowData":
196
+ """Create a default flow data.
197
+
198
+ Returns
199
+ -------
200
+ WaldiezFlowData
201
+ The default flow data.
202
+ """
203
+ return cls(
204
+ nodes=[],
205
+ edges=[],
206
+ viewport={},
207
+ agents=WaldiezAgents(
208
+ userProxyAgents=[],
209
+ assistantAgents=[
210
+ WaldiezAssistant(
211
+ id="assistant1",
212
+ name="Assistant 1",
213
+ created_at=now(),
214
+ updated_at=now(),
215
+ data=WaldiezAssistantData(
216
+ termination=WaldiezAgentTerminationMessage()
217
+ ),
218
+ ),
219
+ WaldiezAssistant(
220
+ id="assistant2",
221
+ name="Assistant 2",
222
+ created_at=now(),
223
+ updated_at=now(),
224
+ data=WaldiezAssistantData(
225
+ # is_multimodal=True, # we need an api key for this
226
+ termination=WaldiezAgentTerminationMessage(),
227
+ ),
228
+ ),
229
+ ],
230
+ ragUserProxyAgents=[],
231
+ reasoningAgents=[],
232
+ captainAgents=[],
233
+ ),
234
+ models=[],
235
+ tools=[],
236
+ chats=[
237
+ WaldiezChat(
238
+ id="chat1",
239
+ type="chat",
240
+ source="assistant1",
241
+ target="assistant2",
242
+ data=WaldiezChatData(
243
+ name="Chat 1",
244
+ order=0,
245
+ position=0,
246
+ source_type="assistant",
247
+ target_type="assistant",
248
+ summary=WaldiezChatSummary(),
249
+ message=WaldiezChatMessage(
250
+ type="string",
251
+ content="Hello, how can I help you?",
252
+ ),
253
+ condition=WaldiezDefaultCondition.create(),
254
+ available=WaldiezTransitionAvailability(),
255
+ nested_chat=WaldiezChatNested(),
256
+ ),
257
+ ),
258
+ WaldiezChat(
259
+ id="chat2",
260
+ type="chat",
261
+ source="assistant2",
262
+ target="assistant1",
263
+ data=WaldiezChatData(
264
+ name="Chat 2",
265
+ order=1,
266
+ position=1,
267
+ source_type="assistant",
268
+ target_type="assistant",
269
+ summary=WaldiezChatSummary(),
270
+ message=WaldiezChatMessage(
271
+ type="string",
272
+ content="Hello, I need some help.",
273
+ ),
274
+ condition=WaldiezDefaultCondition.create(),
275
+ available=WaldiezTransitionAvailability(),
276
+ nested_chat=WaldiezChatNested(),
277
+ prerequisites=["chat1"],
278
+ ),
279
+ ),
280
+ ],
281
+ is_async=False,
282
+ cache_seed=42,
283
+ )
284
+
285
+
286
+ def get_flow_data(
287
+ data: dict[str, Any],
288
+ flow_id: Optional[str] = None,
289
+ name: Optional[str] = None,
290
+ description: Optional[str] = None,
291
+ tags: Optional[list[str]] = None,
292
+ requirements: Optional[list[str]] = None,
293
+ ) -> dict[str, Any]:
294
+ """Get the flow from the passed data dict.
295
+
296
+ Parameters
297
+ ----------
298
+ data : dict[str, Any]
299
+ The data dict.
300
+ flow_id : Optional[str], optional
301
+ The flow ID, by default None.
302
+ name : Optional[str], optional
303
+ The flow name, by default None.
304
+ description : Optional[str], optional
305
+ The flow description, by default None.
306
+ tags : Optional[list[str]], optional
307
+ The flow tags, by default None.
308
+ requirements : Optional[list[str]], optional
309
+ The flow requirements, by default None.
310
+
311
+ Returns
312
+ -------
313
+ dict[str, Any]
314
+ The flow data.
315
+
316
+ Raises
317
+ ------
318
+ ValueError
319
+ If the flow type is not "flow".
320
+ """
321
+ item_type = data.get("type", "flow")
322
+ if item_type != "flow":
323
+ # empty flow (from exported model/tool ?)
324
+ raise ValueError(f"Invalid flow type: {item_type}")
325
+ from_args: dict[str, Any] = {
326
+ "id": flow_id,
327
+ "name": name,
328
+ "description": description,
329
+ "tags": tags,
330
+ "requirements": requirements,
331
+ }
332
+ for key, value in from_args.items():
333
+ if value:
334
+ data[key] = value
335
+ if "name" not in data:
336
+ data["name"] = "Waldiez Flow"
337
+ if "description" not in data:
338
+ data["description"] = "Waldiez Flow description"
339
+ if "tags" not in data:
340
+ data["tags"] = []
341
+ if "requirements" not in data:
342
+ data["requirements"] = []
343
+ return data
@@ -0,0 +1,85 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Waldiez chat info model."""
4
+
5
+ from typing import Iterable
6
+
7
+ from pydantic import Field
8
+ from typing_extensions import Annotated
9
+
10
+ from ..agents import WaldiezAgent, WaldiezAgentHumanInputMode, WaldiezAgentType
11
+ from ..common import (
12
+ WaldiezBase,
13
+ )
14
+
15
+
16
+ class WaldiezAgentInfo(WaldiezBase):
17
+ """Agent info class.
18
+
19
+ Attributes
20
+ ----------
21
+ name : str
22
+ The name of the agent.
23
+ human_input_mode : WaldiezAgentHumanInputMode
24
+ The human input mode of the agent
25
+ (e.g., "ALWAYS", "NEVER", "TERMINATE").
26
+ agent_type : WaldiezAgentType
27
+ The type of the agent (e.g., "user", "assistant").
28
+ """
29
+
30
+ name: Annotated[str, Field(description="Name of the agent")]
31
+ human_input_mode: Annotated[
32
+ WaldiezAgentHumanInputMode,
33
+ Field(description="Human input mode of the agent"),
34
+ ]
35
+ agent_type: Annotated[
36
+ WaldiezAgentType,
37
+ Field(description="Type of the agent (e.g., 'user', 'assistant')"),
38
+ ]
39
+
40
+
41
+ class WaldiezFlowInfo(WaldiezBase):
42
+ """Flow info class.
43
+
44
+ Attributes
45
+ ----------
46
+ participants : WaldiezAgentInfo
47
+ The chat info of the participant in the flow.
48
+ """
49
+
50
+ participants: Annotated[
51
+ list[WaldiezAgentInfo],
52
+ Field(
53
+ description="List of chat participants with their info",
54
+ default_factory=list[WaldiezAgentInfo],
55
+ ),
56
+ ]
57
+
58
+ @classmethod
59
+ def create(
60
+ cls, agents: Iterable[WaldiezAgent], agent_names: dict[str, str]
61
+ ) -> "WaldiezFlowInfo":
62
+ """Create a WaldiezFlowInfo instance from a list of agents.
63
+
64
+ Parameters
65
+ ----------
66
+ agents : Iterable[WaldiezAgent]
67
+ The agents to include in the flow info.
68
+ agent_names : dict[str, str]
69
+ A dictionary mapping agent IDs to their names.
70
+
71
+ Returns
72
+ -------
73
+ WaldiezFlowInfo
74
+ An instance of WaldiezFlowInfo containing the agent info.
75
+ """
76
+ participants: list[WaldiezAgentInfo] = []
77
+ for agent in agents:
78
+ participants.append(
79
+ WaldiezAgentInfo(
80
+ name=agent_names.get(agent.id, agent.name),
81
+ human_input_mode=agent.data.human_input_mode,
82
+ agent_type=agent.agent_type,
83
+ )
84
+ )
85
+ return cls(participants=participants)
@@ -0,0 +1,131 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Ensure unique names for agents, models, tools, and chats."""
4
+
5
+ from typing import Iterable, TypedDict
6
+
7
+ from ..agents import WaldiezAgent
8
+ from ..chat import WaldiezChat
9
+ from ..common import MAX_VARIABLE_LENGTH, get_valid_instance_name
10
+ from ..model import WaldiezModel
11
+ from ..tool import WaldiezTool
12
+
13
+
14
+ class WaldiezUniqueNames(TypedDict):
15
+ """The result type for ensure_unique_names."""
16
+
17
+ agent_names: dict[str, str]
18
+ model_names: dict[str, str]
19
+ tool_names: dict[str, str]
20
+ chat_names: dict[str, str]
21
+ agents: list[WaldiezAgent]
22
+ models: list[WaldiezModel]
23
+ tools: list[WaldiezTool]
24
+ chats: list[WaldiezChat]
25
+ flow_name: str
26
+
27
+
28
+ # pylint: disable=too-many-locals
29
+ def ensure_unique_names(
30
+ flow_id: str,
31
+ flow_name: str,
32
+ flow_agents: Iterable[WaldiezAgent],
33
+ flow_models: Iterable[WaldiezModel],
34
+ flow_tools: Iterable[WaldiezTool],
35
+ flow_chats: Iterable[WaldiezChat],
36
+ max_length: int = MAX_VARIABLE_LENGTH,
37
+ flow_name_max_length: int = 20,
38
+ ) -> WaldiezUniqueNames:
39
+ """Ensure unique names for agents, models, tools, and chats and flow.
40
+
41
+ Parameters
42
+ ----------
43
+ flow_id : str
44
+ The ID of the flow.
45
+ flow_name : str
46
+ The name of the flow.
47
+ flow_agents : Iterable[WaldiezAgent]
48
+ The agents in the flow.
49
+ flow_models : Iterable[WaldiezModel]
50
+ The models in the flow.
51
+ flow_tools : Iterable[WaldiezTool]
52
+ The tools in the flow.
53
+ flow_chats : Iterable[WaldiezChat]
54
+ The chats in the flow.
55
+ max_length : int, optional
56
+ The maximum length of the name, by default 46
57
+ flow_name_max_length : int, optional
58
+ The maximum length of the flow name, by default 20
59
+
60
+ Returns
61
+ -------
62
+ ResultType
63
+ The result with unique names for agents, models, tools, chats, flow.
64
+ """
65
+ all_names: dict[str, str] = {}
66
+ agent_names: dict[str, str] = {}
67
+ model_names: dict[str, str] = {}
68
+ tool_names: dict[str, str] = {}
69
+ chat_names: dict[str, str] = {}
70
+ agents: list[WaldiezAgent] = []
71
+ models: list[WaldiezModel] = []
72
+ tools: list[WaldiezTool] = []
73
+ chats: list[WaldiezChat] = []
74
+
75
+ for agent in flow_agents:
76
+ all_names = get_valid_instance_name(
77
+ (agent.id, agent.name),
78
+ all_names,
79
+ prefix="wa",
80
+ max_length=max_length,
81
+ )
82
+ agent_names[agent.id] = all_names[agent.id]
83
+ agents.append(agent)
84
+
85
+ for model in flow_models:
86
+ all_names = get_valid_instance_name(
87
+ (model.id, model.name),
88
+ all_names,
89
+ prefix="wm",
90
+ max_length=max_length,
91
+ )
92
+ model_names[model.id] = all_names[model.id]
93
+ models.append(model)
94
+
95
+ for tool in flow_tools:
96
+ all_names = get_valid_instance_name(
97
+ (tool.id, tool.name),
98
+ all_names,
99
+ prefix="ws",
100
+ max_length=max_length,
101
+ )
102
+ tool_names[tool.id] = all_names[tool.id]
103
+ tools.append(tool)
104
+
105
+ for chat in flow_chats:
106
+ all_names = get_valid_instance_name(
107
+ (chat.id, chat.name), all_names, prefix="wc", max_length=max_length
108
+ )
109
+ chat_names[chat.id] = all_names[chat.id]
110
+ chats.append(chat)
111
+
112
+ all_names = get_valid_instance_name(
113
+ (flow_id, flow_name),
114
+ all_names,
115
+ prefix="wf",
116
+ max_length=flow_name_max_length,
117
+ )
118
+ flow_name = all_names[flow_id]
119
+
120
+ result: WaldiezUniqueNames = {
121
+ "agent_names": agent_names,
122
+ "model_names": model_names,
123
+ "tool_names": tool_names,
124
+ "chat_names": chat_names,
125
+ "agents": agents,
126
+ "models": models,
127
+ "tools": tools,
128
+ "chats": chats,
129
+ "flow_name": flow_name,
130
+ }
131
+ return result
@@ -4,7 +4,12 @@
4
4
 
5
5
  from .extra_requirements import get_models_extra_requirements
6
6
  from .model import DEFAULT_BASE_URLS, MODEL_NEEDS_BASE_URL, WaldiezModel
7
- from .model_data import WaldiezModelAPIType, WaldiezModelData, WaldiezModelPrice
7
+ from .model_data import (
8
+ WaldiezModelAPIType,
9
+ WaldiezModelAWS,
10
+ WaldiezModelData,
11
+ WaldiezModelPrice,
12
+ )
8
13
 
9
14
  __all__ = [
10
15
  "get_models_extra_requirements",
@@ -14,4 +19,5 @@ __all__ = [
14
19
  "WaldiezModelData",
15
20
  "WaldiezModelPrice",
16
21
  "WaldiezModelAPIType",
22
+ "WaldiezModelAWS",
17
23
  ]
@@ -14,14 +14,14 @@ def get_models_extra_requirements(
14
14
 
15
15
  Parameters
16
16
  ----------
17
- models : List[WaldiezModel]
17
+ models : list[WaldiezModel]
18
18
  The models.
19
19
  autogen_version : str
20
20
  The autogen version.
21
21
 
22
22
  Returns
23
23
  -------
24
- List[str]
24
+ list[str]
25
25
  The models extra requirements.
26
26
  """
27
27
  model_requirements: Set[str] = set()
@@ -33,7 +33,7 @@ def get_models_extra_requirements(
33
33
  "groq",
34
34
  "anthropic",
35
35
  "cohere",
36
- "bedrock", # we might add this later
36
+ "bedrock",
37
37
  ]
38
38
  for model in models:
39
39
  for requirement in model.requirements:
@@ -46,12 +46,3 @@ def get_models_extra_requirements(
46
46
  f"ag2[{model.data.api_type}]=={autogen_version}"
47
47
  )
48
48
  return model_requirements
49
-
50
-
51
- # for bedrock, there are some additional params needed
52
- # (both here and on the ui part):
53
- # aws_region (mandatory)
54
- # aws_access_key (or environment variable: AWS_ACCESS_KEY)
55
- # aws_secret_key (or environment variable: AWS_SECRET_KEY)
56
- # aws_session_token (or environment variable: AWS_SESSION_TOKEN)
57
- # aws_profile_name