waldiez 0.6.0__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 +18 -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 +9 -10
- 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 +34 -23
- waldiez/exporting/agent/extras/group_member_extras.py +6 -5
- waldiez/exporting/agent/extras/handoffs/after_work.py +1 -1
- waldiez/exporting/agent/extras/handoffs/available.py +1 -1
- waldiez/exporting/agent/extras/handoffs/condition.py +3 -2
- waldiez/exporting/agent/extras/handoffs/handoff.py +1 -1
- waldiez/exporting/agent/extras/handoffs/target.py +6 -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/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/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 +2 -2
- waldiez/exporting/core/protocols.py +6 -5
- waldiez/exporting/core/result.py +25 -28
- waldiez/exporting/core/types.py +10 -10
- waldiez/exporting/core/utils/llm_config.py +2 -2
- waldiez/exporting/core/validation.py +10 -11
- waldiez/exporting/flow/execution_generator.py +98 -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 +5 -5
- waldiez/exporting/flow/utils/importing.py +6 -7
- waldiez/exporting/flow/utils/linting.py +25 -9
- waldiez/exporting/flow/utils/logging.py +2 -2
- 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 +8 -4
- waldiez/io/_ws.py +10 -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 +52 -53
- waldiez/io/utils.py +3 -0
- waldiez/io/ws.py +5 -1
- waldiez/logger.py +16 -3
- waldiez/models/agents/__init__.py +3 -0
- waldiez/models/agents/agent/agent.py +23 -16
- 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 +27 -20
- waldiez/models/chat/chat_data.py +22 -19
- 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/dict_utils.py +8 -6
- waldiez/models/common/handoff.py +18 -17
- waldiez/models/common/method_utils.py +7 -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 +5 -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 +1 -0
- waldiez/models/tool/predefined/_google.py +1 -0
- waldiez/models/tool/predefined/_perplexity.py +1 -0
- waldiez/models/tool/predefined/_searxng.py +1 -0
- waldiez/models/tool/predefined/_tavily.py +1 -0
- waldiez/models/tool/predefined/_wikipedia.py +1 -0
- 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 +117 -264
- 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 +22 -25
- waldiez/running/step_by_step/breakpoints_mixin.py +192 -60
- waldiez/running/step_by_step/command_handler.py +3 -0
- waldiez/running/step_by_step/events_processor.py +194 -14
- waldiez/running/step_by_step/step_by_step_models.py +110 -43
- waldiez/running/step_by_step/step_by_step_runner.py +107 -57
- waldiez/running/subprocess_runner/__base__.py +9 -1
- waldiez/running/subprocess_runner/_async_runner.py +5 -3
- waldiez/running/subprocess_runner/_sync_runner.py +6 -2
- waldiez/running/subprocess_runner/runner.py +39 -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/_file_handler.py +18 -18
- waldiez/ws/_mock.py +2 -1
- waldiez/ws/cli.py +36 -12
- waldiez/ws/client_manager.py +35 -27
- waldiez/ws/errors.py +3 -0
- waldiez/ws/models.py +43 -52
- waldiez/ws/reloader.py +12 -4
- waldiez/ws/server.py +85 -55
- waldiez/ws/session_manager.py +8 -9
- waldiez/ws/session_stats.py +1 -1
- waldiez/ws/utils.py +4 -1
- {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/METADATA +82 -93
- waldiez-0.6.1.dist-info/RECORD +254 -0
- waldiez/running/post_run.py +0 -186
- waldiez/running/pre_run.py +0 -281
- waldiez/running/run_results.py +0 -14
- waldiez/running/utils.py +0 -625
- waldiez-0.6.0.dist-info/RECORD +0 -251
- {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/WHEEL +0 -0
- {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/entry_points.txt +0 -0
- {waldiez-0.6.0.dist-info → waldiez-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.6.0.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",
|
|
@@ -171,6 +181,7 @@ def run(
|
|
|
171
181
|
dot_env=env_file,
|
|
172
182
|
subprocess_mode=subprocess_mode,
|
|
173
183
|
waldiez_file=file,
|
|
184
|
+
breakpoints=breakpoints,
|
|
174
185
|
)
|
|
175
186
|
except FileNotFoundError as error:
|
|
176
187
|
typer.echo(f"File not found: {file}")
|
|
@@ -271,7 +282,7 @@ def check(
|
|
|
271
282
|
LOG.success("Waldiez flow seems valid.")
|
|
272
283
|
|
|
273
284
|
|
|
274
|
-
def _get_output_path(output:
|
|
285
|
+
def _get_output_path(output: Path | None, force: bool) -> Path | None:
|
|
275
286
|
if output is not None:
|
|
276
287
|
output = Path(output).resolve()
|
|
277
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.
|
|
@@ -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):
|
|
@@ -253,12 +260,13 @@ class GroupManagerProcessor:
|
|
|
253
260
|
as_dict=True,
|
|
254
261
|
)
|
|
255
262
|
manager_name = self.agent_names[self.agent.id]
|
|
256
|
-
|
|
263
|
+
pattern_line = (
|
|
257
264
|
" group_manager_args={\n"
|
|
258
265
|
f"{llm_config_arg}"
|
|
259
266
|
f' "name": "{manager_name}",\n'
|
|
260
267
|
" },"
|
|
261
268
|
)
|
|
269
|
+
pattern_lines.append(pattern_line)
|
|
262
270
|
|
|
263
271
|
# Add context variables if present
|
|
264
272
|
if self.agent.data.context_variables:
|
|
@@ -339,7 +347,7 @@ class GroupManagerProcessor:
|
|
|
339
347
|
|
|
340
348
|
def _generate_speakers_configuration(
|
|
341
349
|
self,
|
|
342
|
-
) -> tuple[list[str],
|
|
350
|
+
) -> tuple[list[str], str | None]:
|
|
343
351
|
"""Generate speakers configuration for traditional group chat."""
|
|
344
352
|
if not isinstance(self.agent, WaldiezGroupManager):
|
|
345
353
|
return [], None
|
|
@@ -350,10 +358,11 @@ class GroupManagerProcessor:
|
|
|
350
358
|
|
|
351
359
|
# Max retries
|
|
352
360
|
if speakers.max_retries_for_selecting is not None:
|
|
353
|
-
|
|
361
|
+
config_line = (
|
|
354
362
|
" max_retries_for_selecting_speaker="
|
|
355
363
|
f"{speakers.max_retries_for_selecting},"
|
|
356
364
|
)
|
|
365
|
+
config_lines.append(config_line)
|
|
357
366
|
|
|
358
367
|
# Selection method
|
|
359
368
|
if speakers.selection_method != "custom":
|
|
@@ -394,7 +403,7 @@ class GroupManagerProcessor:
|
|
|
394
403
|
|
|
395
404
|
if isinstance(allow_repeat, bool):
|
|
396
405
|
lines.append(f" allow_repeat_speaker={allow_repeat},")
|
|
397
|
-
|
|
406
|
+
elif allow_repeat is not None:
|
|
398
407
|
# List of agent names
|
|
399
408
|
agent_names = ", ".join(
|
|
400
409
|
self.agent_names[agent_id] for agent_id in allow_repeat
|
|
@@ -425,15 +434,14 @@ class GroupManagerProcessor:
|
|
|
425
434
|
# Serialize transitions
|
|
426
435
|
transitions_str = self.serializer(transitions_dict, tabs=1)
|
|
427
436
|
transitions_str = transitions_str.replace('"', "").replace("'", "")
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
[
|
|
431
|
-
" allowed_or_disallowed_speaker_transitions="
|
|
432
|
-
f"{transitions_str},",
|
|
433
|
-
' speaker_transitions_type="'
|
|
434
|
-
f'"{self.agent.data.speakers.transitions_type}",',
|
|
435
|
-
]
|
|
437
|
+
allowed_or_disallowed_line = (
|
|
438
|
+
f" allowed_or_disallowed_speaker_transitions={transitions_str},"
|
|
436
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])
|
|
437
445
|
|
|
438
446
|
return lines
|
|
439
447
|
|
|
@@ -475,8 +483,8 @@ class GroupManagerProcessor:
|
|
|
475
483
|
),
|
|
476
484
|
"GroupManagerTarget": (
|
|
477
485
|
"GroupManagerTarget()",
|
|
478
|
-
|
|
479
|
-
"import GroupManagerTarget",
|
|
486
|
+
# pylint: disable=line-too-long
|
|
487
|
+
f"{import_prefix}.targets.group_manager_target import GroupManagerTarget", # noqa: E501
|
|
480
488
|
),
|
|
481
489
|
}
|
|
482
490
|
|
|
@@ -501,10 +509,13 @@ class GroupManagerProcessor:
|
|
|
501
509
|
for agent in self.group_chat_members
|
|
502
510
|
]
|
|
503
511
|
target_names_str = ", ".join(target_names)
|
|
512
|
+
import_line = (
|
|
513
|
+
f"{import_prefix}.targets.transition_target "
|
|
514
|
+
"import RandomAgentTarget"
|
|
515
|
+
)
|
|
504
516
|
return (
|
|
505
517
|
f"RandomAgentTarget(agents=[{target_names_str}])",
|
|
506
|
-
|
|
507
|
-
"import RandomAgentTarget",
|
|
518
|
+
import_line,
|
|
508
519
|
)
|
|
509
520
|
|
|
510
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
|
)
|
|
@@ -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:
|
|
@@ -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)}")
|
|
@@ -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,7 +33,7 @@ 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
39
|
# noinspection PyTypeHints
|
|
@@ -128,10 +128,11 @@ class TransitionTargetProcessor:
|
|
|
128
128
|
) -> str:
|
|
129
129
|
"""Process random agent target."""
|
|
130
130
|
if not isinstance(target, WaldiezRandomAgentTarget):
|
|
131
|
-
|
|
131
|
+
msg = (
|
|
132
132
|
"Expected WaldiezRandomAgentTarget"
|
|
133
133
|
" for random agent target processing."
|
|
134
134
|
)
|
|
135
|
+
raise ValueError(msg)
|
|
135
136
|
agent_vars = [self.agent_names[agent_id] for agent_id in target.value]
|
|
136
137
|
agents_str = ", ".join(agent_vars)
|
|
137
138
|
return f"RandomAgentTarget([{agents_str}])"
|
|
@@ -141,10 +142,11 @@ class TransitionTargetProcessor:
|
|
|
141
142
|
) -> str:
|
|
142
143
|
"""Process group chat target."""
|
|
143
144
|
if not isinstance(target, WaldiezGroupOrNestedTarget):
|
|
144
|
-
|
|
145
|
+
msg = (
|
|
145
146
|
"Expected WaldiezGroupOrNestedTarget for group chat target "
|
|
146
147
|
"processing."
|
|
147
148
|
)
|
|
149
|
+
raise ValueError(msg)
|
|
148
150
|
chat_name = self.chat_names[target.value[0]]
|
|
149
151
|
return f"GroupChatTarget({chat_name})"
|
|
150
152
|
|