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,9 +2,10 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Group chat manager agent."""
4
4
 
5
- from typing import List, Literal
5
+ import warnings
6
+ from typing import Literal
6
7
 
7
- from pydantic import Field
8
+ from pydantic import Field, field_validator
8
9
  from typing_extensions import Annotated
9
10
 
10
11
  from ..agent import WaldiezAgent
@@ -21,36 +22,125 @@ class WaldiezGroupManager(WaldiezAgent):
21
22
 
22
23
  Attributes
23
24
  ----------
24
- agent_type : Literal["manager"]
25
- The agent type: 'manager' for a group manager agent
25
+ agent_type : Literal["group_manager"]
26
+ The agent type: 'group_manager' for a group manager agent
26
27
  data : WaldiezGroupManagerData
27
28
  The group manager agent's data.
28
29
 
29
30
  Functions
30
31
  ---------
31
- validate_transitions(agent_ids: List[str])
32
+ validate_transitions(agent_ids: list[str])
32
33
  Validate the transitions.
33
34
  """
34
35
 
35
- agent_type: Annotated[
36
- Literal["manager"],
36
+ agent_type: Annotated[ # pyright: ignore
37
+ Literal["group_manager", "manager"],
37
38
  Field(
38
39
  "manager",
39
40
  title="Agent type",
40
- description="The agent type: 'manager' for a group manager agent",
41
+ description=(
42
+ "The agent type: 'group_manager' for a group manager agent"
43
+ ),
41
44
  alias="agentType",
42
45
  ),
43
- ]
44
- data: Annotated[
46
+ ] = "group_manager"
47
+ data: Annotated[ # pyright: ignore
45
48
  WaldiezGroupManagerData,
46
49
  Field(
47
50
  title="Data",
48
51
  description="The group manager agent's data",
49
- default_factory=WaldiezGroupManagerData,
52
+ default_factory=WaldiezGroupManagerData, # pyright: ignore
50
53
  ),
51
54
  ]
52
55
 
53
- def validate_transitions(self, agent_ids: List[str]) -> None:
56
+ @field_validator("agent_type", mode="before")
57
+ @classmethod
58
+ def validate_agent_type(cls, v: str) -> Literal["group_manager"]:
59
+ """Validate the agent type.
60
+
61
+ The agent type must be `group_manager`.
62
+ The other two are deprecated and will be removed in the future.
63
+
64
+ Parameters
65
+ ----------
66
+ v : str
67
+ The agent type.
68
+
69
+ Returns
70
+ -------
71
+ str
72
+ The validated agent type.
73
+
74
+ Raises
75
+ ------
76
+ ValueError
77
+ If the agent type is not `group_manager`.
78
+ """
79
+ if v in ["groupManager", "manager"]: # pragma: no cover
80
+ # Deprecated agent type names
81
+ warnings.warn(
82
+ (
83
+ "The agent types 'groupManager' and 'manager' are "
84
+ "deprecated. Use 'group_manager' instead."
85
+ ),
86
+ DeprecationWarning,
87
+ stacklevel=2,
88
+ )
89
+ if v != "group_manager": # pragma: no cover
90
+ raise ValueError(
91
+ "The agent type must be 'group_manager'. "
92
+ "Use 'group_manager' instead."
93
+ )
94
+ return "group_manager"
95
+
96
+ def validate_initial_agent_id(self, all_agent_ids: list[str]) -> None:
97
+ """Validate the initial agent ID.
98
+
99
+ The initial agent ID must be in the list of agent IDs.
100
+
101
+ Parameters
102
+ ----------
103
+ all_agent_ids : list[str]
104
+ The list of agent IDs.
105
+
106
+ Raises
107
+ ------
108
+ ValueError
109
+ If the initial agent ID is not in the list of agent IDs.
110
+ """
111
+ initial_agent_id = self.data.initial_agent_id
112
+ if initial_agent_id not in all_agent_ids:
113
+ raise ValueError(
114
+ f"Initial agent ID '{initial_agent_id}' "
115
+ f"is not in the list of agent IDs: {all_agent_ids}"
116
+ )
117
+
118
+ def get_speakers_order(self) -> list[str]:
119
+ """Get the order of the speakers.
120
+
121
+ Returns
122
+ -------
123
+ list[str]
124
+ The order of the speakers.
125
+
126
+ Raises
127
+ ------
128
+ RuntimeError
129
+ If the order is not set.
130
+ """
131
+ return self.data.speakers.get_order()
132
+
133
+ def set_speakers_order(self, group_members: list[str]) -> None:
134
+ """Set the order of the speakers.
135
+
136
+ Parameters
137
+ ----------
138
+ group_members : list[str]
139
+ The group members' IDs.
140
+ """
141
+ self.data.speakers.set_order(self.data.initial_agent_id, group_members)
142
+
143
+ def validate_transitions(self, agent_ids: list[str]) -> None:
54
144
  """Validate the transitions.
55
145
 
56
146
  If the selection mode is `transition`:
@@ -62,7 +152,7 @@ class WaldiezGroupManager(WaldiezAgent):
62
152
 
63
153
  Parameters
64
154
  ----------
65
- agent_ids : List[str]
155
+ agent_ids : list[str]
66
156
  The list of agent IDs.
67
157
 
68
158
  Raises
@@ -22,8 +22,8 @@ class WaldiezGroupManagerData(WaldiezAgentData):
22
22
  ----------
23
23
  human_input_mode : Literal["ALWAYS", "NEVER", "TERMINATE"]
24
24
  The human input mode, Defaults to `NEVER`
25
- max_round : Optional[int]
26
- The maximum number of rounds to have in the group.
25
+ max_round : int
26
+ The maximum number of rounds to have in the group. Defaults to 20.
27
27
  admin_name : Optional[str]
28
28
  The name of the group's admin.
29
29
  Make sure you use a name of an agent in the group.
@@ -33,30 +33,34 @@ class WaldiezGroupManagerData(WaldiezAgentData):
33
33
  Enable clearing the history in the chat group.
34
34
  send_introductions : bool
35
35
  Send the group members' introductions.
36
+ group_name : Optional[str]
37
+ The name of the group.
38
+ initial_agent_id: str
39
+ The ID of the initial agent to be used in the group.
36
40
  """
37
41
 
38
42
  human_input_mode: Annotated[
39
43
  Literal["ALWAYS", "NEVER", "TERMINATE"],
40
44
  Field(
41
- "NEVER",
45
+ default="NEVER",
42
46
  title="Human input mode",
43
47
  description="The human input mode, Defaults to `NEVER`",
44
48
  alias="humanInputMode",
45
49
  ),
46
- ]
50
+ ] = "NEVER"
47
51
  max_round: Annotated[
48
- Optional[int],
52
+ int,
49
53
  Field(
50
- None,
54
+ default=20,
51
55
  title="Max round",
52
56
  description="The maximum number of rounds to have in the group.",
53
57
  alias="maxRound",
54
58
  ),
55
- ]
59
+ ] = 20
56
60
  admin_name: Annotated[
57
61
  Optional[str],
58
62
  Field(
59
- None,
63
+ default=None,
60
64
  title="Group Admin name",
61
65
  description=(
62
66
  "The name of the group's admin. "
@@ -64,30 +68,48 @@ class WaldiezGroupManagerData(WaldiezAgentData):
64
68
  ),
65
69
  alias="adminName",
66
70
  ),
67
- ]
71
+ ] = None
68
72
  speakers: Annotated[
69
73
  WaldiezGroupManagerSpeakers,
70
74
  Field(
71
75
  title="Speakers",
72
76
  description="The rules for the speaker selection and repetition",
73
- default_factory=WaldiezGroupManagerSpeakers,
77
+ default_factory=WaldiezGroupManagerSpeakers, # pyright: ignore
74
78
  ),
75
79
  ]
