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.
- waldiez/__init__.py +5 -5
- waldiez/_version.py +1 -1
- waldiez/cli.py +112 -73
- waldiez/exporter.py +61 -19
- waldiez/exporting/__init__.py +25 -6
- waldiez/exporting/agent/__init__.py +7 -3
- waldiez/exporting/agent/code_execution.py +114 -0
- waldiez/exporting/agent/exporter.py +354 -0
- waldiez/exporting/agent/extras/__init__.py +15 -0
- waldiez/exporting/agent/extras/captain_agent_extras.py +315 -0
- waldiez/exporting/agent/extras/group/target.py +178 -0
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +500 -0
- waldiez/exporting/agent/extras/group_member_extras.py +181 -0
- waldiez/exporting/agent/extras/handoffs/__init__.py +19 -0
- waldiez/exporting/agent/extras/handoffs/after_work.py +78 -0
- waldiez/exporting/agent/extras/handoffs/available.py +74 -0
- waldiez/exporting/agent/extras/handoffs/condition.py +158 -0
- waldiez/exporting/agent/extras/handoffs/handoff.py +171 -0
- waldiez/exporting/agent/extras/handoffs/target.py +189 -0
- waldiez/exporting/agent/extras/rag/__init__.py +10 -0
- waldiez/exporting/agent/{utils/rag_user/chroma_utils.py → extras/rag/chroma_extras.py} +16 -15
- waldiez/exporting/agent/{utils/rag_user/mongo_utils.py → extras/rag/mongo_extras.py} +10 -10
- waldiez/exporting/agent/{utils/rag_user/pgvector_utils.py → extras/rag/pgvector_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/qdrant_utils.py → extras/rag/qdrant_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/vector_db.py → extras/rag/vector_db_extras.py} +59 -46
- waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +245 -0
- waldiez/exporting/agent/extras/reasoning_agent_extras.py +88 -0
- waldiez/exporting/agent/factory.py +95 -0
- waldiez/exporting/agent/processor.py +150 -0
- waldiez/exporting/agent/system_message.py +36 -0
- waldiez/exporting/agent/termination.py +50 -0
- waldiez/exporting/chats/__init__.py +7 -3
- waldiez/exporting/chats/exporter.py +97 -0
- waldiez/exporting/chats/factory.py +65 -0
- waldiez/exporting/chats/processor.py +226 -0
- waldiez/exporting/chats/utils/__init__.py +6 -5
- waldiez/exporting/chats/utils/common.py +11 -45
- waldiez/exporting/chats/utils/group.py +55 -0
- waldiez/exporting/chats/utils/nested.py +37 -52
- waldiez/exporting/chats/utils/sequential.py +72 -61
- waldiez/exporting/chats/utils/{single_chat.py → single.py} +48 -50
- waldiez/exporting/core/__init__.py +196 -0
- waldiez/exporting/core/constants.py +17 -0
- waldiez/exporting/core/content.py +69 -0
- waldiez/exporting/core/context.py +244 -0
- waldiez/exporting/core/enums.py +89 -0
- waldiez/exporting/core/errors.py +19 -0
- waldiez/exporting/core/exporter.py +390 -0
- waldiez/exporting/core/exporters.py +67 -0
- waldiez/exporting/core/extras/__init__.py +39 -0
- waldiez/exporting/core/extras/agent_extras/__init__.py +27 -0
- waldiez/exporting/core/extras/agent_extras/captain_extras.py +57 -0
- waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +102 -0
- waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +53 -0
- waldiez/exporting/core/extras/agent_extras/reasoning_extras.py +68 -0
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +263 -0
- waldiez/exporting/core/extras/base.py +241 -0
- waldiez/exporting/core/extras/chat_extras.py +118 -0
- waldiez/exporting/core/extras/flow_extras.py +70 -0
- waldiez/exporting/core/extras/model_extras.py +73 -0
- waldiez/exporting/core/extras/path_resolver.py +93 -0
- waldiez/exporting/core/extras/serializer.py +138 -0
- waldiez/exporting/core/extras/tool_extras.py +82 -0
- waldiez/exporting/core/protocols.py +259 -0
- waldiez/exporting/core/result.py +705 -0
- waldiez/exporting/core/types.py +329 -0
- waldiez/exporting/core/utils/__init__.py +11 -0
- waldiez/exporting/core/utils/comment.py +33 -0
- waldiez/exporting/core/utils/llm_config.py +117 -0
- waldiez/exporting/core/validation.py +96 -0
- waldiez/exporting/flow/__init__.py +6 -2
- waldiez/exporting/flow/execution_generator.py +193 -0
- waldiez/exporting/flow/exporter.py +107 -0
- waldiez/exporting/flow/factory.py +94 -0
- waldiez/exporting/flow/file_generator.py +214 -0
- waldiez/exporting/flow/merger.py +387 -0
- waldiez/exporting/flow/orchestrator.py +411 -0
- waldiez/exporting/flow/utils/__init__.py +9 -36
- waldiez/exporting/flow/utils/common.py +206 -0
- waldiez/exporting/flow/utils/importing.py +373 -0
- waldiez/exporting/flow/utils/linting.py +200 -0
- waldiez/exporting/flow/utils/{logging_utils.py → logging.py} +23 -9
- waldiez/exporting/models/__init__.py +3 -1
- waldiez/exporting/models/exporter.py +233 -0
- waldiez/exporting/models/factory.py +66 -0
- waldiez/exporting/models/processor.py +139 -0
- waldiez/exporting/tools/__init__.py +11 -0
- waldiez/exporting/tools/exporter.py +207 -0
- waldiez/exporting/tools/factory.py +57 -0
- waldiez/exporting/tools/processor.py +248 -0
- waldiez/exporting/tools/registration.py +133 -0
- waldiez/io/__init__.py +128 -0
- waldiez/io/_ws.py +199 -0
- waldiez/io/models/__init__.py +60 -0
- waldiez/io/models/base.py +66 -0
- waldiez/io/models/constants.py +78 -0
- waldiez/io/models/content/__init__.py +23 -0
- waldiez/io/models/content/audio.py +43 -0
- waldiez/io/models/content/base.py +45 -0
- waldiez/io/models/content/file.py +43 -0
- waldiez/io/models/content/image.py +96 -0
- waldiez/io/models/content/text.py +37 -0
- waldiez/io/models/content/video.py +43 -0
- waldiez/io/models/user_input.py +269 -0
- waldiez/io/models/user_response.py +215 -0
- waldiez/io/mqtt.py +681 -0
- waldiez/io/redis.py +782 -0
- waldiez/io/structured.py +419 -0
- waldiez/io/utils.py +184 -0
- waldiez/io/ws.py +298 -0
- waldiez/logger.py +481 -0
- waldiez/models/__init__.py +108 -51
- waldiez/models/agents/__init__.py +34 -70
- waldiez/models/agents/agent/__init__.py +10 -4
- waldiez/models/agents/agent/agent.py +466 -65
- waldiez/models/agents/agent/agent_data.py +119 -47
- waldiez/models/agents/agent/agent_type.py +13 -2
- waldiez/models/agents/agent/code_execution.py +12 -12
- waldiez/models/agents/agent/human_input_mode.py +8 -0
- waldiez/models/agents/agent/{linked_skill.py → linked_tool.py} +7 -7
- waldiez/models/agents/agent/nested_chat.py +35 -7
- waldiez/models/agents/agent/termination_message.py +30 -22
- waldiez/models/agents/{swarm_agent → agent}/update_system_message.py +22 -22
- waldiez/models/agents/agents.py +58 -63
- waldiez/models/agents/assistant/assistant.py +4 -4
- waldiez/models/agents/assistant/assistant_data.py +13 -1
- waldiez/models/agents/{captain_agent → captain}/captain_agent.py +5 -5
- waldiez/models/agents/{captain_agent → captain}/captain_agent_data.py +5 -5
- waldiez/models/agents/extra_requirements.py +11 -16
- waldiez/models/agents/group_manager/group_manager.py +103 -13
- waldiez/models/agents/group_manager/group_manager_data.py +36 -14
- waldiez/models/agents/group_manager/speakers.py +77 -24
- waldiez/models/agents/{rag_user → rag_user_proxy}/__init__.py +16 -16
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +64 -0
- waldiez/models/agents/{rag_user/rag_user_data.py → rag_user_proxy/rag_user_proxy_data.py} +6 -5
- waldiez/models/agents/{rag_user → rag_user_proxy}/retrieve_config.py +182 -114
- waldiez/models/agents/{rag_user → rag_user_proxy}/vector_db_config.py +13 -13
- waldiez/models/agents/reasoning/reasoning_agent.py +6 -6
- waldiez/models/agents/reasoning/reasoning_agent_data.py +110 -63
- waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +38 -10
- waldiez/models/agents/user_proxy/user_proxy.py +11 -7
- waldiez/models/agents/user_proxy/user_proxy_data.py +2 -2
- waldiez/models/chat/__init__.py +2 -1
- waldiez/models/chat/chat.py +166 -87
- waldiez/models/chat/chat_data.py +99 -136
- waldiez/models/chat/chat_message.py +33 -23
- waldiez/models/chat/chat_nested.py +31 -30
- waldiez/models/chat/chat_summary.py +10 -8
- waldiez/models/common/__init__.py +52 -2
- waldiez/models/common/ag2_version.py +1 -1
- waldiez/models/common/base.py +38 -7
- waldiez/models/common/dict_utils.py +42 -17
- waldiez/models/common/handoff.py +459 -0
- waldiez/models/common/id_generator.py +19 -0
- waldiez/models/common/method_utils.py +130 -68
- waldiez/{exporting/base/utils → models/common}/naming.py +38 -61
- waldiez/models/common/waldiez_version.py +37 -0
- waldiez/models/flow/__init__.py +9 -2
- waldiez/models/flow/connection.py +18 -0
- waldiez/models/flow/flow.py +311 -215
- waldiez/models/flow/flow_data.py +207 -40
- waldiez/models/flow/info.py +85 -0
- waldiez/models/flow/naming.py +131 -0
- waldiez/models/model/__init__.py +7 -1
- waldiez/models/model/extra_requirements.py +3 -12
- waldiez/models/model/model.py +76 -21
- waldiez/models/model/model_data.py +108 -20
- waldiez/models/tool/__init__.py +16 -0
- waldiez/models/tool/extra_requirements.py +36 -0
- waldiez/models/{skill/skill.py → tool/tool.py} +88 -88
- waldiez/models/tool/tool_data.py +51 -0
- waldiez/models/tool/tool_type.py +8 -0
- waldiez/models/waldiez.py +97 -80
- waldiez/runner.py +114 -49
- waldiez/running/__init__.py +1 -1
- waldiez/running/environment.py +49 -68
- waldiez/running/gen_seq_diagram.py +16 -14
- waldiez/running/running.py +53 -34
- waldiez/utils/__init__.py +0 -4
- waldiez/utils/cli_extras/jupyter.py +5 -3
- waldiez/utils/cli_extras/runner.py +6 -4
- waldiez/utils/cli_extras/studio.py +6 -4
- waldiez/utils/conflict_checker.py +15 -9
- waldiez/utils/flaml_warnings.py +5 -5
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/METADATA +235 -91
- waldiez-0.4.8.dist-info/RECORD +200 -0
- waldiez/exporting/agent/agent_exporter.py +0 -297
- waldiez/exporting/agent/utils/__init__.py +0 -23
- waldiez/exporting/agent/utils/captain_agent.py +0 -263
- waldiez/exporting/agent/utils/code_execution.py +0 -65
- waldiez/exporting/agent/utils/group_manager.py +0 -220
- waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
- waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
- waldiez/exporting/agent/utils/reasoning.py +0 -36
- waldiez/exporting/agent/utils/swarm_agent.py +0 -469
- waldiez/exporting/agent/utils/teachability.py +0 -41
- waldiez/exporting/agent/utils/termination_message.py +0 -44
- waldiez/exporting/base/__init__.py +0 -25
- waldiez/exporting/base/agent_position.py +0 -75
- waldiez/exporting/base/base_exporter.py +0 -118
- waldiez/exporting/base/export_position.py +0 -48
- waldiez/exporting/base/import_position.py +0 -23
- waldiez/exporting/base/mixin.py +0 -137
- waldiez/exporting/base/utils/__init__.py +0 -18
- waldiez/exporting/base/utils/comments.py +0 -96
- waldiez/exporting/base/utils/path_check.py +0 -68
- waldiez/exporting/base/utils/to_string.py +0 -84
- waldiez/exporting/chats/chats_exporter.py +0 -240
- waldiez/exporting/chats/utils/swarm.py +0 -210
- waldiez/exporting/flow/flow_exporter.py +0 -528
- waldiez/exporting/flow/utils/agent_utils.py +0 -204
- waldiez/exporting/flow/utils/chat_utils.py +0 -71
- waldiez/exporting/flow/utils/def_main.py +0 -77
- waldiez/exporting/flow/utils/flow_content.py +0 -202
- waldiez/exporting/flow/utils/flow_names.py +0 -116
- waldiez/exporting/flow/utils/importing_utils.py +0 -227
- waldiez/exporting/models/models_exporter.py +0 -199
- waldiez/exporting/models/utils.py +0 -174
- waldiez/exporting/skills/__init__.py +0 -9
- waldiez/exporting/skills/skills_exporter.py +0 -176
- waldiez/exporting/skills/utils.py +0 -369
- waldiez/models/agents/agent/teachability.py +0 -70
- waldiez/models/agents/rag_user/rag_user.py +0 -60
- waldiez/models/agents/swarm_agent/__init__.py +0 -50
- waldiez/models/agents/swarm_agent/after_work.py +0 -179
- waldiez/models/agents/swarm_agent/on_condition.py +0 -105
- waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
- waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
- waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
- waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
- waldiez/models/flow/utils.py +0 -232
- waldiez/models/skill/__init__.py +0 -16
- waldiez/models/skill/extra_requirements.py +0 -36
- waldiez/models/skill/skill_data.py +0 -53
- waldiez/models/skill/skill_type.py +0 -8
- waldiez/utils/pysqlite3_checker.py +0 -308
- waldiez/utils/rdps_checker.py +0 -122
- waldiez-0.4.7.dist-info/RECORD +0 -149
- /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
- /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/WHEEL +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -4,29 +4,30 @@
|
|
|
4
4
|
# pylint: disable=line-too-long
|
|
5
5
|
"""Utilities for exporting a single chat in a flow."""
|
|
6
6
|
|
|
7
|
-
from typing import Any, Callable,
|
|
7
|
+
from typing import Any, Callable, Optional
|
|
8
8
|
|
|
9
9
|
from waldiez.models import (
|
|
10
10
|
WaldiezAgent,
|
|
11
11
|
WaldiezChat,
|
|
12
12
|
WaldiezChatMessage,
|
|
13
|
-
|
|
13
|
+
WaldiezRagUserProxy,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
from .common import get_chat_message_string
|
|
16
|
+
from .common import get_chat_message_string
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def export_single_chat(
|
|
20
20
|
sender: WaldiezAgent,
|
|
21
21
|
recipient: WaldiezAgent,
|
|
22
22
|
chat: WaldiezChat,
|
|
23
|
-
agent_names:
|
|
24
|
-
chat_names:
|
|
23
|
+
agent_names: dict[str, str],
|
|
24
|
+
chat_names: dict[str, str],
|
|
25
25
|
serializer: Callable[[str], str],
|
|
26
|
-
string_escape: Callable[[str], str],
|
|
27
26
|
tabs: int,
|
|
28
27
|
is_async: bool,
|
|
29
|
-
|
|
28
|
+
skip_cache: bool,
|
|
29
|
+
tab_leng: int = 4,
|
|
30
|
+
) -> tuple[str, str]:
|
|
30
31
|
"""Get the chat string when there is only one chat in the flow.
|
|
31
32
|
|
|
32
33
|
Parameters
|
|
@@ -37,22 +38,24 @@ def export_single_chat(
|
|
|
37
38
|
The recipient.
|
|
38
39
|
chat : WaldiezChat
|
|
39
40
|
The chat.
|
|
40
|
-
agent_names :
|
|
41
|
+
agent_names : dict[str, str]
|
|
41
42
|
A mapping of agent id to agent name.
|
|
42
|
-
chat_names :
|
|
43
|
+
chat_names : dict[str, str]
|
|
43
44
|
A mapping of chat id to chat name.
|
|
44
45
|
serializer : Callable[[str], str]
|
|
45
46
|
The serializer function to escape quotes in a string.
|
|
46
|
-
string_escape : Callable[[str], str]
|
|
47
|
-
The string escape function.
|
|
48
47
|
tabs : int
|
|
49
48
|
The number of tabs to use for indentation.
|
|
50
49
|
is_async : bool
|
|
51
50
|
Whether the chat is asynchronous.
|
|
51
|
+
skip_cache : bool
|
|
52
|
+
Whether to skip the cache argument.
|
|
53
|
+
tab_leng : int, optional
|
|
54
|
+
The length of the tab string, by default 4.
|
|
52
55
|
|
|
53
56
|
Returns
|
|
54
57
|
-------
|
|
55
|
-
|
|
58
|
+
tuple[str, str]
|
|
56
59
|
The chat string and additional methods string if any
|
|
57
60
|
|
|
58
61
|
Example
|
|
@@ -91,18 +94,18 @@ def export_single_chat(
|
|
|
91
94
|
)
|
|
92
95
|
```
|
|
93
96
|
"""
|
|
94
|
-
tab = "
|
|
97
|
+
tab = " " * tab_leng * tabs if tabs > 0 else ""
|
|
95
98
|
chat_args = chat.get_chat_args(for_queue=False, sender=sender)
|
|
96
|
-
chat_args = update_summary_chat_args(chat_args,
|
|
99
|
+
# chat_args = update_summary_chat_args(chat_args, skip_summary=True)
|
|
97
100
|
if not chat_args:
|
|
98
101
|
return get_empty_simple_chat_string(
|
|
99
102
|
chat=chat,
|
|
100
103
|
sender=sender,
|
|
101
104
|
recipient=recipient,
|
|
102
105
|
agent_names=agent_names,
|
|
103
|
-
string_escape=string_escape,
|
|
104
106
|
tab=tab,
|
|
105
107
|
is_async=is_async,
|
|
108
|
+
skip_cache=skip_cache,
|
|
106
109
|
)
|
|
107
110
|
return get_simple_chat_string(
|
|
108
111
|
chat=chat,
|
|
@@ -112,9 +115,9 @@ def export_single_chat(
|
|
|
112
115
|
agent_names=agent_names,
|
|
113
116
|
chat_names=chat_names,
|
|
114
117
|
serializer=serializer,
|
|
115
|
-
string_escape=string_escape,
|
|
116
118
|
tabs=tabs,
|
|
117
119
|
is_async=is_async,
|
|
120
|
+
skip_cache=skip_cache,
|
|
118
121
|
)
|
|
119
122
|
|
|
120
123
|
|
|
@@ -123,14 +126,14 @@ def get_simple_chat_string(
|
|
|
123
126
|
chat: WaldiezChat,
|
|
124
127
|
sender: WaldiezAgent,
|
|
125
128
|
recipient: WaldiezAgent,
|
|
126
|
-
agent_names:
|
|
127
|
-
chat_names:
|
|
128
|
-
chat_args:
|
|
129
|
+
agent_names: dict[str, str],
|
|
130
|
+
chat_names: dict[str, str],
|
|
131
|
+
chat_args: dict[str, Any],
|
|
129
132
|
serializer: Callable[..., str],
|
|
130
|
-
string_escape: Callable[[str], str],
|
|
131
133
|
tabs: int,
|
|
132
134
|
is_async: bool,
|
|
133
|
-
|
|
135
|
+
skip_cache: bool,
|
|
136
|
+
) -> tuple[str, str]:
|
|
134
137
|
"""Get the chat string when there are chat arguments.
|
|
135
138
|
|
|
136
139
|
Parameters
|
|
@@ -141,24 +144,24 @@ def get_simple_chat_string(
|
|
|
141
144
|
The sender.
|
|
142
145
|
recipient : WaldiezAgent
|
|
143
146
|
The recipient.
|
|
144
|
-
agent_names :
|
|
147
|
+
agent_names : dict[str, str]
|
|
145
148
|
A mapping of agent id to agent name.
|
|
146
|
-
chat_names :
|
|
149
|
+
chat_names : dict[str, str]
|
|
147
150
|
A mapping of chat id to chat name.
|
|
148
|
-
chat_args :
|
|
151
|
+
chat_args : dict[str, Any]
|
|
149
152
|
The chat arguments.
|
|
150
153
|
serializer : Callable[[str], str]
|
|
151
154
|
The serializer function to escape quotes in a string.
|
|
152
|
-
string_escape : Callable[[str], str]
|
|
153
|
-
The string escape function.
|
|
154
155
|
tabs : int
|
|
155
156
|
The number of tabs to use for indentation.
|
|
156
157
|
is_async : bool
|
|
157
158
|
Whether the chat is asynchronous.
|
|
159
|
+
skip_cache : bool
|
|
160
|
+
Whether to skip the cache argument.
|
|
158
161
|
|
|
159
162
|
Returns
|
|
160
163
|
-------
|
|
161
|
-
|
|
164
|
+
tuple[str, str]
|
|
162
165
|
The chat string and additional methods string if any.
|
|
163
166
|
"""
|
|
164
167
|
tab = " " * tabs
|
|
@@ -170,13 +173,14 @@ def get_simple_chat_string(
|
|
|
170
173
|
recipient_name = agent_names[recipient.id]
|
|
171
174
|
chat_string = "\n" + f"{tab}results = {sender_name}.{initiate}(" + "\n"
|
|
172
175
|
chat_string += f"{tab} {recipient_name},"
|
|
173
|
-
|
|
176
|
+
if not skip_cache:
|
|
177
|
+
chat_string += "\n" + f"{tab} cache=cache,"
|
|
174
178
|
for key, value in chat_args.items():
|
|
175
179
|
if isinstance(value, str):
|
|
176
180
|
chat_string += "\n" + f'{tab} {key}="{value}",'
|
|
177
181
|
elif isinstance(value, dict):
|
|
178
182
|
chat_string += (
|
|
179
|
-
"\n" + f"{tab} {key}={serializer(value, tabs + 1)},"
|
|
183
|
+
"\n" + f"{tab} {key}={serializer(value, tabs=tabs + 1)},"
|
|
180
184
|
)
|
|
181
185
|
else:
|
|
182
186
|
chat_string += "\n" + f"{tab} {key}={value},"
|
|
@@ -186,7 +190,6 @@ def get_simple_chat_string(
|
|
|
186
190
|
chat_names=chat_names,
|
|
187
191
|
sender=sender,
|
|
188
192
|
sender_name=sender_name,
|
|
189
|
-
string_escape=string_escape,
|
|
190
193
|
)
|
|
191
194
|
chat_string += message_arg
|
|
192
195
|
chat_string += "\n" + f"{tab})" + "\n"
|
|
@@ -197,11 +200,11 @@ def get_empty_simple_chat_string(
|
|
|
197
200
|
chat: WaldiezChat,
|
|
198
201
|
sender: WaldiezAgent,
|
|
199
202
|
recipient: WaldiezAgent,
|
|
200
|
-
agent_names:
|
|
201
|
-
string_escape: Callable[[str], str],
|
|
203
|
+
agent_names: dict[str, str],
|
|
202
204
|
tab: str,
|
|
203
205
|
is_async: bool,
|
|
204
|
-
|
|
206
|
+
skip_cache: bool,
|
|
207
|
+
) -> tuple[str, str]:
|
|
205
208
|
"""Get the chat string when there are no chat arguments.
|
|
206
209
|
|
|
207
210
|
Parameters
|
|
@@ -212,18 +215,18 @@ def get_empty_simple_chat_string(
|
|
|
212
215
|
The sender.
|
|
213
216
|
recipient : WaldiezAgent
|
|
214
217
|
The recipient.
|
|
215
|
-
agent_names :
|
|
218
|
+
agent_names : dict[str, str]
|
|
216
219
|
A mapping of agent id to agent name.
|
|
217
|
-
string_escape : Callable[[str], str]
|
|
218
|
-
The string escape function.
|
|
219
220
|
tab : str
|
|
220
221
|
The tab string.
|
|
221
222
|
is_async : bool
|
|
222
223
|
Whether the chat is asynchronous.
|
|
224
|
+
skip_cache : bool
|
|
225
|
+
Whether to skip the cache argument.
|
|
223
226
|
|
|
224
227
|
Returns
|
|
225
228
|
-------
|
|
226
|
-
|
|
229
|
+
tuple[str, str]
|
|
227
230
|
The chat string and additional methods string if any
|
|
228
231
|
"""
|
|
229
232
|
sender_name = agent_names[sender.id]
|
|
@@ -233,14 +236,14 @@ def get_empty_simple_chat_string(
|
|
|
233
236
|
initiate = "a_initiate_chat" if is_async else "initiate_chat"
|
|
234
237
|
content = "\n" + f"{tab}results = {sender_name}.{initiate}(" + "\n"
|
|
235
238
|
content += f"{tab} {recipient_name}," + "\n"
|
|
236
|
-
|
|
239
|
+
if not skip_cache:
|
|
240
|
+
content += f"{tab} cache=cache," + "\n"
|
|
237
241
|
message_arg, _ = get_chat_message(
|
|
238
242
|
tab=tab,
|
|
239
243
|
chat=chat,
|
|
240
244
|
chat_names={},
|
|
241
245
|
sender=sender,
|
|
242
246
|
sender_name=sender_name,
|
|
243
|
-
string_escape=string_escape,
|
|
244
247
|
)
|
|
245
248
|
content += message_arg
|
|
246
249
|
content += f"{tab})" + "\n"
|
|
@@ -250,11 +253,10 @@ def get_empty_simple_chat_string(
|
|
|
250
253
|
def get_chat_message(
|
|
251
254
|
tab: str,
|
|
252
255
|
chat: WaldiezChat,
|
|
253
|
-
chat_names:
|
|
256
|
+
chat_names: dict[str, str],
|
|
254
257
|
sender: WaldiezAgent,
|
|
255
258
|
sender_name: str,
|
|
256
|
-
|
|
257
|
-
) -> Tuple[str, str]:
|
|
259
|
+
) -> tuple[str, str]:
|
|
258
260
|
"""Get the chat message string.
|
|
259
261
|
|
|
260
262
|
Parameters
|
|
@@ -263,25 +265,23 @@ def get_chat_message(
|
|
|
263
265
|
The tab string.
|
|
264
266
|
chat : WaldiezChat
|
|
265
267
|
The chat.
|
|
266
|
-
chat_names :
|
|
268
|
+
chat_names : dict[str, str]
|
|
267
269
|
A mapping of chat id to chat name.
|
|
268
270
|
sender : WaldiezAgent
|
|
269
271
|
The sender.
|
|
270
272
|
sender_name : str
|
|
271
273
|
The sender name.
|
|
272
|
-
string_escape : Callable[[str], str]
|
|
273
|
-
The string escape function.
|
|
274
274
|
|
|
275
275
|
Returns
|
|
276
276
|
-------
|
|
277
|
-
|
|
277
|
+
tuple[str, str]
|
|
278
278
|
The message argument and additional methods string if any.
|
|
279
279
|
"""
|
|
280
280
|
additional_methods_string = ""
|
|
281
281
|
method_content: Optional[str] = None
|
|
282
282
|
if (
|
|
283
|
-
sender.
|
|
284
|
-
and isinstance(sender,
|
|
283
|
+
sender.is_rag_user
|
|
284
|
+
and isinstance(sender, WaldiezRagUserProxy)
|
|
285
285
|
and chat.message.type == "rag_message_generator"
|
|
286
286
|
and chat.message.use_carryover is False
|
|
287
287
|
):
|
|
@@ -291,10 +291,8 @@ def get_chat_message(
|
|
|
291
291
|
sender=sender,
|
|
292
292
|
chat=chat,
|
|
293
293
|
chat_names=chat_names,
|
|
294
|
-
string_escape=string_escape,
|
|
295
294
|
)
|
|
296
295
|
if message and isinstance(chat.data.message, WaldiezChatMessage):
|
|
297
|
-
message = string_escape(message)
|
|
298
296
|
if chat.data.message.type == "method":
|
|
299
297
|
additional_methods_string += (
|
|
300
298
|
method_content if method_content else ""
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
"""Core exporting infrastructure.
|
|
5
|
+
|
|
6
|
+
This module provides base classes, types, result builders,
|
|
7
|
+
and extras for exportign flows.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Core base class
|
|
11
|
+
# Context management
|
|
12
|
+
# Constants / defaults
|
|
13
|
+
from .constants import (
|
|
14
|
+
DEFAULT_AGENT_POSITION,
|
|
15
|
+
DEFAULT_EXPORT_POSITION,
|
|
16
|
+
DEFAULT_IMPORT_POSITION,
|
|
17
|
+
FILE_HEADER,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# Content
|
|
21
|
+
from .content import ContentMetadata, PositionedContent
|
|
22
|
+
|
|
23
|
+
# Context management
|
|
24
|
+
from .context import (
|
|
25
|
+
ExporterContext,
|
|
26
|
+
create_exporter_context,
|
|
27
|
+
get_default_exporter_context,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Enums
|
|
31
|
+
from .enums import (
|
|
32
|
+
AgentPosition,
|
|
33
|
+
ContentOrder,
|
|
34
|
+
ContentType,
|
|
35
|
+
ExportPosition,
|
|
36
|
+
GroupManagerStrategy,
|
|
37
|
+
ImportPosition,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# Errors
|
|
41
|
+
from .errors import (
|
|
42
|
+
ExporterContentError,
|
|
43
|
+
ExporterError,
|
|
44
|
+
ExporterInitializationError,
|
|
45
|
+
ExporterValidationError,
|
|
46
|
+
)
|
|
47
|
+
from .exporter import (
|
|
48
|
+
Exporter,
|
|
49
|
+
)
|
|
50
|
+
from .exporters import (
|
|
51
|
+
ConfigurableExporter,
|
|
52
|
+
SimpleExporter,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Agent-specific extras
|
|
56
|
+
from .extras.agent_extras import (
|
|
57
|
+
CaptainExtras,
|
|
58
|
+
CodeExecutionConfig,
|
|
59
|
+
GroupManagerExtras,
|
|
60
|
+
RAGUserExtras,
|
|
61
|
+
ReasoningExtras,
|
|
62
|
+
StandardExtras,
|
|
63
|
+
SystemMessageConfig,
|
|
64
|
+
TerminationConfig,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Base extras system
|
|
68
|
+
from .extras.base import BaseExtras
|
|
69
|
+
|
|
70
|
+
# Chat-specific extras
|
|
71
|
+
from .extras.chat_extras import (
|
|
72
|
+
ChatExtras,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Model-specific extras
|
|
76
|
+
from .extras.model_extras import (
|
|
77
|
+
ModelExtras,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Defaults
|
|
81
|
+
from .extras.path_resolver import DefaultPathResolver
|
|
82
|
+
from .extras.serializer import DefaultSerializer
|
|
83
|
+
|
|
84
|
+
# Tool-specific extras
|
|
85
|
+
from .extras.tool_extras import (
|
|
86
|
+
ToolExtras,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# Protocols
|
|
90
|
+
from .protocols import (
|
|
91
|
+
ContentGenerator,
|
|
92
|
+
ExportContributor,
|
|
93
|
+
ExportingLogger,
|
|
94
|
+
PathResolver,
|
|
95
|
+
Serializer,
|
|
96
|
+
Validator,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Export result system
|
|
100
|
+
from .result import (
|
|
101
|
+
ExportResult,
|
|
102
|
+
ExportResultBuilder,
|
|
103
|
+
create_empty_result,
|
|
104
|
+
create_result_with_content,
|
|
105
|
+
merge_export_results,
|
|
106
|
+
)
|
|
107
|
+
from .types import (
|
|
108
|
+
EnvironmentVariable,
|
|
109
|
+
ExportConfig,
|
|
110
|
+
Extras,
|
|
111
|
+
ImportStatement,
|
|
112
|
+
InstanceArgument,
|
|
113
|
+
NoExtras,
|
|
114
|
+
)
|
|
115
|
+
from .utils import (
|
|
116
|
+
get_agent_llm_config_arg,
|
|
117
|
+
get_comment,
|
|
118
|
+
)
|
|
119
|
+
from .validation import (
|
|
120
|
+
ValidationError,
|
|
121
|
+
ValidationResult,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
__all__ = [
|
|
125
|
+
# Core base classes
|
|
126
|
+
"Exporter",
|
|
127
|
+
"SimpleExporter",
|
|
128
|
+
"ConfigurableExporter",
|
|
129
|
+
# Protocols
|
|
130
|
+
"ContentGenerator",
|
|
131
|
+
"ExportingLogger",
|
|
132
|
+
"ExportContributor",
|
|
133
|
+
"Validator",
|
|
134
|
+
"Serializer",
|
|
135
|
+
"PathResolver",
|
|
136
|
+
# Core types and enums
|
|
137
|
+
"ImportPosition",
|
|
138
|
+
"ExportPosition",
|
|
139
|
+
"AgentPosition",
|
|
140
|
+
"ContentOrder",
|
|
141
|
+
"GroupManagerStrategy",
|
|
142
|
+
"Extras",
|
|
143
|
+
"ImportStatement",
|
|
144
|
+
"PositionedContent",
|
|
145
|
+
"EnvironmentVariable",
|
|
146
|
+
"ExportConfig",
|
|
147
|
+
"ContentType",
|
|
148
|
+
"ContentMetadata",
|
|
149
|
+
"InstanceArgument",
|
|
150
|
+
"NoExtras",
|
|
151
|
+
"ValidationError",
|
|
152
|
+
"ValidationResult",
|
|
153
|
+
# Constants
|
|
154
|
+
"FILE_HEADER",
|
|
155
|
+
"DEFAULT_IMPORT_POSITION",
|
|
156
|
+
"DEFAULT_EXPORT_POSITION",
|
|
157
|
+
"DEFAULT_AGENT_POSITION",
|
|
158
|
+
# Context management
|
|
159
|
+
"ExporterContext",
|
|
160
|
+
"get_default_exporter_context",
|
|
161
|
+
"create_exporter_context",
|
|
162
|
+
"create_exporter_context",
|
|
163
|
+
# Export result system
|
|
164
|
+
"ExportResult",
|
|
165
|
+
"ExportResultBuilder",
|
|
166
|
+
"merge_export_results",
|
|
167
|
+
"create_empty_result",
|
|
168
|
+
"create_result_with_content",
|
|
169
|
+
# Base extras
|
|
170
|
+
"BaseExtras",
|
|
171
|
+
"DefaultSerializer",
|
|
172
|
+
"DefaultPathResolver",
|
|
173
|
+
# Agent extras
|
|
174
|
+
"StandardExtras",
|
|
175
|
+
"GroupManagerExtras",
|
|
176
|
+
"CaptainExtras",
|
|
177
|
+
"CodeExecutionConfig",
|
|
178
|
+
"RAGUserExtras",
|
|
179
|
+
"ReasoningExtras",
|
|
180
|
+
"SystemMessageConfig",
|
|
181
|
+
"TerminationConfig",
|
|
182
|
+
# Model extras
|
|
183
|
+
"ModelExtras",
|
|
184
|
+
# Tool extras
|
|
185
|
+
"ToolExtras",
|
|
186
|
+
# Chat extras
|
|
187
|
+
"ChatExtras",
|
|
188
|
+
# Errors
|
|
189
|
+
"ExporterError",
|
|
190
|
+
"ExporterInitializationError",
|
|
191
|
+
"ExporterValidationError",
|
|
192
|
+
"ExporterContentError",
|
|
193
|
+
# utils
|
|
194
|
+
"get_comment",
|
|
195
|
+
"get_agent_llm_config_arg",
|
|
196
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Constants for Waldiez exporting core."""
|
|
4
|
+
|
|
5
|
+
from .enums import (
|
|
6
|
+
AgentPosition,
|
|
7
|
+
ExportPosition,
|
|
8
|
+
ImportPosition,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
FILE_HEADER = (
|
|
12
|
+
"# SPDX-License-Identifier: Apache-2.0.\n"
|
|
13
|
+
"# Copyright (c) 2024 - 2025 Waldiez and contributors."
|
|
14
|
+
)
|
|
15
|
+
DEFAULT_IMPORT_POSITION = ImportPosition.THIRD_PARTY
|
|
16
|
+
DEFAULT_EXPORT_POSITION = ExportPosition.AGENTS
|
|
17
|
+
DEFAULT_AGENT_POSITION = AgentPosition.AFTER
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Content module for Waldiez exporting core."""
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import Any, Optional
|
|
7
|
+
|
|
8
|
+
from .enums import (
|
|
9
|
+
AgentPosition,
|
|
10
|
+
ContentType,
|
|
11
|
+
ExportPosition,
|
|
12
|
+
)
|
|
13
|
+
from .errors import ExporterContentError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class PositionedContent:
|
|
18
|
+
"""Content with position and ordering metadata."""
|
|
19
|
+
|
|
20
|
+
content: str
|
|
21
|
+
position: ExportPosition
|
|
22
|
+
order: int = 0
|
|
23
|
+
agent_id: Optional[str] = None
|
|
24
|
+
agent_position: Optional[AgentPosition] = None
|
|
25
|
+
metadata: dict[str, Any] = field(default_factory=dict[str, Any])
|
|
26
|
+
|
|
27
|
+
def __post_init__(self) -> None:
|
|
28
|
+
"""Validate positioned content."""
|
|
29
|
+
if not self.content.strip():
|
|
30
|
+
raise ExporterContentError("Content cannot be empty or whitespace.")
|
|
31
|
+
|
|
32
|
+
def is_agent_positioned(self) -> bool:
|
|
33
|
+
"""Check if this content is positioned relative to an agent.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
bool
|
|
38
|
+
True if this content has an agent ID and position, otherwise False.
|
|
39
|
+
"""
|
|
40
|
+
return self.agent_position is not None and self.agent_id is not None
|
|
41
|
+
|
|
42
|
+
def __lt__(self, other: "PositionedContent") -> bool:
|
|
43
|
+
"""Enable sorting by position, then order, then content.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
other : PositionedContent
|
|
48
|
+
The other positioned content to compare against.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
bool
|
|
53
|
+
True if this positioned content should come before the other.
|
|
54
|
+
"""
|
|
55
|
+
if self.position != other.position:
|
|
56
|
+
return self.position.value < other.position.value
|
|
57
|
+
if self.order != other.order:
|
|
58
|
+
return self.order < other.order
|
|
59
|
+
return self.content < other.content
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class ContentMetadata:
|
|
64
|
+
"""Metadata about exported content."""
|
|
65
|
+
|
|
66
|
+
content_type: ContentType
|
|
67
|
+
source_id: Optional[str] = None
|
|
68
|
+
dependencies: list[str] = field(default_factory=list[str])
|
|
69
|
+
tags: set[str] = field(default_factory=set[str])
|