waldiez 0.5.6__py3-none-any.whl → 0.5.7__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/_version.py +1 -1
- waldiez/cli.py +1 -1
- waldiez/exporter.py +1 -1
- waldiez/exporting/agent/code_execution.py +8 -1
- waldiez/exporting/agent/exporter.py +2 -1
- waldiez/exporting/agent/extras/captain_agent_extras.py +1 -0
- waldiez/exporting/agent/extras/doc_agent_extras.py +2 -3
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +1 -0
- waldiez/exporting/agent/extras/handoffs/after_work.py +4 -4
- waldiez/exporting/agent/extras/handoffs/target.py +3 -0
- waldiez/exporting/agent/extras/rag/chroma_extras.py +0 -4
- waldiez/exporting/agent/extras/rag/mongo_extras.py +0 -1
- waldiez/exporting/agent/extras/rag/pgvector_extras.py +0 -2
- waldiez/exporting/agent/extras/rag/qdrant_extras.py +0 -3
- waldiez/exporting/agent/extras/rag/vector_db_extras.py +3 -2
- waldiez/exporting/agent/factory.py +11 -11
- waldiez/exporting/agent/processor.py +3 -2
- waldiez/exporting/chats/exporter.py +2 -2
- waldiez/exporting/chats/factory.py +5 -5
- waldiez/exporting/chats/processor.py +22 -1
- waldiez/exporting/chats/utils/sequential.py +3 -68
- waldiez/exporting/chats/utils/single.py +1 -38
- waldiez/exporting/core/context.py +39 -38
- waldiez/exporting/core/exporter.py +10 -10
- waldiez/exporting/core/exporters.py +36 -0
- waldiez/exporting/core/extras/base.py +2 -2
- waldiez/exporting/core/extras/chat_extras.py +4 -2
- waldiez/exporting/core/extras/path_resolver.py +6 -4
- waldiez/exporting/core/extras/serializer.py +1 -0
- waldiez/exporting/core/protocols.py +6 -0
- waldiez/exporting/core/result.py +8 -7
- waldiez/exporting/core/types.py +2 -2
- waldiez/exporting/core/utils/llm_config.py +2 -0
- waldiez/exporting/flow/factory.py +2 -2
- waldiez/exporting/flow/file_generator.py +8 -7
- waldiez/exporting/flow/merger.py +8 -7
- waldiez/exporting/flow/orchestrator.py +22 -8
- waldiez/exporting/flow/utils/__init__.py +2 -0
- waldiez/exporting/flow/utils/common.py +16 -0
- waldiez/exporting/flow/utils/logging.py +5 -2
- waldiez/exporting/models/factory.py +6 -7
- waldiez/exporting/tools/exporter.py +5 -5
- waldiez/exporting/tools/factory.py +4 -5
- waldiez/exporting/tools/processor.py +3 -3
- waldiez/exporting/tools/registration.py +1 -0
- waldiez/io/_ws.py +2 -0
- waldiez/io/models/content/audio.py +1 -0
- waldiez/io/models/content/file.py +1 -0
- waldiez/io/models/content/image.py +1 -0
- waldiez/io/models/content/text.py +1 -0
- waldiez/io/models/content/video.py +1 -0
- waldiez/io/models/user_input.py +1 -0
- waldiez/io/models/user_response.py +1 -0
- waldiez/io/mqtt.py +6 -3
- waldiez/io/redis.py +7 -9
- waldiez/io/structured.py +8 -6
- waldiez/io/utils.py +11 -4
- waldiez/io/ws.py +4 -3
- waldiez/logger.py +11 -1
- waldiez/models/agents/agent/agent.py +1 -0
- waldiez/models/agents/agent/agent_data.py +2 -2
- waldiez/models/agents/agent/nested_chat.py +1 -4
- waldiez/models/agents/agent/termination_message.py +0 -7
- waldiez/models/agents/agent/update_system_message.py +2 -2
- waldiez/models/agents/doc_agent/doc_agent_data.py +33 -26
- waldiez/models/agents/doc_agent/rag_query_engine.py +1 -1
- waldiez/models/agents/extra_requirements.py +5 -5
- waldiez/models/agents/group_manager/group_manager.py +3 -7
- waldiez/models/agents/group_manager/speakers.py +0 -7
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +0 -2
- waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +0 -2
- waldiez/models/agents/rag_user_proxy/retrieve_config.py +1 -17
- waldiez/models/agents/rag_user_proxy/vector_db_config.py +0 -5
- waldiez/models/chat/chat_data.py +0 -2
- waldiez/models/chat/chat_summary.py +5 -3
- waldiez/models/common/handoff.py +26 -18
- waldiez/models/common/naming.py +1 -0
- waldiez/models/flow/flow.py +9 -7
- waldiez/models/model/_llm.py +4 -2
- waldiez/models/model/extra_requirements.py +3 -3
- waldiez/models/model/model.py +3 -2
- waldiez/models/tool/extra_requirements.py +2 -2
- waldiez/models/tool/predefined/_google.py +3 -1
- waldiez/models/tool/predefined/_perplexity.py +4 -1
- waldiez/models/tool/predefined/_searxng.py +4 -1
- waldiez/models/tool/predefined/_wikipedia.py +5 -1
- waldiez/models/tool/tool.py +7 -7
- waldiez/models/tool/tool_data.py +39 -2
- waldiez/models/waldiez.py +29 -29
- waldiez/runner.py +1 -0
- waldiez/running/base_runner.py +9 -4
- waldiez/running/environment.py +2 -0
- waldiez/running/patch_io_stream.py +2 -0
- waldiez/running/post_run.py +3 -0
- waldiez/running/pre_run.py +1 -0
- waldiez/running/standard_runner.py +28 -4
- waldiez/running/timeline_processor.py +12 -1
- waldiez/running/utils.py +2 -0
- waldiez/utils/conflict_checker.py +1 -1
- waldiez/utils/version.py +1 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/METADATA +59 -57
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/RECORD +106 -107
- waldiez/exporting/agent/extras/group/target.py +0 -178
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/WHEEL +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.7.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -18,11 +18,11 @@ from .types import ExportConfig
|
|
|
18
18
|
class ExporterContext:
|
|
19
19
|
"""Context object containing common exporter dependencies."""
|
|
20
20
|
|
|
21
|
-
serializer:
|
|
22
|
-
path_resolver:
|
|
23
|
-
validator:
|
|
24
|
-
config:
|
|
25
|
-
logger:
|
|
21
|
+
serializer: Serializer | None = None
|
|
22
|
+
path_resolver: PathResolver | None = None
|
|
23
|
+
validator: Validator | None = None
|
|
24
|
+
config: ExportConfig | None = None
|
|
25
|
+
logger: ExportingLogger | None = None
|
|
26
26
|
|
|
27
27
|
def get_serializer(self) -> Serializer:
|
|
28
28
|
"""Get serializer or raise if not set.
|
|
@@ -46,34 +46,34 @@ class ExporterContext:
|
|
|
46
46
|
|
|
47
47
|
def get_config(
|
|
48
48
|
self,
|
|
49
|
-
name:
|
|
50
|
-
description:
|
|
51
|
-
requirements:
|
|
52
|
-
tags:
|
|
53
|
-
output_extension:
|
|
49
|
+
name: str | None = None,
|
|
50
|
+
description: str | None = None,
|
|
51
|
+
requirements: list[str] | None = None,
|
|
52
|
+
tags: list[str] | None = None,
|
|
53
|
+
output_extension: str | None = None,
|
|
54
54
|
is_async: bool = False,
|
|
55
|
-
output_directory:
|
|
56
|
-
cache_seed:
|
|
55
|
+
output_directory: str | None = None,
|
|
56
|
+
cache_seed: int | None = None,
|
|
57
57
|
) -> ExportConfig:
|
|
58
58
|
"""Get export config or return default.
|
|
59
59
|
|
|
60
60
|
Parameters
|
|
61
61
|
----------
|
|
62
|
-
name :
|
|
62
|
+
name : str], optional
|
|
63
63
|
The name of the export, by default None
|
|
64
|
-
description :
|
|
64
|
+
description : str], optional
|
|
65
65
|
A brief description of the export, by default None
|
|
66
|
-
requirements :
|
|
66
|
+
requirements : list[str]], optional
|
|
67
67
|
A list of requirements for the export, by default None
|
|
68
|
-
tags :
|
|
68
|
+
tags : list[str]], optional
|
|
69
69
|
A list of tags associated with the export, by default None
|
|
70
|
-
output_extension :
|
|
70
|
+
output_extension : str], optional
|
|
71
71
|
The file extension for the output, by default None
|
|
72
72
|
is_async : bool, optional
|
|
73
73
|
Whether the export is asynchronous, by default False
|
|
74
|
-
output_directory :
|
|
74
|
+
output_directory : str], optional
|
|
75
75
|
The directory where the output will be saved, by default None
|
|
76
|
-
cache_seed :
|
|
76
|
+
cache_seed : int], optional
|
|
77
77
|
The seed for caching, by default None
|
|
78
78
|
|
|
79
79
|
Returns
|
|
@@ -124,6 +124,7 @@ class ExporterContext:
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
# pylint: disable=too-few-public-methods
|
|
127
|
+
# noinspection PyUnresolvedReferences,PyTypeChecker
|
|
127
128
|
class DefaultExporterContext(ExporterContext):
|
|
128
129
|
"""Singleton context for exporters.
|
|
129
130
|
|
|
@@ -164,11 +165,11 @@ class DefaultExporterContext(ExporterContext):
|
|
|
164
165
|
|
|
165
166
|
def __init__(
|
|
166
167
|
self,
|
|
167
|
-
serializer:
|
|
168
|
-
validator:
|
|
169
|
-
path_resolver:
|
|
170
|
-
logger:
|
|
171
|
-
config:
|
|
168
|
+
serializer: Serializer | None = None,
|
|
169
|
+
validator: Validator | None = None,
|
|
170
|
+
path_resolver: PathResolver | None = None,
|
|
171
|
+
logger: ExportingLogger | None = None,
|
|
172
|
+
config: ExportConfig | None = None,
|
|
172
173
|
) -> None:
|
|
173
174
|
if hasattr(self, "_initialized"):
|
|
174
175
|
return
|
|
@@ -183,16 +184,16 @@ class DefaultExporterContext(ExporterContext):
|
|
|
183
184
|
|
|
184
185
|
|
|
185
186
|
def get_default_exporter_context(
|
|
186
|
-
config:
|
|
187
|
-
logger:
|
|
187
|
+
config: ExportConfig | None = None,
|
|
188
|
+
logger: ExportingLogger | None = None,
|
|
188
189
|
) -> ExporterContext:
|
|
189
190
|
"""Get the default exporter context.
|
|
190
191
|
|
|
191
192
|
Parameters
|
|
192
193
|
----------
|
|
193
|
-
config :
|
|
194
|
+
config : ExportConfig | None, optional
|
|
194
195
|
The export configuration, by default None
|
|
195
|
-
logger :
|
|
196
|
+
logger : ExportingLogger | None, optional
|
|
196
197
|
The logger instance, by default None
|
|
197
198
|
|
|
198
199
|
Returns
|
|
@@ -209,25 +210,25 @@ def get_default_exporter_context(
|
|
|
209
210
|
|
|
210
211
|
|
|
211
212
|
def create_exporter_context(
|
|
212
|
-
serializer:
|
|
213
|
-
validator:
|
|
214
|
-
path_resolver:
|
|
215
|
-
config:
|
|
216
|
-
logger:
|
|
213
|
+
serializer: Serializer | None = None,
|
|
214
|
+
validator: Validator | None = None,
|
|
215
|
+
path_resolver: PathResolver | None = None,
|
|
216
|
+
config: ExportConfig | None = None,
|
|
217
|
+
logger: ExportingLogger | None = None,
|
|
217
218
|
) -> ExporterContext:
|
|
218
219
|
"""Create an exporter context with the given components.
|
|
219
220
|
|
|
220
221
|
Parameters
|
|
221
222
|
----------
|
|
222
|
-
serializer :
|
|
223
|
+
serializer : Serializer | None, optional
|
|
223
224
|
The serializer component, by default None
|
|
224
|
-
path_resolver :
|
|
225
|
+
path_resolver : PathResolver | None, optional
|
|
225
226
|
The path resolver component, by default None
|
|
226
|
-
validator :
|
|
227
|
+
validator : Validator | None, optional
|
|
227
228
|
The validator component, by default None
|
|
228
|
-
config :
|
|
229
|
+
config : ExportConfig | None, optional
|
|
229
230
|
The export configuration, by default None
|
|
230
|
-
logger :
|
|
231
|
+
logger : ExportingLogger | None, optional
|
|
231
232
|
The logger instance, by default None
|
|
232
233
|
|
|
233
234
|
Returns
|
|
@@ -90,12 +90,12 @@ class Exporter(abc.ABC, Generic[Extras]):
|
|
|
90
90
|
"""
|
|
91
91
|
|
|
92
92
|
@abc.abstractmethod
|
|
93
|
-
def generate_main_content(self) ->
|
|
93
|
+
def generate_main_content(self) -> str | None:
|
|
94
94
|
"""Generate the main export content.
|
|
95
95
|
|
|
96
96
|
Returns
|
|
97
97
|
-------
|
|
98
|
-
|
|
98
|
+
str | None
|
|
99
99
|
The main content, or None if no content should be generated.
|
|
100
100
|
"""
|
|
101
101
|
|
|
@@ -182,8 +182,8 @@ class Exporter(abc.ABC, Generic[Extras]):
|
|
|
182
182
|
content: str,
|
|
183
183
|
position: ExportPosition,
|
|
184
184
|
order: ContentOrder = ContentOrder.MAIN_CONTENT,
|
|
185
|
-
agent_id:
|
|
186
|
-
agent_position:
|
|
185
|
+
agent_id: str | None = None,
|
|
186
|
+
agent_position: AgentPosition | None = None,
|
|
187
187
|
skip_strip: bool | None = None,
|
|
188
188
|
**metadata: Any,
|
|
189
189
|
) -> None:
|
|
@@ -195,11 +195,11 @@ class Exporter(abc.ABC, Generic[Extras]):
|
|
|
195
195
|
The content to add.
|
|
196
196
|
position : ExportPosition
|
|
197
197
|
The position of the content.
|
|
198
|
-
order :
|
|
199
|
-
The order within the position, by default
|
|
200
|
-
agent_id :
|
|
198
|
+
order : ContentOrder, optional
|
|
199
|
+
The order within the position, by default ContentOrder.MAIN_CONTENT
|
|
200
|
+
agent_id : str | None, optional
|
|
201
201
|
Agent ID for agent-relative positioning, by default None
|
|
202
|
-
agent_position :
|
|
202
|
+
agent_position : AgentPosition | None, optional
|
|
203
203
|
Position relative to agent, by default None
|
|
204
204
|
skip_strip : bool | None, optional
|
|
205
205
|
Whether to skip stripping whitespace, by default None
|
|
@@ -223,7 +223,7 @@ class Exporter(abc.ABC, Generic[Extras]):
|
|
|
223
223
|
self,
|
|
224
224
|
name: str,
|
|
225
225
|
value: str,
|
|
226
|
-
description:
|
|
226
|
+
description: str | None = None,
|
|
227
227
|
required: bool = True,
|
|
228
228
|
) -> None:
|
|
229
229
|
"""Add environment variable.
|
|
@@ -234,7 +234,7 @@ class Exporter(abc.ABC, Generic[Extras]):
|
|
|
234
234
|
The name of the environment variable.
|
|
235
235
|
value : str
|
|
236
236
|
The value of the environment variable.
|
|
237
|
-
description :
|
|
237
|
+
description : str | None, optional
|
|
238
238
|
Description of the variable, by default None
|
|
239
239
|
required : bool, optional
|
|
240
240
|
Whether the variable is required, by default True
|
|
@@ -12,6 +12,16 @@ from .types import Extras
|
|
|
12
12
|
class SimpleExporter(Exporter[None]):
|
|
13
13
|
"""Simple exporter that doesn't use extras system."""
|
|
14
14
|
|
|
15
|
+
def generate_main_content(self) -> str | None:
|
|
16
|
+
"""Generate main content for the exporter.
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
str | None
|
|
21
|
+
The main content as a string or None if not applicable.
|
|
22
|
+
"""
|
|
23
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
24
|
+
|
|
15
25
|
@property
|
|
16
26
|
def extras(self) -> None:
|
|
17
27
|
"""Simple exporters don't have extras."""
|
|
@@ -24,6 +34,22 @@ class SimpleExporter(Exporter[None]):
|
|
|
24
34
|
class ConfigurableExporter(Exporter[Extras]):
|
|
25
35
|
"""Exporter with configuration support."""
|
|
26
36
|
|
|
37
|
+
@property
|
|
38
|
+
def extras(self) -> Extras:
|
|
39
|
+
"""Get the extras for this exporter.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
Extras
|
|
44
|
+
The extras associated with this exporter.
|
|
45
|
+
|
|
46
|
+
Raises
|
|
47
|
+
------
|
|
48
|
+
NotImplementedError
|
|
49
|
+
If the method is not implemented in a subclass.
|
|
50
|
+
"""
|
|
51
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
52
|
+
|
|
27
53
|
def __init__(self, config: Optional[dict[str, Any]] = None, **kwargs: Any):
|
|
28
54
|
"""Initialize with configuration.
|
|
29
55
|
|
|
@@ -37,6 +63,16 @@ class ConfigurableExporter(Exporter[Extras]):
|
|
|
37
63
|
super().__init__(**kwargs)
|
|
38
64
|
self._config = config or {}
|
|
39
65
|
|
|
66
|
+
def generate_main_content(self) -> str | None:
|
|
67
|
+
"""Generate main content for the exporter.
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
str | None
|
|
72
|
+
The main content as a string or None if not applicable.
|
|
73
|
+
"""
|
|
74
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
75
|
+
|
|
40
76
|
def get_config_value(self, key: str, default: Any = None) -> Any:
|
|
41
77
|
"""Get a configuration value.
|
|
42
78
|
|
|
@@ -43,7 +43,7 @@ class BaseExtras(ExportContributor):
|
|
|
43
43
|
|
|
44
44
|
Parameters
|
|
45
45
|
----------
|
|
46
|
-
arg : InstanceArgument
|
|
46
|
+
arg : InstanceArgument | str
|
|
47
47
|
The argument to add.
|
|
48
48
|
tabs : int, optional
|
|
49
49
|
The number of tabs to indent the argument, by default 0.
|
|
@@ -76,7 +76,7 @@ class BaseExtras(ExportContributor):
|
|
|
76
76
|
|
|
77
77
|
Parameters
|
|
78
78
|
----------
|
|
79
|
-
import_statement :
|
|
79
|
+
import_statement : ImportStatement
|
|
80
80
|
The import statement to add.
|
|
81
81
|
"""
|
|
82
82
|
if import_statement and import_statement.statement.strip():
|
|
@@ -16,10 +16,12 @@ class ChatExtras(BaseExtras):
|
|
|
16
16
|
|
|
17
17
|
Attributes
|
|
18
18
|
----------
|
|
19
|
-
|
|
20
|
-
The chat
|
|
19
|
+
chat_prerequisites : str
|
|
20
|
+
The chat prerequisites content.
|
|
21
21
|
chat_initiation : str
|
|
22
22
|
The chat initiation content.
|
|
23
|
+
chat_registration : str
|
|
24
|
+
The chat registration content.
|
|
23
25
|
"""
|
|
24
26
|
|
|
25
27
|
chat_prerequisites: str = ""
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"""Default path resolver for Waldiez items."""
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import Union
|
|
7
7
|
|
|
8
8
|
from ..protocols import PathResolver
|
|
9
9
|
|
|
@@ -45,7 +45,7 @@ class DefaultPathResolver(PathResolver):
|
|
|
45
45
|
return DefaultPathResolver._check_local_path(path) is not None
|
|
46
46
|
|
|
47
47
|
@staticmethod
|
|
48
|
-
def _check_local_path(string: str) ->
|
|
48
|
+
def _check_local_path(string: str) -> Path | None:
|
|
49
49
|
"""Check if a string is a local path.
|
|
50
50
|
|
|
51
51
|
Parameters
|
|
@@ -55,10 +55,12 @@ class DefaultPathResolver(PathResolver):
|
|
|
55
55
|
|
|
56
56
|
Returns
|
|
57
57
|
-------
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
Path | None
|
|
59
|
+
The resolved local path string (raw path format) or
|
|
60
|
+
None if it does not exist.
|
|
60
61
|
"""
|
|
61
62
|
# pylint: disable=broad-exception-caught
|
|
63
|
+
# noinspection PyBroadException
|
|
62
64
|
try:
|
|
63
65
|
path = Path(string).resolve()
|
|
64
66
|
except BaseException: # pragma: no cover
|
waldiez/exporting/core/result.py
CHANGED
|
@@ -215,7 +215,7 @@ class ExportResult:
|
|
|
215
215
|
self,
|
|
216
216
|
content: str,
|
|
217
217
|
position: ExportPosition = DEFAULT_EXPORT_POSITION,
|
|
218
|
-
order:
|
|
218
|
+
order: ContentOrder | int = ContentOrder.MAIN_CONTENT,
|
|
219
219
|
skip_strip: bool = False,
|
|
220
220
|
agent_id: Optional[str] = None,
|
|
221
221
|
agent_position: Optional[AgentPosition] = None,
|
|
@@ -229,15 +229,15 @@ class ExportResult:
|
|
|
229
229
|
The content to add.
|
|
230
230
|
position : ExportPosition, optional
|
|
231
231
|
The position of the content, by default AGENTS
|
|
232
|
-
order : int, optional
|
|
232
|
+
order : ContentOrder | int, optional
|
|
233
233
|
The order within the position, by default 0
|
|
234
234
|
skip_strip : bool, optional
|
|
235
235
|
Whether to skip stripping whitespace from content, by default False
|
|
236
|
-
agent_id :
|
|
236
|
+
agent_id : str | None, optional
|
|
237
237
|
The agent ID if positioned relative to an agent, by default None
|
|
238
|
-
agent_position :
|
|
238
|
+
agent_position : AgentPosition | None, optional
|
|
239
239
|
The position relative to the agent, by default None
|
|
240
|
-
metadata :
|
|
240
|
+
metadata : dict[str, Any] | None, optional
|
|
241
241
|
Additional metadata for the content, by default None
|
|
242
242
|
"""
|
|
243
243
|
order_value = order.value if isinstance(order, ContentOrder) else order
|
|
@@ -662,6 +662,7 @@ def merge_export_results(*results: ExportResult) -> ExportResult:
|
|
|
662
662
|
return ExportResult()
|
|
663
663
|
|
|
664
664
|
merged = ExportResult()
|
|
665
|
+
# noinspection PyTypeChecker
|
|
665
666
|
for result in results:
|
|
666
667
|
merged.merge_with(result)
|
|
667
668
|
|
|
@@ -681,7 +682,7 @@ def create_empty_result() -> ExportResult:
|
|
|
681
682
|
|
|
682
683
|
def create_result_with_content(
|
|
683
684
|
main_content: str,
|
|
684
|
-
imports:
|
|
685
|
+
imports: list[str] | None = None,
|
|
685
686
|
) -> ExportResult:
|
|
686
687
|
"""Create an ExportResult with basic content.
|
|
687
688
|
|
|
@@ -689,7 +690,7 @@ def create_result_with_content(
|
|
|
689
690
|
----------
|
|
690
691
|
main_content : str
|
|
691
692
|
The main content.
|
|
692
|
-
imports :
|
|
693
|
+
imports : list[str], optional
|
|
693
694
|
list of import statements, by default None
|
|
694
695
|
|
|
695
696
|
Returns
|
waldiez/exporting/core/types.py
CHANGED
|
@@ -133,7 +133,7 @@ class EnvironmentVariable:
|
|
|
133
133
|
tuple[str, str]
|
|
134
134
|
The environment variable as a tuple.
|
|
135
135
|
"""
|
|
136
|
-
return
|
|
136
|
+
return self.name, self.value
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
# Instance Argument
|
|
@@ -311,7 +311,7 @@ class ExportConfig:
|
|
|
311
311
|
valid_fields = {f.name for f in fields(cls)}
|
|
312
312
|
output_extension = kwargs.pop("output_extension", "py")
|
|
313
313
|
for_notebook = kwargs.pop("for_notebook", output_extension == "ipynb")
|
|
314
|
-
if for_notebook
|
|
314
|
+
if for_notebook:
|
|
315
315
|
output_extension = "ipynb"
|
|
316
316
|
cache_seed = kwargs.pop("cache_seed", None)
|
|
317
317
|
if cache_seed is not None and not isinstance(cache_seed, int):
|
|
@@ -52,6 +52,7 @@ def get_agent_llm_config_arg(
|
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
# noinspection DuplicatedCode
|
|
55
56
|
def _get_agent_llm_config_arg_as_arg(
|
|
56
57
|
agent: WaldiezAgent,
|
|
57
58
|
all_models: list[WaldiezModel],
|
|
@@ -85,6 +86,7 @@ def _get_agent_llm_config_arg_as_arg(
|
|
|
85
86
|
return content
|
|
86
87
|
|
|
87
88
|
|
|
89
|
+
# noinspection DuplicatedCode
|
|
88
90
|
def _get_agent_llm_config_arg_as_dict(
|
|
89
91
|
agent: WaldiezAgent,
|
|
90
92
|
all_models: list[WaldiezModel],
|
|
@@ -31,9 +31,9 @@ def create_flow_exporter(
|
|
|
31
31
|
----------
|
|
32
32
|
waldiez : Waldiez
|
|
33
33
|
The Waldiez instance containing the flow data.
|
|
34
|
-
output_dir : Path
|
|
34
|
+
output_dir : Path | None
|
|
35
35
|
The directory where the exported flow will be saved.
|
|
36
|
-
uploads_root : Path
|
|
36
|
+
uploads_root : Path | None
|
|
37
37
|
The root directory for uploads, if applicable.
|
|
38
38
|
for_notebook : bool
|
|
39
39
|
Whether the export is intended for a notebook environment.
|
|
@@ -17,6 +17,7 @@ from .execution_generator import ExecutionGenerator
|
|
|
17
17
|
from .utils.common import generate_header
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
# noinspection PyProtocol
|
|
20
21
|
class FileGenerator(ContentGenerator):
|
|
21
22
|
"""Generate the complete flow notebook content."""
|
|
22
23
|
|
|
@@ -34,7 +35,7 @@ class FileGenerator(ContentGenerator):
|
|
|
34
35
|
self.context = context
|
|
35
36
|
self.config = context.get_config()
|
|
36
37
|
|
|
37
|
-
# pylint: disable=too-many-locals
|
|
38
|
+
# pylint: disable=too-many-locals,unused-argument
|
|
38
39
|
def generate(
|
|
39
40
|
self,
|
|
40
41
|
merged_result: ExportResult,
|
|
@@ -42,26 +43,26 @@ class FileGenerator(ContentGenerator):
|
|
|
42
43
|
after_run: str,
|
|
43
44
|
skip_logging: bool,
|
|
44
45
|
**kwargs: Any,
|
|
45
|
-
) -> str:
|
|
46
|
-
"""Generate
|
|
46
|
+
) -> str: # pyright: ignore
|
|
47
|
+
"""Generate content based on provided parameters.
|
|
47
48
|
|
|
48
49
|
Parameters
|
|
49
50
|
----------
|
|
50
51
|
merged_result : ExportResult
|
|
51
52
|
The merged export result containing all content.
|
|
52
53
|
is_async : bool
|
|
53
|
-
Whether to generate async
|
|
54
|
+
Whether to generate async content.
|
|
54
55
|
after_run : str
|
|
55
56
|
Additional content to add after the main flow execution.
|
|
56
57
|
skip_logging : bool
|
|
57
58
|
Whether to skip logging setup.
|
|
58
59
|
**kwargs : Any
|
|
59
|
-
|
|
60
|
+
Parameters to influence content generation.
|
|
60
61
|
|
|
61
62
|
Returns
|
|
62
63
|
-------
|
|
63
64
|
str
|
|
64
|
-
The
|
|
65
|
+
The generated content.
|
|
65
66
|
|
|
66
67
|
Raises
|
|
67
68
|
------
|
|
@@ -214,7 +215,7 @@ class FileGenerator(ContentGenerator):
|
|
|
214
215
|
tags=self.config.tags,
|
|
215
216
|
for_notebook=self.config.for_notebook,
|
|
216
217
|
)
|
|
217
|
-
header_string = "\n".join(
|
|
218
|
+
header_string = "\n".join(item.content for item in from_result)
|
|
218
219
|
while not header_string.endswith("\n\n"):
|
|
219
220
|
header_string += "\n"
|
|
220
221
|
return header_string
|
waldiez/exporting/flow/merger.py
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
"""Content merger for combining multiple export results."""
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
|
-
from typing import Optional, Union
|
|
8
7
|
|
|
9
8
|
from ..core import (
|
|
10
9
|
ContentOrder,
|
|
@@ -34,12 +33,12 @@ class MergeStatistics:
|
|
|
34
33
|
class ContentMerger:
|
|
35
34
|
"""Intelligently merges multiple ExportResult objects."""
|
|
36
35
|
|
|
37
|
-
def __init__(self, context:
|
|
36
|
+
def __init__(self, context: ExporterContext | None = None):
|
|
38
37
|
"""Initialize the content merger.
|
|
39
38
|
|
|
40
39
|
Parameters
|
|
41
40
|
----------
|
|
42
|
-
context :
|
|
41
|
+
context : ExporterContext | None, optional
|
|
43
42
|
The exporter context, by default None
|
|
44
43
|
"""
|
|
45
44
|
self.context = context or ExporterContext()
|
|
@@ -245,12 +244,13 @@ class ContentMerger:
|
|
|
245
244
|
)
|
|
246
245
|
|
|
247
246
|
# pylint: disable=no-self-use
|
|
248
|
-
|
|
247
|
+
# noinspection PyMethodMayBeStatic
|
|
248
|
+
def _get_order_value(self, order: int | ContentOrder) -> int:
|
|
249
249
|
"""Get numeric value from order for sorting.
|
|
250
250
|
|
|
251
251
|
Parameters
|
|
252
252
|
----------
|
|
253
|
-
order :
|
|
253
|
+
order : int | ContentOrder
|
|
254
254
|
The order value
|
|
255
255
|
|
|
256
256
|
Returns
|
|
@@ -352,7 +352,8 @@ class ContentMerger:
|
|
|
352
352
|
warnings=all_warnings,
|
|
353
353
|
)
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
# noinspection PyMethodMayBeStatic
|
|
356
|
+
def _merge_main_content(self, results: list[ExportResult]) -> str | None:
|
|
356
357
|
"""Merge main content from results.
|
|
357
358
|
|
|
358
359
|
For flow exports, main content is typically empty since all content
|
|
@@ -365,7 +366,7 @@ class ContentMerger:
|
|
|
365
366
|
|
|
366
367
|
Returns
|
|
367
368
|
-------
|
|
368
|
-
|
|
369
|
+
str | None
|
|
369
370
|
The merged main content, or None
|
|
370
371
|
"""
|
|
371
372
|
main_contents: list[str] = []
|
|
@@ -22,6 +22,7 @@ from .merger import ContentMerger
|
|
|
22
22
|
from .utils import (
|
|
23
23
|
generate_header,
|
|
24
24
|
get_after_run_content,
|
|
25
|
+
get_common_env_var_setup,
|
|
25
26
|
get_np_no_nep50_handle,
|
|
26
27
|
get_sqlite_out,
|
|
27
28
|
get_start_logging,
|
|
@@ -31,6 +32,7 @@ from .utils import (
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
# pylint: disable=no-self-use,too-many-instance-attributes
|
|
35
|
+
# noinspection PyMethodMayBeStatic
|
|
34
36
|
class ExportOrchestrator:
|
|
35
37
|
"""Coordinates the export process."""
|
|
36
38
|
|
|
@@ -168,10 +170,15 @@ class ExportOrchestrator:
|
|
|
168
170
|
position=ExportPosition.TOP, # befoe everything
|
|
169
171
|
order=ContentOrder.EARLY_SETUP,
|
|
170
172
|
)
|
|
173
|
+
merged_result.add_content(
|
|
174
|
+
get_common_env_var_setup(),
|
|
175
|
+
position=ExportPosition.IMPORTS, # after imports (need os)
|
|
176
|
+
order=ContentOrder.CLEANUP,
|
|
177
|
+
)
|
|
171
178
|
merged_result.add_content(
|
|
172
179
|
get_np_no_nep50_handle(),
|
|
173
180
|
position=ExportPosition.IMPORTS, # after imports (need np)
|
|
174
|
-
order=ContentOrder.CLEANUP,
|
|
181
|
+
order=ContentOrder.CLEANUP.value + 1,
|
|
175
182
|
)
|
|
176
183
|
if not self.should_skip_logging():
|
|
177
184
|
merged_result.add_content(
|
|
@@ -180,7 +187,7 @@ class ExportOrchestrator:
|
|
|
180
187
|
for_notebook=self.config.for_notebook,
|
|
181
188
|
),
|
|
182
189
|
position=ExportPosition.IMPORTS, # after imports, before models
|
|
183
|
-
order=ContentOrder.CLEANUP.value +
|
|
190
|
+
order=ContentOrder.CLEANUP.value + 2, # after imports and np
|
|
184
191
|
skip_strip=True, # keep newlines
|
|
185
192
|
)
|
|
186
193
|
# merged_result.add_content
|
|
@@ -266,6 +273,7 @@ class ExportOrchestrator:
|
|
|
266
273
|
def _get_chats_exporter(self) -> ChatsExporter:
|
|
267
274
|
"""Get or create chats exporter."""
|
|
268
275
|
if self._chats_exporter is None:
|
|
276
|
+
# noinspection PyTypeChecker
|
|
269
277
|
self._chats_exporter = create_chats_exporter(
|
|
270
278
|
waldiez=self.waldiez,
|
|
271
279
|
all_agents=self.agents,
|
|
@@ -325,6 +333,7 @@ class ExportOrchestrator:
|
|
|
325
333
|
agent_arguments: dict[str, list[str]],
|
|
326
334
|
) -> AgentExporter:
|
|
327
335
|
"""Create an exporter for a specific agent."""
|
|
336
|
+
# noinspection PyTypeChecker
|
|
328
337
|
return create_agent_exporter(
|
|
329
338
|
agent=agent,
|
|
330
339
|
agent_names=self.agent_names,
|
|
@@ -343,6 +352,7 @@ class ExportOrchestrator:
|
|
|
343
352
|
),
|
|
344
353
|
)
|
|
345
354
|
|
|
355
|
+
# noinspection PyMethodMayBeStatic
|
|
346
356
|
def _extract_agent_arguments_from_result(
|
|
347
357
|
self, result: ExportResult
|
|
348
358
|
) -> dict[str, list[str]]:
|
|
@@ -416,14 +426,18 @@ class ExportOrchestrator:
|
|
|
416
426
|
def should_skip_logging(self) -> bool:
|
|
417
427
|
"""Determine if logging should be skipped.
|
|
418
428
|
|
|
429
|
+
In case there is any compatibility issue with logging
|
|
430
|
+
we can skip logging entirely (until handled/fixed).
|
|
431
|
+
|
|
432
|
+
e.g:
|
|
433
|
+
return self.waldiez.has_doc_agents
|
|
434
|
+
or:
|
|
435
|
+
if self.waldiez.flow.is_group_chat:
|
|
436
|
+
return any(tool.is_predefined for tool in self.waldiez.tools)
|
|
437
|
+
|
|
419
438
|
Returns
|
|
420
439
|
-------
|
|
421
440
|
bool
|
|
422
441
|
True if logging should be skipped, False otherwise.
|
|
423
442
|
"""
|
|
424
|
-
return
|
|
425
|
-
# if not self.waldiez.tools:
|
|
426
|
-
# return False
|
|
427
|
-
# if self.waldiez.flow.is_group_chat:
|
|
428
|
-
# return any(tool.is_predefined for tool in self.waldiez.tools)
|
|
429
|
-
# return False
|
|
443
|
+
return False
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
from .common import (
|
|
6
6
|
generate_header,
|
|
7
7
|
get_after_run_content,
|
|
8
|
+
get_common_env_var_setup,
|
|
8
9
|
get_np_no_nep50_handle,
|
|
9
10
|
)
|
|
10
11
|
from .importing import get_sorted_imports, get_the_imports_string
|
|
@@ -12,6 +13,7 @@ from .logging import get_sqlite_out, get_start_logging, get_stop_logging
|
|
|
12
13
|
|
|
13
14
|
__all__ = [
|
|
14
15
|
"generate_header",
|
|
16
|
+
"get_common_env_var_setup",
|
|
15
17
|
"get_np_no_nep50_handle",
|
|
16
18
|
"get_after_run_content",
|
|
17
19
|
"get_the_imports_string",
|