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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pyright: reportArgumentType=false,reportIncompatibleVariableOverride=false
|
|
5
|
+
|
|
3
6
|
"""User proxy agent model."""
|
|
4
7
|
|
|
5
8
|
from pydantic import Field
|
|
@@ -24,7 +27,7 @@ class WaldiezUserProxy(WaldiezAgent):
|
|
|
24
27
|
The user proxy agent's data
|
|
25
28
|
"""
|
|
26
29
|
|
|
27
|
-
agent_type: Annotated[
|
|
30
|
+
agent_type: Annotated[
|
|
28
31
|
Literal["user", "user_proxy"],
|
|
29
32
|
Field(
|
|
30
33
|
"user_proxy",
|
|
@@ -37,11 +40,11 @@ class WaldiezUserProxy(WaldiezAgent):
|
|
|
37
40
|
alias="agentType",
|
|
38
41
|
),
|
|
39
42
|
]
|
|
40
|
-
data: Annotated[
|
|
43
|
+
data: Annotated[
|
|
41
44
|
WaldiezUserProxyData,
|
|
42
45
|
Field(
|
|
43
46
|
title="Data",
|
|
44
47
|
description="The user proxy agent's data",
|
|
45
|
-
default_factory=WaldiezUserProxyData,
|
|
48
|
+
default_factory=WaldiezUserProxyData,
|
|
46
49
|
),
|
|
47
50
|
]
|
waldiez/models/chat/chat.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pyright: reportDeprecated=false,reportUnknownMemberType=false
|
|
5
|
+
# pyright: reportAttributeAccessIssue=false,reportUnknownVariableType=false
|
|
6
|
+
|
|
3
7
|
"""Waldiez chat model."""
|
|
4
8
|
|
|
5
|
-
from typing import Any, Optional
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Optional
|
|
6
10
|
|
|
7
11
|
from pydantic import Field, model_validator
|
|
8
12
|
from typing_extensions import Annotated, Literal, Self
|
|
9
13
|
|
|
10
|
-
from ..agents import WaldiezAgent, WaldiezRagUserProxy
|
|
11
14
|
from ..common import (
|
|
12
15
|
WaldiezAgentTarget,
|
|
13
16
|
WaldiezBase,
|
|
@@ -34,6 +37,9 @@ from .chat_nested import (
|
|
|
34
37
|
WaldiezChatNested,
|
|
35
38
|
)
|
|
36
39
|
|
|
40
|
+
if TYPE_CHECKING:
|
|
41
|
+
from ..agents import WaldiezAgent
|
|
42
|
+
|
|
37
43
|
WaldiezChatType = Literal["chat", "nested", "group", "hidden"]
|
|
38
44
|
"""Possible chat types: "chat", "nested", "group", "hidden"."""
|
|
39
45
|
|
|
@@ -61,7 +67,7 @@ class WaldiezChat(WaldiezBase):
|
|
|
61
67
|
The nested chat message/reply if any.
|
|
62
68
|
message : WaldiezChatMessage
|
|
63
69
|
The chat message.
|
|
64
|
-
message_content :
|
|
70
|
+
message_content : str | None
|
|
65
71
|
The chat message content if any. If method, the method's body.
|
|
66
72
|
|
|
67
73
|
Functions
|
|
@@ -146,12 +152,12 @@ class WaldiezChat(WaldiezBase):
|
|
|
146
152
|
return self.data.message
|
|
147
153
|
|
|
148
154
|
@property
|
|
149
|
-
def message_content(self) ->
|
|
155
|
+
def message_content(self) -> str | None:
|
|
150
156
|
"""Get the message content."""
|
|
151
157
|
return self.data.message_content
|
|
152
158
|
|
|
153
159
|
@property
|
|
154
|
-
def max_turns(self) ->
|
|
160
|
+
def max_turns(self) -> int | None:
|
|
155
161
|
"""Get the max rounds for the chat."""
|
|
156
162
|
return self.data.max_turns
|
|
157
163
|
|
|
@@ -227,8 +233,8 @@ class WaldiezChat(WaldiezBase):
|
|
|
227
233
|
|
|
228
234
|
def get_message_function(
|
|
229
235
|
self,
|
|
230
|
-
name_prefix:
|
|
231
|
-
name_suffix:
|
|
236
|
+
name_prefix: str | None = None,
|
|
237
|
+
name_suffix: str | None = None,
|
|
232
238
|
is_rag: bool = False,
|
|
233
239
|
) -> tuple[str, str]:
|
|
234
240
|
"""Get the message function.
|
|
@@ -281,10 +287,10 @@ class WaldiezChat(WaldiezBase):
|
|
|
281
287
|
|
|
282
288
|
@staticmethod
|
|
283
289
|
def _get_nested_chat_function(
|
|
284
|
-
content:
|
|
290
|
+
content: str | None,
|
|
285
291
|
function_name_base: str,
|
|
286
|
-
name_prefix:
|
|
287
|
-
name_suffix:
|
|
292
|
+
name_prefix: str | None = None,
|
|
293
|
+
name_suffix: str | None = None,
|
|
288
294
|
) -> tuple[str, str]:
|
|
289
295
|
"""Get the nested chat function.
|
|
290
296
|
|
|
@@ -323,16 +329,16 @@ class WaldiezChat(WaldiezBase):
|
|
|
323
329
|
|
|
324
330
|
def get_nested_chat_message_function(
|
|
325
331
|
self,
|
|
326
|
-
name_prefix:
|
|
327
|
-
name_suffix:
|
|
332
|
+
name_prefix: str | None = None,
|
|
333
|
+
name_suffix: str | None = None,
|
|
328
334
|
) -> tuple[str, str]:
|
|
329
335
|
"""Get the nested chat message function.
|
|
330
336
|
|
|
331
337
|
Parameters
|
|
332
338
|
----------
|
|
333
|
-
name_prefix : str
|
|
339
|
+
name_prefix : str | None
|
|
334
340
|
The function name prefix.
|
|
335
|
-
name_suffix : str
|
|
341
|
+
name_suffix : str | None
|
|
336
342
|
The function name suffix.
|
|
337
343
|
|
|
338
344
|
Returns
|
|
@@ -358,16 +364,16 @@ class WaldiezChat(WaldiezBase):
|
|
|
358
364
|
|
|
359
365
|
def get_nested_chat_reply_function(
|
|
360
366
|
self,
|
|
361
|
-
name_prefix:
|
|
362
|
-
name_suffix:
|
|
367
|
+
name_prefix: str | None = None,
|
|
368
|
+
name_suffix: str | None = None,
|
|
363
369
|
) -> tuple[str, str]:
|
|
364
370
|
"""Get the nested chat reply function.
|
|
365
371
|
|
|
366
372
|
Parameters
|
|
367
373
|
----------
|
|
368
|
-
name_prefix : str
|
|
374
|
+
name_prefix : str | None
|
|
369
375
|
The function name prefix.
|
|
370
|
-
name_suffix : str
|
|
376
|
+
name_suffix : str | None
|
|
371
377
|
The function name suffix.
|
|
372
378
|
|
|
373
379
|
Returns
|
|
@@ -394,7 +400,7 @@ class WaldiezChat(WaldiezBase):
|
|
|
394
400
|
def get_chat_args(
|
|
395
401
|
self,
|
|
396
402
|
for_queue: bool,
|
|
397
|
-
sender: Optional[WaldiezAgent] = None,
|
|
403
|
+
sender: Optional["WaldiezAgent"] = None,
|
|
398
404
|
) -> dict[str, Any]:
|
|
399
405
|
"""Get the chat arguments to use in autogen.
|
|
400
406
|
|
|
@@ -412,9 +418,10 @@ class WaldiezChat(WaldiezBase):
|
|
|
412
418
|
"""
|
|
413
419
|
args_dict = self.data.get_chat_args(for_queue)
|
|
414
420
|
if (
|
|
415
|
-
|
|
421
|
+
sender
|
|
416
422
|
and sender.is_rag_user
|
|
417
423
|
and self.message.type == "rag_message_generator"
|
|
424
|
+
and hasattr(sender.data, "retrieve_config")
|
|
418
425
|
):
|
|
419
426
|
# check for n_results in agent data, to add in context
|
|
420
427
|
n_results = sender.data.retrieve_config.n_results
|
waldiez/models/chat/chat_data.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pyright: reportArgumentType=false
|
|
5
|
+
|
|
3
6
|
"""Chat data model."""
|
|
4
7
|
|
|
5
|
-
from typing import Any
|
|
8
|
+
from typing import Any
|
|
6
9
|
|
|
7
10
|
from pydantic import Field, field_validator, model_validator
|
|
8
11
|
from typing_extensions import Annotated, Self
|
|
@@ -71,7 +74,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
71
74
|
title="Description",
|
|
72
75
|
description="The description of the chat.",
|
|
73
76
|
),
|
|
74
|
-
]
|
|
77
|
+
]
|
|
75
78
|
position: Annotated[
|
|
76
79
|
int,
|
|
77
80
|
Field(
|
|
@@ -79,7 +82,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
79
82
|
title="Position",
|
|
80
83
|
description="The position of the chat in the flow (Ignored).",
|
|
81
84
|
),
|
|
82
|
-
]
|
|
85
|
+
]
|
|
83
86
|
order: Annotated[
|
|
84
87
|
int,
|
|
85
88
|
Field(
|
|
@@ -87,7 +90,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
87
90
|
title="Order",
|
|
88
91
|
description="The order of the chat in the flow.",
|
|
89
92
|
),
|
|
90
|
-
]
|
|
93
|
+
]
|
|
91
94
|
clear_history: Annotated[
|
|
92
95
|
bool,
|
|
93
96
|
Field(
|
|
@@ -96,9 +99,9 @@ class WaldiezChatData(WaldiezBase):
|
|
|
96
99
|
title="Clear History",
|
|
97
100
|
description="Whether to clear the chat history.",
|
|
98
101
|
),
|
|
99
|
-
]
|
|
102
|
+
]
|
|
100
103
|
message: Annotated[
|
|
101
|
-
|
|
104
|
+
str | WaldiezChatMessage,
|
|
102
105
|
Field(
|
|
103
106
|
title="Message",
|
|
104
107
|
description="The message of the chat.",
|
|
@@ -123,14 +126,14 @@ class WaldiezChatData(WaldiezBase):
|
|
|
123
126
|
),
|
|
124
127
|
]
|
|
125
128
|
max_turns: Annotated[
|
|
126
|
-
|
|
129
|
+
int | None,
|
|
127
130
|
Field(
|
|
128
131
|
default=None,
|
|
129
132
|
alias="maxTurns",
|
|
130
133
|
title="Max Turns",
|
|
131
134
|
description="The maximum number of turns for the chat.",
|
|
132
135
|
),
|
|
133
|
-
]
|
|
136
|
+
]
|
|
134
137
|
prerequisites: Annotated[
|
|
135
138
|
list[str],
|
|
136
139
|
Field(
|
|
@@ -138,7 +141,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
138
141
|
description="The prerequisites (chat ids) for the chat (if async).",
|
|
139
142
|
default_factory=list,
|
|
140
143
|
),
|
|
141
|
-
]
|
|
144
|
+
]
|
|
142
145
|
silent: Annotated[
|
|
143
146
|
bool,
|
|
144
147
|
Field(
|
|
@@ -146,25 +149,25 @@ class WaldiezChatData(WaldiezBase):
|
|
|
146
149
|
title="Silent",
|
|
147
150
|
description="Whether to run the chat silently.",
|
|
148
151
|
),
|
|
149
|
-
]
|
|
152
|
+
]
|
|
150
153
|
real_source: Annotated[
|
|
151
|
-
|
|
154
|
+
str | None,
|
|
152
155
|
Field(
|
|
153
156
|
default=None,
|
|
154
157
|
alias="realSource",
|
|
155
158
|
title="Real Source",
|
|
156
159
|
description="The real source of the chat (overrides the source).",
|
|
157
160
|
),
|
|
158
|
-
]
|
|
161
|
+
]
|
|
159
162
|
real_target: Annotated[
|
|
160
|
-
|
|
163
|
+
str | None,
|
|
161
164
|
Field(
|
|
162
165
|
default=None,
|
|
163
166
|
alias="realTarget",
|
|
164
167
|
title="Real Target",
|
|
165
168
|
description="The real target of the chat (overrides the target).",
|
|
166
169
|
),
|
|
167
|
-
]
|
|
170
|
+
]
|
|
168
171
|
source_type: Annotated[
|
|
169
172
|
WaldiezAgentType,
|
|
170
173
|
Field(
|
|
@@ -201,7 +204,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
201
204
|
),
|
|
202
205
|
]
|
|
203
206
|
after_work: Annotated[
|
|
204
|
-
|
|
207
|
+
WaldiezHandoffTransition | None,
|
|
205
208
|
Field(
|
|
206
209
|
None,
|
|
207
210
|
title="After Work",
|
|
@@ -211,13 +214,13 @@ class WaldiezChatData(WaldiezBase):
|
|
|
211
214
|
),
|
|
212
215
|
alias="afterWork",
|
|
213
216
|
),
|
|
214
|
-
]
|
|
215
|
-
_message_content:
|
|
217
|
+
]
|
|
218
|
+
_message_content: str | None = None
|
|
216
219
|
_chat_id: int = 0
|
|
217
220
|
_prerequisites: list[int] = []
|
|
218
221
|
|
|
219
222
|
@property
|
|
220
|
-
def message_content(self) ->
|
|
223
|
+
def message_content(self) -> str | None:
|
|
221
224
|
"""Get the message content."""
|
|
222
225
|
return self._message_content
|
|
223
226
|
|
|
@@ -334,7 +337,7 @@ class WaldiezChatData(WaldiezBase):
|
|
|
334
337
|
return value
|
|
335
338
|
|
|
336
339
|
@property
|
|
337
|
-
def summary_args(self) ->
|
|
340
|
+
def summary_args(self) -> dict[str, Any] | None:
|
|
338
341
|
"""Get the summary args."""
|
|
339
342
|
if self.summary.method not in (
|
|
340
343
|
"reflection_with_llm",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Waldiez Message Model."""
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from pydantic import Field, model_validator
|
|
8
8
|
from typing_extensions import Annotated, Literal, Self
|
|
@@ -72,7 +72,7 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
72
72
|
"the `sender.message_generator` method will be used."
|
|
73
73
|
),
|
|
74
74
|
),
|
|
75
|
-
]
|
|
75
|
+
]
|
|
76
76
|
use_carryover: Annotated[
|
|
77
77
|
bool,
|
|
78
78
|
Field(
|
|
@@ -80,15 +80,15 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
80
80
|
title="Use Carryover",
|
|
81
81
|
description="Use the carryover from the context.",
|
|
82
82
|
),
|
|
83
|
-
]
|
|
83
|
+
]
|
|
84
84
|
content: Annotated[
|
|
85
|
-
|
|
85
|
+
str | None,
|
|
86
86
|
Field(
|
|
87
87
|
default=None,
|
|
88
88
|
title="Content",
|
|
89
89
|
description="The content of the message (string or method).",
|
|
90
90
|
),
|
|
91
|
-
]
|
|
91
|
+
]
|
|
92
92
|
context: Annotated[
|
|
93
93
|
dict[str, Any],
|
|
94
94
|
Field(
|
|
@@ -96,9 +96,9 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
96
96
|
title="Context",
|
|
97
97
|
description="Extra context of the message.",
|
|
98
98
|
),
|
|
99
|
-
]
|
|
99
|
+
]
|
|
100
100
|
|
|
101
|
-
_content_body:
|
|
101
|
+
_content_body: str | None = None
|
|
102
102
|
|
|
103
103
|
def is_method(self) -> bool:
|
|
104
104
|
"""Check if the message is a method.
|
|
@@ -111,7 +111,7 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
111
111
|
return self.type in ("method", "rag_message_generator")
|
|
112
112
|
|
|
113
113
|
@property
|
|
114
|
-
def content_body(self) ->
|
|
114
|
+
def content_body(self) -> str | None:
|
|
115
115
|
"""Get the content body."""
|
|
116
116
|
return self._content_body
|
|
117
117
|
|
|
@@ -141,7 +141,7 @@ class WaldiezChatMessage(WaldiezBase):
|
|
|
141
141
|
ValueError
|
|
142
142
|
If the content is invalid.
|
|
143
143
|
"""
|
|
144
|
-
content:
|
|
144
|
+
content: str | None = None
|
|
145
145
|
if self.type == "none":
|
|
146
146
|
content = "None"
|
|
147
147
|
if self.type == "method":
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Nested chat model."""
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from pydantic import Field, field_validator, model_validator
|
|
8
8
|
from typing_extensions import Annotated, Self
|
|
@@ -36,32 +36,32 @@ class WaldiezChatNested(WaldiezBase):
|
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
message: Annotated[
|
|
39
|
-
|
|
39
|
+
WaldiezChatMessage | None,
|
|
40
40
|
Field(
|
|
41
41
|
default=None,
|
|
42
42
|
title="Message",
|
|
43
43
|
description="The message in a nested chat (sender -> recipient).",
|
|
44
44
|
),
|
|
45
|
-
]
|
|
45
|
+
]
|
|
46
46
|
reply: Annotated[
|
|
47
|
-
|
|
47
|
+
WaldiezChatMessage | None,
|
|
48
48
|
Field(
|
|
49
49
|
default=None,
|
|
50
50
|
title="Reply",
|
|
51
51
|
description="The reply in a nested chat (recipient -> sender).",
|
|
52
52
|
),
|
|
53
|
-
]
|
|
53
|
+
]
|
|
54
54
|
|
|
55
|
-
_message_content:
|
|
56
|
-
_reply_content:
|
|
55
|
+
_message_content: str | None = None
|
|
56
|
+
_reply_content: str | None = None
|
|
57
57
|
|
|
58
58
|
@property
|
|
59
|
-
def message_content(self) ->
|
|
59
|
+
def message_content(self) -> str | None:
|
|
60
60
|
"""Get the message content."""
|
|
61
61
|
return self._message_content
|
|
62
62
|
|
|
63
63
|
@property
|
|
64
|
-
def reply_content(self) ->
|
|
64
|
+
def reply_content(self) -> str | None:
|
|
65
65
|
"""Get the reply content."""
|
|
66
66
|
return self._reply_content
|
|
67
67
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Waldiez chat summary options."""
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from pydantic import (
|
|
8
8
|
Field,
|
|
@@ -37,13 +37,13 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
method: Annotated[
|
|
40
|
-
|
|
40
|
+
WaldiezChatSummaryMethod | None,
|
|
41
41
|
Field(
|
|
42
42
|
default="last_msg",
|
|
43
43
|
title="Method",
|
|
44
44
|
description="The method to use for the LLM summary.",
|
|
45
45
|
),
|
|
46
|
-
]
|
|
46
|
+
]
|
|
47
47
|
prompt: Annotated[
|
|
48
48
|
str,
|
|
49
49
|
Field(
|
|
@@ -51,7 +51,7 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
51
51
|
title="Prompt",
|
|
52
52
|
description="The prompt for the LLM summary method.",
|
|
53
53
|
),
|
|
54
|
-
]
|
|
54
|
+
]
|
|
55
55
|
args: Annotated[
|
|
56
56
|
dict[str, str],
|
|
57
57
|
Field(
|
|
@@ -59,13 +59,13 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
59
59
|
description="The additional arguments for the LLM summary method.",
|
|
60
60
|
default_factory=dict,
|
|
61
61
|
),
|
|
62
|
-
]
|
|
62
|
+
]
|
|
63
63
|
|
|
64
64
|
# noinspection PyNestedDecorators
|
|
65
65
|
@field_validator("method", mode="before")
|
|
66
66
|
@classmethod
|
|
67
67
|
def validate_summary_method(
|
|
68
|
-
cls, value:
|
|
68
|
+
cls, value: WaldiezChatSummaryMethod | None
|
|
69
69
|
) -> WaldiezChatSummaryMethod | None:
|
|
70
70
|
"""Validate the summary method.
|
|
71
71
|
|
|
@@ -38,6 +38,7 @@ from .naming import (
|
|
|
38
38
|
MAX_VARIABLE_LENGTH,
|
|
39
39
|
get_valid_instance_name,
|
|
40
40
|
get_valid_python_variable_name,
|
|
41
|
+
safe_filename,
|
|
41
42
|
)
|
|
42
43
|
from .waldiez_version import get_waldiez_version
|
|
43
44
|
|
|
@@ -56,6 +57,7 @@ __all__ = [
|
|
|
56
57
|
"generate_function",
|
|
57
58
|
"now",
|
|
58
59
|
"parse_code_string",
|
|
60
|
+
"safe_filename",
|
|
59
61
|
"WaldiezDefaultCondition",
|
|
60
62
|
"WaldiezAgentTarget",
|
|
61
63
|
"WaldiezContextBasedCondition",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pyright: reportUnknownVariableType=false
|
|
3
5
|
"""Dictionary related utilities."""
|
|
4
6
|
|
|
5
7
|
import ast
|
|
6
8
|
import json
|
|
7
9
|
import re
|
|
8
|
-
from typing import Any
|
|
10
|
+
from typing import Any
|
|
9
11
|
|
|
10
12
|
BOOL_VALUES = {"true", "false"}
|
|
11
13
|
NULL_VALUES = {"none", "null", "nil", "undefined"}
|
|
@@ -21,7 +23,7 @@ def _strip_outer_quotes(value: str) -> str:
|
|
|
21
23
|
return value_stripped
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
def _detect_null_or_boolean(value: str) ->
|
|
26
|
+
def _detect_null_or_boolean(value: str) -> bool | str | None:
|
|
25
27
|
"""
|
|
26
28
|
Detect null values or booleans.
|
|
27
29
|
|
|
@@ -45,7 +47,7 @@ def _detect_null_or_boolean(value: str) -> Union[None, bool, str]:
|
|
|
45
47
|
return value
|
|
46
48
|
|
|
47
49
|
|
|
48
|
-
def _detect_numeric_type(value: str) ->
|
|
50
|
+
def _detect_numeric_type(value: str) -> int | float | str:
|
|
49
51
|
"""
|
|
50
52
|
Detect if string represents an integer or float.
|
|
51
53
|
|
|
@@ -72,7 +74,7 @@ def _detect_numeric_type(value: str) -> Union[int, float, str]:
|
|
|
72
74
|
|
|
73
75
|
def _detect_container_type(
|
|
74
76
|
value: str,
|
|
75
|
-
) ->
|
|
77
|
+
) -> dict[str, Any] | list[Any] | tuple[Any] | set[Any] | str:
|
|
76
78
|
"""
|
|
77
79
|
Detect if string represents a container type (dict, list, tuple, set).
|
|
78
80
|
|
|
@@ -97,7 +99,7 @@ def _detect_container_type(
|
|
|
97
99
|
try:
|
|
98
100
|
parsed = json.loads(value)
|
|
99
101
|
if isinstance(parsed, (dict, list)):
|
|
100
|
-
return parsed
|
|
102
|
+
return parsed
|
|
101
103
|
except (json.JSONDecodeError, TypeError):
|
|
102
104
|
pass
|
|
103
105
|
|
|
@@ -105,7 +107,7 @@ def _detect_container_type(
|
|
|
105
107
|
try:
|
|
106
108
|
parsed = ast.literal_eval(value)
|
|
107
109
|
if isinstance(parsed, (dict, list, tuple, set)):
|
|
108
|
-
return parsed
|
|
110
|
+
return parsed
|
|
109
111
|
except (ValueError, SyntaxError):
|
|
110
112
|
pass
|
|
111
113
|
|
waldiez/models/common/handoff.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
|
|
4
|
+
# pylint: disable=invalid-name
|
|
5
|
+
|
|
3
6
|
"""Waldiez Agent Handoff class."""
|
|
4
7
|
|
|
5
|
-
from typing import Any
|
|
8
|
+
from typing import Any
|
|
6
9
|
|
|
7
10
|
from pydantic import Field
|
|
8
11
|
from typing_extensions import Annotated, Literal
|
|
@@ -115,13 +118,13 @@ class WaldiezSimpleTarget(WaldiezBase):
|
|
|
115
118
|
Field(
|
|
116
119
|
"TerminateTarget", description="The type of the transition target."
|
|
117
120
|
),
|
|
118
|
-
]
|
|
121
|
+
]
|
|
119
122
|
value: Annotated[
|
|
120
123
|
list[str],
|
|
121
124
|
Field(
|
|
122
125
|
default_factory=list,
|
|
123
126
|
),
|
|
124
|
-
]
|
|
127
|
+
] # not actually used (just for consistency with other targets)
|
|
125
128
|
|
|
126
129
|
|
|
127
130
|
class WaldiezGroupOrNestedTarget(WaldiezBase):
|
|
@@ -157,12 +160,10 @@ class WaldiezGroupOrNestedTarget(WaldiezBase):
|
|
|
157
160
|
|
|
158
161
|
|
|
159
162
|
WaldiezTransitionTarget = Annotated[
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
WaldiezSimpleTarget,
|
|
165
|
-
],
|
|
163
|
+
WaldiezAgentTarget
|
|
164
|
+
| WaldiezRandomAgentTarget
|
|
165
|
+
| WaldiezGroupOrNestedTarget
|
|
166
|
+
| WaldiezSimpleTarget,
|
|
166
167
|
Field(discriminator="target_type"),
|
|
167
168
|
]
|
|
168
169
|
|
|
@@ -228,7 +229,7 @@ class WaldiezContextStrLLMCondition(WaldiezBase):
|
|
|
228
229
|
|
|
229
230
|
|
|
230
231
|
WaldiezLLMBasedCondition = Annotated[
|
|
231
|
-
|
|
232
|
+
WaldiezStringLLMCondition | WaldiezContextStrLLMCondition,
|
|
232
233
|
Field(discriminator="condition_type"),
|
|
233
234
|
]
|
|
234
235
|
|
|
@@ -293,15 +294,15 @@ class WaldiezExpressionContextCondition(WaldiezBase):
|
|
|
293
294
|
|
|
294
295
|
|
|
295
296
|
WaldiezContextBasedCondition = Annotated[
|
|
296
|
-
|
|
297
|
+
WaldiezStringContextCondition | WaldiezExpressionContextCondition,
|
|
297
298
|
Field(discriminator="condition_type"),
|
|
298
299
|
]
|
|
299
300
|
|
|
300
301
|
|
|
301
302
|
# Union type for just the condition types (without targets)
|
|
302
|
-
WaldiezHandoffCondition =
|
|
303
|
-
WaldiezLLMBasedCondition
|
|
304
|
-
|
|
303
|
+
WaldiezHandoffCondition = (
|
|
304
|
+
WaldiezLLMBasedCondition | WaldiezContextBasedCondition
|
|
305
|
+
)
|
|
305
306
|
|
|
306
307
|
|
|
307
308
|
# pylint: disable=too-few-public-methods
|
|
@@ -362,9 +363,9 @@ class WaldiezContextBasedTransition(WaldiezBase):
|
|
|
362
363
|
|
|
363
364
|
|
|
364
365
|
# Union type for complete transitions (condition + target)
|
|
365
|
-
WaldiezHandoffTransition =
|
|
366
|
-
WaldiezLLMBasedTransition
|
|
367
|
-
|
|
366
|
+
WaldiezHandoffTransition = (
|
|
367
|
+
WaldiezLLMBasedTransition | WaldiezContextBasedTransition
|
|
368
|
+
)
|
|
368
369
|
|
|
369
370
|
|
|
370
371
|
class WaldiezHandoff(WaldiezBase):
|