76
80
  enable_clear_history: Annotated[
77
81
  Optional[bool],
78
82
  Field(
79
- None,
83
+ default=None,
80
84
  title="Enable clear history",
81
- description="Enable clearing hte history in the chat group.",
85
+ description="Enable clearing the history in the chat group.",
82
86
  alias="enableClearHistory",
83
87
  ),
84
- ]
88
+ ] = None
85
89
  send_introductions: Annotated[
86
90
  bool,
87
91
  Field(
88
- False,
92
+ default=False,
89
93
  title="Send Introductions",
90
94
  description="Send the group members' introductions.",
91
95
  alias="sendIntroductions",
92
96
  ),
97
+ ] = False
98
+ group_name: Annotated[
99
+ Optional[str],
100
+ Field(
101
+ default=None,
102
+ title="Group name",
103
+ description="The name of the group.",
104
+ alias="groupName",
105
+ ),
106
+ ] = None
107
+ initial_agent_id: Annotated[
108
+ str,
109
+ Field(
110
+ ...,
111
+ title="Initial agent ID",
112
+ description="The ID of the agent that starts the conversation.",
113
+ alias="initialAgentId",
114
+ ),
93
115
  ]
@@ -2,7 +2,7 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """Group chat speakers."""
4
4
 
5
- from typing import Dict, List, Optional, Tuple, Union
5
+ from typing import Optional, Union
6
6
 
