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
@@ -1,11 +1,11 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
- """Waldiez Skill model."""
3
+ """Waldiez Tool model."""
4
4
 
5
5
  import json
6
6
  import re
7
7
  from pathlib import Path
8
- from typing import Any, Dict, List, Tuple, Union
8
+ from typing import Any, Union
9
9
 
10
10
  from pydantic import Field, model_validator
11
11
  from typing_extensions import Annotated, Literal, Self
@@ -17,85 +17,85 @@ from ..common import (
17
17
  now,
18
18
  parse_code_string,
19
19
  )
20
- from .skill_data import WaldiezSkillData
21
- from .skill_type import WaldiezSkillType
20
+ from .tool_data import WaldiezToolData
21
+ from .tool_type import WaldiezToolType
22
22
 
23
- SHARED_SKILL_NAME = "waldiez_shared"
23
+ SHARED_TOOL_NAME = "waldiez_shared"
24
24
 
25
25
 
26
- class WaldiezSkill(WaldiezBase):
27
- """Waldiez Skill.
26
+ class WaldiezTool(WaldiezBase):
27
+ """Waldiez Tool.
28
28
 
29
29
  Attributes
30
30
  ----------
31
31
  id : str
32
- The ID of the skill.
33
- type : Literal["skill"]
34
- The type of the "node" in a graph: "skill".
32
+ The ID of the tool.
33
+ type : Literal["tool"]
34
+ The type of the "node" in a graph: "tool".
35
35
  name : str
36
- The name of the skill.
36
+ The name of the tool.
37
37
  description : str
38
- The description of the skill.
39
- tags : List[str]
40
- The tags of the skill.
41
- requirements : List[str]
42
- The requirements of the skill.
38
+ The description of the tool.
39
+ tags : list[str]
40
+ The tags of the tool.
41
+ requirements : list[str]
42
+ The requirements of the tool.
43
43
  created_at : str
44
- The date and time when the skill was created.
44
+ The date and time when the tool was created.
45
45
  updated_at : str
46
- The date and time when the skill was last updated.
47
- data : WaldiezSkillData
48
- The data of the skill. See `WaldiezSkillData`.
46
+ The date and time when the tool was last updated.
47
+ data : WaldiezToolData
48
+ The data of the tool. See `WaldiezToolData`.
49
49
  """
50
50
 
51
51
  id: Annotated[
52
- str, Field(..., title="ID", description="The ID of the skill.")
52
+ str, Field(..., title="ID", description="The ID of the tool.")
53
53
  ]
54
54
  type: Annotated[
55
- Literal["skill"],
55
+ Literal["tool"],
56
56
  Field(
57
- default="skill",
57
+ default="tool",
58
58
  title="Type",
59
59
  description="The type of the 'node' in a graph.",
60
60
  ),
61
61
  ]
62
62
  name: Annotated[
63
- str, Field(..., title="Name", description="The name of the skill.")
63
+ str, Field(..., title="Name", description="The name of the tool.")
64
64
  ]
65
65
  description: Annotated[
66
66
  str,
67
67
  Field(
68
68
  ...,
69
69
  title="Description",
70
- description="The description of the skill.",
70
+ description="The description of the tool.",
71
71
  ),
72
72
  ]
73
73
  tags: Annotated[
74
- List[str],
74
+ list[str],
75
75
  Field(
76
76
  title="Tags",
77
- description="The tags of the skill.",
77
+ description="The tags of the tool.",
78
78
  default_factory=list,
79
79
  ),
80
80
  ]
81
81
  requirements: Annotated[
82
- List[str],
82
+ list[str],
83
83
  Field(
84
84
  title="Requirements",
85
- description="The requirements of the skill.",
85
+ description="The requirements of the tool.",
86
86
  default_factory=list,
87
87
  ),
88
88
  ]
89
89
  data: Annotated[
90
- WaldiezSkillData,
91
- Field(..., title="Data", description="The data of the skill."),
90
+ WaldiezToolData,
91
+ Field(..., title="Data", description="The data of the tool."),
92
92
  ]
93
93
  created_at: Annotated[
94
94
  str,
95
95
  Field(
96
96
  default_factory=now,
97
97
  title="Created At",
98
- description="The date and time when the skill was created.",
98
+ description="The date and time when the tool was created.",
99
99
  ),
100
100
  ]
101
101
  updated_at: Annotated[
@@ -103,23 +103,23 @@ class WaldiezSkill(WaldiezBase):
103
103
  Field(
104
104
  default_factory=now,
105
105
  title="Updated At",
106
- description="The date and time when the skill was last updated.",
106
+ description="The date and time when the tool was last updated.",
107
107
  ),
108
108
  ]
109
109
 
110
110
  @staticmethod
111
- def load(data_or_path: Union[str, Path, Dict[str, Any]]) -> "WaldiezSkill":
112
- """Load a skill from a read-only file.
111
+ def load(data_or_path: Union[str, Path, dict[str, Any]]) -> "WaldiezTool":
112
+ """Load a tool from a read-only file.
113
113
 
114
114
  Parameters
115
115
  ----------
116
- data_or_path : Union[str, Path, Dict[str, Any]]
116
+ data_or_path : Union[str, Path, dict[str, Any]]
117
117
  The path to the read-only file or the loaded data.
118
118
 
119
119
  Returns
120
120
  -------
121
- WaldiezSkill
122
- The skill.
121
+ WaldiezTool
122
+ The tool.
123
123
 
124
124
  Raises
125
125
  ------
@@ -129,7 +129,7 @@ class WaldiezSkill(WaldiezBase):
129
129
  If the JSON is invalid or the data is invalid.
130
130
  """
