waldiez 0.4.6__py3-none-any.whl → 0.4.8__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 +5 -5
- waldiez/_version.py +1 -1
- waldiez/cli.py +112 -73
- waldiez/exporter.py +61 -19
- waldiez/exporting/__init__.py +25 -6
- waldiez/exporting/agent/__init__.py +7 -3
- waldiez/exporting/agent/code_execution.py +114 -0
- waldiez/exporting/agent/exporter.py +354 -0
- waldiez/exporting/agent/extras/__init__.py +15 -0
- waldiez/exporting/agent/extras/captain_agent_extras.py +315 -0
- waldiez/exporting/agent/extras/group/target.py +178 -0
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +500 -0
- waldiez/exporting/agent/extras/group_member_extras.py +181 -0
- waldiez/exporting/agent/extras/handoffs/__init__.py +19 -0
- waldiez/exporting/agent/extras/handoffs/after_work.py +78 -0
- waldiez/exporting/agent/extras/handoffs/available.py +74 -0
- waldiez/exporting/agent/extras/handoffs/condition.py +158 -0
- waldiez/exporting/agent/extras/handoffs/handoff.py +171 -0
- waldiez/exporting/agent/extras/handoffs/target.py +189 -0
- waldiez/exporting/agent/extras/rag/__init__.py +10 -0
- waldiez/exporting/agent/{utils/rag_user/chroma_utils.py → extras/rag/chroma_extras.py} +16 -15
- waldiez/exporting/agent/{utils/rag_user/mongo_utils.py → extras/rag/mongo_extras.py} +10 -10
- waldiez/exporting/agent/{utils/rag_user/pgvector_utils.py → extras/rag/pgvector_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/qdrant_utils.py → extras/rag/qdrant_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/vector_db.py → extras/rag/vector_db_extras.py} +59 -46
- waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +245 -0
- waldiez/exporting/agent/extras/reasoning_agent_extras.py +88 -0
- waldiez/exporting/agent/factory.py +95 -0
- waldiez/exporting/agent/processor.py +150 -0
- waldiez/exporting/agent/system_message.py +36 -0
- waldiez/exporting/agent/termination.py +50 -0
- waldiez/exporting/chats/__init__.py +7 -3
- waldiez/exporting/chats/exporter.py +97 -0
- waldiez/exporting/chats/factory.py +65 -0
- waldiez/exporting/chats/processor.py +226 -0
- waldiez/exporting/chats/utils/__init__.py +6 -5
- waldiez/exporting/chats/utils/common.py +11 -45
- waldiez/exporting/chats/utils/group.py +55 -0
- waldiez/exporting/chats/utils/nested.py +37 -52
- waldiez/exporting/chats/utils/sequential.py +72 -61
- waldiez/exporting/chats/utils/{single_chat.py → single.py} +48 -50
- waldiez/exporting/core/__init__.py +196 -0
- waldiez/exporting/core/constants.py +17 -0
- waldiez/exporting/core/content.py +69 -0
- waldiez/exporting/core/context.py +244 -0
- waldiez/exporting/core/enums.py +89 -0
- waldiez/exporting/core/errors.py +19 -0
- waldiez/exporting/core/exporter.py +390 -0
- waldiez/exporting/core/exporters.py +67 -0
- waldiez/exporting/core/extras/__init__.py +39 -0
- waldiez/exporting/core/extras/agent_extras/__init__.py +27 -0
- waldiez/exporting/core/extras/agent_extras/captain_extras.py +57 -0
- waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +102 -0
- waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +53 -0
- waldiez/exporting/core/extras/agent_extras/reasoning_extras.py +68 -0
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +263 -0
- waldiez/exporting/core/extras/base.py +241 -0
- waldiez/exporting/core/extras/chat_extras.py +118 -0
- waldiez/exporting/core/extras/flow_extras.py +70 -0
- waldiez/exporting/core/extras/model_extras.py +73 -0
- waldiez/exporting/core/extras/path_resolver.py +93 -0
- waldiez/exporting/core/extras/serializer.py +138 -0
- waldiez/exporting/core/extras/tool_extras.py +82 -0
- waldiez/exporting/core/protocols.py +259 -0
- waldiez/exporting/core/result.py +705 -0
- waldiez/exporting/core/types.py +329 -0
- waldiez/exporting/core/utils/__init__.py +11 -0
- waldiez/exporting/core/utils/comment.py +33 -0
- waldiez/exporting/core/utils/llm_config.py +117 -0
- waldiez/exporting/core/validation.py +96 -0
- waldiez/exporting/flow/__init__.py +6 -2
- waldiez/exporting/flow/execution_generator.py +193 -0
- waldiez/exporting/flow/exporter.py +107 -0
- waldiez/exporting/flow/factory.py +94 -0
- waldiez/exporting/flow/file_generator.py +214 -0
- waldiez/exporting/flow/merger.py +387 -0
- waldiez/exporting/flow/orchestrator.py +411 -0
- waldiez/exporting/flow/utils/__init__.py +9 -36
- waldiez/exporting/flow/utils/common.py +206 -0
- waldiez/exporting/flow/utils/importing.py +373 -0
- waldiez/exporting/flow/utils/linting.py +200 -0
- waldiez/exporting/flow/utils/{logging_utils.py → logging.py} +23 -9
- waldiez/exporting/models/__init__.py +3 -1
- waldiez/exporting/models/exporter.py +233 -0
- waldiez/exporting/models/factory.py +66 -0
- waldiez/exporting/models/processor.py +139 -0
- waldiez/exporting/tools/__init__.py +11 -0
- waldiez/exporting/tools/exporter.py +207 -0
- waldiez/exporting/tools/factory.py +57 -0
- waldiez/exporting/tools/processor.py +248 -0
- waldiez/exporting/tools/registration.py +133 -0
- waldiez/io/__init__.py +128 -0
- waldiez/io/_ws.py +199 -0
- waldiez/io/models/__init__.py +60 -0
- waldiez/io/models/base.py +66 -0
- waldiez/io/models/constants.py +78 -0
- waldiez/io/models/content/__init__.py +23 -0
- waldiez/io/models/content/audio.py +43 -0
- waldiez/io/models/content/base.py +45 -0
- waldiez/io/models/content/file.py +43 -0
- waldiez/io/models/content/image.py +96 -0
- waldiez/io/models/content/text.py +37 -0
- waldiez/io/models/content/video.py +43 -0
- waldiez/io/models/user_input.py +269 -0
- waldiez/io/models/user_response.py +215 -0
- waldiez/io/mqtt.py +681 -0
- waldiez/io/redis.py +782 -0
- waldiez/io/structured.py +419 -0
- waldiez/io/utils.py +184 -0
- waldiez/io/ws.py +298 -0
- waldiez/logger.py +481 -0
- waldiez/models/__init__.py +108 -51
- waldiez/models/agents/__init__.py +34 -70
- waldiez/models/agents/agent/__init__.py +10 -4
- waldiez/models/agents/agent/agent.py +466 -65
- waldiez/models/agents/agent/agent_data.py +119 -47
- waldiez/models/agents/agent/agent_type.py +13 -2
- waldiez/models/agents/agent/code_execution.py +12 -12
- waldiez/models/agents/agent/human_input_mode.py +8 -0
- waldiez/models/agents/agent/{linked_skill.py → linked_tool.py} +7 -7
- waldiez/models/agents/agent/nested_chat.py +35 -7
- waldiez/models/agents/agent/termination_message.py +30 -22
- waldiez/models/agents/{swarm_agent → agent}/update_system_message.py +22 -22
- waldiez/models/agents/agents.py +58 -63
- waldiez/models/agents/assistant/assistant.py +4 -4
- waldiez/models/agents/assistant/assistant_data.py +13 -1
- waldiez/models/agents/{captain_agent → captain}/captain_agent.py +5 -5
- waldiez/models/agents/{captain_agent → captain}/captain_agent_data.py +5 -5
- waldiez/models/agents/extra_requirements.py +11 -16
- waldiez/models/agents/group_manager/group_manager.py +103 -13
- waldiez/models/agents/group_manager/group_manager_data.py +36 -14
- waldiez/models/agents/group_manager/speakers.py +77 -24
- waldiez/models/agents/{rag_user → rag_user_proxy}/__init__.py +16 -16
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +64 -0
- waldiez/models/agents/{rag_user/rag_user_data.py → rag_user_proxy/rag_user_proxy_data.py} +6 -5
- waldiez/models/agents/{rag_user → rag_user_proxy}/retrieve_config.py +182 -114
- waldiez/models/agents/{rag_user → rag_user_proxy}/vector_db_config.py +13 -13
- waldiez/models/agents/reasoning/reasoning_agent.py +6 -6
- waldiez/models/agents/reasoning/reasoning_agent_data.py +110 -63
- waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +38 -10
- waldiez/models/agents/user_proxy/user_proxy.py +11 -7
- waldiez/models/agents/user_proxy/user_proxy_data.py +2 -2
- waldiez/models/chat/__init__.py +2 -1
- waldiez/models/chat/chat.py +166 -87
- waldiez/models/chat/chat_data.py +99 -136
- waldiez/models/chat/chat_message.py +33 -23
- waldiez/models/chat/chat_nested.py +31 -30
- waldiez/models/chat/chat_summary.py +10 -8
- waldiez/models/common/__init__.py +52 -2
- waldiez/models/common/ag2_version.py +1 -1
- waldiez/models/common/base.py +38 -7
- waldiez/models/common/dict_utils.py +42 -17
- waldiez/models/common/handoff.py +459 -0
- waldiez/models/common/id_generator.py +19 -0
- waldiez/models/common/method_utils.py +130 -68
- waldiez/{exporting/base/utils → models/common}/naming.py +38 -61
- waldiez/models/common/waldiez_version.py +37 -0
- waldiez/models/flow/__init__.py +9 -2
- waldiez/models/flow/connection.py +18 -0
- waldiez/models/flow/flow.py +311 -215
- waldiez/models/flow/flow_data.py +207 -40
- waldiez/models/flow/info.py +85 -0
- waldiez/models/flow/naming.py +131 -0
- waldiez/models/model/__init__.py +7 -1
- waldiez/models/model/extra_requirements.py +3 -12
- waldiez/models/model/model.py +76 -21
- waldiez/models/model/model_data.py +108 -20
- waldiez/models/tool/__init__.py +16 -0
- waldiez/models/tool/extra_requirements.py +36 -0
- waldiez/models/{skill/skill.py → tool/tool.py} +88 -88
- waldiez/models/tool/tool_data.py +51 -0
- waldiez/models/tool/tool_type.py +8 -0
- waldiez/models/waldiez.py +97 -80
- waldiez/runner.py +114 -49
- waldiez/running/__init__.py +1 -1
- waldiez/running/environment.py +49 -68
- waldiez/running/gen_seq_diagram.py +16 -14
- waldiez/running/running.py +53 -34
- waldiez/utils/__init__.py +0 -4
- waldiez/utils/cli_extras/jupyter.py +5 -3
- waldiez/utils/cli_extras/runner.py +6 -4
- waldiez/utils/cli_extras/studio.py +6 -4
- waldiez/utils/conflict_checker.py +15 -9
- waldiez/utils/flaml_warnings.py +5 -5
- {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/METADATA +235 -91
- waldiez-0.4.8.dist-info/RECORD +200 -0
- waldiez/exporting/agent/agent_exporter.py +0 -297
- waldiez/exporting/agent/utils/__init__.py +0 -23
- waldiez/exporting/agent/utils/captain_agent.py +0 -263
- waldiez/exporting/agent/utils/code_execution.py +0 -65
- waldiez/exporting/agent/utils/group_manager.py +0 -220
- waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
- waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
- waldiez/exporting/agent/utils/reasoning.py +0 -36
- waldiez/exporting/agent/utils/swarm_agent.py +0 -469
- waldiez/exporting/agent/utils/teachability.py +0 -41
- waldiez/exporting/agent/utils/termination_message.py +0 -44
- waldiez/exporting/base/__init__.py +0 -25
- waldiez/exporting/base/agent_position.py +0 -75
- waldiez/exporting/base/base_exporter.py +0 -118
- waldiez/exporting/base/export_position.py +0 -48
- waldiez/exporting/base/import_position.py +0 -23
- waldiez/exporting/base/mixin.py +0 -137
- waldiez/exporting/base/utils/__init__.py +0 -18
- waldiez/exporting/base/utils/comments.py +0 -96
- waldiez/exporting/base/utils/path_check.py +0 -68
- waldiez/exporting/base/utils/to_string.py +0 -84
- waldiez/exporting/chats/chats_exporter.py +0 -240
- waldiez/exporting/chats/utils/swarm.py +0 -210
- waldiez/exporting/flow/flow_exporter.py +0 -528
- waldiez/exporting/flow/utils/agent_utils.py +0 -204
- waldiez/exporting/flow/utils/chat_utils.py +0 -71
- waldiez/exporting/flow/utils/def_main.py +0 -77
- waldiez/exporting/flow/utils/flow_content.py +0 -202
- waldiez/exporting/flow/utils/flow_names.py +0 -116
- waldiez/exporting/flow/utils/importing_utils.py +0 -227
- waldiez/exporting/models/models_exporter.py +0 -199
- waldiez/exporting/models/utils.py +0 -174
- waldiez/exporting/skills/__init__.py +0 -9
- waldiez/exporting/skills/skills_exporter.py +0 -176
- waldiez/exporting/skills/utils.py +0 -369
- waldiez/models/agents/agent/teachability.py +0 -70
- waldiez/models/agents/rag_user/rag_user.py +0 -60
- waldiez/models/agents/swarm_agent/__init__.py +0 -50
- waldiez/models/agents/swarm_agent/after_work.py +0 -179
- waldiez/models/agents/swarm_agent/on_condition.py +0 -105
- waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
- waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
- waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
- waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
- waldiez/models/flow/utils.py +0 -232
- waldiez/models/skill/__init__.py +0 -16
- waldiez/models/skill/extra_requirements.py +0 -36
- waldiez/models/skill/skill_data.py +0 -53
- waldiez/models/skill/skill_type.py +0 -8
- waldiez/utils/pysqlite3_checker.py +0 -308
- waldiez/utils/rdps_checker.py +0 -122
- waldiez-0.4.6.dist-info/RECORD +0 -149
- /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
- /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
- {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/WHEEL +0 -0
- {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
- {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.4.6.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
waldiez/models/chat/chat.py
CHANGED
|
@@ -2,13 +2,21 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Waldiez chat model."""
|
|
4
4
|
|
|
5
|
-
from typing import Any,
|
|
6
|
-
|
|
7
|
-
from pydantic import Field
|
|
8
|
-
from typing_extensions import Annotated
|
|
9
|
-
|
|
10
|
-
from ..agents import WaldiezAgent,
|
|
11
|
-
from ..common import
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import Field, model_validator
|
|
8
|
+
from typing_extensions import Annotated, Literal, Self
|
|
9
|
+
|
|
10
|
+
from ..agents import WaldiezAgent, WaldiezRagUserProxy
|
|
11
|
+
from ..common import (
|
|
12
|
+
WaldiezAgentTarget,
|
|
13
|
+
WaldiezBase,
|
|
14
|
+
WaldiezHandoff,
|
|
15
|
+
WaldiezHandoffCondition,
|
|
16
|
+
WaldiezTransitionAvailability,
|
|
17
|
+
WaldiezTransitionTarget,
|
|
18
|
+
generate_function,
|
|
19
|
+
)
|
|
12
20
|
from .chat_data import WaldiezChatData
|
|
13
21
|
from .chat_message import (
|
|
14
22
|
CALLABLE_MESSAGE,
|
|
@@ -26,7 +34,11 @@ from .chat_nested import (
|
|
|
26
34
|
WaldiezChatNested,
|
|
27
35
|
)
|
|
28
36
|
|
|
37
|
+
WaldiezChatType = Literal["chat", "nested", "group", "hidden"]
|
|
38
|
+
"""Possible chat types: "chat", "nested", "group", "hidden"."""
|
|
29
39
|
|
|
40
|
+
|
|
41
|
+
# noinspection PyUnresolvedReferences
|
|
30
42
|
class WaldiezChat(WaldiezBase):
|
|
31
43
|
"""Chat class.
|
|
32
44
|
|
|
@@ -34,15 +46,17 @@ class WaldiezChat(WaldiezBase):
|
|
|
34
46
|
----------
|
|
35
47
|
id : str
|
|
36
48
|
The chat ID.
|
|
49
|
+
source : str
|
|
50
|
+
The source of the chat (sender).
|
|
51
|
+
target : str
|
|
52
|
+
The target of the chat (recipient).
|
|
53
|
+
type : WaldiezChatType
|
|
54
|
+
The type of the chat data: "chat", "nested", "group", or "hidden".
|
|
37
55
|
data : WaldiezChatData
|
|
38
56
|
The chat data.
|
|
39
57
|
See `waldiez.models.chat.WaldiezChatData` for more information.
|
|
40
58
|
name : str
|
|
41
59
|
The chat name.
|
|
42
|
-
source : str
|
|
43
|
-
The chat source.
|
|
44
|
-
target : str
|
|
45
|
-
The chat target.
|
|
46
60
|
nested_chat : WaldiezChatNested
|
|
47
61
|
The nested chat message/reply if any.
|
|
48
62
|
message : WaldiezChatMessage
|
|
@@ -64,6 +78,30 @@ class WaldiezChat(WaldiezBase):
|
|
|
64
78
|
description="The chat ID.",
|
|
65
79
|
),
|
|
66
80
|
]
|
|
81
|
+
type: Annotated[
|
|
82
|
+
WaldiezChatType,
|
|
83
|
+
Field(
|
|
84
|
+
default="chat",
|
|
85
|
+
title="Type",
|
|
86
|
+
description="The type of the chat data.",
|
|
87
|
+
),
|
|
88
|
+
]
|
|
89
|
+
source: Annotated[
|
|
90
|
+
str,
|
|
91
|
+
Field(
|
|
92
|
+
...,
|
|
93
|
+
title="Source",
|
|
94
|
+
description="The chat source.",
|
|
95
|
+
),
|
|
96
|
+
]
|
|
97
|
+
target: Annotated[
|
|
98
|
+
str,
|
|
99
|
+
Field(
|
|
100
|
+
...,
|
|
101
|
+
title="Target",
|
|
102
|
+
description="The chat target.",
|
|
103
|
+
),
|
|
104
|
+
]
|
|
67
105
|
data: Annotated[
|
|
68
106
|
WaldiezChatData,
|
|
69
107
|
Field(
|
|
@@ -83,20 +121,6 @@ class WaldiezChat(WaldiezBase):
|
|
|
83
121
|
"""Get the description."""
|
|
84
122
|
return self.data.description
|
|
85
123
|
|
|
86
|
-
@property
|
|
87
|
-
def source(self) -> str:
|
|
88
|
-
"""Get the source."""
|
|
89
|
-
if self.data.real_source:
|
|
90
|
-
return self.data.real_source
|
|
91
|
-
return self.data.source
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def target(self) -> str:
|
|
95
|
-
"""Get the target."""
|
|
96
|
-
if self.data.real_target:
|
|
97
|
-
return self.data.real_target
|
|
98
|
-
return self.data.target
|
|
99
|
-
|
|
100
124
|
@property
|
|
101
125
|
def order(self) -> int:
|
|
102
126
|
"""Get the order."""
|
|
@@ -127,19 +151,9 @@ class WaldiezChat(WaldiezBase):
|
|
|
127
151
|
return self.data.message_content
|
|
128
152
|
|
|
129
153
|
@property
|
|
130
|
-
def
|
|
131
|
-
"""Get the
|
|
132
|
-
return self.data.
|
|
133
|
-
|
|
134
|
-
@property
|
|
135
|
-
def max_rounds(self) -> int:
|
|
136
|
-
"""Get the max rounds for swarm chat."""
|
|
137
|
-
return self.data.max_rounds
|
|
138
|
-
|
|
139
|
-
@property
|
|
140
|
-
def after_work(self) -> Optional[WaldiezSwarmAfterWork]:
|
|
141
|
-
"""Get the after work."""
|
|
142
|
-
return self.data.after_work
|
|
154
|
+
def max_turns(self) -> Optional[int]:
|
|
155
|
+
"""Get the max rounds for the chat."""
|
|
156
|
+
return self.data.max_turns
|
|
143
157
|
|
|
144
158
|
@property
|
|
145
159
|
def chat_id(self) -> int:
|
|
@@ -147,10 +161,49 @@ class WaldiezChat(WaldiezBase):
|
|
|
147
161
|
return self.data.get_chat_id()
|
|
148
162
|
|
|
149
163
|
@property
|
|
150
|
-
def prerequisites(self) ->
|
|
164
|
+
def prerequisites(self) -> list[int]:
|
|
151
165
|
"""Get the chat prerequisites."""
|
|
152
166
|
return self.data.get_prerequisites()
|
|
153
167
|
|
|
168
|
+
@property
|
|
169
|
+
def condition(self) -> WaldiezHandoffCondition:
|
|
170
|
+
"""Get the handoff condition."""
|
|
171
|
+
return self.data.condition
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def available(self) -> WaldiezTransitionAvailability:
|
|
175
|
+
"""Get the transition availability."""
|
|
176
|
+
return self.data.available
|
|
177
|
+
|
|
178
|
+
@model_validator(mode="after")
|
|
179
|
+
def _validate_chat(self) -> Self:
|
|
180
|
+
"""Override if needed the source and target of the chat."""
|
|
181
|
+
if self.data.real_source:
|
|
182
|
+
self.source = self.data.real_source
|
|
183
|
+
if self.data.real_target:
|
|
184
|
+
self.target = self.data.real_target
|
|
185
|
+
return self
|
|
186
|
+
|
|
187
|
+
def as_handoff(
|
|
188
|
+
self,
|
|
189
|
+
) -> WaldiezHandoff:
|
|
190
|
+
"""Convert the chat to a handoff.
|
|
191
|
+
|
|
192
|
+
Returns
|
|
193
|
+
-------
|
|
194
|
+
WaldiezHandoff
|
|
195
|
+
The handoff representation of the chat.
|
|
196
|
+
"""
|
|
197
|
+
target: WaldiezTransitionTarget = WaldiezAgentTarget(
|
|
198
|
+
target_type="AgentTarget",
|
|
199
|
+
value=[self.target],
|
|
200
|
+
)
|
|
201
|
+
return WaldiezHandoff(
|
|
202
|
+
target=target,
|
|
203
|
+
condition=self.condition,
|
|
204
|
+
available=self.available,
|
|
205
|
+
)
|
|
206
|
+
|
|
154
207
|
def set_chat_id(self, value: int) -> None:
|
|
155
208
|
"""Set the chat ID.
|
|
156
209
|
|
|
@@ -161,12 +214,12 @@ class WaldiezChat(WaldiezBase):
|
|
|
161
214
|
"""
|
|
162
215
|
self.data.set_chat_id(value)
|
|
163
216
|
|
|
164
|
-
def set_prerequisites(self, value:
|
|
217
|
+
def set_prerequisites(self, value: list[int]) -> None:
|
|
165
218
|
"""Set the chat prerequisites.
|
|
166
219
|
|
|
167
220
|
Parameters
|
|
168
221
|
----------
|
|
169
|
-
value :
|
|
222
|
+
value : list[int]
|
|
170
223
|
The chat prerequisites.
|
|
171
224
|
"""
|
|
172
225
|
self.data.set_prerequisites(value)
|
|
@@ -176,7 +229,7 @@ class WaldiezChat(WaldiezBase):
|
|
|
176
229
|
name_prefix: Optional[str] = None,
|
|
177
230
|
name_suffix: Optional[str] = None,
|
|
178
231
|
is_rag: bool = False,
|
|
179
|
-
) ->
|
|
232
|
+
) -> tuple[str, str]:
|
|
180
233
|
"""Get the message function.
|
|
181
234
|
|
|
182
235
|
Parameters
|
|
@@ -190,7 +243,7 @@ class WaldiezChat(WaldiezBase):
|
|
|
190
243
|
|
|
191
244
|
Returns
|
|
192
245
|
-------
|
|
193
|
-
|
|
246
|
+
tuple[str, str]
|
|
194
247
|
The message function and the function name.
|
|
195
248
|
"""
|
|
196
249
|
if self.message.type in ("string", "none") or (
|
|
@@ -225,15 +278,21 @@ class WaldiezChat(WaldiezBase):
|
|
|
225
278
|
function_name,
|
|
226
279
|
)
|
|
227
280
|
|
|
228
|
-
|
|
229
|
-
|
|
281
|
+
@staticmethod
|
|
282
|
+
def _get_nested_chat_function(
|
|
283
|
+
content: Optional[str],
|
|
284
|
+
function_name_base: str,
|
|
230
285
|
name_prefix: Optional[str] = None,
|
|
231
286
|
name_suffix: Optional[str] = None,
|
|
232
|
-
) ->
|
|
233
|
-
"""Get the nested chat
|
|
287
|
+
) -> tuple[str, str]:
|
|
288
|
+
"""Get the nested chat function.
|
|
234
289
|
|
|
235
290
|
Parameters
|
|
236
291
|
----------
|
|
292
|
+
content : str
|
|
293
|
+
The content for the function body.
|
|
294
|
+
function_name_base : str
|
|
295
|
+
The base name of the function.
|
|
237
296
|
name_prefix : str
|
|
238
297
|
The function name prefix.
|
|
239
298
|
name_suffix : str
|
|
@@ -241,16 +300,12 @@ class WaldiezChat(WaldiezBase):
|
|
|
241
300
|
|
|
242
301
|
Returns
|
|
243
302
|
-------
|
|
244
|
-
|
|
245
|
-
The
|
|
303
|
+
tuple[str, str]
|
|
304
|
+
The generated function and its name.
|
|
246
305
|
"""
|
|
247
|
-
if
|
|
248
|
-
not self.nested_chat.message
|
|
249
|
-
or self.nested_chat.message.type in ("string", "none")
|
|
250
|
-
or not self.nested_chat.message_content
|
|
251
|
-
):
|
|
306
|
+
if not content:
|
|
252
307
|
return "", ""
|
|
253
|
-
function_name =
|
|
308
|
+
function_name = function_name_base
|
|
254
309
|
if name_prefix:
|
|
255
310
|
function_name = f"{name_prefix}_{function_name}"
|
|
256
311
|
if name_suffix:
|
|
@@ -260,16 +315,51 @@ class WaldiezChat(WaldiezBase):
|
|
|
260
315
|
function_name=function_name,
|
|
261
316
|
function_args=NESTED_CHAT_ARGS,
|
|
262
317
|
function_types=NESTED_CHAT_TYPES,
|
|
263
|
-
function_body=
|
|
318
|
+
function_body=content,
|
|
264
319
|
),
|
|
265
320
|
function_name,
|
|
266
321
|
)
|
|
267
322
|
|
|
323
|
+
def get_nested_chat_message_function(
|
|
324
|
+
self,
|
|
325
|
+
name_prefix: Optional[str] = None,
|
|
326
|
+
name_suffix: Optional[str] = None,
|
|
327
|
+
) -> tuple[str, str]:
|
|
328
|
+
"""Get the nested chat message function.
|
|
329
|
+
|
|
330
|
+
Parameters
|
|
331
|
+
----------
|
|
332
|
+
name_prefix : str
|
|
333
|
+
The function name prefix.
|
|
334
|
+
name_suffix : str
|
|
335
|
+
The function name suffix.
|
|
336
|
+
|
|
337
|
+
Returns
|
|
338
|
+
-------
|
|
339
|
+
tuple[str, str]
|
|
340
|
+
The nested chat message function and the function name.
|
|
341
|
+
"""
|
|
342
|
+
if not self.nested_chat.message or (
|
|
343
|
+
self.nested_chat.message.use_carryover is False
|
|
344
|
+
and self.nested_chat.message.type
|
|
345
|
+
in (
|
|
346
|
+
"string",
|
|
347
|
+
"none",
|
|
348
|
+
)
|
|
349
|
+
):
|
|
350
|
+
return "", ""
|
|
351
|
+
return self._get_nested_chat_function(
|
|
352
|
+
content=self.nested_chat.message_content,
|
|
353
|
+
function_name_base=NESTED_CHAT_MESSAGE,
|
|
354
|
+
name_prefix=name_prefix,
|
|
355
|
+
name_suffix=name_suffix,
|
|
356
|
+
)
|
|
357
|
+
|
|
268
358
|
def get_nested_chat_reply_function(
|
|
269
359
|
self,
|
|
270
360
|
name_prefix: Optional[str] = None,
|
|
271
361
|
name_suffix: Optional[str] = None,
|
|
272
|
-
) ->
|
|
362
|
+
) -> tuple[str, str]:
|
|
273
363
|
"""Get the nested chat reply function.
|
|
274
364
|
|
|
275
365
|
Parameters
|
|
@@ -281,35 +371,30 @@ class WaldiezChat(WaldiezBase):
|
|
|
281
371
|
|
|
282
372
|
Returns
|
|
283
373
|
-------
|
|
284
|
-
|
|
374
|
+
tuple[str, str]
|
|
285
375
|
The nested chat reply function and the function name.
|
|
286
376
|
"""
|
|
287
|
-
if (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
377
|
+
if not self.nested_chat.reply or (
|
|
378
|
+
self.nested_chat.reply.use_carryover is False
|
|
379
|
+
and self.nested_chat.reply.type
|
|
380
|
+
in (
|
|
381
|
+
"string",
|
|
382
|
+
"none",
|
|
383
|
+
)
|
|
291
384
|
):
|
|
292
385
|
return "", ""
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return (
|
|
299
|
-
generate_function(
|
|
300
|
-
function_name=function_name,
|
|
301
|
-
function_args=NESTED_CHAT_ARGS,
|
|
302
|
-
function_types=NESTED_CHAT_TYPES,
|
|
303
|
-
function_body=self.nested_chat.reply_content,
|
|
304
|
-
),
|
|
305
|
-
function_name,
|
|
386
|
+
return self._get_nested_chat_function(
|
|
387
|
+
content=self.nested_chat.reply_content,
|
|
388
|
+
function_name_base=NESTED_CHAT_REPLY,
|
|
389
|
+
name_prefix=name_prefix,
|
|
390
|
+
name_suffix=name_suffix,
|
|
306
391
|
)
|
|
307
392
|
|
|
308
393
|
def get_chat_args(
|
|
309
394
|
self,
|
|
310
395
|
for_queue: bool,
|
|
311
396
|
sender: Optional[WaldiezAgent] = None,
|
|
312
|
-
) ->
|
|
397
|
+
) -> dict[str, Any]:
|
|
313
398
|
"""Get the chat arguments to use in autogen.
|
|
314
399
|
|
|
315
400
|
Parameters
|
|
@@ -326,8 +411,8 @@ class WaldiezChat(WaldiezBase):
|
|
|
326
411
|
"""
|
|
327
412
|
args_dict = self.data.get_chat_args(for_queue)
|
|
328
413
|
if (
|
|
329
|
-
isinstance(sender,
|
|
330
|
-
and sender.
|
|
414
|
+
isinstance(sender, WaldiezRagUserProxy)
|
|
415
|
+
and sender.is_rag_user
|
|
331
416
|
and self.message.type == "rag_message_generator"
|
|
332
417
|
):
|
|
333
418
|
# check for n_results in agent data, to add in context
|
|
@@ -336,7 +421,7 @@ class WaldiezChat(WaldiezBase):
|
|
|
336
421
|
args_dict["n_results"] = n_results
|
|
337
422
|
return args_dict
|
|
338
423
|
|
|
339
|
-
def model_dump(self, **kwargs: Any) ->
|
|
424
|
+
def model_dump(self, **kwargs: Any) -> dict[str, Any]:
|
|
340
425
|
"""Dump the model to a dict including the chat attributes.
|
|
341
426
|
|
|
342
427
|
Parameters
|
|
@@ -346,20 +431,14 @@ class WaldiezChat(WaldiezBase):
|
|
|
346
431
|
|
|
347
432
|
Returns
|
|
348
433
|
-------
|
|
349
|
-
|
|
434
|
+
dict[str, Any]
|
|
350
435
|
The model dump with the chat attributes.
|
|
351
436
|
"""
|
|
352
437
|
dump = super().model_dump(**kwargs)
|
|
353
438
|
dump["name"] = self.name
|
|
354
439
|
dump["description"] = self.description
|
|
355
|
-
dump["source"] = self.source
|
|
356
|
-
dump["target"] = self.target
|
|
357
440
|
dump["nested_chat"] = self.nested_chat.model_dump()
|
|
358
441
|
dump["message"] = self.message.model_dump()
|
|
359
442
|
dump["message_content"] = self.message_content
|
|
360
|
-
dump["
|
|
361
|
-
dump["max_rounds"] = self.max_rounds
|
|
362
|
-
dump["after_work"] = (
|
|
363
|
-
self.after_work.model_dump() if self.after_work else None
|
|
364
|
-
)
|
|
443
|
+
dump["max_turns"] = self.max_turns
|
|
365
444
|
return dump
|