7
7
  from pydantic import Field, model_validator
8
8
  from typing_extensions import Annotated, Literal, Self
@@ -14,6 +14,7 @@ WaldiezGroupManagerSpeakersSelectionMethod = Literal[
14
14
  "manual",
15
15
  "random",
16
16
  "round_robin",
17
+ "default",
17
18
  "custom",
18
19
  ]
19
20
  """Possible methods for the speaker selection."""
@@ -66,13 +67,13 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
66
67
  Max retries for selecting a speaker.
67
68
  selection_mode : WaldiezGroupManagerSpeakersSelectionMode
68
69
  Selection mode.
69
- allow_repeat : Union[bool, List[str]]
70
+ allow_repeat : Union[bool, list[str]]
70
71
  Allow repeat.
71
- allowed_or_disallowed_transitions : Dict[str, List[str]]
72
+ allowed_or_disallowed_transitions : dict[str, list[str]]
72
73
  Allowed or disallowed transitions.
73
74
  transitions_type : WaldiezGroupManagerSpeakersTransitionsType
74
75
  The type of transition rules to use if
75
- if a mapping (agent => List[agents]) is used:
76
+ if a mapping (agent => list[agents]) is used:
76
77
  `allowed` (default) or `disallowed`
77
78
  custom_method_string : Optional[str]
78
79
  The custom method string.