131
131
  if isinstance(data_or_path, dict):
132
- return WaldiezSkill.model_validate(data_or_path)
132
+ return WaldiezTool.model_validate(data_or_path)
133
133
  if not isinstance(data_or_path, Path):
134
134
  data_or_path = Path(data_or_path)
135
135
  resolved = data_or_path.resolve()
@@ -140,88 +140,88 @@ class WaldiezSkill(WaldiezBase):
140
140
  try:
141
141
  data_dict = json.loads(data_string)
142
142
  except BaseException as exc: # pylint: disable=broad-except
143
- raise ValueError(f"Invalid WaldiezSkill/JSON: {exc}") from exc
144
- return WaldiezSkill.model_validate(data_dict)
143
+ raise ValueError(f"Invalid WaldiezTool/JSON: {exc}") from exc
144
+ return WaldiezTool.model_validate(data_dict)
145
145
 
146
146
  @property
147
- def skill_type(self) -> WaldiezSkillType:
148
- """Get the skill type.
147
+ def tool_type(self) -> WaldiezToolType:
148
+ """Get the tool type.
149
149
 
150
150
  Returns
151
151
  -------
152
- WaldiezSkillType
153
- The type of the skill:
152
+ WaldiezToolType
153
+ The type of the tool:
154
154
  [shared, custom, langchain, crewai].
155
155
  """
156
- return self.data.skill_type
156
+ return self.data.tool_type
157
157
 
158
- _skill_imports: Tuple[List[str], List[str]] = ([], [])
158
+ _tool_imports: tuple[list[str], list[str]] = ([], [])
159
159
 
160
- def get_imports(self) -> Tuple[List[str], List[str]]:
161
- """Get the skill imports.
160
+ def get_imports(self) -> tuple[list[str], list[str]]:
161
+ """Get the tool imports.
162
162
 
163
163
  Returns
164
164
  -------
165
- Tuple[List[str], List[str]]
165
+ tuple[list[str], list[str]]
166
166
  The builtin and external imports.
167
167
  """
168
- return self._skill_imports
168
+ return self._tool_imports
169
169
 
170
170
  @property
171
171
  def is_shared(self) -> bool:
172
- """Check if the skill is shared.
172
+ """Check if the tool is shared.
173
173
 
174
174
  Returns
175
175
  -------
