waldiez 0.2.2__py3-none-any.whl → 0.3.1__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 (138) hide show
  1. waldiez/__init__.py +2 -0
  2. waldiez/__main__.py +2 -0
  3. waldiez/_version.py +3 -1
  4. waldiez/cli.py +13 -3
  5. waldiez/cli_extras.py +4 -3
  6. waldiez/conflict_checker.py +4 -3
  7. waldiez/exporter.py +28 -105
  8. waldiez/exporting/__init__.py +8 -9
  9. waldiez/exporting/agent/__init__.py +7 -0
  10. waldiez/exporting/agent/agent_exporter.py +279 -0
  11. waldiez/exporting/agent/utils/__init__.py +23 -0
  12. waldiez/exporting/agent/utils/agent_class_name.py +34 -0
  13. waldiez/exporting/agent/utils/agent_imports.py +50 -0
  14. waldiez/exporting/{agents → agent/utils}/code_execution.py +9 -11
  15. waldiez/exporting/{agents → agent/utils}/group_manager.py +47 -35
  16. waldiez/exporting/{agents → agent/utils}/rag_user/__init__.py +2 -0
  17. waldiez/exporting/{agents → agent/utils}/rag_user/chroma_utils.py +22 -17
  18. waldiez/exporting/{agents → agent/utils}/rag_user/mongo_utils.py +14 -10
  19. waldiez/exporting/{agents → agent/utils}/rag_user/pgvector_utils.py +12 -8
  20. waldiez/exporting/{agents → agent/utils}/rag_user/qdrant_utils.py +11 -8
  21. waldiez/exporting/{agents → agent/utils}/rag_user/rag_user.py +78 -55
  22. waldiez/exporting/{agents → agent/utils}/rag_user/vector_db.py +10 -8
  23. waldiez/exporting/agent/utils/swarm_agent.py +463 -0
  24. waldiez/exporting/{agents → agent/utils}/teachability.py +10 -6
  25. waldiez/exporting/{agents → agent/utils}/termination_message.py +7 -8
  26. waldiez/exporting/base/__init__.py +25 -0
  27. waldiez/exporting/base/agent_position.py +75 -0
  28. waldiez/exporting/base/base_exporter.py +118 -0
  29. waldiez/exporting/base/export_position.py +48 -0
  30. waldiez/exporting/base/import_position.py +23 -0
  31. waldiez/exporting/base/mixin.py +134 -0
  32. waldiez/exporting/base/utils/__init__.py +18 -0
  33. waldiez/exporting/{utils → base/utils}/comments.py +12 -55
  34. waldiez/exporting/{utils → base/utils}/naming.py +14 -4
  35. waldiez/exporting/base/utils/path_check.py +68 -0
  36. waldiez/exporting/{utils/object_string.py → base/utils/to_string.py} +21 -20
  37. waldiez/exporting/chats/__init__.py +5 -12
  38. waldiez/exporting/chats/chats_exporter.py +240 -0
  39. waldiez/exporting/chats/utils/__init__.py +15 -0
  40. waldiez/exporting/chats/utils/common.py +81 -0
  41. waldiez/exporting/chats/{nested.py → utils/nested.py} +125 -86
  42. waldiez/exporting/chats/utils/sequential.py +244 -0
  43. waldiez/exporting/chats/utils/single_chat.py +313 -0
  44. waldiez/exporting/chats/utils/swarm.py +207 -0
  45. waldiez/exporting/flow/__init__.py +5 -3
  46. waldiez/exporting/flow/flow_exporter.py +503 -0
  47. waldiez/exporting/flow/utils/__init__.py +47 -0
  48. waldiez/exporting/flow/utils/agent_utils.py +204 -0
  49. waldiez/exporting/flow/utils/chat_utils.py +71 -0
  50. waldiez/exporting/flow/utils/def_main.py +62 -0
  51. waldiez/exporting/flow/utils/flow_content.py +112 -0
  52. waldiez/exporting/flow/utils/flow_names.py +115 -0
  53. waldiez/exporting/flow/utils/importing_utils.py +182 -0
  54. waldiez/exporting/{utils → flow/utils}/logging_utils.py +34 -31
  55. waldiez/exporting/models/__init__.py +7 -242
  56. waldiez/exporting/models/models_exporter.py +192 -0
  57. waldiez/exporting/models/utils.py +166 -0
  58. waldiez/exporting/skills/__init__.py +7 -161
  59. waldiez/exporting/skills/skills_exporter.py +169 -0
  60. waldiez/exporting/skills/utils.py +281 -0
  61. waldiez/models/__init__.py +25 -7
  62. waldiez/models/agents/__init__.py +70 -0
  63. waldiez/models/agents/agent/__init__.py +11 -1
  64. waldiez/models/agents/agent/agent.py +9 -4
  65. waldiez/models/agents/agent/agent_data.py +3 -1
  66. waldiez/models/agents/agent/code_execution.py +2 -0
  67. waldiez/models/agents/agent/linked_skill.py +2 -0
  68. waldiez/models/agents/agent/nested_chat.py +2 -0
  69. waldiez/models/agents/agent/teachability.py +2 -0
  70. waldiez/models/agents/agent/termination_message.py +49 -13
  71. waldiez/models/agents/agents.py +15 -3
  72. waldiez/models/agents/assistant/__init__.py +2 -0
  73. waldiez/models/agents/assistant/assistant.py +2 -0
  74. waldiez/models/agents/assistant/assistant_data.py +2 -0
  75. waldiez/models/agents/group_manager/__init__.py +9 -1
  76. waldiez/models/agents/group_manager/group_manager.py +2 -0
  77. waldiez/models/agents/group_manager/group_manager_data.py +2 -0
  78. waldiez/models/agents/group_manager/speakers.py +49 -13
  79. waldiez/models/agents/rag_user/__init__.py +21 -4
  80. waldiez/models/agents/rag_user/rag_user.py +3 -1
  81. waldiez/models/agents/rag_user/rag_user_data.py +2 -0
  82. waldiez/models/agents/rag_user/retrieve_config.py +268 -17
  83. waldiez/models/agents/rag_user/vector_db_config.py +5 -3
  84. waldiez/models/agents/swarm_agent/__init__.py +49 -0
  85. waldiez/models/agents/swarm_agent/after_work.py +178 -0
  86. waldiez/models/agents/swarm_agent/on_condition.py +103 -0
  87. waldiez/models/agents/swarm_agent/on_condition_available.py +140 -0
  88. waldiez/models/agents/swarm_agent/on_condition_target.py +40 -0
  89. waldiez/models/agents/swarm_agent/swarm_agent.py +107 -0
  90. waldiez/models/agents/swarm_agent/swarm_agent_data.py +125 -0
  91. waldiez/models/agents/swarm_agent/update_system_message.py +144 -0
  92. waldiez/models/agents/user_proxy/__init__.py +2 -0
  93. waldiez/models/agents/user_proxy/user_proxy.py +2 -0
  94. waldiez/models/agents/user_proxy/user_proxy_data.py +2 -0
  95. waldiez/models/chat/__init__.py +21 -3
  96. waldiez/models/chat/chat.py +241 -7
  97. waldiez/models/chat/chat_data.py +192 -48
  98. waldiez/models/chat/chat_message.py +153 -144
  99. waldiez/models/chat/chat_nested.py +33 -53
  100. waldiez/models/chat/chat_summary.py +2 -0
  101. waldiez/models/common/__init__.py +6 -6
  102. waldiez/models/common/base.py +4 -1
  103. waldiez/models/common/method_utils.py +163 -83
  104. waldiez/models/flow/__init__.py +2 -0
  105. waldiez/models/flow/flow.py +176 -40
  106. waldiez/models/flow/flow_data.py +63 -2
  107. waldiez/models/flow/utils.py +172 -0
  108. waldiez/models/model/__init__.py +2 -0
  109. waldiez/models/model/model.py +30 -9
  110. waldiez/models/model/model_data.py +3 -1
  111. waldiez/models/skill/__init__.py +4 -1
  112. waldiez/models/skill/skill.py +30 -2
  113. waldiez/models/skill/skill_data.py +2 -0
  114. waldiez/models/waldiez.py +28 -4
  115. waldiez/runner.py +142 -228
  116. waldiez/running/__init__.py +33 -0
  117. waldiez/running/environment.py +83 -0
  118. waldiez/running/gen_seq_diagram.py +185 -0
  119. waldiez/running/running.py +300 -0
  120. {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/METADATA +35 -28
  121. waldiez-0.3.1.dist-info/RECORD +125 -0
  122. waldiez-0.3.1.dist-info/licenses/LICENSE +201 -0
  123. waldiez/exporting/agents/__init__.py +0 -5
  124. waldiez/exporting/agents/agent.py +0 -236
  125. waldiez/exporting/agents/agent_skills.py +0 -67
  126. waldiez/exporting/agents/llm_config.py +0 -53
  127. waldiez/exporting/chats/chats.py +0 -46
  128. waldiez/exporting/chats/helpers.py +0 -420
  129. waldiez/exporting/flow/def_main.py +0 -32
  130. waldiez/exporting/flow/flow.py +0 -189
  131. waldiez/exporting/utils/__init__.py +0 -36
  132. waldiez/exporting/utils/importing.py +0 -265
  133. waldiez/exporting/utils/method_utils.py +0 -35
  134. waldiez/exporting/utils/path_check.py +0 -51
  135. waldiez-0.2.2.dist-info/RECORD +0 -92
  136. waldiez-0.2.2.dist-info/licenses/LICENSE +0 -21
  137. {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/WHEEL +0 -0
  138. {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/entry_points.txt +0 -0
@@ -1,189 +0,0 @@
1
- """Export the entire flow to string."""
2
-
3
- from pathlib import Path
4
- from typing import Dict, List, Optional, Set, Tuple
5
-
6
- from waldiez.models import (
7
- Waldiez,
8
- WaldiezAgent,
9
- WaldiezChat,
10
- WaldiezModel,
11
- WaldiezSkill,
12
- )
13
-
14
- from ..agents import export_agent
15
- from ..chats import export_chats, export_nested_chat
16
- from ..models import export_models
17
- from ..skills import export_skills
18
- from ..utils import (
19
- get_comment,
20
- get_imports_string,
21
- get_logging_start_string,
22
- get_logging_stop_string,
23
- get_pylint_ignore_comment,
24
- get_sqlite_to_csv_call_string,
25
- get_sqlite_to_csv_string,
26
- )
27
- from .def_main import get_def_main
28
-
29
-
30
- # pylint: disable=too-many-locals
31
- def export_flow(
32
- waldiez: Waldiez,
33
- agents: Tuple[List[WaldiezAgent], Dict[str, str]],
34
- chats: Tuple[List[WaldiezChat], Dict[str, str]],
35
- models: Tuple[List[WaldiezModel], Dict[str, str]],
36
- skills: Tuple[List[WaldiezSkill], Dict[str, str]],
37
- output_dir: Optional[Path],
38
- notebook: bool,
39
- ) -> str:
40
- """Export the entire flow to a string.
41
-
42
- It contains the required imports, the model and skill definitions,
43
- the agent definitions, the links between agents, models and skills,
44
- the agents' nested chats, the chat definitions, and the actual call
45
- to start the chat(s).
46
-
47
- Parameters
48
- ----------
49
- waldiez : Waldiez
50
- The Waldiez instance.
51
- agents : Tuple[List[WaldiezAgent], Dict[str, str]]
52
- The agents and their names.
53
- chats : Tuple[List[WaldiezChat], Dict[str, str]]
54
- The chats and their names.
55
- models : Tuple[List[WaldiezModel], Dict[str, str]]
56
- The models and their names.
57
- skills : Tuple[List[WaldiezSkill], Dict[str, str]]
58
- The skills and their names.
59
- output_dir : Optional[Path]
60
- The output directory.
61
- notebook : bool
62
- Whether the export is for a jupyter notebook or a python script.
63
-
64
- Returns
65
- -------
66
- str
67
- The flow string.
68
- """
69
- all_agents, agent_names = agents
70
- all_models, model_names = models
71
- all_skills, skill_names = skills
72
- all_chats, chat_names = chats
73
- agent_strings = ""
74
- # we need to add `skipped_agent_strings` after the other agents are defined
75
- # for example, a group_manager needs the group members to have been defined
76
- skipped_agent_strings = ""
77
- nested_chats_strings = ""
78
- builtin_imports: Set[str] = {
79
- "import csv",
80
- "import os",
81
- "import sqlite3",
82
- }
83
- common_imports: Set[str] = {
84
- "from autogen import Agent",
85
- "from autogen import ConversableAgent",
86
- "from autogen import ChatResult",
87
- "from autogen import runtime_logging",
88
- }
89
- local_imports: Set[str] = {
90
- "from waldiez_api_keys import get_model_api_key",
91
- }
92
- skill_imports, _ = export_skills(
93
- skills=all_skills,
94
- skill_names=skill_names,
95
- output_dir=output_dir,
96
- )
97
- if len(waldiez.chats) > 1:
98
- common_imports.add("from autogen import initiate_chats")
99
- for agent in all_agents:
100
- agent_string, after_agent, agent_imports = export_agent(
101
- agent=agent,
102
- agent_names=agent_names,
103
- model_names=model_names,
104
- skill_names=skill_names,
105
- all_models=all_models,
106
- all_skills=all_skills,
107
- group_chat_members=waldiez.flow.get_group_chat_members(agent.id),
108
- )
109
- common_imports.update(agent_imports)
110
- if after_agent:
111
- skipped_agent_strings += after_agent
112
- if agent.agent_type == "manager":
113
- skipped_agent_strings += agent_string
114
- else:
115
- agent_strings += agent_string
116
- agent_nested_chats_string = export_nested_chat(
117
- agent=agent,
118
- agent_names=agent_names,
119
- all_chats=all_chats,
120
- chat_names=chat_names,
121
- )
122
- if agent_nested_chats_string:
123
- nested_chats_strings += "\n" + agent_nested_chats_string
124
- agent_strings += skipped_agent_strings
125
- models_string = export_models(
126
- all_models=all_models,
127
- model_names=model_names,
128
- notebook=notebook,
129
- output_dir=output_dir,
130
- )
131
- all_imports_string = get_imports_string(
132
- imports=common_imports,
133
- builtin_imports=builtin_imports,
134
- skill_imports=skill_imports,
135
- local_imports=local_imports,
136
- )
137
- return _combine_strings(
138
- waldiez=waldiez,
139
- imports_string=all_imports_string,
140
- agents_string=agent_strings,
141
- nested_chats_string=nested_chats_strings,
142
- models_string=models_string,
143
- agent_names=agent_names,
144
- chat_names=chat_names,
145
- notebook=notebook,
146
- )
147
-
148
-
149
- # pylint: disable=too-many-arguments
150
- def _combine_strings(
151
- waldiez: Waldiez,
152
- imports_string: str,
153
- agents_string: str,
154
- nested_chats_string: str,
155
- models_string: str,
156
- agent_names: Dict[str, str],
157
- chat_names: Dict[str, str],
158
- notebook: bool,
159
- ) -> str:
160
- content = get_pylint_ignore_comment(notebook)
161
- content += imports_string
162
- content += get_comment("logging", notebook) + "\n"
163
- content += get_logging_start_string(tabs=0) + "\n\n"
164
- content += models_string
165
- content += get_comment("agents", notebook) + "\n"
166
- content += agents_string
167
- if nested_chats_string:
168
- content += get_comment("nested", notebook) + "\n"
169
- content += nested_chats_string
170
- chats_content, additional_methods = export_chats(
171
- main_chats=waldiez.chats,
172
- agent_names=agent_names,
173
- chat_names=chat_names,
174
- tabs=0 if notebook else 1,
175
- )
176
- if additional_methods:
177
- while not content.endswith("\n\n"): # pragma: no cover
178
- content += "\n"
179
- content += "\n" + additional_methods + "\n"
180
- content += get_sqlite_to_csv_string()
181
- content += get_comment("run", notebook) + "\n"
182
- if not notebook:
183
- content += get_def_main(chats_content)
184
- else:
185
- content += "\n" + chats_content + "\n"
186
- content += get_logging_stop_string(tabs=0) + "\n"
187
- content += get_sqlite_to_csv_call_string(tabs=0) + "\n"
188
- content = content.replace("\n\n\n\n", "\n\n\n")
189
- return content
@@ -1,36 +0,0 @@
1
- """Generic utils to be used for exporting."""
2
-
3
- from .comments import comment, get_comment, get_pylint_ignore_comment
4
- from .importing import add_autogen_dot_import, get_imports_string
5
- from .logging_utils import (
6
- get_logging_start_string,
7
- get_logging_stop_string,
8
- get_sqlite_to_csv_call_string,
9
- get_sqlite_to_csv_string,
10
- )
11
- from .method_utils import get_method_string
12
- from .naming import (
13
- get_escaped_string,
14
- get_valid_instance_name,
15
- get_valid_python_variable_name,
16
- )
17
- from .object_string import get_object_string
18
- from .path_check import get_path_string
19
-
20
- __all__ = [
21
- "add_autogen_dot_import",
22
- "comment",
23
- "get_logging_start_string",
24
- "get_logging_stop_string",
25
- "get_path_string",
26
- "get_pylint_ignore_comment",
27
- "get_sqlite_to_csv_string",
28
- "get_sqlite_to_csv_call_string",
29
- "get_imports_string",
30
- "get_comment",
31
- "get_escaped_string",
32
- "get_method_string",
33
- "get_object_string",
34
- "get_valid_instance_name",
35
- "get_valid_python_variable_name",
36
- ]
@@ -1,265 +0,0 @@
1
- """Importing related string generation functions.
2
-
3
- Functions
4
- ---------
5
- add_autogen_dot_import
6
- Add an autogen dot import (from autogen.{x.y} import {z}).
7
- get_imports_string
8
- Get the imports for the whole file/flow.
9
- """
10
-
11
- from typing import Dict, List, Optional, Set, Tuple
12
-
13
- DEFAULT_TYPING_IMPORTS = {
14
- "Any",
15
- "Callable",
16
- "Dict",
17
- "List",
18
- "Optional",
19
- "Tuple",
20
- "Union",
21
- }
22
-
23
-
24
- def add_autogen_dot_import(
25
- current_imports: Dict[str, List[str]], new_import: Tuple[str, str]
26
- ) -> Dict[str, List[str]]:
27
- """Add an autogen dot import (from autogen.{x} import {y}).
28
-
29
- Parameters
30
- ----------
31
- current_imports : Dict[str, List[str]]
32
- The current autogen dot imports.
33
- new_import : Tuple[str, str]
34
- The new import.
35
-
36
- Returns
37
- -------
38
- Dict[str, List[str]]
39
- The updated imports.
40
-
41
- Example
42
- -------
43
- ```python
44
- >>> current_imports = {"a": ["b", "c"], "d": ["e"]}
45
- >>> new_import = ("a", "f")
46
- >>> add_autogen_dot_import(current_imports, new_import)
47
- {'a': ['b', 'c', 'f'], 'd': ['e']}
48
- # and the final string would be:
49
- from autogen.a import b, c, f
50
- from autogen.d import e
51
- ```
52
- """
53
- dot_part, module_part = new_import
54
- if not module_part:
55
- return current_imports
56
- imports_copy = current_imports.copy()
57
- if dot_part not in current_imports:
58
- imports_copy[dot_part] = []
59
- imports_copy[dot_part].append(module_part)
60
- return imports_copy
61
-
62
-
63
- def get_imports_string(
64
- imports: Set[str],
65
- skill_imports: Set[str],
66
- typing_imports: Optional[Set[str]] = None,
67
- builtin_imports: Optional[Set[str]] = None,
68
- local_imports: Optional[Set[str]] = None,
69
- ) -> str:
70
- """Get the imports.
71
-
72
- Parameters
73
- ----------
74
- imports : Set[str]
75
- The flow imports (e.g. from autogen.{x[y.z]} import {w}).
76
- skill_imports : Set[str]
77
- The skill imports.
78
- typing_imports : Set[str], optional
79
- The typing imports, by default None.
80
- builtin_imports : Set[str], optional
81
- The builtin imports, by default None.
82
- local_imports : Set[str], optional
83
- The local imports (like for getting model api keys), by default None.
84
-
85
- Returns
86
- -------
87
- str
88
- The imports string.
89
-
90
- Example
91
- -------
92
- ```python
93
- >>> autogen_imports = {"from autogen import a", "from autogen.b import c"}
94
- >>> skill_imports = {"from skill_name import skill_name"}
95
- >>> get_imports_string(autogen_imports, skill_imports)
96
-
97
- from typing import Any, Callable, Dict, List, Optional, Tuple, Union
98
- from typing_extensions import Annotated
99
-
100
- from autogen import a
101
- from autogen.b import c
102
-
103
- from skill_name import skill_name'
104
- ```
105
- """
106
- if not typing_imports:
107
- typing_imports = DEFAULT_TYPING_IMPORTS
108
- if not builtin_imports:
109
- builtin_imports = set()
110
- if not local_imports:
111
- local_imports = set()
112
- string = _get_builtin_imports_string(builtin_imports, typing_imports)
113
- string += _get_third_party_imports_string(imports)
114
- if local_imports:
115
- string += "\n\n" + "\n".join(sorted(local_imports)) + "\n"
116
- string += _get_skill_imports_string(skill_imports)
117
- string = "\n\n".join([line for line in string.split("\n\n") if line])
118
- while not string.endswith("\n\n"):
119
- string += "\n"
120
- return string
121
-
122
-
123
- # pylint: disable=line-too-long
124
- def _get_builtin_imports_string(
125
- builtin_imports: Set[str],
126
- typing_imports: Set[str],
127
- include_annotations: bool = True,
128
- ) -> str:
129
- """Get the builtin imports."""
130
- imports = []
131
- from_imports = []
132
- for imp in sorted(builtin_imports):
133
- if imp.startswith("from "):
134
- from_imports.append(imp)
135
- elif imp.startswith("import "):
136
- imports.append(imp)
137
- else:
138
- imports.append(f"import {imp}")
139
- if typing_imports:
140
- without_from_typing = []
141
- for typing_import in typing_imports:
142
- if typing_import.startswith("from typing import "):
143
- without_from_typing.extend(
144
- typing_import.split("from typing import ")[1].split(", ")
145
- )
146
- else:
147
- without_from_typing.append(typing_import)
148
- from_imports.append(
149
- "from typing import "
150
- + ", ".join(sorted(without_from_typing))
151
- + " # noqa"
152
- )
153
- if include_annotations:
154
- from_imports.append("from typing_extensions import Annotated")
155
- string = (
156
- "\n".join(sorted(imports)) + "\n\n" + "\n".join(sorted(from_imports))
157
- )
158
- return string
159
-
160
-
161
- def _get_autogen_import(import_string: str) -> List[str]:
162
- """Get the autogen import.
163
-
164
- In case the import is a "full" import statement,
165
- we keep only the module to import.
166
- """
167
- things = []
168
- if import_string.startswith("from autogen import "):
169
- import_part = import_string.split("from autogen import ")[1]
170
- things = import_part.split(", ")
171
- return things
172
-
173
-
174
- def _prepare_imports(
175
- autogen_imports: Set[str],
176
- autogen_dot_imports: Dict[str, List[str]],
177
- other_imports: Set[str],
178
- ) -> Tuple[List[str], Dict[str, List[str]]]:
179
- plain_imports = [] # plain `import {x}`
180
- autogen_imports_list = [] # from autogen import {y}
181
- for autogen_import in autogen_imports:
182
- autogen_imports_list.extend(_get_autogen_import(autogen_import))
183
- from_imports_dict: Dict[str, List[str]] = {
184
- "autogen": autogen_imports_list,
185
- }
186
- # from autogen.{z} import {w} # z could be "a.b.c.."
187
- for autogen_dot_package, autogen_dot_modules in autogen_dot_imports.items():
188
- sub_package = f"autogen.{autogen_dot_package}"
189
- if sub_package not in from_imports_dict:
190
- from_imports_dict[sub_package] = []
191
- from_imports_dict[sub_package].extend(autogen_dot_modules)
192
- for imp in other_imports:
193
- if imp.startswith("from "):
194
- line_parts = imp.split("from ")
195
- package = line_parts[1].split(" import ")[0]
196
- if package not in from_imports_dict:
197
- from_imports_dict[package] = []
198
- import_part = line_parts[1].split(" import ")[1]
199
- things = import_part.split(", ")
200
- from_imports_dict[package].extend(things)
201
- elif imp.startswith("import "):
202
- plain_imports.append(imp)
203
- else:
204
- plain_imports.append(f"import {imp}")
205
- plain_imports.sort()
206
- return plain_imports, from_imports_dict
207
-
208
-
209
- def _get_autogen_imports(
210
- imports: Set[str],
211
- ) -> Tuple[Set[str], Dict[str, List[str]], Set[str]]:
212
- """Get the autogen imports."""
213
- autogen_imports = set()
214
- _autogen_dot_imports: Dict[str, List[str]] = {}
215
- remaining_imports: Set[str] = set()
216
- for imp in imports:
217
- if imp.startswith("from autogen import "):
218
- autogen_imports.add(imp)
219
- elif imp.startswith("from autogen."):
220
- parts = imp.split("from autogen.")[1].split(" import ")
221
- if len(parts) == 2:
222
- package = parts[0]
223
- module = parts[1]
224
- if package not in _autogen_dot_imports:
225
- _autogen_dot_imports[package] = []
226
- _autogen_dot_imports[package].append(module)
227
- else:
228
- remaining_imports.add(imp)
229
- # sort the autogen imports
230
- autogen_imports = set(sorted(list(autogen_imports)))
231
- autogen_dot_imports = {}
232
- # sort the autogen dot imports (both keys and values)
233
- sorted_keys = sorted(_autogen_dot_imports.keys())
234
- for key in sorted_keys:
235
- autogen_dot_imports[key] = sorted(_autogen_dot_imports[key])
236
- return autogen_imports, autogen_dot_imports, remaining_imports
237
-
238
-
239
- def _get_third_party_imports_string(imports: Set[str]) -> str:
240
- """Get the third party imports."""
241
- autogen_imports, autogen_dot_imports, rest = _get_autogen_imports(imports)
242
- plain_imports, from_imports_dict = _prepare_imports(
243
- autogen_imports=autogen_imports,
244
- autogen_dot_imports=autogen_dot_imports,
245
- other_imports=rest,
246
- )
247
- from_imports = []
248
- # pylint: disable=inconsistent-quotes
249
- for package, modules in from_imports_dict.items():
250
- # remove duplicates
251
- modules = sorted(set(modules))
252
- if modules:
253
- from_imports.append(f"from {package} import {', '.join(modules)}")
254
- string = (
255
- "\n\n" + "\n".join(plain_imports) + "\n\n" + "\n".join(from_imports)
256
- )
257
- return string
258
-
259
-
260
- def _get_skill_imports_string(skill_imports: Set[str]) -> str:
261
- """Get the skill imports."""
262
- if not skill_imports:
263
- return ""
264
- string = "\n\n" + "\n".join(sorted(skill_imports)) + "\n"
265
- return string
@@ -1,35 +0,0 @@
1
- """Method related string generation utilities."""
2
-
3
- from waldiez.models import METHOD_ARGS, WaldiezMethodName
4
-
5
-
6
- def get_method_string(
7
- method_name: WaldiezMethodName, renamed_method_name: str, method_body: str
8
- ) -> str:
9
- """Get a function string.
10
-
11
- Parameters
12
- ----------
13
- method_name : WaldiezMethodName
14
- The method name.
15
- renamed_method_name : str
16
- The renamed method name.
17
- method_body : str
18
- The method body.
19
-
20
- Returns
21
- -------
22
- str
23
- The function string having the definition, type hints and body.
24
- """
25
- method_args = METHOD_ARGS[method_name]
26
- content = f"def {renamed_method_name}("
27
- if len(method_args) == 0:
28
- content += "):"
29
- else:
30
- content += "\n"
31
- for arg in method_args:
32
- content += f" {arg},\n"
33
- content += "):"
34
- content += f"\n{method_body}"
35
- return content
@@ -1,51 +0,0 @@
1
- """Path check utility functions."""
2
-
3
- import os
4
- from pathlib import Path
5
- from typing import Optional
6
-
7
- # pylint: disable=broad-except
8
-
9
-
10
- def _check_local_path(string: str) -> Optional[Path]:
11
- """Check if a string is a local path.
12
-
13
- Parameters
14
- ----------
15
- string : str
16
- The string to check.
17
-
18
- Returns
19
- -------
20
- bool
21
- True if the path is a local path.
22
- """
23
- try:
24
- path = Path(string).resolve()
25
- except Exception: # pragma: no cover
26
- return None
27
- if path.exists():
28
- return path
29
- return None
30
-
31
-
32
- def get_path_string(string: str) -> str:
33
- """Get the path string.
34
-
35
- Parameters
36
- ----------
37
- string : str
38
- The string to check.
39
-
40
- Returns
41
- -------
42
- str
43
- The local path string.
44
- """
45
- # On windows, we get paths like "C:\path\to\file"
46
- # if so, let's try to avoid invalid escape sequences
47
- if not _check_local_path(string):
48
- return string
49
- if os.name == "nt": # pragma: no cover
50
- return f"r'{string}'"
51
- return f"{Path(string).resolve()}"
@@ -1,92 +0,0 @@
1
- waldiez/__init__.py,sha256=06YinMpFcPN2mGHwloBAaCUXvWJYN9HW6sxLwRz_0G4,2056
2
- waldiez/__main__.py,sha256=mUQWu4CF03Jbbscvcfb_9EFTnIMliJJJmAuWf0sRRZU,110
3
- waldiez/_version.py,sha256=unGlwga1PykxDeWOaTFSIbEfv1EcyKFLju1lsfFRMAM,62
4
- waldiez/cli.py,sha256=yaPq02XRN1z0xS0lNn63rIO7SI7eHv7xksTwyrNm0RI,6544
5
- waldiez/cli_extras.py,sha256=deJlQ31WnUS5RTHJ9M6a6OQPrVZQeI2T3u_ll1IurRg,2926
6
- waldiez/conflict_checker.py,sha256=E-w0TfTivDAVpNvjd_NSBeaaFsWtWAyxKoSz0-g6x2U,880
7
- waldiez/exporter.py,sha256=yDtJL-p-wm4DeJnNE5xlyQUAeMTBkeFz5e9DikjDX5k,9517
8
- waldiez/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- waldiez/runner.py,sha256=5QjsJOYZlStTBQKyGjViLPhC94JuEaYIgrKP6XMvCHA,13045
10
- waldiez/exporting/__init__.py,sha256=GMY7qTRpNmc7tpaCFNGLT5wX9eu26NvoNPuYX8MzP50,344
11
- waldiez/exporting/agents/__init__.py,sha256=v5KA112W_EFYwXE2TSBKYyO8rRKUOUAOpFS5CMSnfRs,110
12
- waldiez/exporting/agents/agent.py,sha256=d2ut2B90-aG4uBRhPWS7B4MKIvSJqQva6DjlXiqleVQ,7513
13
- waldiez/exporting/agents/agent_skills.py,sha256=4et3DduwV6dvYTzR4hQRBQGdIkQuJwp1w4oGnjBek6Y,1852
14
- waldiez/exporting/agents/code_execution.py,sha256=fA_E8EuxUqCzlQMoIDQODiN32CSTttjLXGKBJaAEyqY,2299
15
- waldiez/exporting/agents/group_manager.py,sha256=rVYtg72dM4J_agEtpN60cGT1dWNqP9msd9I9YRVR1cc,7112
16
- waldiez/exporting/agents/llm_config.py,sha256=A88e-RKp09r8n9MG11hArpITzxK8nVrTZ6dtJ60iRXE,1455
17
- waldiez/exporting/agents/teachability.py,sha256=ame4hHJCZRBp7hAQGZzv2Cjs6QtcV9vlQ1zheMEMac0,1103
18
- waldiez/exporting/agents/termination_message.py,sha256=tzI4-tcveYKBVx5PsznQZwAoghSX3mbn_vPu4rX8tuU,1276
19
- waldiez/exporting/agents/rag_user/__init__.py,sha256=01F4gwgUwtSpZbGXcfieqIuLNT64u9KiqMIB2f0mplI,196
20
- waldiez/exporting/agents/rag_user/chroma_utils.py,sha256=yASPPnowIFXv86qojBSZWfJQMSId4HIvMlFoU4MYMl8,4720
21
- waldiez/exporting/agents/rag_user/mongo_utils.py,sha256=y5IL-Anfktg9cYo2o-ED1A7lwHQWdVMWD_W1AT5_RmE,2664
22
- waldiez/exporting/agents/rag_user/pgvector_utils.py,sha256=EyGDwvo1Pe8bqoJl3NFpqK6zizN81lPPaSMBMQF79Dc,2722
23
- waldiez/exporting/agents/rag_user/qdrant_utils.py,sha256=tn1A7pjQjJfGS33ALgnPYTz7xu8rVBidcc5-WHLq8e8,3487
24
- waldiez/exporting/agents/rag_user/rag_user.py,sha256=uT0wlYCYbBjsw6uZm9bXAk6IaMtk0fev7sM6Xf1MuTo,6268
25
- waldiez/exporting/agents/rag_user/vector_db.py,sha256=bqcPPG-eDABWOsZDDX0kDWhZSwaPO-QbqaFmPqdoYys,3679
26
- waldiez/exporting/chats/__init__.py,sha256=v5aR1gWqSN5xeDDMIFo-ceC_Z9UgL8qJZofC2sU8HqQ,296
27
- waldiez/exporting/chats/chats.py,sha256=xI5ZzWpcqYz8Kuu7B9pU6iHN16wUwHxOvYFhH5vxWuA,1259
28
- waldiez/exporting/chats/helpers.py,sha256=M9-FLK_YACrCQaqpKV4Cep-u0LSSoZK7T5H4U-RW8Uw,13372
29
- waldiez/exporting/chats/nested.py,sha256=nYzxOTHSBpyFdqvX_NtZUvUgTdmoTZcCRaGTFzdnmII,7916
30
- waldiez/exporting/flow/__init__.py,sha256=WhdPrjXQAcihrS1KUtPNgbx0y1tqD5HtGykzpEAcsBM,98
31
- waldiez/exporting/flow/def_main.py,sha256=UWNw3xrXLelx39FF5CNIBGMqUiFRfV-T_VdIHs6FQ4o,966
32
- waldiez/exporting/flow/flow.py,sha256=ewSyWMoAuHekGkh5KnMAN10_cYv9mmlxzQGzRVQdYpE,6150
33
- waldiez/exporting/models/__init__.py,sha256=wVjBMexIWihD5i1TkOyivDsouJ94FRzyiAjYchDYBfk,7106
34
- waldiez/exporting/skills/__init__.py,sha256=hjW16Uu3MkZfoEKyGnIrTBTVLvW0GdGzJmWXBcSDvsQ,4666
35
- waldiez/exporting/utils/__init__.py,sha256=tP1V4g9-MyARlfOEL_1YWMJNW7UivUrrukq7DIwdq6k,1018
36
- waldiez/exporting/utils/comments.py,sha256=X9j8w48rh3DfFDjiMverU9DBSuE9yuMMbbStxBbN1sE,3190
37
- waldiez/exporting/utils/importing.py,sha256=dA4HCQ-OxmodUjovgXyLI9IwNvLwbY67P41969XoZ7g,8649
38
- waldiez/exporting/utils/logging_utils.py,sha256=DfnC13PqnadG0nRxz_gHA4IIZGnMawpTPlkKYdGT94w,5864
39
- waldiez/exporting/utils/method_utils.py,sha256=7-RUMTylNM2W0iM1bPX2_Gn3553XZSl2s2VGEijxNp4,891
40
- waldiez/exporting/utils/naming.py,sha256=VdoVODQduhXIs9hQFWUVEVqTaSyNDt7rkECsuIgXYwI,3196
41
- waldiez/exporting/utils/object_string.py,sha256=2kdIu4in3iUV92a2KbLWwp9POhvY-fzF_r2AGVnCKls,2166
42
- waldiez/exporting/utils/path_check.py,sha256=aO49sbk6hUHEr65UjNNUSKO5WCGnQitiT733W-kGVtI,1062
43
- waldiez/models/__init__.py,sha256=IMq8vzuAgmv92kHSSuZQLF38vVd31ojgOHonuHqWYj0,2888
44
- waldiez/models/waldiez.py,sha256=IedhA4gPOWBca057xFstVoR5fsHtpFfItrydMKfGngw,9566
45
- waldiez/models/agents/__init__.py,sha256=3ZyVYBHMFzZjRMIdPrBF6HLg82LPAlEubL6utL6KhfU,1856
46
- waldiez/models/agents/agents.py,sha256=zIqihnoBjzaQLL_P6FcVoHddcusRNYsWPIFLZD091bE,3641
47
- waldiez/models/agents/agent/__init__.py,sha256=inA0zV3dnwmcQlcObH_FLaZSURjFG31E_XUampJAnJU,746
48
- waldiez/models/agents/agent/agent.py,sha256=DAwreQtIdoM2x_vVccIkALl5whyS07GvfKRUxdVhLeY,5513
49
- waldiez/models/agents/agent/agent_data.py,sha256=HMrVqTOh5PtQ5VtgNTIaZl3tFgfyVLyBMm75oe8wkJg,5334
50
- waldiez/models/agents/agent/code_execution.py,sha256=kgL3pbEEyuMvJid0sIbfe4os7SWKpzL1Bv4O525Biyk,1942
51
- waldiez/models/agents/agent/linked_skill.py,sha256=8RHWHkHXqFuv7lEe1PuQoK1hTO3kBQ7ILKm9kCEWqNs,667
52
- waldiez/models/agents/agent/nested_chat.py,sha256=VKzHI38CUCnOlB6oBdO7CJdCk-wmG0aGXIkWpJPa4-Q,1757
53
- waldiez/models/agents/agent/teachability.py,sha256=IIR4LY9dwx3T7Ok17RYN2g6zGiga2gGizGteaeI3eGs,1703
54
- waldiez/models/agents/agent/termination_message.py,sha256=aGsIdwGs42BxDktkxoqHGEWM1wzhXr-zh_MlETsbycA,5674
55
- waldiez/models/agents/assistant/__init__.py,sha256=Zlf-4EI9HXl-LrqGosL7UucoyqIl74GZzohZlRLx2QI,175
56
- waldiez/models/agents/assistant/assistant.py,sha256=OFh5nr8HrOLg2KXnwzFUU7_JBWrYfM7lRtTRQT1E_gI,1095
57
- waldiez/models/agents/assistant/assistant_data.py,sha256=VGdF1IZBBqBvZwe6BP2s4LinmkQ2IjesaDvs9Me9iHY,823
58
- waldiez/models/agents/group_manager/__init__.py,sha256=To97X5vdRTcTSylWUH2hlgkNH2pdn4TRUJqvLiU5-Bk,592
59
- waldiez/models/agents/group_manager/group_manager.py,sha256=0Bg3rEGL414M8gIMlgg6q3et7RFgGheHbvHUcONc-qw,2687
60
- waldiez/models/agents/group_manager/group_manager_data.py,sha256=NHA_uRC3KxqquhW4sEoNVhT8XWpXD1W_8EYaRjzJuG8,2785
61
- waldiez/models/agents/group_manager/speakers.py,sha256=OXYEEexGeQUf9hllixJTCE3atp2-_hMmdSsEW5XCg8g,6646
62
- waldiez/models/agents/rag_user/__init__.py,sha256=_Ge6ekCPHGuDuebbP3unUKbWrjeN8Hx3ST68_DapE7w,678
63
- waldiez/models/agents/rag_user/rag_user.py,sha256=l4a_IzlNPtNb-GTx22r15XIVmHxvhuM5KbXjkUwS8JU,1558
64
- waldiez/models/agents/rag_user/rag_user_data.py,sha256=4WjG8UcQ8ltLAxvZgsZUUlaEqHrX3KewrVIH7UJeUYo,870
65
- waldiez/models/agents/rag_user/retrieve_config.py,sha256=ZG0kqdza35aoMm9ZJdU-jLPDo-PJFkeUZycnaE3secI,21817
66
- waldiez/models/agents/rag_user/vector_db_config.py,sha256=JdPoQ8wVnZGyIkNrb85xZzSuia8PF4ejQkGDbbXsDC4,4922
67
- waldiez/models/agents/user_proxy/__init__.py,sha256=RNLQ5ws58mJE-8ckjAvC8UvXPUu5CyTe8-iDLxSFogQ,178
68
- waldiez/models/agents/user_proxy/user_proxy.py,sha256=Um9Oxprpct1Dlg7dwi0S4v6z8IGjlcrirM-BpgV5XaU,1071
69
- waldiez/models/agents/user_proxy/user_proxy_data.py,sha256=3aQ4N-C1mEt4FDkOzaknLGbwfoFuDD47OkLJSNgSvcQ,833
70
- waldiez/models/chat/__init__.py,sha256=AVFHRig7T4TBHx1B5MczW3s79wVN4G98ThLYm7pBfr8,553
71
- waldiez/models/chat/chat.py,sha256=lqyNvC2XjffLy8RIGcYOi8CEMenmfd_brapfDVenAqc,3408
72
- waldiez/models/chat/chat_data.py,sha256=EGWIPj1U0SoEdl0Wc5e9l4ncNbMaDndfLnVSV7qRmJo,9870
73
- waldiez/models/chat/chat_message.py,sha256=OtA65nNm4J0N3G5EHz7ga9dKsKqzClyhsVNm7-XKvow,8761
74
- waldiez/models/chat/chat_nested.py,sha256=OFeytlQ1Rgt6hx9_-xe47PdNnmgztokxldEDPJuGKsc,4685
75
- waldiez/models/chat/chat_summary.py,sha256=fiF0X6nk5dLoZFfwKBHoytk2ArhvIpVHETyCIH7uKd4,2823
76
- waldiez/models/common/__init__.py,sha256=1WhzhGYYUWMuHgxjiT1UralMClutO3_5BhFtnkhp8Yk,686
77
- waldiez/models/common/base.py,sha256=Aef91uGtbDfpUBGpY0m49L0tBHSaX23xvHDekIq-3H0,1687
78
- waldiez/models/common/method_utils.py,sha256=5DnZ6svR04FmQrSdP7elyEr2O2DfjOVJfOe1-Nda278,5522
79
- waldiez/models/flow/__init__.py,sha256=oy_G58xDkZk_LZEvqmr-0MJrpYy1JRf-U-F5-bI1944,162
80
- waldiez/models/flow/flow.py,sha256=1r0g_vBMd2PKcRC8P1ylWOUW3zwb529oOglf91SkILI,9663
81
- waldiez/models/flow/flow_data.py,sha256=m-RYaqlWjVpjyUzX9iAtXn1GOH0pFGKd2QD3e_e7yrk,2694
82
- waldiez/models/model/__init__.py,sha256=nT9jdKqeV4LPkqWi84Z7hCYZ1257Tj8YhUWbxhFlQl0,290
83
- waldiez/models/model/model.py,sha256=9A-pIufm9Sn4X9syphxtCOFfZ3BNo8ft07uxNXSRRiI,6130
84
- waldiez/models/model/model_data.py,sha256=IBXZLaTs4RzEb0xaHuouqesTLgKp3jEBlKlIKNGI2as,3699
85
- waldiez/models/skill/__init__.py,sha256=rU88bajKOGMYoHFcE8MP0jW9H0MswbQmvz5wxS35BYE,169
86
- waldiez/models/skill/skill.py,sha256=fhsAI413an2_d4DBIkf7dzEuWk6rGs2t4sl97a4dj20,3473
87
- waldiez/models/skill/skill_data.py,sha256=RTWn8Od6w7g-nRIpsS29sqZ8sPm5dCPiK7-qXmU-KD4,815
88
- waldiez-0.2.2.dist-info/METADATA,sha256=kmKg8v8CgE2t-hu30FZcOQqH8H2YX4we_5Zz9E0-fU4,8748
89
- waldiez-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
90
- waldiez-0.2.2.dist-info/entry_points.txt,sha256=9MQ8Y1rD19CU7UwjNPwoyTRpQsPs2QimjrtwTD0bD6k,44
91
- waldiez-0.2.2.dist-info/licenses/LICENSE,sha256=5ds5KvqN0audHYSaoarNtEITRRx9cZhq4wWPmFvmU48,1065
92
- waldiez-0.2.2.dist-info/RECORD,,