@@ -86,16 +87,16 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
86
87
  selection_method: Annotated[
87
88
  WaldiezGroupManagerSpeakersSelectionMethod,
88
89
  Field(
89
- "auto",
90
+ default="auto",
90
91
  title="Selection Method",
91
92
  description="The next speaker selection method",
92
93
  alias="selectionMethod",
93
94
  ),
94
- ]
95
+ ] = "auto"
95
96
  selection_custom_method: Annotated[
96
97
  Optional[str],
97
98
  Field(
98
- None,
99
+ default=None,
99
100
  title="Method for custom selection.",
100
101
  description=(
101
102
  "If the method for the speaker selection if `custom`"
@@ -108,11 +109,11 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
108
109
  ),
109
110
  alias="selectionCustomMethod",
110
111
  ),
111
- ]
112
+ ] = None
112
113
  max_retries_for_selecting: Annotated[
113
114
  Optional[int],
114
115
  Field(
115
- None,
116
+ default=None,
116
117
  title="Max retries for a selecting",
117
118
  description=(
118
119
  "The maximum number of retries for the group manager "
@@ -120,11 +121,11 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
120
121
  ),
121
122
  alias="maxRetriesForSelecting",
122
123
  ),
123
- ]
124
+ ] = None
124
125
  selection_mode: Annotated[
125
126
  WaldiezGroupManagerSpeakersSelectionMode,
126
127
  Field(
127
- "repeat",
128
+ default="repeat",
128
129
  title="Selection Mode",
129
130
  description=(
130
131
  "The method to use for selecting a next speaker: "
@@ -133,11 +134,11 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
133
134
  ),
134
135
  alias="selectionMode",
135
136
  ),
136
- ]
137
+ ] = "repeat"
137
138
  allow_repeat: Annotated[
138
- Union[bool, List[str]],
139
+ Union[bool, list[str]],
139
140
  Field(
140
- True,
141
+ default=True,
141
142
  title="Allow repeat",
142
143
  description=(
143
144
  "The speakers' repetition mode: "
@@ -145,34 +146,46 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
145
146
  ),
146
147
  alias="allowRepeat",
147
148
  ),
148
- ]
149
+ ] = True
149
150
  allowed_or_disallowed_transitions: Annotated[
150
- Dict[str, List[str]],
151
+ dict[str, list[str]],
151
152
  Field(
152
153
  default_factory=dict,
153
154
  title="Allowed or disallowed transitions",
154
155
  description=(
155
- "A mapping (agent.id => List[agent.ids])"
156
+ "A mapping (agent.id => list[agent.ids])"
156
157
  "with the allowed or disallowed transitions."
157
158
  ),
158
159
  alias="allowedOrDisallowedTransitions",
159
160
  ),
160
- ]
161
+ ] = {}
161
162
  transitions_type: Annotated[
162
163
  WaldiezGroupManagerSpeakersTransitionsType,
163
164
  Field(
164
- "allowed",
165
+ default="allowed",
165
166
  title="Transitions type",
166
167
  description=(
167
168
  "The type of transition rules to use if "
168
- "if a mapping (agent => List[agents]) is used: "
169
+ "if a mapping (agent => list[agents]) is used: "
169
170
  "`allowed` (default) or `disallowed`"
170
171
  ),
171
172
  alias="transitionsType",
172
173
  ),
173
- ]
174
-
174
+ ] = "allowed"
175
+ order: Annotated[
176
+ list[str],
177
+ Field(
178
+ default_factory=list,
179
+ title="Order",
180
+ description=(
181
+ "The order of the speakers in the group "
182
+ "(if round_robin is used). If empty, the order "
183
+ "will be determined by the order of the agents in the flow."
184
+ ),
185
+ ),
186
+ ] = []
175
187
  _custom_method_string: Optional[str] = None
188
+ _order: Optional[list[str]] = None
176
189
 
177
190
  @property
178
191
  def custom_method_string(self) -> Optional[str]:
@@ -189,7 +202,7 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
189
202
  self,
190
203
  name_prefix: Optional[str] = None,
191
204
  name_suffix: Optional[str] = None,
192
- ) -> Tuple[str, str]:
205
+ ) -> tuple[str, str]:
193
206
  """Get the custom method function.
194
207
 
195
208
  Parameters
@@ -201,7 +214,7 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
201
214
 
202
215
  Returns
203
216
  -------
204
- Tuple[str, str]
217
+ tuple[str, str]
205
218
  The custom method function and the function name.
206
219
  """
207
220
  function_name = CUSTOM_SPEAKER_SELECTION
@@ -219,6 +232,46 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
219
232
  function_name,
220
233
  )
221
234
 