176
176
  bool
177
- True if the skill is shared, False otherwise.
177
+ True if the tool is shared, False otherwise.
178
178
  """
179
- return self.skill_type == "shared" or self.name == SHARED_SKILL_NAME
179
+ return self.tool_type == "shared" or self.name == SHARED_TOOL_NAME
180
180
 
181
181
  @property
182
182
  def is_interop(self) -> bool:
183
- """Check if the skill is interoperability.
183
+ """Check if the tool is interoperability.
184
184
 
185
185
  Returns
186
186
  -------
187
187
  bool
188
- True if the skill is interoperability, False otherwise.
188
+ True if the tool is interoperability, False otherwise.
189
189
  """
190
- return self.skill_type in ("langchain", "crewai")
190
+ return self.tool_type in ("langchain", "crewai")
191
191
 
192
192
  def get_content(self) -> str:
193
- """Get the content of the skill.
193
+ """Get the content of the tool.
194
194
 
195
195
  Returns
196
196
  -------
197
197
  str
198
- The content of the skill.
198
+ The content of the tool.
199
199
  """
200
200
  if self.is_shared or self.is_interop:
201
201
  return self.data.content
202
202
  # if custom, only the function content
203
203
  return get_function(self.data.content, self.name)
204
204
 
205
- def _validate_interop_skill(self) -> None:
206
- """Validate the interoperability skill.
205
+ def _validate_interop_tool(self) -> None:
206
+ """Validate the interoperability tool.
207
207
 
208
208
  Raises
209
209
  ------
210
210
  ValueError
211
- If the skill name is not in the content.
211
+ If the tool name is not in the content.
212
212
  """
213
213
  if self.is_interop:
214
214
  # we expect sth like:
215
- # with single or double quotes for type={skill_type}
216
- # {skill_name} = *.convert_tool(..., type="{skill_type}", ...)
215
+ # with single or double quotes for type={tool_type}
216
+ # {tool_name} = *.convert_tool(..., type="{tool_type}", ...)
217
217
  if f"{self.name} = " not in self.data.content:
218
218
  raise ValueError(
219
- f"The skill name '{self.name}' is not in the content."
219
+ f"The tool name '{self.name}' is not in the content."
220
220
  )
221
221
  # we don't want the conversion to ag2 tool (we do it internally)
