waldiez 0.5.3__py3-none-any.whl → 0.5.4__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 +3 -27
- waldiez/exporter.py +0 -13
- waldiez/exporting/agent/exporter.py +38 -0
- waldiez/exporting/agent/extras/__init__.py +2 -0
- waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
- waldiez/exporting/agent/extras/group_member_extras.py +3 -2
- waldiez/exporting/agent/processor.py +113 -15
- waldiez/exporting/chats/processor.py +2 -21
- waldiez/exporting/chats/utils/common.py +66 -1
- waldiez/exporting/chats/utils/group.py +6 -3
- waldiez/exporting/chats/utils/nested.py +1 -1
- waldiez/exporting/chats/utils/sequential.py +25 -9
- waldiez/exporting/chats/utils/single.py +8 -6
- waldiez/exporting/core/context.py +0 -12
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
- waldiez/exporting/core/extras/base.py +20 -17
- waldiez/exporting/core/extras/path_resolver.py +39 -41
- waldiez/exporting/core/extras/serializer.py +16 -1
- waldiez/exporting/core/protocols.py +17 -0
- waldiez/exporting/core/types.py +6 -9
- waldiez/exporting/flow/execution_generator.py +56 -21
- waldiez/exporting/flow/exporter.py +1 -4
- waldiez/exporting/flow/factory.py +0 -9
- waldiez/exporting/flow/file_generator.py +6 -0
- waldiez/exporting/flow/orchestrator.py +27 -21
- waldiez/exporting/flow/utils/__init__.py +0 -2
- waldiez/exporting/flow/utils/common.py +15 -96
- waldiez/exporting/flow/utils/importing.py +4 -0
- waldiez/io/mqtt.py +33 -14
- waldiez/io/redis.py +18 -13
- waldiez/io/structured.py +9 -4
- waldiez/io/utils.py +32 -0
- waldiez/io/ws.py +8 -2
- waldiez/models/__init__.py +6 -0
- waldiez/models/agents/__init__.py +8 -0
- waldiez/models/agents/agent/agent.py +136 -38
- waldiez/models/agents/agent/agent_type.py +3 -2
- waldiez/models/agents/agents.py +10 -0
- waldiez/models/agents/doc_agent/__init__.py +13 -0
- waldiez/models/agents/doc_agent/doc_agent.py +126 -0
- waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
- waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
- waldiez/models/flow/flow.py +13 -2
- waldiez/models/model/__init__.py +2 -2
- waldiez/models/model/_aws.py +75 -0
- waldiez/models/model/_llm.py +516 -0
- waldiez/models/model/_price.py +30 -0
- waldiez/models/model/model.py +45 -2
- waldiez/models/model/model_data.py +2 -83
- waldiez/models/tool/predefined/_duckduckgo.py +123 -0
- waldiez/models/tool/predefined/_google.py +31 -9
- waldiez/models/tool/predefined/_perplexity.py +161 -0
- waldiez/models/tool/predefined/_searxng.py +152 -0
- waldiez/models/tool/predefined/_tavily.py +46 -9
- waldiez/models/tool/predefined/_wikipedia.py +26 -6
- waldiez/models/tool/predefined/_youtube.py +36 -8
- waldiez/models/tool/predefined/registry.py +6 -0
- waldiez/models/waldiez.py +12 -0
- waldiez/runner.py +177 -408
- waldiez/running/__init__.py +2 -4
- waldiez/running/base_runner.py +100 -112
- waldiez/running/environment.py +29 -4
- waldiez/running/post_run.py +0 -1
- waldiez/running/protocol.py +36 -48
- waldiez/running/run_results.py +5 -5
- waldiez/running/standard_runner.py +429 -0
- waldiez/running/timeline_processor.py +0 -82
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/METADATA +58 -61
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/RECORD +74 -64
- waldiez/running/import_runner.py +0 -437
- waldiez/running/subprocess_runner.py +0 -104
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/WHEEL +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.4.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -8,7 +8,6 @@ from typing import Optional, Union
|
|
|
8
8
|
from ..protocols import PathResolver
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
# pylint: disable=too-few-public-methods
|
|
12
11
|
class DefaultPathResolver(PathResolver):
|
|
13
12
|
"""Default path resolver for Waldiez items."""
|
|
14
13
|
|
|
@@ -22,36 +21,51 @@ class DefaultPathResolver(PathResolver):
|
|
|
22
21
|
|
|
23
22
|
Returns
|
|
24
23
|
-------
|
|
25
|
-
|
|
26
|
-
The resolved local path
|
|
24
|
+
str
|
|
25
|
+
The resolved local path string (raw path format).
|
|
27
26
|
"""
|
|
28
|
-
resolved = _check_local_path(path)
|
|
27
|
+
resolved = DefaultPathResolver._check_local_path(path)
|
|
29
28
|
if not resolved:
|
|
30
29
|
return _get_raw_path_string(path)
|
|
31
30
|
return _get_raw_path_string(resolved)
|
|
32
31
|
|
|
32
|
+
def is_local(self, path: str) -> bool:
|
|
33
|
+
"""Check if the given path is a local path.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
path : str
|
|
38
|
+
The path to check.
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
bool
|
|
43
|
+
True if the path is a local path, False otherwise.
|
|
44
|
+
"""
|
|
45
|
+
return DefaultPathResolver._check_local_path(path) is not None
|
|
41
46
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
@staticmethod
|
|
48
|
+
def _check_local_path(string: str) -> Optional[Path]:
|
|
49
|
+
"""Check if a string is a local path.
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
string : str
|
|
54
|
+
The string to check.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
bool
|
|
59
|
+
True if the path is a local path.
|
|
60
|
+
"""
|
|
61
|
+
# pylint: disable=broad-exception-caught
|
|
62
|
+
try:
|
|
63
|
+
path = Path(string).resolve()
|
|
64
|
+
except BaseException: # pragma: no cover
|
|
65
|
+
return None
|
|
66
|
+
if path.exists():
|
|
67
|
+
return path
|
|
51
68
|
return None
|
|
52
|
-
if path.exists():
|
|
53
|
-
return path
|
|
54
|
-
return None
|
|
55
69
|
|
|
56
70
|
|
|
57
71
|
def _get_raw_path_string(path: Union[str, Path]) -> str:
|
|
@@ -71,23 +85,7 @@ def _get_raw_path_string(path: Union[str, Path]) -> str:
|
|
|
71
85
|
path = str(path)
|
|
72
86
|
while path.startswith('r"') and path.endswith('"'):
|
|
73
87
|
path = path[2:-1]
|
|
88
|
+
while path.startswith("r'") and path.endswith("'"):
|
|
89
|
+
path = path[2:-1]
|
|
90
|
+
# return repr(path)
|
|
74
91
|
return f'r"{path}"'
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
# def get_path_string(path: str) -> str:
|
|
78
|
-
# """Get the path string.
|
|
79
|
-
|
|
80
|
-
# Parameters
|
|
81
|
-
# ----------
|
|
82
|
-
# path : str
|
|
83
|
-
# The string to check.
|
|
84
|
-
|
|
85
|
-
# Returns
|
|
86
|
-
# -------
|
|
87
|
-
# str
|
|
88
|
-
# The local path string.
|
|
89
|
-
# """
|
|
90
|
-
# resolved = _check_local_path(path)
|
|
91
|
-
# if not resolved:
|
|
92
|
-
# return _get_raw_path_string(path)
|
|
93
|
-
# return _get_raw_path_string(resolved)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
# pylint: disable=too-many-return-statements
|
|
3
4
|
# pyright: reportUnknownArgumentType=false,reportUnknownVariableType=false
|
|
4
5
|
"""serializer for converting items to formatted strings."""
|
|
5
6
|
|
|
@@ -90,7 +91,7 @@ def serialize_item(
|
|
|
90
91
|
return _format_primitive(item)
|
|
91
92
|
|
|
92
93
|
# Handle circular references in containers
|
|
93
|
-
if isinstance(item, (dict, list)) and id(item) in _visited:
|
|
94
|
+
if isinstance(item, (dict, list, tuple, set)) and id(item) in _visited:
|
|
94
95
|
return '"<circular reference>"'
|
|
95
96
|
|
|
96
97
|
next_indent = " " * 4 * (tabs + 1)
|
|
@@ -111,6 +112,20 @@ def serialize_item(
|
|
|
111
112
|
]
|
|
112
113
|
return _format_container(items, "[", "]", tabs)
|
|
113
114
|
|
|
115
|
+
if isinstance(item, tuple):
|
|
116
|
+
items = [
|
|
117
|
+
f"{next_indent}{serialize_item(sub_item, tabs + 1, _visited)}"
|
|
118
|
+
for sub_item in item
|
|
119
|
+
]
|
|
120
|
+
return _format_container(items, "(", ")", tabs)
|
|
121
|
+
|
|
122
|
+
if isinstance(item, set):
|
|
123
|
+
items = [
|
|
124
|
+
f"{next_indent}{serialize_item(sub_item, tabs + 1, _visited)}"
|
|
125
|
+
for sub_item in item
|
|
126
|
+
]
|
|
127
|
+
return _format_container(items, "{", "}", tabs)
|
|
128
|
+
|
|
114
129
|
# Fallback for unknown object types
|
|
115
130
|
return repr(item)
|
|
116
131
|
|
|
@@ -87,6 +87,20 @@ class PathResolver(Protocol):
|
|
|
87
87
|
If the path cannot be resolved.
|
|
88
88
|
"""
|
|
89
89
|
|
|
90
|
+
def is_local(self, path: str) -> bool: # pyright: ignore
|
|
91
|
+
"""Check if the given path is a local path.
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
path : str
|
|
96
|
+
The path to check.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
bool
|
|
101
|
+
True if the path is a local path, False otherwise.
|
|
102
|
+
"""
|
|
103
|
+
|
|
90
104
|
|
|
91
105
|
class ContentGenerator(Protocol):
|
|
92
106
|
"""Protocol for generating content."""
|
|
@@ -96,6 +110,7 @@ class ContentGenerator(Protocol):
|
|
|
96
110
|
merged_result: ExportResult,
|
|
97
111
|
is_async: bool,
|
|
98
112
|
after_run: str,
|
|
113
|
+
skip_logging: bool,
|
|
99
114
|
**kwargs: Any,
|
|
100
115
|
) -> str: # pyright: ignore
|
|
101
116
|
"""Generate content based on provided parameters.
|
|
@@ -108,6 +123,8 @@ class ContentGenerator(Protocol):
|
|
|
108
123
|
Whether to generate async content.
|
|
109
124
|
after_run : str
|
|
110
125
|
Additional content to add after the main flow execution.
|
|
126
|
+
skip_logging : bool
|
|
127
|
+
Whether to skip logging setup.
|
|
111
128
|
**kwargs : Any
|
|
112
129
|
Parameters to influence content generation.
|
|
113
130
|
|
waldiez/exporting/core/types.py
CHANGED
|
@@ -150,6 +150,7 @@ class InstanceArgument:
|
|
|
150
150
|
with_new_line_after: bool = False
|
|
151
151
|
with_new_line_if_empty: bool = False
|
|
152
152
|
skip_if_empty_string: bool = True
|
|
153
|
+
skip_trailing_comma: bool = False
|
|
153
154
|
comment: Optional[str] = None
|
|
154
155
|
|
|
155
156
|
def has_content(self) -> bool:
|
|
@@ -192,9 +193,11 @@ class InstanceArgument:
|
|
|
192
193
|
):
|
|
193
194
|
return "\n" if self.with_new_line_if_empty else ""
|
|
194
195
|
space = " " * (self.tabs * self.tabs_length)
|
|
195
|
-
content = f"{space}{self.name}={self.value}
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
content = f"{space}{self.name}={self.value}"
|
|
197
|
+
if not self.skip_trailing_comma:
|
|
198
|
+
content += ","
|
|
199
|
+
if self.comment:
|
|
200
|
+
content += f" # {self.comment}"
|
|
198
201
|
if self.with_new_line_before or prepend_new_line:
|
|
199
202
|
content = "\n" + content
|
|
200
203
|
if self.with_new_line_after or append_new_line:
|
|
@@ -253,14 +256,10 @@ class ExportConfig:
|
|
|
253
256
|
The root directory for uploads, if applicable.
|
|
254
257
|
cache_seed : Optional[int]
|
|
255
258
|
The seed for caching, if applicable.
|
|
256
|
-
structured_io : bool
|
|
257
|
-
Whether the export should use structured I/O.
|
|
258
259
|
output_extension : str
|
|
259
260
|
The file extension for the exported content.
|
|
260
261
|
is_async : bool
|
|
261
262
|
Whether the exported content should be asynchronous.
|
|
262
|
-
skip_patch_io : bool
|
|
263
|
-
Whether to skip patching I/O operations.
|
|
264
263
|
"""
|
|
265
264
|
|
|
266
265
|
name: str = "Waldiez Flow"
|
|
@@ -274,8 +273,6 @@ class ExportConfig:
|
|
|
274
273
|
output_directory: Optional[str | Path] = None
|
|
275
274
|
uploads_root: Optional[Path] = None
|
|
276
275
|
cache_seed: Optional[int] = None
|
|
277
|
-
structured_io: bool = False
|
|
278
|
-
skip_patch_io: bool = True
|
|
279
276
|
|
|
280
277
|
@property
|
|
281
278
|
def for_notebook(self) -> bool:
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Generates the main() and call_main() functions."""
|
|
4
4
|
|
|
5
|
-
# pylint: disable=no-self-use,unused-argument
|
|
5
|
+
# pylint: disable=no-self-use,unused-argument,line-too-long
|
|
6
|
+
# flake8: noqa: E501
|
|
6
7
|
|
|
7
8
|
from ..core import get_comment
|
|
8
|
-
from .utils.common import
|
|
9
|
+
from .utils.common import main_doc_string
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class ExecutionGenerator:
|
|
@@ -18,6 +19,7 @@ class ExecutionGenerator:
|
|
|
18
19
|
for_notebook: bool,
|
|
19
20
|
cache_seed: int | None,
|
|
20
21
|
after_run: str,
|
|
22
|
+
skip_logging: bool,
|
|
21
23
|
) -> str:
|
|
22
24
|
"""Generate the complete flow script content.
|
|
23
25
|
|
|
@@ -34,6 +36,8 @@ class ExecutionGenerator:
|
|
|
34
36
|
after_run : str, optional
|
|
35
37
|
Additional content to add after the main chat execution,
|
|
36
38
|
by default ""
|
|
39
|
+
skip_logging : bool, optional
|
|
40
|
+
Whether to skip logging setup, by default False
|
|
37
41
|
|
|
38
42
|
Returns
|
|
39
43
|
-------
|
|
@@ -46,6 +50,7 @@ class ExecutionGenerator:
|
|
|
46
50
|
cache_seed=cache_seed,
|
|
47
51
|
after_run=after_run,
|
|
48
52
|
for_notebook=for_notebook,
|
|
53
|
+
skip_logging=skip_logging,
|
|
49
54
|
)
|
|
50
55
|
call_main_function = ExecutionGenerator.generate_call_main_function(
|
|
51
56
|
is_async=is_async,
|
|
@@ -69,6 +74,7 @@ class ExecutionGenerator:
|
|
|
69
74
|
cache_seed: int | None,
|
|
70
75
|
after_run: str,
|
|
71
76
|
for_notebook: bool,
|
|
77
|
+
skip_logging: bool,
|
|
72
78
|
) -> str:
|
|
73
79
|
"""Generate the main function for the flow script.
|
|
74
80
|
|
|
@@ -84,6 +90,8 @@ class ExecutionGenerator:
|
|
|
84
90
|
Additional content to add after the main chat execution.
|
|
85
91
|
for_notebook : bool
|
|
86
92
|
Whether the export is intended for a notebook environment.
|
|
93
|
+
skip_logging : bool, optional
|
|
94
|
+
Whether to skip logging setup, by default False
|
|
87
95
|
|
|
88
96
|
Returns
|
|
89
97
|
-------
|
|
@@ -100,9 +108,18 @@ class ExecutionGenerator:
|
|
|
100
108
|
flow_content += f"{comment}\n"
|
|
101
109
|
if is_async:
|
|
102
110
|
flow_content += "async "
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
on_event_arg = "on_event: Optional[Callable[[BaseEvent], bool]] = None"
|
|
112
|
+
if is_async:
|
|
113
|
+
on_event_arg = (
|
|
114
|
+
"on_event: Optional["
|
|
115
|
+
"Callable[[BaseEvent], Coroutine[None, None, bool]]"
|
|
116
|
+
"] = None"
|
|
117
|
+
)
|
|
118
|
+
return_type_hint = (
|
|
119
|
+
"AsyncRunResponseProtocol" if is_async else "RunResponseProtocol"
|
|
120
|
+
)
|
|
121
|
+
flow_content += f"def main({on_event_arg}) -> {return_type_hint}:\n"
|
|
122
|
+
flow_content += f" {main_doc_string(is_async=is_async)}\n"
|
|
106
123
|
space = " "
|
|
107
124
|
if cache_seed is not None:
|
|
108
125
|
flow_content += (
|
|
@@ -111,10 +128,11 @@ class ExecutionGenerator:
|
|
|
111
128
|
)
|
|
112
129
|
space = f"{space} "
|
|
113
130
|
flow_content += f"{content}" + "\n"
|
|
114
|
-
if
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
131
|
+
if not skip_logging:
|
|
132
|
+
if is_async:
|
|
133
|
+
flow_content += f"{space}await stop_logging()"
|
|
134
|
+
else:
|
|
135
|
+
flow_content += f"{space}stop_logging()"
|
|
118
136
|
flow_content += "\n"
|
|
119
137
|
if after_run:
|
|
120
138
|
flow_content += after_run + "\n"
|
|
@@ -140,30 +158,47 @@ class ExecutionGenerator:
|
|
|
140
158
|
The complete call_main function content.
|
|
141
159
|
"""
|
|
142
160
|
content = "\n"
|
|
161
|
+
tab = " "
|
|
143
162
|
if for_notebook:
|
|
144
163
|
if is_async:
|
|
145
164
|
return "# %%\nawait main()\n"
|
|
146
165
|
return "# %%\nmain()\n"
|
|
147
166
|
if is_async:
|
|
148
167
|
content += "async def call_main() -> None:\n"
|
|
168
|
+
return_type_hint = "list[AsyncRunResponseProtocol]"
|
|
149
169
|
else:
|
|
150
170
|
content += "def call_main() -> None:\n"
|
|
151
|
-
|
|
152
|
-
content += f
|
|
171
|
+
return_type_hint = "list[RunResponseProtocol]"
|
|
172
|
+
content += f'{tab}"""Run the main function and print the results."""\n'
|
|
173
|
+
content += f"{tab}results: {return_type_hint} = "
|
|
153
174
|
if is_async:
|
|
154
175
|
content += "await "
|
|
155
176
|
content += "main()\n"
|
|
156
|
-
content += "
|
|
157
|
-
content += "
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
content += f"{tab}results_dicts: list[dict[str, Any]] = []\n"
|
|
178
|
+
content += f"{tab}for result in results:\n"
|
|
179
|
+
if is_async:
|
|
180
|
+
content += f"{tab}{tab}result_summary = await result.summary\n"
|
|
181
|
+
content += f"{tab}{tab}result_messages = await result.messages\n"
|
|
182
|
+
content += f"{tab}{tab}result_cost = await result.cost\n"
|
|
183
|
+
else:
|
|
184
|
+
content += f"{tab}{tab}result_summary = result.summary\n"
|
|
185
|
+
content += f"{tab}{tab}result_messages = result.messages\n"
|
|
186
|
+
content += f"{tab}{tab}result_cost = result.cost\n"
|
|
187
|
+
content += f"{tab}{tab}cost: dict[str, Any] | None = None\n"
|
|
188
|
+
content += f"{tab}{tab}if result_cost:\n"
|
|
189
|
+
content += f'{tab}{tab}{tab}cost = result_cost.model_dump(mode="json", fallback=str)\n'
|
|
190
|
+
content += f"{tab}{tab}results_dicts.append(\n"
|
|
191
|
+
content += f"{tab}{tab}{tab}{{\n"
|
|
192
|
+
content += f"{tab}{tab}{tab}{tab}'summary': result_summary,\n"
|
|
193
|
+
content += f"{tab}{tab}{tab}{tab}'messages': result_messages,\n"
|
|
194
|
+
content += f"{tab}{tab}{tab}{tab}'cost': cost,\n"
|
|
195
|
+
content += f"{tab}{tab}{tab}}}\n"
|
|
196
|
+
content += f"{tab}{tab})\n"
|
|
166
197
|
content += "\n"
|
|
198
|
+
content += f"{tab}results_dict = {{\n"
|
|
199
|
+
content += f"{tab}{tab}'results': results_dicts,\n"
|
|
200
|
+
content += f"{tab}}}\n"
|
|
201
|
+
content += f"{tab}print(json.dumps(results_dict, indent=2))\n"
|
|
167
202
|
return content
|
|
168
203
|
|
|
169
204
|
@staticmethod
|
|
@@ -21,8 +21,6 @@ class FlowExporter(Exporter[FlowExtras]):
|
|
|
21
21
|
waldiez: Waldiez,
|
|
22
22
|
output_dir: Path | None,
|
|
23
23
|
for_notebook: bool,
|
|
24
|
-
structured_io: bool = False,
|
|
25
|
-
skip_patch_io: bool = True,
|
|
26
24
|
context: Optional[ExporterContext] = None,
|
|
27
25
|
**kwargs: Any,
|
|
28
26
|
) -> None:
|
|
@@ -54,8 +52,6 @@ class FlowExporter(Exporter[FlowExtras]):
|
|
|
54
52
|
is_async=waldiez.is_async,
|
|
55
53
|
output_directory=str(self.output_dir) if self.output_dir else None,
|
|
56
54
|
cache_seed=waldiez.cache_seed,
|
|
57
|
-
structured_io=structured_io,
|
|
58
|
-
skip_patch_io=skip_patch_io,
|
|
59
55
|
)
|
|
60
56
|
self._extras = self._generate_extras()
|
|
61
57
|
|
|
@@ -108,4 +104,5 @@ class FlowExporter(Exporter[FlowExtras]):
|
|
|
108
104
|
merged_result=merged_result,
|
|
109
105
|
is_async=self.waldiez.is_async,
|
|
110
106
|
after_run=after_run,
|
|
107
|
+
skip_logging=orchestrator.should_skip_logging(),
|
|
111
108
|
)
|
|
@@ -47,8 +47,6 @@ def create_flow_exporter(
|
|
|
47
47
|
ChatsExporter
|
|
48
48
|
The created chats exporter.
|
|
49
49
|
"""
|
|
50
|
-
structured_io = kwargs.pop("structured_io", False)
|
|
51
|
-
skip_patch_io = kwargs.pop("skip_patch_io", True)
|
|
52
50
|
if context is None:
|
|
53
51
|
config = ExportConfig(
|
|
54
52
|
name=waldiez.name,
|
|
@@ -60,8 +58,6 @@ def create_flow_exporter(
|
|
|
60
58
|
output_directory=output_dir,
|
|
61
59
|
uploads_root=uploads_root,
|
|
62
60
|
cache_seed=waldiez.cache_seed,
|
|
63
|
-
structured_io=structured_io,
|
|
64
|
-
skip_patch_io=skip_patch_io,
|
|
65
61
|
)
|
|
66
62
|
context = ExporterContext(
|
|
67
63
|
config=config,
|
|
@@ -81,8 +77,6 @@ def create_flow_exporter(
|
|
|
81
77
|
output_directory=output_dir,
|
|
82
78
|
uploads_root=uploads_root,
|
|
83
79
|
cache_seed=waldiez.cache_seed,
|
|
84
|
-
structured_io=structured_io,
|
|
85
|
-
skip_patch_io=skip_patch_io,
|
|
86
80
|
)
|
|
87
81
|
else:
|
|
88
82
|
context.config.update(
|
|
@@ -95,8 +89,6 @@ def create_flow_exporter(
|
|
|
95
89
|
output_directory=output_dir,
|
|
96
90
|
uploads_root=uploads_root,
|
|
97
91
|
cache_seed=waldiez.cache_seed,
|
|
98
|
-
structured_io=structured_io,
|
|
99
|
-
skip_patch_io=skip_patch_io,
|
|
100
92
|
)
|
|
101
93
|
|
|
102
94
|
return FlowExporter(
|
|
@@ -104,7 +96,6 @@ def create_flow_exporter(
|
|
|
104
96
|
output_dir=output_dir,
|
|
105
97
|
uploads_root=uploads_root,
|
|
106
98
|
for_notebook=for_notebook,
|
|
107
|
-
structured_io=structured_io,
|
|
108
99
|
context=context,
|
|
109
100
|
**kwargs,
|
|
110
101
|
)
|
|
@@ -40,6 +40,7 @@ class FileGenerator(ContentGenerator):
|
|
|
40
40
|
merged_result: ExportResult,
|
|
41
41
|
is_async: bool,
|
|
42
42
|
after_run: str,
|
|
43
|
+
skip_logging: bool,
|
|
43
44
|
**kwargs: Any,
|
|
44
45
|
) -> str:
|
|
45
46
|
"""Generate the complete flow notebook content.
|
|
@@ -52,6 +53,8 @@ class FileGenerator(ContentGenerator):
|
|
|
52
53
|
Whether to generate async conten
|
|
53
54
|
after_run : str
|
|
54
55
|
Additional content to add after the main flow execution.
|
|
56
|
+
skip_logging : bool
|
|
57
|
+
Whether to skip logging setup.
|
|
55
58
|
**kwargs : Any
|
|
56
59
|
Additional keyword arguments for the generator.
|
|
57
60
|
|
|
@@ -101,6 +104,7 @@ class FileGenerator(ContentGenerator):
|
|
|
101
104
|
is_async=is_async,
|
|
102
105
|
after_run=after_run,
|
|
103
106
|
for_notebook=self.config.for_notebook,
|
|
107
|
+
skip_logging=skip_logging,
|
|
104
108
|
)
|
|
105
109
|
|
|
106
110
|
# 5. Combine everything
|
|
@@ -160,6 +164,7 @@ class FileGenerator(ContentGenerator):
|
|
|
160
164
|
is_async: bool,
|
|
161
165
|
for_notebook: bool,
|
|
162
166
|
after_run: str,
|
|
167
|
+
skip_logging: bool,
|
|
163
168
|
) -> tuple[str, str, str]:
|
|
164
169
|
cache_seed = (
|
|
165
170
|
self.context.config.cache_seed if self.context.config else None
|
|
@@ -172,6 +177,7 @@ class FileGenerator(ContentGenerator):
|
|
|
172
177
|
for_notebook=for_notebook,
|
|
173
178
|
cache_seed=cache_seed,
|
|
174
179
|
after_run=after_run,
|
|
180
|
+
skip_logging=skip_logging,
|
|
175
181
|
)
|
|
176
182
|
call_main = execution_gen.generate_call_main_function(
|
|
177
183
|
is_async=is_async,
|
|
@@ -23,7 +23,6 @@ from .utils import (
|
|
|
23
23
|
generate_header,
|
|
24
24
|
get_after_run_content,
|
|
25
25
|
get_np_no_nep50_handle,
|
|
26
|
-
get_set_io_stream,
|
|
27
26
|
get_sqlite_out,
|
|
28
27
|
get_start_logging,
|
|
29
28
|
get_stop_logging,
|
|
@@ -174,24 +173,15 @@ class ExportOrchestrator:
|
|
|
174
173
|
position=ExportPosition.IMPORTS, # after imports (need np)
|
|
175
174
|
order=ContentOrder.CLEANUP,
|
|
176
175
|
)
|
|
177
|
-
|
|
178
|
-
get_start_logging(
|
|
179
|
-
is_async=self.waldiez.is_async,
|
|
180
|
-
for_notebook=self.config.for_notebook,
|
|
181
|
-
),
|
|
182
|
-
position=ExportPosition.IMPORTS, # after imports, before models
|
|
183
|
-
order=ContentOrder.CLEANUP.value + 1, # after imports
|
|
184
|
-
skip_strip=True, # keep newlines
|
|
185
|
-
)
|
|
186
|
-
if not self.config.skip_patch_io:
|
|
176
|
+
if not self.should_skip_logging():
|
|
187
177
|
merged_result.add_content(
|
|
188
|
-
|
|
189
|
-
use_structured_io=self.config.structured_io,
|
|
178
|
+
get_start_logging(
|
|
190
179
|
is_async=self.waldiez.is_async,
|
|
191
|
-
|
|
180
|
+
for_notebook=self.config.for_notebook,
|
|
192
181
|
),
|
|
193
182
|
position=ExportPosition.IMPORTS, # after imports, before models
|
|
194
|
-
order=ContentOrder.CLEANUP.value +
|
|
183
|
+
order=ContentOrder.CLEANUP.value + 1, # after imports
|
|
184
|
+
skip_strip=True, # keep newlines
|
|
195
185
|
)
|
|
196
186
|
# merged_result.add_content
|
|
197
187
|
merged_result.add_content(
|
|
@@ -199,12 +189,13 @@ class ExportOrchestrator:
|
|
|
199
189
|
position=ExportPosition.AGENTS,
|
|
200
190
|
order=ContentOrder.LATE_CLEANUP.value + 1, # after all agents
|
|
201
191
|
)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
if not self.should_skip_logging():
|
|
193
|
+
merged_result.add_content(
|
|
194
|
+
get_stop_logging(is_async=self.waldiez.is_async),
|
|
195
|
+
position=ExportPosition.AGENTS,
|
|
196
|
+
order=ContentOrder.LATE_CLEANUP.value
|
|
197
|
+
+ 2, # before def main (chats)
|
|
198
|
+
)
|
|
208
199
|
all_imports: list[tuple[str, ImportPosition]] = [
|
|
209
200
|
(item.statement, item.position)
|
|
210
201
|
for item in merged_result.get_sorted_imports()
|
|
@@ -421,3 +412,18 @@ class ExportOrchestrator:
|
|
|
421
412
|
agent_result = agent_exporter.export()
|
|
422
413
|
results.append(agent_result)
|
|
423
414
|
return results
|
|
415
|
+
|
|
416
|
+
def should_skip_logging(self) -> bool:
|
|
417
|
+
"""Determine if logging should be skipped.
|
|
418
|
+
|
|
419
|
+
Returns
|
|
420
|
+
-------
|
|
421
|
+
bool
|
|
422
|
+
True if logging should be skipped, False otherwise.
|
|
423
|
+
"""
|
|
424
|
+
return self.waldiez.has_doc_agents
|
|
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
|
|
@@ -6,7 +6,6 @@ from .common import (
|
|
|
6
6
|
generate_header,
|
|
7
7
|
get_after_run_content,
|
|
8
8
|
get_np_no_nep50_handle,
|
|
9
|
-
get_set_io_stream,
|
|
10
9
|
)
|
|
11
10
|
from .importing import get_sorted_imports, get_the_imports_string
|
|
12
11
|
from .logging import get_sqlite_out, get_start_logging, get_stop_logging
|
|
@@ -20,5 +19,4 @@ __all__ = [
|
|
|
20
19
|
"get_start_logging",
|
|
21
20
|
"get_stop_logging",
|
|
22
21
|
"get_sqlite_out",
|
|
23
|
-
"get_set_io_stream",
|
|
24
22
|
]
|