waldiez 0.5.10__py3-none-any.whl → 0.6.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 +1 -1
- waldiez/_version.py +1 -1
- waldiez/cli.py +19 -7
- waldiez/cli_extras/jupyter.py +3 -0
- waldiez/cli_extras/runner.py +3 -1
- waldiez/cli_extras/studio.py +3 -1
- waldiez/exporter.py +9 -3
- waldiez/exporting/agent/exporter.py +15 -16
- waldiez/exporting/agent/extras/captain_agent_extras.py +6 -6
- waldiez/exporting/agent/extras/doc_agent_extras.py +6 -6
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +40 -24
- waldiez/exporting/agent/extras/group_member_extras.py +6 -5
- waldiez/exporting/agent/extras/handoffs/after_work.py +2 -1
- waldiez/exporting/agent/extras/handoffs/available.py +2 -1
- waldiez/exporting/agent/extras/handoffs/condition.py +3 -2
- waldiez/exporting/agent/extras/handoffs/handoff.py +2 -1
- waldiez/exporting/agent/extras/handoffs/target.py +7 -4
- waldiez/exporting/agent/extras/rag/chroma_extras.py +27 -19
- waldiez/exporting/agent/extras/rag/mongo_extras.py +8 -8
- waldiez/exporting/agent/extras/rag/pgvector_extras.py +5 -5
- waldiez/exporting/agent/extras/rag/qdrant_extras.py +5 -4
- waldiez/exporting/agent/extras/rag/vector_db_extras.py +1 -1
- waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +5 -7
- waldiez/exporting/agent/extras/reasoning_agent_extras.py +3 -5
- waldiez/exporting/agent/termination.py +1 -0
- waldiez/exporting/chats/exporter.py +4 -4
- waldiez/exporting/chats/processor.py +1 -2
- waldiez/exporting/chats/utils/common.py +89 -48
- waldiez/exporting/chats/utils/group.py +9 -9
- waldiez/exporting/chats/utils/nested.py +7 -7
- waldiez/exporting/chats/utils/sequential.py +1 -1
- waldiez/exporting/chats/utils/single.py +2 -2
- waldiez/exporting/core/constants.py +3 -1
- waldiez/exporting/core/content.py +7 -7
- waldiez/exporting/core/context.py +5 -3
- waldiez/exporting/core/exporter.py +5 -3
- waldiez/exporting/core/exporters.py +2 -2
- waldiez/exporting/core/extras/agent_extras/captain_extras.py +2 -2
- waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +2 -2
- waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +2 -2
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -8
- waldiez/exporting/core/extras/base.py +7 -5
- waldiez/exporting/core/extras/flow_extras.py +4 -5
- waldiez/exporting/core/extras/model_extras.py +2 -2
- waldiez/exporting/core/extras/path_resolver.py +1 -2
- waldiez/exporting/core/extras/serializer.py +13 -11
- waldiez/exporting/core/protocols.py +6 -5
- waldiez/exporting/core/result.py +25 -28
- waldiez/exporting/core/types.py +11 -10
- waldiez/exporting/core/utils/llm_config.py +4 -4
- waldiez/exporting/core/validation.py +10 -11
- waldiez/exporting/flow/execution_generator.py +99 -10
- waldiez/exporting/flow/exporter.py +2 -2
- waldiez/exporting/flow/factory.py +2 -2
- waldiez/exporting/flow/file_generator.py +4 -2
- waldiez/exporting/flow/merger.py +5 -3
- waldiez/exporting/flow/orchestrator.py +72 -2
- waldiez/exporting/flow/utils/common.py +6 -6
- waldiez/exporting/flow/utils/importing.py +7 -8
- waldiez/exporting/flow/utils/linting.py +25 -9
- waldiez/exporting/flow/utils/logging.py +5 -77
- waldiez/exporting/models/exporter.py +8 -8
- waldiez/exporting/models/processor.py +5 -5
- waldiez/exporting/tools/exporter.py +2 -2
- waldiez/exporting/tools/processor.py +7 -4
- waldiez/io/__init__.py +11 -5
- waldiez/io/_ws.py +12 -6
- waldiez/io/models/constants.py +10 -10
- waldiez/io/models/content/audio.py +1 -0
- waldiez/io/models/content/base.py +20 -18
- 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 +10 -5
- waldiez/io/models/user_response.py +17 -16
- waldiez/io/mqtt.py +18 -31
- waldiez/io/redis.py +18 -22
- waldiez/io/structured.py +122 -70
- waldiez/io/utils.py +19 -10
- waldiez/io/ws.py +7 -3
- waldiez/logger.py +16 -3
- waldiez/models/agents/__init__.py +3 -0
- waldiez/models/agents/agent/agent.py +25 -17
- waldiez/models/agents/agent/agent_data.py +25 -22
- waldiez/models/agents/agent/code_execution.py +9 -11
- waldiez/models/agents/agent/termination_message.py +10 -12
- waldiez/models/agents/agent/update_system_message.py +2 -4
- waldiez/models/agents/agents.py +8 -8
- waldiez/models/agents/assistant/assistant.py +6 -3
- waldiez/models/agents/assistant/assistant_data.py +2 -2
- waldiez/models/agents/captain/captain_agent.py +7 -4
- waldiez/models/agents/captain/captain_agent_data.py +5 -7
- waldiez/models/agents/doc_agent/doc_agent.py +7 -4
- waldiez/models/agents/doc_agent/doc_agent_data.py +9 -10
- waldiez/models/agents/doc_agent/rag_query_engine.py +10 -12
- waldiez/models/agents/extra_requirements.py +3 -3
- waldiez/models/agents/group_manager/group_manager.py +12 -7
- waldiez/models/agents/group_manager/group_manager_data.py +13 -12
- waldiez/models/agents/group_manager/speakers.py +17 -19
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +7 -4
- waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +4 -1
- waldiez/models/agents/rag_user_proxy/retrieve_config.py +69 -63
- waldiez/models/agents/rag_user_proxy/vector_db_config.py +19 -19
- waldiez/models/agents/reasoning/reasoning_agent.py +7 -4
- waldiez/models/agents/reasoning/reasoning_agent_data.py +3 -2
- waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +8 -8
- waldiez/models/agents/user_proxy/user_proxy.py +6 -3
- waldiez/models/agents/user_proxy/user_proxy_data.py +1 -1
- waldiez/models/chat/chat.py +28 -20
- waldiez/models/chat/chat_data.py +22 -21
- waldiez/models/chat/chat_message.py +9 -9
- waldiez/models/chat/chat_nested.py +9 -9
- waldiez/models/chat/chat_summary.py +6 -6
- waldiez/models/common/__init__.py +2 -0
- waldiez/models/common/ag2_version.py +2 -0
- waldiez/models/common/base.py +2 -0
- waldiez/models/common/dict_utils.py +8 -6
- waldiez/models/common/handoff.py +20 -17
- waldiez/models/common/method_utils.py +9 -7
- waldiez/models/common/naming.py +49 -0
- waldiez/models/flow/flow.py +11 -6
- waldiez/models/flow/flow_data.py +23 -17
- waldiez/models/flow/info.py +3 -3
- waldiez/models/flow/naming.py +2 -1
- waldiez/models/model/_aws.py +11 -13
- waldiez/models/model/_llm.py +8 -0
- waldiez/models/model/_price.py +2 -4
- waldiez/models/model/extra_requirements.py +1 -3
- waldiez/models/model/model.py +2 -2
- waldiez/models/model/model_data.py +21 -21
- waldiez/models/tool/extra_requirements.py +2 -4
- waldiez/models/tool/predefined/_duckduckgo.py +1 -0
- waldiez/models/tool/predefined/_email.py +4 -0
- waldiez/models/tool/predefined/_google.py +1 -0
- waldiez/models/tool/predefined/_perplexity.py +2 -1
- waldiez/models/tool/predefined/_searxng.py +2 -1
- waldiez/models/tool/predefined/_tavily.py +1 -0
- waldiez/models/tool/predefined/_wikipedia.py +2 -1
- waldiez/models/tool/predefined/_youtube.py +1 -0
- waldiez/models/tool/tool.py +8 -5
- waldiez/models/tool/tool_data.py +2 -2
- waldiez/models/waldiez.py +152 -4
- waldiez/runner.py +11 -5
- waldiez/running/async_utils.py +192 -0
- waldiez/running/base_runner.py +155 -241
- waldiez/running/dir_utils.py +52 -0
- waldiez/running/environment.py +10 -44
- waldiez/running/events_mixin.py +252 -0
- waldiez/running/exceptions.py +20 -0
- waldiez/running/gen_seq_diagram.py +18 -15
- waldiez/running/io_utils.py +216 -0
- waldiez/running/protocol.py +11 -5
- waldiez/running/requirements_mixin.py +65 -0
- waldiez/running/results_mixin.py +926 -0
- waldiez/running/standard_runner.py +24 -27
- waldiez/running/step_by_step/breakpoints_mixin.py +503 -47
- waldiez/running/step_by_step/command_handler.py +154 -0
- waldiez/running/step_by_step/events_processor.py +379 -0
- waldiez/running/step_by_step/step_by_step_models.py +425 -41
- waldiez/running/step_by_step/step_by_step_runner.py +437 -382
- waldiez/running/subprocess_runner/__base__.py +13 -8
- waldiez/running/subprocess_runner/_async_runner.py +6 -4
- waldiez/running/subprocess_runner/_sync_runner.py +11 -6
- waldiez/running/subprocess_runner/runner.py +48 -23
- waldiez/running/timeline_processor.py +1 -1
- waldiez/utils/__init__.py +2 -0
- waldiez/utils/conflict_checker.py +4 -4
- waldiez/utils/python_manager.py +415 -0
- waldiez/ws/__init__.py +8 -7
- waldiez/ws/_file_handler.py +18 -20
- waldiez/ws/_mock.py +75 -0
- waldiez/ws/cli.py +58 -10
- waldiez/ws/client_manager.py +77 -53
- waldiez/ws/errors.py +3 -0
- waldiez/ws/models.py +61 -53
- waldiez/ws/reloader.py +33 -4
- waldiez/ws/server.py +121 -52
- waldiez/ws/session_manager.py +8 -9
- waldiez/ws/session_stats.py +1 -1
- waldiez/ws/utils.py +33 -5
- {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/METADATA +107 -109
- waldiez-0.6.1.dist-info/RECORD +254 -0
- waldiez/running/post_run.py +0 -180
- waldiez/running/pre_run.py +0 -159
- waldiez/running/run_results.py +0 -14
- waldiez/running/utils.py +0 -511
- waldiez-0.5.10.dist-info/RECORD +0 -248
- {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/WHEEL +0 -0
- {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.10.dist-info → waldiez-0.6.1.dist-info}/licenses/NOTICE.md +0 -0
waldiez/__init__.py
CHANGED
|
@@ -9,7 +9,7 @@ from .utils import check_conflicts
|
|
|
9
9
|
|
|
10
10
|
# flake8: noqa: F401
|
|
11
11
|
# pylint: disable=import-error,line-too-long
|
|
12
|
-
# pyright: reportMissingImports=false
|
|
12
|
+
# pyright: reportMissingImports=false,reportUnknownVariableType=false
|
|
13
13
|
try:
|
|
14
14
|
# noqa: I001
|
|
15
15
|
from ._version import __version__ # type: ignore[unused-ignore, unused-import, import-not-found, import-untyped] # noqa
|
waldiez/_version.py
CHANGED
waldiez/cli.py
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
# flake8: noqa: E501
|
|
4
4
|
# pylint: disable=missing-function-docstring, missing-param-doc, missing-raises-doc
|
|
5
5
|
# pylint: disable=line-too-long, import-outside-toplevel
|
|
6
|
+
# pyright: reportUnknownArgumentType=false,reportCallInDefaultInitializer=false
|
|
7
|
+
# pyright: reportUnusedCallResult=false,reportAny=false
|
|
6
8
|
"""Command line interface to convert or run a waldiez file."""
|
|
7
9
|
|
|
8
10
|
import json
|
|
9
11
|
import os
|
|
10
12
|
import sys
|
|
11
13
|
from pathlib import Path
|
|
12
|
-
from typing import TYPE_CHECKING, Literal
|
|
14
|
+
from typing import TYPE_CHECKING, Literal
|
|
13
15
|
|
|
14
16
|
import anyio
|
|
15
17
|
import typer
|
|
@@ -81,7 +83,7 @@ def run(
|
|
|
81
83
|
resolve_path=True,
|
|
82
84
|
),
|
|
83
85
|
],
|
|
84
|
-
output:
|
|
86
|
+
output: Path | None = typer.Option( # noqa: B008
|
|
85
87
|
None,
|
|
86
88
|
help=(
|
|
87
89
|
"Path to the output (.py) file. "
|
|
@@ -91,7 +93,7 @@ def run(
|
|
|
91
93
|
dir_okay=False,
|
|
92
94
|
resolve_path=True,
|
|
93
95
|
),
|
|
94
|
-
uploads_root:
|
|
96
|
+
uploads_root: Path | None = typer.Option( # noqa: B008
|
|
95
97
|
None,
|
|
96
98
|
help=(
|
|
97
99
|
"Path to the uploads root directory. "
|
|
@@ -104,15 +106,15 @@ def run(
|
|
|
104
106
|
structured: bool = typer.Option( # noqa: B008
|
|
105
107
|
False,
|
|
106
108
|
help=(
|
|
107
|
-
"If set,
|
|
108
|
-
"
|
|
109
|
+
"If set, structured messages will be used for I/O when "
|
|
110
|
+
"using print and/or input"
|
|
109
111
|
),
|
|
110
112
|
),
|
|
111
113
|
force: bool = typer.Option( # noqa: B008
|
|
112
114
|
False,
|
|
113
115
|
help="Override the output file if it already exists.",
|
|
114
116
|
),
|
|
115
|
-
env_file:
|
|
117
|
+
env_file: Path | None = typer.Option( # noqa: B008
|
|
116
118
|
None,
|
|
117
119
|
"--env-file",
|
|
118
120
|
"-e",
|
|
@@ -136,6 +138,14 @@ def run(
|
|
|
136
138
|
is_eager=True,
|
|
137
139
|
rich_help_panel="Debug",
|
|
138
140
|
),
|
|
141
|
+
breakpoints: list[str] = typer.Option( # noqa: B008
|
|
142
|
+
...,
|
|
143
|
+
"--breakpoints",
|
|
144
|
+
"-b",
|
|
145
|
+
default_factory=list,
|
|
146
|
+
help="Optional list with initial breakpoints (if using step mode).",
|
|
147
|
+
rich_help_panel="Debug",
|
|
148
|
+
),
|
|
139
149
|
subprocess: bool = typer.Option(
|
|
140
150
|
False,
|
|
141
151
|
"--subprocess",
|
|
@@ -170,6 +180,8 @@ def run(
|
|
|
170
180
|
structured_io=structured,
|
|
171
181
|
dot_env=env_file,
|
|
172
182
|
subprocess_mode=subprocess_mode,
|
|
183
|
+
waldiez_file=file,
|
|
184
|
+
breakpoints=breakpoints,
|
|
173
185
|
)
|
|
174
186
|
except FileNotFoundError as error:
|
|
175
187
|
typer.echo(f"File not found: {file}")
|
|
@@ -270,7 +282,7 @@ def check(
|
|
|
270
282
|
LOG.success("Waldiez flow seems valid.")
|
|
271
283
|
|
|
272
284
|
|
|
273
|
-
def _get_output_path(output:
|
|
285
|
+
def _get_output_path(output: Path | None, force: bool) -> Path | None:
|
|
274
286
|
if output is not None:
|
|
275
287
|
output = Path(output).resolve()
|
|
276
288
|
if output is not None and not output.parent.exists():
|
waldiez/cli_extras/jupyter.py
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# pylint: skip-file
|
|
4
4
|
# isort: skip_file
|
|
5
|
+
# pyright: reportMissingImports=false,reportUnusedImport=false
|
|
6
|
+
# pyright: reportCallInDefaultInitializer=false,reportPrivateImportUsage=false
|
|
7
|
+
# pyright: reportUnknownVariableType=false
|
|
5
8
|
# flake8: noqa: E501
|
|
6
9
|
"""Waldiez-jupyter extra typer commands for CLI."""
|
|
7
10
|
|
waldiez/cli_extras/runner.py
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
# pylint: skip-file
|
|
4
4
|
# isort: skip_file
|
|
5
5
|
# flake8: noqa: E501,E402
|
|
6
|
+
# pyright: reportMissingImports=false,reportUnusedImport=false
|
|
7
|
+
# pyright: reportUnknownVariableType=false
|
|
6
8
|
"""Waldiez-runner extra typer commands for CLI."""
|
|
7
9
|
|
|
8
10
|
from typing import Any, Callable
|
|
@@ -18,7 +20,7 @@ runner_app: Callable[..., Any] | None = None
|
|
|
18
20
|
try:
|
|
19
21
|
from waldiez_runner.cli import run # type: ignore[unused-ignore, import-not-found, import-untyped]
|
|
20
22
|
|
|
21
|
-
runner_app = run
|
|
23
|
+
runner_app = run
|
|
22
24
|
|
|
23
25
|
_have_runner = True
|
|
24
26
|
except BaseException:
|
waldiez/cli_extras/studio.py
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
# pylint: skip-file
|
|
4
4
|
# isort: skip_file
|
|
5
5
|
# flake8: noqa: E501,E402
|
|
6
|
+
# pyright: reportMissingImports=false,reportUnusedImport=false
|
|
7
|
+
# pyright: reportUnknownVariableType=false
|
|
6
8
|
"""Waldiez-studio extra typer commands for CLI."""
|
|
7
9
|
|
|
8
10
|
from typing import Any, Callable
|
|
@@ -18,7 +20,7 @@ studio_app: Callable[..., Any] | None = None
|
|
|
18
20
|
try:
|
|
19
21
|
from waldiez_studio.cli import run # type: ignore[unused-ignore, import-not-found, import-untyped]
|
|
20
22
|
|
|
21
|
-
studio_app = run
|
|
23
|
+
studio_app = run
|
|
22
24
|
|
|
23
25
|
_have_studio = True
|
|
24
26
|
except BaseException:
|
waldiez/exporter.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pyright: reportMissingTypeStubs=false,reportUnknownMemberType=false
|
|
5
|
+
# pyright: reportUnknownVariableType=false,reportAny=false
|
|
6
|
+
# pyright: reportUnusedCallResult=false
|
|
3
7
|
"""
|
|
4
8
|
Waldiez exporter class.
|
|
5
9
|
|
|
@@ -29,7 +33,8 @@ class WaldiezExporter:
|
|
|
29
33
|
waldiez (Waldiez): The Waldiez instance.
|
|
30
34
|
"""
|
|
31
35
|
|
|
32
|
-
flow_extras: FlowExtras
|
|
36
|
+
flow_extras: FlowExtras | None
|
|
37
|
+
waldiez: Waldiez
|
|
33
38
|
|
|
34
39
|
def __init__(self, waldiez: Waldiez) -> None:
|
|
35
40
|
"""Initialize the Waldiez exporter.
|
|
@@ -40,6 +45,7 @@ class WaldiezExporter:
|
|
|
40
45
|
The Waldiez instance.
|
|
41
46
|
"""
|
|
42
47
|
self.waldiez = waldiez
|
|
48
|
+
self.flow_extras = None
|
|
43
49
|
|
|
44
50
|
@classmethod
|
|
45
51
|
def load(cls, file_path: Path) -> "WaldiezExporter":
|
|
@@ -173,13 +179,13 @@ class WaldiezExporter:
|
|
|
173
179
|
cell_metadata_filter="-all",
|
|
174
180
|
)
|
|
175
181
|
with open(py_path, "r", encoding="utf-8") as py_out:
|
|
176
|
-
jp_content = jupytext.read(
|
|
182
|
+
jp_content = jupytext.read(
|
|
177
183
|
py_out,
|
|
178
184
|
fmt="py:percent",
|
|
179
185
|
config=config,
|
|
180
186
|
)
|
|
181
187
|
ipynb_path = str(py_path).replace(".tmp.py", ".tmp.ipynb")
|
|
182
|
-
jupytext.write(
|
|
188
|
+
jupytext.write(
|
|
183
189
|
jp_content,
|
|
184
190
|
ipynb_path,
|
|
185
191
|
fmt="ipynb",
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
4
4
|
# pylint: disable=too-many-return-statements,too-many-instance-attributes
|
|
5
|
+
# pyright: reportUnusedParameter=false
|
|
5
6
|
"""Export agents."""
|
|
6
7
|
|
|
7
8
|
from pathlib import Path
|
|
8
|
-
from typing import Any, Callable
|
|
9
|
+
from typing import Any, Callable
|
|
9
10
|
|
|
10
11
|
from waldiez.models import (
|
|
11
12
|
WaldiezAgent,
|
|
@@ -45,14 +46,12 @@ class AgentExporter(Exporter[StandardExtras]):
|
|
|
45
46
|
tool_names: dict[str, str],
|
|
46
47
|
is_async: bool = False,
|
|
47
48
|
for_notebook: bool = False,
|
|
48
|
-
cache_seed:
|
|
49
|
-
initial_chats:
|
|
50
|
-
group_chat_members:
|
|
51
|
-
arguments_resolver:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
output_dir: Optional[Union[str, Path]] = None,
|
|
55
|
-
context: Optional[ExporterContext] = None,
|
|
49
|
+
cache_seed: int | None = None,
|
|
50
|
+
initial_chats: list[WaldiezAgentConnection] | None = None,
|
|
51
|
+
group_chat_members: list[WaldiezAgent] | None = None,
|
|
52
|
+
arguments_resolver: Callable[[WaldiezAgent], list[str]] | None = None,
|
|
53
|
+
output_dir: str | Path | None = None,
|
|
54
|
+
context: ExporterContext | None = None,
|
|
56
55
|
**kwargs: Any,
|
|
57
56
|
):
|
|
58
57
|
"""Initialize the agent exporter.
|
|
@@ -73,17 +72,17 @@ class AgentExporter(Exporter[StandardExtras]):
|
|
|
73
72
|
Whether the flow is async, by default False
|
|
74
73
|
for_notebook : bool, optional
|
|
75
74
|
Whether exporting for notebook, by default False
|
|
76
|
-
cache_seed :
|
|
75
|
+
cache_seed : int, optional
|
|
77
76
|
Cache seed if any, by default None
|
|
78
|
-
initial_chats :
|
|
77
|
+
initial_chats : list[WaldiezAgentConnection], optional
|
|
79
78
|
Initial chats for group managers, by default None
|
|
80
|
-
group_chat_members :
|
|
79
|
+
group_chat_members : list[WaldiezAgent], optional
|
|
81
80
|
Group chat members if group manager, by default None
|
|
82
|
-
arguments_resolver :
|
|
81
|
+
arguments_resolver : Callable, optional
|
|
83
82
|
Function to resolve additional arguments, by default None
|
|
84
|
-
output_dir :
|
|
83
|
+
output_dir : str | Path, optional
|
|
85
84
|
Output directory for generated files, by default None
|
|
86
|
-
context :
|
|
85
|
+
context : ExporterContext, optional
|
|
87
86
|
Exporter context with dependencies, by default None
|
|
88
87
|
**kwargs : Any
|
|
89
88
|
Additional keyword arguments.
|
|
@@ -336,7 +335,7 @@ class AgentExporter(Exporter[StandardExtras]):
|
|
|
336
335
|
|
|
337
336
|
return reason_extras
|
|
338
337
|
|
|
339
|
-
def generate_main_content(self) ->
|
|
338
|
+
def generate_main_content(self) -> str | None:
|
|
340
339
|
"""Generate the main agent definition.
|
|
341
340
|
|
|
342
341
|
Returns
|
|
@@ -10,7 +10,7 @@ import os
|
|
|
10
10
|
import uuid
|
|
11
11
|
from datetime import datetime, timezone
|
|
12
12
|
from pathlib import Path
|
|
13
|
-
from typing import Any
|
|
13
|
+
from typing import Any
|
|
14
14
|
|
|
15
15
|
from waldiez.models import (
|
|
16
16
|
WaldiezAgent,
|
|
@@ -37,8 +37,8 @@ class CaptainAgentProcessor:
|
|
|
37
37
|
agent: WaldiezAgent,
|
|
38
38
|
agent_names: dict[str, str],
|
|
39
39
|
all_models: list[WaldiezModel],
|
|
40
|
-
serializer:
|
|
41
|
-
output_dir:
|
|
40
|
+
serializer: Serializer | None = None,
|
|
41
|
+
output_dir: Path | None = None,
|
|
42
42
|
):
|
|
43
43
|
self.agent = agent
|
|
44
44
|
self.agent_names = agent_names
|
|
@@ -48,9 +48,9 @@ class CaptainAgentProcessor:
|
|
|
48
48
|
|
|
49
49
|
def process(
|
|
50
50
|
self,
|
|
51
|
-
code_execution_config:
|
|
52
|
-
termination_config:
|
|
53
|
-
system_message_config:
|
|
51
|
+
code_execution_config: CodeExecutionConfig | None = None,
|
|
52
|
+
termination_config: TerminationConfig | None = None,
|
|
53
|
+
system_message_config: SystemMessageConfig | None = None,
|
|
54
54
|
) -> CaptainExtras:
|
|
55
55
|
"""Process group manager and return extras.
|
|
56
56
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# pylint: disable=too-few-public-methods,no-self-use
|
|
4
|
+
# pyright: reportUninitializedInstanceVariable=false
|
|
4
5
|
|
|
5
6
|
# before agent: query engine initialization
|
|
6
7
|
# agent extra args:
|
|
@@ -13,7 +14,6 @@
|
|
|
13
14
|
# import shutil
|
|
14
15
|
import shutil
|
|
15
16
|
from pathlib import Path
|
|
16
|
-
from typing import Optional
|
|
17
17
|
|
|
18
18
|
from waldiez.exporting.core.extras.path_resolver import DefaultPathResolver
|
|
19
19
|
from waldiez.exporting.core.protocols import PathResolver
|
|
@@ -49,10 +49,10 @@ class DocAgentProcessor:
|
|
|
49
49
|
agent_names: dict[str, str],
|
|
50
50
|
model_names: dict[str, str],
|
|
51
51
|
all_models: list[WaldiezModel],
|
|
52
|
-
cache_seed:
|
|
52
|
+
cache_seed: int | None = None,
|
|
53
53
|
serializer: Serializer | None = None,
|
|
54
54
|
path_resolver: PathResolver | None = None,
|
|
55
|
-
output_dir:
|
|
55
|
+
output_dir: Path | None = None,
|
|
56
56
|
):
|
|
57
57
|
self.agent = agent
|
|
58
58
|
self.agent_name = agent_names.get(agent.id, agent.name)
|
|
@@ -65,9 +65,9 @@ class DocAgentProcessor:
|
|
|
65
65
|
|
|
66
66
|
def process(
|
|
67
67
|
self,
|
|
68
|
-
code_execution_config:
|
|
69
|
-
termination_config:
|
|
70
|
-
system_message_config:
|
|
68
|
+
code_execution_config: CodeExecutionConfig | None = None,
|
|
69
|
+
termination_config: TerminationConfig | None = None,
|
|
70
|
+
system_message_config: SystemMessageConfig | None = None,
|
|
71
71
|
) -> StandardExtras:
|
|
72
72
|
"""Process the document agent configuration.
|
|
73
73
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# pylint: disable=no-self-use,too-few-public-methods
|
|
4
4
|
"""Group manager agent configuration processor."""
|
|
5
5
|
|
|
6
|
-
from typing import Callable
|
|
6
|
+
from typing import Callable
|
|
7
7
|
|
|
8
8
|
from waldiez.models import (
|
|
9
9
|
WaldiezAgent,
|
|
@@ -35,7 +35,8 @@ class GroupManagerProcessor:
|
|
|
35
35
|
model_names: dict[str, str],
|
|
36
36
|
all_models: list[WaldiezModel],
|
|
37
37
|
serializer: Callable[..., str],
|
|
38
|
-
cache_seed:
|
|
38
|
+
cache_seed: int | None = None,
|
|
39
|
+
strategy: GroupManagerStrategy | None = None,
|
|
39
40
|
):
|
|
40
41
|
"""Initialize the group manager processor.
|
|
41
42
|
|
|
@@ -57,6 +58,8 @@ class GroupManagerProcessor:
|
|
|
57
58
|
Function to serialize data into a string format.
|
|
58
59
|
cache_seed : Optional[int], optional
|
|
59
60
|
Seed for caching purposes, by default None.
|
|
61
|
+
strategy : Optional[GroupManagerStrategy]
|
|
62
|
+
Optional strategy to force (pattern based or traditional)
|
|
60
63
|
"""
|
|
61
64
|
self.agent = agent
|
|
62
65
|
self.initial_chats = initial_chats
|
|
@@ -66,12 +69,13 @@ class GroupManagerProcessor:
|
|
|
66
69
|
self.all_models = all_models
|
|
67
70
|
self.serializer = serializer
|
|
68
71
|
self.cache_seed = cache_seed
|
|
72
|
+
self.strategy = strategy
|
|
69
73
|
|
|
70
74
|
def process(
|
|
71
75
|
self,
|
|
72
|
-
code_execution_config:
|
|
73
|
-
termination_config:
|
|
74
|
-
system_message_config:
|
|
76
|
+
code_execution_config: CodeExecutionConfig | None = None,
|
|
77
|
+
termination_config: TerminationConfig | None = None,
|
|
78
|
+
system_message_config: SystemMessageConfig | None = None,
|
|
75
79
|
) -> GroupManagerExtras:
|
|
76
80
|
"""Process group manager and return extras.
|
|
77
81
|
|
|
@@ -133,6 +137,8 @@ class GroupManagerProcessor:
|
|
|
133
137
|
|
|
134
138
|
def _determine_strategy(self) -> GroupManagerStrategy:
|
|
135
139
|
"""Determine which strategy to use for this group manager."""
|
|
140
|
+
if self.strategy is not None:
|
|
141
|
+
return self.strategy
|
|
136
142
|
if self.is_pattern_strategy(self.initial_chats):
|
|
137
143
|
# Use AG2 Pattern system
|
|
138
144
|
return GroupManagerStrategy.PATTERN
|
|
@@ -145,10 +151,11 @@ class GroupManagerProcessor:
|
|
|
145
151
|
extras.pattern_class_name = self._get_pattern_class_name()
|
|
146
152
|
|
|
147
153
|
# Add required imports
|
|
148
|
-
|
|
154
|
+
pattern_import = (
|
|
149
155
|
"from autogen.agentchat.group.patterns import "
|
|
150
156
|
f"{extras.pattern_class_name}"
|
|
151
157
|
)
|
|
158
|
+
extras.pattern_imports.add(pattern_import)
|
|
152
159
|
|
|
153
160
|
# Get user agent if applicable
|
|
154
161
|
user_agent = None
|
|
@@ -222,7 +229,7 @@ class GroupManagerProcessor:
|
|
|
222
229
|
return pattern_map.get(selection_method, "AutoPattern")
|
|
223
230
|
|
|
224
231
|
def _generate_pattern_definition(
|
|
225
|
-
self, pattern_class: str, user_agent:
|
|
232
|
+
self, pattern_class: str, user_agent: WaldiezAgent | None
|
|
226
233
|
) -> str:
|
|
227
234
|
"""Generate the pattern definition string."""
|
|
228
235
|
if not isinstance(self.agent, WaldiezGroupManager):
|
|
@@ -252,9 +259,14 @@ class GroupManagerProcessor:
|
|
|
252
259
|
cache_seed=self.cache_seed,
|
|
253
260
|
as_dict=True,
|
|
254
261
|
)
|
|
255
|
-
|
|
256
|
-
|
|
262
|
+
manager_name = self.agent_names[self.agent.id]
|
|
263
|
+
pattern_line = (
|
|
264
|
+
" group_manager_args={\n"
|
|
265
|
+
f"{llm_config_arg}"
|
|
266
|
+
f' "name": "{manager_name}",\n'
|
|
267
|
+
" },"
|
|
257
268
|
)
|
|
269
|
+
pattern_lines.append(pattern_line)
|
|
258
270
|
|
|
259
271
|
# Add context variables if present
|
|
260
272
|
if self.agent.data.context_variables:
|
|
@@ -335,7 +347,7 @@ class GroupManagerProcessor:
|
|
|
335
347
|
|
|
336
348
|
def _generate_speakers_configuration(
|
|
337
349
|
self,
|
|
338
|
-
) -> tuple[list[str],
|
|
350
|
+
) -> tuple[list[str], str | None]:
|
|
339
351
|
"""Generate speakers configuration for traditional group chat."""
|
|
340
352
|
if not isinstance(self.agent, WaldiezGroupManager):
|
|
341
353
|
return [], None
|
|
@@ -346,10 +358,11 @@ class GroupManagerProcessor:
|
|
|
346
358
|
|
|
347
359
|
# Max retries
|
|
348
360
|
if speakers.max_retries_for_selecting is not None:
|
|
349
|
-
|
|
361
|
+
config_line = (
|
|
350
362
|
" max_retries_for_selecting_speaker="
|
|
351
363
|
f"{speakers.max_retries_for_selecting},"
|
|
352
364
|
)
|
|
365
|
+
config_lines.append(config_line)
|
|
353
366
|
|
|
354
367
|
# Selection method
|
|
355
368
|
if speakers.selection_method != "custom":
|
|
@@ -390,7 +403,7 @@ class GroupManagerProcessor:
|
|
|
390
403
|
|
|
391
404
|
if isinstance(allow_repeat, bool):
|
|
392
405
|
lines.append(f" allow_repeat_speaker={allow_repeat},")
|
|
393
|
-
|
|
406
|
+
elif allow_repeat is not None:
|
|
394
407
|
# List of agent names
|
|
395
408
|
agent_names = ", ".join(
|
|
396
409
|
self.agent_names[agent_id] for agent_id in allow_repeat
|
|
@@ -421,15 +434,14 @@ class GroupManagerProcessor:
|
|
|
421
434
|
# Serialize transitions
|
|
422
435
|
transitions_str = self.serializer(transitions_dict, tabs=1)
|
|
423
436
|
transitions_str = transitions_str.replace('"', "").replace("'", "")
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
[
|
|
427
|
-
" allowed_or_disallowed_speaker_transitions="
|
|
428
|
-
f"{transitions_str},",
|
|
429
|
-
' speaker_transitions_type="'
|
|
430
|
-
f'"{self.agent.data.speakers.transitions_type}",',
|
|
431
|
-
]
|
|
437
|
+
allowed_or_disallowed_line = (
|
|
438
|
+
f" allowed_or_disallowed_speaker_transitions={transitions_str},"
|
|
432
439
|
)
|
|
440
|
+
transition_type_line = (
|
|
441
|
+
' speaker_transitions_type="'
|
|
442
|
+
f'"{self.agent.data.speakers.transitions_type}",'
|
|
443
|
+
)
|
|
444
|
+
lines.extend([allowed_or_disallowed_line, transition_type_line])
|
|
433
445
|
|
|
434
446
|
return lines
|
|
435
447
|
|
|
@@ -445,6 +457,7 @@ class GroupManagerProcessor:
|
|
|
445
457
|
|
|
446
458
|
return self._get_transition_target(self.agent.data.after_work)
|
|
447
459
|
|
|
460
|
+
# noinspection PyTypeHints
|
|
448
461
|
def _get_transition_target(
|
|
449
462
|
self, target: WaldiezTransitionTarget
|
|
450
463
|
) -> tuple[str, str]:
|
|
@@ -470,8 +483,8 @@ class GroupManagerProcessor:
|
|
|
470
483
|
),
|
|
471
484
|
"GroupManagerTarget": (
|
|
472
485
|
"GroupManagerTarget()",
|
|
473
|
-
|
|
474
|
-
"import GroupManagerTarget",
|
|
486
|
+
# pylint: disable=line-too-long
|
|
487
|
+
f"{import_prefix}.targets.group_manager_target import GroupManagerTarget", # noqa: E501
|
|
475
488
|
),
|
|
476
489
|
}
|
|
477
490
|
|
|
@@ -496,10 +509,13 @@ class GroupManagerProcessor:
|
|
|
496
509
|
for agent in self.group_chat_members
|
|
497
510
|
]
|
|
498
511
|
target_names_str = ", ".join(target_names)
|
|
512
|
+
import_line = (
|
|
513
|
+
f"{import_prefix}.targets.transition_target "
|
|
514
|
+
"import RandomAgentTarget"
|
|
515
|
+
)
|
|
499
516
|
return (
|
|
500
517
|
f"RandomAgentTarget(agents=[{target_names_str}])",
|
|
501
|
-
|
|
502
|
-
"import RandomAgentTarget",
|
|
518
|
+
import_line,
|
|
503
519
|
)
|
|
504
520
|
|
|
505
521
|
return "", ""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# pylint: disable=no-self-use,too-few-public-methods
|
|
4
|
+
# pyright: reportUninitializedInstanceVariable=false
|
|
4
5
|
"""Group member agent configuration processor."""
|
|
5
6
|
|
|
6
7
|
from dataclasses import dataclass, field
|
|
@@ -26,10 +27,10 @@ class GroupMemberProcessorResult:
|
|
|
26
27
|
before_agent: str = ""
|
|
27
28
|
after_agent: str = ""
|
|
28
29
|
extra_arguments: list[InstanceArgument] = field(
|
|
29
|
-
default_factory=list
|
|
30
|
+
default_factory=list,
|
|
30
31
|
)
|
|
31
32
|
extra_imports: set[ImportStatement] = field(
|
|
32
|
-
default_factory=set
|
|
33
|
+
default_factory=set,
|
|
33
34
|
)
|
|
34
35
|
|
|
35
36
|
|
|
@@ -108,10 +109,10 @@ class GroupMemberAgentProcessor:
|
|
|
108
109
|
tab = " "
|
|
109
110
|
arg_string = "["
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
arg_content = self._process_update_functions()
|
|
112
113
|
|
|
113
|
-
if
|
|
114
|
-
arg_string += f"{
|
|
114
|
+
if arg_content:
|
|
115
|
+
arg_string += f"{arg_content}\n{tab}"
|
|
115
116
|
self.result.extra_imports.add(
|
|
116
117
|
ImportStatement("from autogen import UpdateSystemMessage")
|
|
117
118
|
)
|
|
@@ -27,7 +27,7 @@ class AfterWorkResult:
|
|
|
27
27
|
|
|
28
28
|
content: str = ""
|
|
29
29
|
before_content: str = ""
|
|
30
|
-
extra_imports: set[str] = field(default_factory=set
|
|
30
|
+
extra_imports: set[str] = field(default_factory=set)
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class AfterWorkProcessor:
|
|
@@ -49,6 +49,7 @@ class AfterWorkProcessor:
|
|
|
49
49
|
self.all_chats = all_chats
|
|
50
50
|
self.serializer = serializer
|
|
51
51
|
|
|
52
|
+
# noinspection PyTypeHints
|
|
52
53
|
def process(self, after_work: WaldiezTransitionTarget) -> AfterWorkResult:
|
|
53
54
|
"""Process after-work configuration.
|
|
54
55
|
|
|
@@ -14,7 +14,7 @@ class TransitionAvailableResult:
|
|
|
14
14
|
"""Result from processing transition availability."""
|
|
15
15
|
|
|
16
16
|
content: str = ""
|
|
17
|
-
extra_imports: set[str] = field(default_factory=set
|
|
17
|
+
extra_imports: set[str] = field(default_factory=set)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class TransitionAvailableProcessor:
|
|
@@ -69,6 +69,7 @@ class TransitionAvailableProcessor:
|
|
|
69
69
|
)
|
|
70
70
|
result.extra_imports.add(f"{import_prefix}ContextExpression")
|
|
71
71
|
return result
|
|
72
|
+
# noinspection PyUnreachableCode
|
|
72
73
|
raise ValueError(
|
|
73
74
|
f"Unsupported transition availability type: {available.type}"
|
|
74
75
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
# pylint: disable=too-few-public-methods
|
|
4
|
+
# pyright: reportUnnecessaryIsInstance=false,reportUnreachable=false
|
|
4
5
|
"""Handoff condition processing for Waldiez agents."""
|
|
5
6
|
|
|
6
7
|
from dataclasses import dataclass, field
|
|
@@ -30,7 +31,7 @@ class ConditionResult:
|
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
33
|
content: str = ""
|
|
33
|
-
extra_imports: set[str] = field(default_factory=set
|
|
34
|
+
extra_imports: set[str] = field(default_factory=set)
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
class ConditionProcessor:
|
|
@@ -82,7 +83,7 @@ class ConditionProcessor:
|
|
|
82
83
|
elif isinstance(
|
|
83
84
|
condition,
|
|
84
85
|
WaldiezExpressionContextCondition,
|
|
85
|
-
):
|
|
86
|
+
):
|
|
86
87
|
self._process_expression_context_condition(condition)
|
|
87
88
|
else:
|
|
88
89
|
raise ValueError(f"Unsupported condition type: {type(condition)}")
|
|
@@ -35,7 +35,7 @@ class HandoffResult:
|
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
37
|
after_agent: str = ""
|
|
38
|
-
extra_imports: set[str] = field(default_factory=set
|
|
38
|
+
extra_imports: set[str] = field(default_factory=set)
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
class HandoffProcessor:
|
|
@@ -146,6 +146,7 @@ class HandoffProcessor:
|
|
|
146
146
|
reg_string += ")"
|
|
147
147
|
return reg_string
|
|
148
148
|
|
|
149
|
+
# noinspection PyTypeHints
|
|
149
150
|
def _process_after_work(
|
|
150
151
|
self, after_work: WaldiezTransitionTarget
|
|
151
152
|
) -> TargetResult:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"""Transition target processor for Waldiez agents."""
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
|
-
from typing import Callable
|
|
7
|
+
from typing import Callable
|
|
8
8
|
|
|
9
9
|
from waldiez.exporting.chats.utils.nested import get_nested_chat_queue
|
|
10
10
|
from waldiez.models import (
|
|
@@ -33,9 +33,10 @@ class TargetResult:
|
|
|
33
33
|
|
|
34
34
|
content: str = ""
|
|
35
35
|
before_content: str = ""
|
|
36
|
-
extra_imports:
|
|
36
|
+
extra_imports: set[str] = field(default_factory=set)
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
# noinspection PyTypeHints
|
|
39
40
|
class TransitionTargetProcessor:
|
|
40
41
|
"""Processor for transition targets."""
|
|
41
42
|
|
|
@@ -127,10 +128,11 @@ class TransitionTargetProcessor:
|
|
|
127
128
|
) -> str:
|
|
128
129
|
"""Process random agent target."""
|
|
129
130
|
if not isinstance(target, WaldiezRandomAgentTarget):
|
|
130
|
-
|
|
131
|
+
msg = (
|
|
131
132
|
"Expected WaldiezRandomAgentTarget"
|
|
132
133
|
" for random agent target processing."
|
|
133
134
|
)
|
|
135
|
+
raise ValueError(msg)
|
|
134
136
|
agent_vars = [self.agent_names[agent_id] for agent_id in target.value]
|
|
135
137
|
agents_str = ", ".join(agent_vars)
|
|
136
138
|
return f"RandomAgentTarget([{agents_str}])"
|
|
@@ -140,10 +142,11 @@ class TransitionTargetProcessor:
|
|
|
140
142
|
) -> str:
|
|
141
143
|
"""Process group chat target."""
|
|
142
144
|
if not isinstance(target, WaldiezGroupOrNestedTarget):
|
|
143
|
-
|
|
145
|
+
msg = (
|
|
144
146
|
"Expected WaldiezGroupOrNestedTarget for group chat target "
|
|
145
147
|
"processing."
|
|
146
148
|
)
|
|
149
|
+
raise ValueError(msg)
|
|
147
150
|
chat_name = self.chat_names[target.value[0]]
|
|
148
151
|
return f"GroupChatTarget({chat_name})"
|
|
149
152
|
|