222
- # or the skill registration (we do it after having the agent names)
223
- # so no" .convert_tool(... type="...")
224
- # or .register_for_llm(...), .register_for_execution(...)
222
+ # or the tool registration (we do it after having the agent names)
223
+ # so no `.convert_tool(... type="...")`
224
+ # or `.register_for_llm(...)`, `.register_for_execution(...)`
225
225
  to_exclude = [
226
226
  r".convert_tool\(.+?type=",
227
227
  rf"{self.name}.register_for_llm\(",
@@ -230,27 +230,27 @@ class WaldiezSkill(WaldiezBase):
230
230
  for exclude in to_exclude:
231
231
  if re.search(exclude, self.data.content):
232
232
  raise ValueError(
233
- f"Invalid skill content: '{exclude}' is not allowed."
233
+ f"Invalid tool content: '{exclude}' is not allowed."
234
234
  )
235
235
 
236
- def _validate_custom_skill(self) -> None:
237
- """Validate a custom skill.
236
+ def _validate_custom_tool(self) -> None:
237
+ """Validate a custom tool.
238
238
 
239
239
  Raises
240
240
  ------
241
241
  ValueError
242
- If the skill name is not in the content.
243
- If the skill content is invalid.
242
+ If the tool name is not in the content.
243
+ If the tool content is invalid.
244
244
  """
245
245
  search = f"def {self.name}("
246
- if self.skill_type == "custom" and not self.is_shared:
246
+ if self.tool_type == "custom" and not self.is_shared:
247
247
  if search not in self.data.content:
248
248
  raise ValueError(
249
- f"The skill name '{self.name}' is not in the content."
249
+ f"The tool name '{self.name}' is not in the content."
250
250
  )
251
251
  error, tree = parse_code_string(self.data.content)
252
252
  if error is not None or tree is None:
253
- raise ValueError(f"Invalid skill content: {error}")
253
+ raise ValueError(f"Invalid tool content: {error}")
254
254
 
255
255
  @model_validator(mode="after")
256
256
  def validate_data(self) -> Self:
@@ -258,23 +258,23 @@ class WaldiezSkill(WaldiezBase):
258
258
 
259
259
  Returns
260
260
  -------
261
- WaldiezSkill
262
- The skill.
261
+ WaldiezTool
262
+ The tool.
263
263
 
264
264
  Raises
265
265
  ------
266
266
  ValueError
267
- If the skill name is not in the content.
268
- If the skill content is invalid.
267
+ If the tool name is not in the content.
268
+ If the tool content is invalid.
269
269
  """
270
- self._validate_custom_skill()
271
- self._validate_interop_skill()
272
- self._skill_imports = gather_code_imports(
270
+ self._validate_custom_tool()
271
+ self._validate_interop_tool()
272
+ self._tool_imports = gather_code_imports(
273
273
  self.data.content, self.is_interop
274
274
  )
275
275
  # remove the imports from the content
276
- # we 'll place them at the top of the file
277
- all_imports = self._skill_imports[0] + self._skill_imports[1]
276
+ # we will place them at the top of the file
277
+ all_imports = self._tool_imports[0] + self._tool_imports[1]
278
278
  code_lines = self.data.content.splitlines()
279
279
  valid_lines = [
280
280
  line
@@ -292,10 +292,10 @@ class WaldiezSkill(WaldiezBase):
292
292
 
293
293
  @property
294
294
  def content(self) -> str:
295
- """Get the content (source) of the skill."""
295
+ """Get the content (source) of the tool."""
296
296
  return self.data.content
297
297
 
298
298
  @property
299
- def secrets(self) -> Dict[str, str]:
300
- """Get the secrets (environment variables) of the skill."""
299
+ def secrets(self) -> dict[str, str]:
300
+ """Get the secrets (environment variables) of the tool."""
301
301
  return self.data.secrets or {}
@@ -0,0 +1,51 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Waldiez Tool model."""
4
+
5
+ from pydantic import Field
6
+ from typing_extensions import Annotated
7
+
8
+ from ..common import WaldiezBase
9
+ from .tool_type import WaldiezToolType
10
+
11
+
12
+ class WaldiezToolData(WaldiezBase):
13
+ """Waldiez Tool Data.
14
+
15
+ Attributes
16
+ ----------
17
+ tool_type : WaldiezToolType
18
+ The type of the tool: shared, custom, langchain, crewai.
19
+ content : str
20
+ The content (source code) of the tool.
21
+ secrets : dict[str, str]
22
+ The secrets (environment variables) of the tool.
23
+ """
24
+
25
+ tool_type: Annotated[
26
+ WaldiezToolType,
27
+ Field(
28
+ "custom",
29
+ alias="toolType",
30
+ title="Tool Type",
31
+ description=(
32
+ "The type of the tool: shared, custom, langchain, crewai."
33
+ ),
34
+ ),
35
+ ] = "custom"
36
+ content: Annotated[
37
+ str,
38
+ Field(
39
+ ...,
40
+ title="Content",
41
+ description="The content (source code) of the tool.",
42
+ ),
43
+ ]
44
+ secrets: Annotated[
45
+ dict[str, str],
46
+ Field(
47
+ default_factory=dict,
48
+ title="Secrets",
49
+ description="The secrets (environment variables) of the tool.",
50
+ ),
51
+ ]
@@ -0,0 +1,8 @@
1
+ # SPDX-License-Identifier: Apache-2.0.
2
+ # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ """Waldiez Tool types."""
4
+
5
+ from typing_extensions import Literal
6
+
7
+ WaldiezToolType = Literal["shared", "custom", "langchain", "crewai"]
8
+ """Possible types of a Waldiez Tool."""