235
+ def get_order(self) -> list[str]:
236
+ """Get the order of the speakers.
237
+
238
+ Returns
239
+ -------
240
+ list[str]
241
+ The order of the speakers.
242
+
243
+ Raises
244
+ ------
245
+ RuntimeError
246
+ If the order is not set.
247
+ """
248
+ if self._order is None:
249
+ raise RuntimeError("Order is not set. Call `set_order` first.")
250
+ return self._order
251
+
252
+ def set_order(
253
+ self, initial_agent_id: str, group_members: list[str]
254
+ ) -> None:
255
+ """Generate the order of the speakers.
256
+
257
+ Parameters
258
+ ----------
259
+ initial_agent_id : str
260
+ The ID of the initial agent.
261
+ group_members : list[str]
262
+ The group members' IDs.
263
+ """
264
+ # make sure all the members are in the order
265
+ # also make sure the initial agent is first
266
+ order_copy = self.order.copy() if self.order else []
267
+ all_members = [initial_agent_id] + [
268
+ member for member in order_copy if member != initial_agent_id
269
+ ]
270
+ for member in group_members:
271
+ if member not in all_members:
272
+ all_members.append(member)
273
+ self._order = all_members
274
+
222
275
  @model_validator(mode="after")
223
276
  def validate_group_speakers_config(self) -> Self:
