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.
- waldiez/__init__.py +2 -0
- waldiez/__main__.py +2 -0
- waldiez/_version.py +3 -1
- waldiez/cli.py +13 -3
- waldiez/cli_extras.py +4 -3
- waldiez/conflict_checker.py +4 -3
- waldiez/exporter.py +28 -105
- waldiez/exporting/__init__.py +8 -9
- waldiez/exporting/agent/__init__.py +7 -0
- waldiez/exporting/agent/agent_exporter.py +279 -0
- waldiez/exporting/agent/utils/__init__.py +23 -0
- waldiez/exporting/agent/utils/agent_class_name.py +34 -0
- waldiez/exporting/agent/utils/agent_imports.py +50 -0
- waldiez/exporting/{agents → agent/utils}/code_execution.py +9 -11
- waldiez/exporting/{agents → agent/utils}/group_manager.py +47 -35
- waldiez/exporting/{agents → agent/utils}/rag_user/__init__.py +2 -0
- waldiez/exporting/{agents → agent/utils}/rag_user/chroma_utils.py +22 -17
- waldiez/exporting/{agents → agent/utils}/rag_user/mongo_utils.py +14 -10
- waldiez/exporting/{agents → agent/utils}/rag_user/pgvector_utils.py +12 -8
- waldiez/exporting/{agents → agent/utils}/rag_user/qdrant_utils.py +11 -8
- waldiez/exporting/{agents → agent/utils}/rag_user/rag_user.py +78 -55
- waldiez/exporting/{agents → agent/utils}/rag_user/vector_db.py +10 -8
- waldiez/exporting/agent/utils/swarm_agent.py +463 -0
- waldiez/exporting/{agents → agent/utils}/teachability.py +10 -6
- waldiez/exporting/{agents → agent/utils}/termination_message.py +7 -8
- waldiez/exporting/base/__init__.py +25 -0
- waldiez/exporting/base/agent_position.py +75 -0
- waldiez/exporting/base/base_exporter.py +118 -0
- waldiez/exporting/base/export_position.py +48 -0
- waldiez/exporting/base/import_position.py +23 -0
- waldiez/exporting/base/mixin.py +134 -0
- waldiez/exporting/base/utils/__init__.py +18 -0
- waldiez/exporting/{utils → base/utils}/comments.py +12 -55
- waldiez/exporting/{utils → base/utils}/naming.py +14 -4
- waldiez/exporting/base/utils/path_check.py +68 -0
- waldiez/exporting/{utils/object_string.py → base/utils/to_string.py} +21 -20
- waldiez/exporting/chats/__init__.py +5 -12
- waldiez/exporting/chats/chats_exporter.py +240 -0
- waldiez/exporting/chats/utils/__init__.py +15 -0
- waldiez/exporting/chats/utils/common.py +81 -0
- waldiez/exporting/chats/{nested.py → utils/nested.py} +125 -86
- waldiez/exporting/chats/utils/sequential.py +244 -0
- waldiez/exporting/chats/utils/single_chat.py +313 -0
- waldiez/exporting/chats/utils/swarm.py +207 -0
- waldiez/exporting/flow/__init__.py +5 -3
- waldiez/exporting/flow/flow_exporter.py +503 -0
- waldiez/exporting/flow/utils/__init__.py +47 -0
- waldiez/exporting/flow/utils/agent_utils.py +204 -0
- waldiez/exporting/flow/utils/chat_utils.py +71 -0
- waldiez/exporting/flow/utils/def_main.py +62 -0
- waldiez/exporting/flow/utils/flow_content.py +112 -0
- waldiez/exporting/flow/utils/flow_names.py +115 -0
- waldiez/exporting/flow/utils/importing_utils.py +182 -0
- waldiez/exporting/{utils → flow/utils}/logging_utils.py +34 -31
- waldiez/exporting/models/__init__.py +7 -242
- waldiez/exporting/models/models_exporter.py +192 -0
- waldiez/exporting/models/utils.py +166 -0
- waldiez/exporting/skills/__init__.py +7 -161
- waldiez/exporting/skills/skills_exporter.py +169 -0
- waldiez/exporting/skills/utils.py +281 -0
- waldiez/models/__init__.py +25 -7
- waldiez/models/agents/__init__.py +70 -0
- waldiez/models/agents/agent/__init__.py +11 -1
- waldiez/models/agents/agent/agent.py +9 -4
- waldiez/models/agents/agent/agent_data.py +3 -1
- waldiez/models/agents/agent/code_execution.py +2 -0
- waldiez/models/agents/agent/linked_skill.py +2 -0
- waldiez/models/agents/agent/nested_chat.py +2 -0
- waldiez/models/agents/agent/teachability.py +2 -0
- waldiez/models/agents/agent/termination_message.py +49 -13
- waldiez/models/agents/agents.py +15 -3
- waldiez/models/agents/assistant/__init__.py +2 -0
- waldiez/models/agents/assistant/assistant.py +2 -0
- waldiez/models/agents/assistant/assistant_data.py +2 -0
- waldiez/models/agents/group_manager/__init__.py +9 -1
- waldiez/models/agents/group_manager/group_manager.py +2 -0
- waldiez/models/agents/group_manager/group_manager_data.py +2 -0
- waldiez/models/agents/group_manager/speakers.py +49 -13
- waldiez/models/agents/rag_user/__init__.py +21 -4
- waldiez/models/agents/rag_user/rag_user.py +3 -1
- waldiez/models/agents/rag_user/rag_user_data.py +2 -0
- waldiez/models/agents/rag_user/retrieve_config.py +268 -17
- waldiez/models/agents/rag_user/vector_db_config.py +5 -3
- waldiez/models/agents/swarm_agent/__init__.py +49 -0
- waldiez/models/agents/swarm_agent/after_work.py +178 -0
- waldiez/models/agents/swarm_agent/on_condition.py +103 -0
- waldiez/models/agents/swarm_agent/on_condition_available.py +140 -0
- waldiez/models/agents/swarm_agent/on_condition_target.py +40 -0
- waldiez/models/agents/swarm_agent/swarm_agent.py +107 -0
- waldiez/models/agents/swarm_agent/swarm_agent_data.py +125 -0
- waldiez/models/agents/swarm_agent/update_system_message.py +144 -0
- waldiez/models/agents/user_proxy/__init__.py +2 -0
- waldiez/models/agents/user_proxy/user_proxy.py +2 -0
- waldiez/models/agents/user_proxy/user_proxy_data.py +2 -0
- waldiez/models/chat/__init__.py +21 -3
- waldiez/models/chat/chat.py +241 -7
- waldiez/models/chat/chat_data.py +192 -48
- waldiez/models/chat/chat_message.py +153 -144
- waldiez/models/chat/chat_nested.py +33 -53
- waldiez/models/chat/chat_summary.py +2 -0
- waldiez/models/common/__init__.py +6 -6
- waldiez/models/common/base.py +4 -1
- waldiez/models/common/method_utils.py +163 -83
- waldiez/models/flow/__init__.py +2 -0
- waldiez/models/flow/flow.py +176 -40
- waldiez/models/flow/flow_data.py +63 -2
- waldiez/models/flow/utils.py +172 -0
- waldiez/models/model/__init__.py +2 -0
- waldiez/models/model/model.py +30 -9
- waldiez/models/model/model_data.py +3 -1
- waldiez/models/skill/__init__.py +4 -1
- waldiez/models/skill/skill.py +30 -2
- waldiez/models/skill/skill_data.py +2 -0
- waldiez/models/waldiez.py +28 -4
- waldiez/runner.py +142 -228
- waldiez/running/__init__.py +33 -0
- waldiez/running/environment.py +83 -0
- waldiez/running/gen_seq_diagram.py +185 -0
- waldiez/running/running.py +300 -0
- {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/METADATA +35 -28
- waldiez-0.3.1.dist-info/RECORD +125 -0
- waldiez-0.3.1.dist-info/licenses/LICENSE +201 -0
- waldiez/exporting/agents/__init__.py +0 -5
- waldiez/exporting/agents/agent.py +0 -236
- waldiez/exporting/agents/agent_skills.py +0 -67
- waldiez/exporting/agents/llm_config.py +0 -53
- waldiez/exporting/chats/chats.py +0 -46
- waldiez/exporting/chats/helpers.py +0 -420
- waldiez/exporting/flow/def_main.py +0 -32
- waldiez/exporting/flow/flow.py +0 -189
- waldiez/exporting/utils/__init__.py +0 -36
- waldiez/exporting/utils/importing.py +0 -265
- waldiez/exporting/utils/method_utils.py +0 -35
- waldiez/exporting/utils/path_check.py +0 -51
- waldiez-0.2.2.dist-info/RECORD +0 -92
- waldiez-0.2.2.dist-info/licenses/LICENSE +0 -21
- {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/WHEEL +0 -0
- {waldiez-0.2.2.dist-info → waldiez-0.3.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
1
3
|
"""RAG User related exporting utils."""
|
|
2
4
|
|
|
3
|
-
from typing import Dict, List, Set, Tuple, Union
|
|
5
|
+
from typing import Callable, Dict, List, Set, Tuple, Union
|
|
4
6
|
|
|
5
7
|
from waldiez.models import (
|
|
6
8
|
WaldiezAgent,
|
|
@@ -9,14 +11,63 @@ from waldiez.models import (
|
|
|
9
11
|
WaldiezRagUserRetrieveConfig,
|
|
10
12
|
)
|
|
11
13
|
|
|
12
|
-
from ...utils import get_object_string, get_path_string
|
|
13
14
|
from .vector_db import get_rag_user_vector_db_string
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
def get_rag_user_extras(
|
|
18
|
+
agent: WaldiezAgent,
|
|
19
|
+
agent_name: str,
|
|
20
|
+
model_names: Dict[str, str],
|
|
21
|
+
path_resolver: Callable[[str], str],
|
|
22
|
+
serializer: Callable[..., str],
|
|
23
|
+
) -> Tuple[str, str, Set[str]]:
|
|
24
|
+
"""Get the RAG user extra argument, imports and content before the agent.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
agent : WaldiezAgent
|
|
29
|
+
The agent.
|
|
30
|
+
agent_name : str
|
|
31
|
+
The agent's name.
|
|
32
|
+
model_names : Dict[str, str]
|
|
33
|
+
A mapping from model id to model name.
|
|
34
|
+
path_resolver : Callable[[str], str]
|
|
35
|
+
The path resolver function.
|
|
36
|
+
serializer : Callable[..., str]
|
|
37
|
+
The serializer function.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
Tuple[str, str, Set[str]]
|
|
42
|
+
The content before the agent, the retrieve arg and the db imports.
|
|
43
|
+
"""
|
|
44
|
+
before_agent_string = ""
|
|
45
|
+
retrieve_arg = ""
|
|
46
|
+
db_imports: Set[str] = set()
|
|
47
|
+
if agent.agent_type == "rag_user" and isinstance(agent, WaldiezRagUser):
|
|
48
|
+
rag_content_before_agent, retrieve_arg, db_imports = (
|
|
49
|
+
get_rag_user_retrieve_config_str(
|
|
50
|
+
agent=agent,
|
|
51
|
+
agent_name=agent_name,
|
|
52
|
+
model_names=model_names,
|
|
53
|
+
path_resolver=path_resolver,
|
|
54
|
+
serializer=serializer,
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
if retrieve_arg:
|
|
58
|
+
retrieve_arg = "\n" + f" retrieve_config={retrieve_arg},"
|
|
59
|
+
if rag_content_before_agent:
|
|
60
|
+
before_agent_string += rag_content_before_agent
|
|
61
|
+
return before_agent_string, retrieve_arg, db_imports
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# pylint: disable=too-many-locals
|
|
16
65
|
def get_rag_user_retrieve_config_str(
|
|
17
66
|
agent: WaldiezRagUser,
|
|
18
67
|
agent_name: str,
|
|
19
68
|
model_names: Dict[str, str],
|
|
69
|
+
path_resolver: Callable[[str], str],
|
|
70
|
+
serializer: Callable[..., str],
|
|
20
71
|
) -> Tuple[str, str, Set[str]]:
|
|
21
72
|
"""Get the RAG user retrieve config string.
|
|
22
73
|
|
|
@@ -28,6 +79,10 @@ def get_rag_user_retrieve_config_str(
|
|
|
28
79
|
The agent's name.
|
|
29
80
|
model_names : Dict[str, str]
|
|
30
81
|
A mapping from model id to model name.
|
|
82
|
+
path_resolver : Callable[[str], str]
|
|
83
|
+
The path resolver function.
|
|
84
|
+
serializer : Callable[..., str]
|
|
85
|
+
The serializer function.
|
|
31
86
|
Returns
|
|
32
87
|
-------
|
|
33
88
|
Tuple[str, str, Set[str]]
|
|
@@ -43,32 +98,34 @@ def get_rag_user_retrieve_config_str(
|
|
|
43
98
|
agent_name=agent_name,
|
|
44
99
|
)
|
|
45
100
|
imports.update(db_imports)
|
|
46
|
-
args_dict = _get_args_dict(
|
|
101
|
+
args_dict = _get_args_dict(
|
|
102
|
+
agent, retrieve_config, model_names, path_resolver
|
|
103
|
+
)
|
|
47
104
|
if retrieve_config.use_custom_token_count:
|
|
48
|
-
token_count_arg_name =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"\n\n"
|
|
105
|
+
function_content, token_count_arg_name = (
|
|
106
|
+
retrieve_config.get_custom_token_count_function(
|
|
107
|
+
name_suffix=agent_name
|
|
108
|
+
)
|
|
53
109
|
)
|
|
110
|
+
before_the_args += "\n" + function_content + "\n"
|
|
54
111
|
args_dict["custom_token_count_function"] = token_count_arg_name
|
|
55
112
|
if retrieve_config.use_custom_text_split:
|
|
56
|
-
text_split_arg_name =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"\n\n"
|
|
113
|
+
function_content, text_split_arg_name = (
|
|
114
|
+
retrieve_config.get_custom_text_split_function(
|
|
115
|
+
name_suffix=agent_name
|
|
116
|
+
)
|
|
61
117
|
)
|
|
118
|
+
before_the_args += "\n" + function_content + "\n"
|
|
62
119
|
args_dict["custom_text_split_function"] = text_split_arg_name
|
|
63
120
|
# docs_path = args_dict.pop("docs_path", [])
|
|
64
|
-
args_content =
|
|
121
|
+
args_content = serializer(args_dict)
|
|
65
122
|
# get the last line (where the dict ends)
|
|
66
123
|
args_parts = args_content.split("\n")
|
|
67
124
|
before_vector_db = args_parts[:-1]
|
|
68
125
|
closing_arg = args_parts[-1]
|
|
69
126
|
args_content = "\n".join(before_vector_db)
|
|
70
127
|
# add the vector_db arg
|
|
71
|
-
args_content += f'
|
|
128
|
+
args_content += ",\n" + f' "vector_db": {vector_db_arg},' + "\n"
|
|
72
129
|
# we should not need to include the client, but let's do it
|
|
73
130
|
# to avoid later issues (with telemetry or other client settings)
|
|
74
131
|
# https://github.com/ag2ai/ag2/blob/main/autogen/agentchat/\
|
|
@@ -77,48 +134,11 @@ def get_rag_user_retrieve_config_str(
|
|
|
77
134
|
f"{agent_name}_client" in before_the_args
|
|
78
135
|
and agent.retrieve_config.vector_db == "chroma"
|
|
79
136
|
):
|
|
80
|
-
args_content += f' "client": {agent_name}_client
|
|
137
|
+
args_content += f' "client": {agent_name}_client,' + "\n"
|
|
81
138
|
args_content += closing_arg
|
|
82
139
|
return before_the_args, args_content, imports
|
|
83
140
|
|
|
84
141
|
|
|
85
|
-
def get_rag_user_extras(
|
|
86
|
-
agent: WaldiezAgent,
|
|
87
|
-
agent_name: str,
|
|
88
|
-
model_names: Dict[str, str],
|
|
89
|
-
) -> Tuple[str, str, Set[str]]:
|
|
90
|
-
"""Get the RAG user extra argument, imports and content before the agent.
|
|
91
|
-
|
|
92
|
-
Parameters
|
|
93
|
-
----------
|
|
94
|
-
agent : WaldiezAgent
|
|
95
|
-
The agent.
|
|
96
|
-
agent_name : str
|
|
97
|
-
The agent's name.
|
|
98
|
-
model_names : Dict[str, str]
|
|
99
|
-
A mapping from model id to model name.
|
|
100
|
-
|
|
101
|
-
Returns
|
|
102
|
-
-------
|
|
103
|
-
Tuple[str, str, Set[str]]
|
|
104
|
-
The content before the agent, the retrieve arg and the db imports.
|
|
105
|
-
"""
|
|
106
|
-
before_agent_string = ""
|
|
107
|
-
retrieve_arg = ""
|
|
108
|
-
db_imports: Set[str] = set()
|
|
109
|
-
if agent.agent_type == "rag_user" and isinstance(agent, WaldiezRagUser):
|
|
110
|
-
rag_content_before_agent, retrieve_arg, db_imports = (
|
|
111
|
-
get_rag_user_retrieve_config_str(
|
|
112
|
-
agent=agent, agent_name=agent_name, model_names=model_names
|
|
113
|
-
)
|
|
114
|
-
)
|
|
115
|
-
if retrieve_arg:
|
|
116
|
-
retrieve_arg = f"\n retrieve_config={retrieve_arg},"
|
|
117
|
-
if rag_content_before_agent:
|
|
118
|
-
before_agent_string += rag_content_before_agent
|
|
119
|
-
return before_agent_string, retrieve_arg, db_imports
|
|
120
|
-
|
|
121
|
-
|
|
122
142
|
def _get_model_arg(
|
|
123
143
|
agent: WaldiezRagUser,
|
|
124
144
|
retrieve_config: WaldiezRagUserRetrieveConfig,
|
|
@@ -141,6 +161,7 @@ def _get_args_dict(
|
|
|
141
161
|
agent: WaldiezRagUser,
|
|
142
162
|
retrieve_config: WaldiezRagUserRetrieveConfig,
|
|
143
163
|
model_names: Dict[str, str],
|
|
164
|
+
path_resolver: Callable[[str], str],
|
|
144
165
|
) -> Dict[str, Union[str, List[str]]]:
|
|
145
166
|
model_arg = _get_model_arg(agent, retrieve_config, model_names)
|
|
146
167
|
args_dict: Dict[str, Union[str, List[str]]] = {
|
|
@@ -160,12 +181,14 @@ def _get_args_dict(
|
|
|
160
181
|
args_dict[arg] = getattr(retrieve_config, arg)
|
|
161
182
|
docs_path: Union[str, List[str]] = []
|
|
162
183
|
if retrieve_config.docs_path:
|
|
163
|
-
|
|
184
|
+
doc_paths = (
|
|
164
185
|
retrieve_config.docs_path
|
|
165
186
|
if isinstance(retrieve_config.docs_path, list)
|
|
166
187
|
else [retrieve_config.docs_path]
|
|
167
188
|
)
|
|
168
|
-
docs_path = [
|
|
189
|
+
docs_path = [
|
|
190
|
+
item for item in [path_resolver(path) for path in doc_paths] if item
|
|
191
|
+
]
|
|
169
192
|
args_dict["docs_path"] = docs_path
|
|
170
193
|
if docs_path:
|
|
171
194
|
args_dict["docs_path"] = docs_path
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# flake8: noqa E501
|
|
4
4
|
# pylint: disable=line-too-long
|
|
5
|
+
"""Vector DB exporting utils for RAG user agents."""
|
|
6
|
+
|
|
5
7
|
from typing import Any, Set, Tuple
|
|
6
8
|
|
|
7
9
|
from waldiez.models import WaldiezRagUser
|
|
@@ -31,15 +33,15 @@ def _get_metadata_arg(
|
|
|
31
33
|
if agent.retrieve_config.db_config.metadata:
|
|
32
34
|
tab = " "
|
|
33
35
|
indent = tab * 3
|
|
34
|
-
metadata_arg += f"{indent}metadata={{\n"
|
|
36
|
+
metadata_arg += f"{indent}metadata={{" + "\n"
|
|
35
37
|
for key, value in agent.retrieve_config.db_config.metadata.items():
|
|
36
38
|
value_string: Any = f'"{value}"'
|
|
37
39
|
if str(value).isdigit():
|
|
38
40
|
value_string = int(value)
|
|
39
41
|
elif str(value).replace(".", "").isdigit():
|
|
40
42
|
value_string = float(value)
|
|
41
|
-
metadata_arg += f'{indent} "{key}": {value_string}
|
|
42
|
-
metadata_arg += f"{indent}}}
|
|
43
|
+
metadata_arg += f'{indent} "{key}": {value_string},' + "\n"
|
|
44
|
+
metadata_arg += f"{indent}}}," + "\n"
|
|
43
45
|
return metadata_arg
|
|
44
46
|
|
|
45
47
|
|
|
@@ -109,12 +111,12 @@ def get_rag_user_vector_db_string(
|
|
|
109
111
|
agent, agent_name
|
|
110
112
|
)
|
|
111
113
|
if content_before:
|
|
112
|
-
before +=
|
|
114
|
+
before += "\n" + f"{content_before}"
|
|
113
115
|
if ef_body:
|
|
114
|
-
before +=
|
|
116
|
+
before += "\n" + f"{ef_body}" + "\n"
|
|
115
117
|
if db_imports:
|
|
116
118
|
imports.update(db_imports)
|
|
117
119
|
kwarg_string += _get_metadata_arg(agent)
|
|
118
|
-
vdb_arg = f"{vdb_class}(\n"
|
|
120
|
+
vdb_arg = f"{vdb_class}(" + "\n"
|
|
119
121
|
vdb_arg += kwarg_string + " )"
|
|
120
122
|
return before, vdb_arg, imports
|