224
277
  """Validate the speakers config.
@@ -2,8 +2,8 @@
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
3
  """It extends a user agent and has RAG related parameters."""
4
4
 
5
- from .rag_user import WaldiezRagUser
6
- from .rag_user_data import WaldiezRagUserData
5
+ from .rag_user_proxy import WaldiezRagUserProxy
6
+ from .rag_user_proxy_data import WaldiezRagUserProxyData
7
7
  from .retrieve_config import (
8
8
  CUSTOM_EMBEDDING_FUNCTION,
9
9
  CUSTOM_EMBEDDING_FUNCTION_ARGS,
@@ -14,13 +14,13 @@ from .retrieve_config import (
14
14
  CUSTOM_TOKEN_COUNT_FUNCTION,
15
15
  CUSTOM_TOKEN_COUNT_FUNCTION_ARGS,
16
16
  CUSTOM_TOKEN_COUNT_FUNCTION_TYPES,
17
- WaldiezRagUserChunkMode,
18
- WaldiezRagUserModels,
19
- WaldiezRagUserRetrieveConfig,
20
- WaldiezRagUserTask,
21
- WaldiezRagUserVectorDb,
17
+ WaldiezRagUserProxyChunkMode,
18
+ WaldiezRagUserProxyModels,
19
+ WaldiezRagUserProxyRetrieveConfig,
20
+ WaldiezRagUserProxyTask,
21
+ WaldiezRagUserProxyVectorDb,
22
22
  )
23
- from .vector_db_config import WaldiezRagUserVectorDbConfig
23
+ from .vector_db_config import WaldiezRagUserProxyVectorDbConfig
24
24
 
25
25
  __all__ = [
26
26
  "CUSTOM_EMBEDDING_FUNCTION",
@@ -32,12 +32,12 @@ __all__ = [
32
32
  "CUSTOM_TOKEN_COUNT_FUNCTION",
33
33
  "CUSTOM_TOKEN_COUNT_FUNCTION_ARGS",
34
34
  "CUSTOM_TOKEN_COUNT_FUNCTION_TYPES",
35
- "WaldiezRagUser",
36
- "WaldiezRagUserData",
37
- "WaldiezRagUserModels",
38
- "WaldiezRagUserVectorDb",
39
- "WaldiezRagUserChunkMode",
40
- "WaldiezRagUserRetrieveConfig",
41
- "WaldiezRagUserTask",
42
- "WaldiezRagUserVectorDbConfig",
35
+ "WaldiezRagUserProxy",
36
+ "WaldiezRagUserProxyData",
37
+ "WaldiezRagUserProxyModels",
38
+ "WaldiezRagUserProxyVectorDb",
39
+ "WaldiezRagUserProxyChunkMode",
40
+ "WaldiezRagUserProxyRetrieveConfig",
41
+ "WaldiezRagUserProxyTask",
42
+ "WaldiezRagUserProxyVectorDbConfig",
43
43
  ]
@@ -0,0 +1,64 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """RAG user agent.
4
+
5
+ It extends a user agent and has RAG related parameters (`retrieve_config`).
6
+ """
7
+
8
+ from pydantic import Field
9
+ from typing_extensions import Annotated, Literal
10
+
11
+ from ..agent import WaldiezAgent
12
+ from .rag_user_proxy_data import WaldiezRagUserProxyData
13
+ from .retrieve_config import WaldiezRagUserProxyRetrieveConfig
14
+
15
+
16
+ class WaldiezRagUserProxy(WaldiezAgent):
17
+ """RAG user agent.
18
+
19
+ It extends a user agent and has RAG related parameters.
20
+
21
+ Attributes
22
+ ----------
23
+ agent_type : Literal["rag_user", "rag_user_proxy"]
24
+ The agent type: 'rag_user' for a RAG user agent.
25
+ data : WaldiezRagUserProxyData
26
+ The RAG user agent's data.
27
+ See `WaldiezRagUserProxyData` for more info.
28
+ retrieve_config : WaldiezRagUserProxyRetrieveConfig
29
+ The RAG user agent's retrieve config.
30
+ """
31
+
32
+ agent_type: Annotated[ # pyright: ignore
33
+ Literal["rag_user", "rag_user_proxy"],
34
+ Field(
35
+ "rag_user_proxy",
36
+ title="Agent type",
37
+ description=(
38
+ "The agent type in a graph. "
39
+ "`rag_user` is deprecated and will be removed in "
40
+ "future versions. Use `rag_user_proxy` instead."
41
+ ),
42
+ alias="agentType",
43
+ ),
44
+ ] = "rag_user_proxy"
45
+
46
+ data: Annotated[ # pyright: ignore
47
+ WaldiezRagUserProxyData,
48
+ Field(
49
+ title="Data",
50
+ description="The RAG user agent's data",
51
+ default_factory=WaldiezRagUserProxyData, # pyright: ignore
52
+ ),
53
+ ]
54
+
55
+ @property
56
+ def retrieve_config(self) -> WaldiezRagUserProxyRetrieveConfig:
57
+ """Get the retrieve config.
58
+
59
+ Returns
60
+ -------
61
+ WaldiezRagUserProxyRetrieveConfig
62
+ The RAG user agent's retrieve config.
63
+ """
64
+ return self.data.retrieve_config
@@ -6,10 +6,10 @@ from pydantic import Field
6
6
  from typing_extensions import Annotated
7
7
 
8
8
  from ..user_proxy import WaldiezUserProxyData
9
- from .retrieve_config import WaldiezRagUserRetrieveConfig
9
+ from .retrieve_config import WaldiezRagUserProxyRetrieveConfig
10
10
 
11
11
 
12
- class WaldiezRagUserData(WaldiezUserProxyData):
12
+ class WaldiezRagUserProxyData(WaldiezUserProxyData):
13
13
  """RAG user agent data.
14
14
 
15
15
  The data for a RAG user agent.
@@ -18,17 +18,18 @@ class WaldiezRagUserData(WaldiezUserProxyData):
18
18
  ----------
19
19
  use_message_generator: bool
20
20
  Whether to use the message generator in user's chats. Defaults to False.
21
- retrieve_config : WaldiezRagUserRetrieveConfig
21
+ retrieve_config : WaldiezRagUserProxyRetrieveConfig
22
22
  The RAG user agent's retrieve config.
23
23
 
24
24
  """
25
25
 
26
+ # pylint: disable=line-too-long
26
27
  retrieve_config: Annotated[
27
- WaldiezRagUserRetrieveConfig,
28
+ WaldiezRagUserProxyRetrieveConfig,
28
29
  Field(
29
30
  title="Retrieve Config",
30
31
  description="The RAG user agent's retrieve config",
31
- default_factory=WaldiezRagUserRetrieveConfig,
32
+ default_factory=WaldiezRagUserProxyRetrieveConfig, # pyright: ignore # noqa: E501
32
33
  alias="retrieveConfig",
33
34
  ),
34
35
  ]