waldiez 0.5.6__py3-none-any.whl → 0.5.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/_version.py +1 -1
- waldiez/cli.py +17 -2
- waldiez/exporter.py +1 -1
- waldiez/exporting/agent/code_execution.py +8 -1
- waldiez/exporting/agent/exporter.py +2 -1
- waldiez/exporting/agent/extras/captain_agent_extras.py +1 -0
- waldiez/exporting/agent/extras/doc_agent_extras.py +2 -3
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +1 -0
- waldiez/exporting/agent/extras/handoffs/after_work.py +4 -4
- waldiez/exporting/agent/extras/handoffs/target.py +3 -0
- waldiez/exporting/agent/extras/rag/chroma_extras.py +0 -4
- waldiez/exporting/agent/extras/rag/mongo_extras.py +0 -1
- waldiez/exporting/agent/extras/rag/pgvector_extras.py +0 -2
- waldiez/exporting/agent/extras/rag/qdrant_extras.py +0 -3
- waldiez/exporting/agent/extras/rag/vector_db_extras.py +3 -2
- waldiez/exporting/agent/factory.py +11 -11
- waldiez/exporting/agent/processor.py +3 -2
- waldiez/exporting/chats/exporter.py +2 -2
- waldiez/exporting/chats/factory.py +5 -5
- waldiez/exporting/chats/processor.py +22 -1
- waldiez/exporting/chats/utils/common.py +45 -1
- waldiez/exporting/chats/utils/group.py +1 -1
- waldiez/exporting/chats/utils/sequential.py +3 -68
- waldiez/exporting/chats/utils/single.py +1 -38
- waldiez/exporting/core/context.py +39 -38
- waldiez/exporting/core/exporter.py +10 -10
- waldiez/exporting/core/exporters.py +36 -0
- waldiez/exporting/core/extras/base.py +2 -2
- waldiez/exporting/core/extras/chat_extras.py +4 -2
- waldiez/exporting/core/extras/path_resolver.py +6 -4
- waldiez/exporting/core/extras/serializer.py +1 -0
- waldiez/exporting/core/protocols.py +6 -0
- waldiez/exporting/core/result.py +8 -7
- waldiez/exporting/core/types.py +2 -2
- waldiez/exporting/core/utils/llm_config.py +2 -0
- waldiez/exporting/flow/execution_generator.py +54 -32
- waldiez/exporting/flow/factory.py +2 -2
- waldiez/exporting/flow/file_generator.py +8 -7
- waldiez/exporting/flow/merger.py +8 -7
- waldiez/exporting/flow/orchestrator.py +22 -8
- waldiez/exporting/flow/utils/__init__.py +2 -0
- waldiez/exporting/flow/utils/common.py +20 -11
- waldiez/exporting/flow/utils/importing.py +2 -1
- waldiez/exporting/flow/utils/logging.py +5 -2
- waldiez/exporting/models/exporter.py +2 -1
- waldiez/exporting/models/factory.py +6 -7
- waldiez/exporting/tools/exporter.py +7 -6
- waldiez/exporting/tools/factory.py +4 -5
- waldiez/exporting/tools/processor.py +9 -4
- waldiez/exporting/tools/registration.py +1 -0
- waldiez/io/_ws.py +2 -0
- waldiez/io/models/content/audio.py +1 -0
- 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 +1 -0
- waldiez/io/models/user_response.py +1 -0
- waldiez/io/mqtt.py +6 -3
- waldiez/io/redis.py +7 -9
- waldiez/io/structured.py +8 -6
- waldiez/io/utils.py +11 -4
- waldiez/io/ws.py +4 -3
- waldiez/logger.py +11 -1
- waldiez/models/agents/agent/agent.py +1 -0
- waldiez/models/agents/agent/agent_data.py +2 -2
- waldiez/models/agents/agent/nested_chat.py +1 -4
- waldiez/models/agents/agent/termination_message.py +0 -7
- waldiez/models/agents/agent/update_system_message.py +2 -2
- waldiez/models/agents/doc_agent/doc_agent_data.py +33 -26
- waldiez/models/agents/doc_agent/rag_query_engine.py +1 -1
- waldiez/models/agents/extra_requirements.py +5 -5
- waldiez/models/agents/group_manager/group_manager.py +3 -7
- waldiez/models/agents/group_manager/speakers.py +0 -7
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +0 -2
- waldiez/models/agents/rag_user_proxy/rag_user_proxy_data.py +0 -2
- waldiez/models/agents/rag_user_proxy/retrieve_config.py +1 -17
- waldiez/models/agents/rag_user_proxy/vector_db_config.py +0 -5
- waldiez/models/chat/chat_data.py +0 -2
- waldiez/models/chat/chat_summary.py +5 -3
- waldiez/models/common/handoff.py +26 -18
- waldiez/models/common/naming.py +1 -0
- waldiez/models/flow/flow.py +9 -7
- waldiez/models/model/_llm.py +4 -2
- waldiez/models/model/extra_requirements.py +3 -3
- waldiez/models/model/model.py +5 -4
- waldiez/models/tool/extra_requirements.py +2 -2
- waldiez/models/tool/predefined/_google.py +7 -12
- waldiez/models/tool/predefined/_perplexity.py +13 -9
- waldiez/models/tool/predefined/_searxng.py +4 -1
- waldiez/models/tool/predefined/_tavily.py +0 -6
- waldiez/models/tool/predefined/_wikipedia.py +5 -1
- waldiez/models/tool/predefined/_youtube.py +0 -4
- waldiez/models/tool/tool.py +7 -7
- waldiez/models/tool/tool_data.py +39 -2
- waldiez/models/waldiez.py +29 -29
- waldiez/runner.py +18 -13
- waldiez/running/base_runner.py +96 -40
- waldiez/running/environment.py +2 -0
- waldiez/running/patch_io_stream.py +2 -0
- waldiez/running/post_run.py +3 -0
- waldiez/running/pre_run.py +1 -0
- waldiez/running/protocol.py +50 -48
- waldiez/running/run_results.py +2 -10
- waldiez/running/standard_runner.py +37 -13
- waldiez/running/timeline_processor.py +12 -1
- waldiez/running/utils.py +2 -0
- waldiez/utils/conflict_checker.py +1 -1
- waldiez/utils/version.py +1 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/METADATA +68 -65
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/RECORD +115 -116
- waldiez/exporting/agent/extras/group/target.py +0 -178
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/WHEEL +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.6.dist-info → waldiez-0.5.8.dist-info}/licenses/NOTICE.md +0 -0
waldiez/io/redis.py
CHANGED
|
@@ -32,6 +32,7 @@ except ImportError as error: # pragma: no cover
|
|
|
32
32
|
) from error
|
|
33
33
|
from autogen.events import BaseEvent # type: ignore
|
|
34
34
|
from autogen.io import IOStream # type: ignore
|
|
35
|
+
from autogen.messages import BaseMessage # type: ignore
|
|
35
36
|
|
|
36
37
|
from .models import (
|
|
37
38
|
PrintMessage,
|
|
@@ -52,6 +53,7 @@ else:
|
|
|
52
53
|
LOG = logging.getLogger(__name__)
|
|
53
54
|
|
|
54
55
|
|
|
56
|
+
# noinspection PyBroadException
|
|
55
57
|
class RedisIOStream(IOStream):
|
|
56
58
|
"""Redis I/O stream."""
|
|
57
59
|
|
|
@@ -158,10 +160,8 @@ class RedisIOStream(IOStream):
|
|
|
158
160
|
|
|
159
161
|
Parameters
|
|
160
162
|
----------
|
|
161
|
-
|
|
163
|
+
payload : dict[str, Any]
|
|
162
164
|
The message to print.
|
|
163
|
-
message_type : str
|
|
164
|
-
The message type.
|
|
165
165
|
"""
|
|
166
166
|
LOG.debug("Sending print message: %s", payload)
|
|
167
167
|
RedisIOStream.try_do(
|
|
@@ -177,10 +177,8 @@ class RedisIOStream(IOStream):
|
|
|
177
177
|
|
|
178
178
|
Parameters
|
|
179
179
|
----------
|
|
180
|
-
|
|
180
|
+
payload : dict[str, Any]
|
|
181
181
|
The message to print.
|
|
182
|
-
message_type : str
|
|
183
|
-
The message type.
|
|
184
182
|
"""
|
|
185
183
|
LOG.debug("Sending print message: %s", payload)
|
|
186
184
|
RedisIOStream.try_do(
|
|
@@ -289,12 +287,12 @@ class RedisIOStream(IOStream):
|
|
|
289
287
|
self._print(payload)
|
|
290
288
|
return user_input
|
|
291
289
|
|
|
292
|
-
def send(self, message: BaseEvent) -> None:
|
|
290
|
+
def send(self, message: BaseEvent | BaseMessage) -> None:
|
|
293
291
|
"""Send a structured message to Redis.
|
|
294
292
|
|
|
295
293
|
Parameters
|
|
296
294
|
----------
|
|
297
|
-
message :
|
|
295
|
+
message : BaseEvent | BaseMessage
|
|
298
296
|
The message to send.
|
|
299
297
|
"""
|
|
300
298
|
message_dump = get_message_dump(message)
|
|
@@ -549,7 +547,7 @@ class RedisIOStream(IOStream):
|
|
|
549
547
|
|
|
550
548
|
Parameters
|
|
551
549
|
----------
|
|
552
|
-
func : Awaitable[Any]
|
|
550
|
+
func : Callable[..., Awaitable[Any]]
|
|
553
551
|
The async function to call.
|
|
554
552
|
args : Any
|
|
555
553
|
The positional arguments.
|
waldiez/io/structured.py
CHANGED
|
@@ -14,6 +14,7 @@ from uuid import uuid4
|
|
|
14
14
|
|
|
15
15
|
from autogen.events import BaseEvent # type: ignore
|
|
16
16
|
from autogen.io import IOStream # type: ignore
|
|
17
|
+
from autogen.messages import BaseMessage # type: ignore
|
|
17
18
|
|
|
18
19
|
from .models import (
|
|
19
20
|
PrintMessage,
|
|
@@ -135,12 +136,12 @@ class StructuredIOStream(IOStream):
|
|
|
135
136
|
|
|
136
137
|
# noinspection PyMethodMayBeStatic
|
|
137
138
|
# pylint: disable=no-self-use,broad-exception-caught
|
|
138
|
-
def send(self, message: BaseEvent) -> None:
|
|
139
|
-
"""Structured sending of a BaseEvent.
|
|
139
|
+
def send(self, message: BaseEvent | BaseMessage) -> None:
|
|
140
|
+
"""Structured sending of a BaseEvent or BaseMessage.
|
|
140
141
|
|
|
141
142
|
Parameters
|
|
142
143
|
----------
|
|
143
|
-
message : BaseEvent
|
|
144
|
+
message : BaseEvent | BaseMessage
|
|
144
145
|
The message to send.
|
|
145
146
|
"""
|
|
146
147
|
message_dump = get_message_dump(message)
|
|
@@ -251,7 +252,7 @@ class StructuredIOStream(IOStream):
|
|
|
251
252
|
str | dict[str, Any]
|
|
252
253
|
The loaded user input, either as a string or a dictionary.
|
|
253
254
|
"""
|
|
254
|
-
response: str | dict[str, Any]
|
|
255
|
+
response: str | dict[str, Any]
|
|
255
256
|
try:
|
|
256
257
|
# Attempt to parse the input as JSON
|
|
257
258
|
response = json.loads(user_input_raw)
|
|
@@ -283,8 +284,8 @@ class StructuredIOStream(IOStream):
|
|
|
283
284
|
|
|
284
285
|
Parameters
|
|
285
286
|
----------
|
|
286
|
-
user_input : str
|
|
287
|
-
The
|
|
287
|
+
user_input : dict[str, Any]
|
|
288
|
+
The user input dictionary containing the response data.
|
|
288
289
|
request_id : str
|
|
289
290
|
The request ID to match against.
|
|
290
291
|
|
|
@@ -341,6 +342,7 @@ class StructuredIOStream(IOStream):
|
|
|
341
342
|
data="",
|
|
342
343
|
)
|
|
343
344
|
|
|
345
|
+
# noinspection PyMethodMayBeStatic
|
|
344
346
|
def _handle_list_response(
|
|
345
347
|
self,
|
|
346
348
|
data: list[dict[str, Any]],
|
waldiez/io/utils.py
CHANGED
|
@@ -12,6 +12,7 @@ from typing import Any, Literal, Union
|
|
|
12
12
|
|
|
13
13
|
from autogen.agentchat.contrib.img_utils import get_pil_image # type: ignore
|
|
14
14
|
from autogen.events import BaseEvent # type: ignore
|
|
15
|
+
from autogen.messages import BaseMessage # type: ignore
|
|
15
16
|
|
|
16
17
|
MessageType = Literal[
|
|
17
18
|
"input_request",
|
|
@@ -169,6 +170,7 @@ def try_parse_maybe_serialized(value: str) -> Any:
|
|
|
169
170
|
"""
|
|
170
171
|
for parser in (json.loads, ast.literal_eval):
|
|
171
172
|
# pylint: disable=broad-exception-caught, too-many-try-statements
|
|
173
|
+
# noinspection PyBroadException
|
|
172
174
|
try:
|
|
173
175
|
parsed: dict[str, Any] | list[Any] | str = parser(value)
|
|
174
176
|
# Normalize: if it's a single-item list of a string
|
|
@@ -185,14 +187,12 @@ def try_parse_maybe_serialized(value: str) -> Any:
|
|
|
185
187
|
return value # Return original if all parsing fails
|
|
186
188
|
|
|
187
189
|
|
|
188
|
-
def get_message_dump(
|
|
189
|
-
message: BaseEvent,
|
|
190
|
-
) -> dict[str, Any]:
|
|
190
|
+
def get_message_dump(message: BaseEvent | BaseMessage) -> dict[str, Any]:
|
|
191
191
|
"""Get the message dump.
|
|
192
192
|
|
|
193
193
|
Parameters
|
|
194
194
|
----------
|
|
195
|
-
message : BaseEvent
|
|
195
|
+
message : BaseEvent | BaseMessage
|
|
196
196
|
The message to dump.
|
|
197
197
|
|
|
198
198
|
Returns
|
|
@@ -200,7 +200,14 @@ def get_message_dump(
|
|
|
200
200
|
dict[str, Any]
|
|
201
201
|
The dumped message.
|
|
202
202
|
"""
|
|
203
|
+
if not hasattr(message, "model_dump"): # pragma: no cover
|
|
204
|
+
return {
|
|
205
|
+
"error": "Message does not have model_dump method.",
|
|
206
|
+
"type": message.__class__.__name__,
|
|
207
|
+
}
|
|
208
|
+
|
|
203
209
|
# pylint: disable=broad-exception-caught
|
|
210
|
+
# noinspection PyBroadException
|
|
204
211
|
try:
|
|
205
212
|
message_dump = message.model_dump(mode="json")
|
|
206
213
|
except Exception:
|
waldiez/io/ws.py
CHANGED
|
@@ -12,6 +12,7 @@ from typing import Any
|
|
|
12
12
|
|
|
13
13
|
from autogen.events import BaseEvent # type: ignore
|
|
14
14
|
from autogen.io import IOStream # type: ignore
|
|
15
|
+
from autogen.messages import BaseMessage # type: ignore
|
|
15
16
|
|
|
16
17
|
from ._ws import (
|
|
17
18
|
WebSocketConnection,
|
|
@@ -110,7 +111,7 @@ class AsyncWebsocketsIOStream(IOStream):
|
|
|
110
111
|
----------
|
|
111
112
|
args : tuple
|
|
112
113
|
The arguments to print.
|
|
113
|
-
kwargs :
|
|
114
|
+
kwargs : Any
|
|
114
115
|
The keyword arguments to print.
|
|
115
116
|
"""
|
|
116
117
|
sep = kwargs.get("sep", " ")
|
|
@@ -134,12 +135,12 @@ class AsyncWebsocketsIOStream(IOStream):
|
|
|
134
135
|
LOG.info(json_dump)
|
|
135
136
|
self._try_send(json_dump)
|
|
136
137
|
|
|
137
|
-
def send(self, message: BaseEvent) -> None:
|
|
138
|
+
def send(self, message: BaseEvent | BaseMessage) -> None:
|
|
138
139
|
"""Send a message to the WebSocket connection.
|
|
139
140
|
|
|
140
141
|
Parameters
|
|
141
142
|
----------
|
|
142
|
-
message : BaseEvent
|
|
143
|
+
message : BaseEvent | BaseMessage
|
|
143
144
|
The message to send.
|
|
144
145
|
"""
|
|
145
146
|
message_dump = get_message_dump(message)
|
waldiez/logger.py
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import inspect
|
|
7
7
|
import os
|
|
8
8
|
import re
|
|
9
|
+
import string
|
|
9
10
|
import threading
|
|
10
11
|
import traceback
|
|
11
12
|
from datetime import datetime
|
|
@@ -323,6 +324,7 @@ class WaldiezLogger:
|
|
|
323
324
|
def _get_caller_info(cls) -> str:
|
|
324
325
|
"""Get caller information (filename and line number) from the stack."""
|
|
325
326
|
frame = inspect.currentframe()
|
|
327
|
+
# noinspection PyBroadException
|
|
326
328
|
try:
|
|
327
329
|
if frame is None: # pragma: no cover
|
|
328
330
|
return ""
|
|
@@ -377,7 +379,15 @@ class WaldiezLogger:
|
|
|
377
379
|
@staticmethod
|
|
378
380
|
def _has_format_braces(msg_str: str) -> bool:
|
|
379
381
|
"""Check if the message contains .format() style placeholders."""
|
|
380
|
-
|
|
382
|
+
# noinspection PyBroadException
|
|
383
|
+
try:
|
|
384
|
+
formatter = string.Formatter()
|
|
385
|
+
for _, field_name, _, _ in formatter.parse(msg_str):
|
|
386
|
+
if field_name is not None:
|
|
387
|
+
return True
|
|
388
|
+
return False
|
|
389
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
390
|
+
return False
|
|
381
391
|
|
|
382
392
|
@staticmethod
|
|
383
393
|
def _has_percent_placeholders(msg_str: str) -> bool:
|
|
@@ -146,7 +146,7 @@ class WaldiezAgentData(WaldiezBase):
|
|
|
146
146
|
Field(
|
|
147
147
|
default_factory=list,
|
|
148
148
|
title="Tools",
|
|
149
|
-
description=
|
|
149
|
+
description="A list of tools (id and executor) to register.",
|
|
150
150
|
),
|
|
151
151
|
] = []
|
|
152
152
|
nested_chats: Annotated[
|
|
@@ -194,7 +194,7 @@ class WaldiezAgentData(WaldiezBase):
|
|
|
194
194
|
Field(
|
|
195
195
|
default_factory=list,
|
|
196
196
|
title="Handoffs",
|
|
197
|
-
description=
|
|
197
|
+
description="A list of handoffs (target ids) to register.",
|
|
198
198
|
),
|
|
199
199
|
] = []
|
|
200
200
|
after_work: Annotated[
|
|
@@ -50,16 +50,13 @@ class WaldiezAgentNestedChat(WaldiezBase):
|
|
|
50
50
|
messages : list[WaldiezAgentNestedChatMessage]
|
|
51
51
|
The list of messages (chat ids and 'is_reply'z)
|
|
52
52
|
to include the in the nested chat registration.
|
|
53
|
-
order : int
|
|
54
|
-
The order of the nested chat (if used as a handoff).
|
|
55
|
-
Defaults to 0.
|
|
56
53
|
"""
|
|
57
54
|
|
|
58
55
|
triggered_by: Annotated[
|
|
59
56
|
list[str],
|
|
60
57
|
Field(
|
|
61
58
|
title="Triggered By",
|
|
62
|
-
description=
|
|
59
|
+
description="A list of agent ids that trigger the nested chat.",
|
|
63
60
|
alias="triggeredBy",
|
|
64
61
|
default_factory=list,
|
|
65
62
|
),
|
|
@@ -33,13 +33,6 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
|
|
|
33
33
|
The method must be called `is_termination_message`,
|
|
34
34
|
have one argument (`message`) which is a dict, and
|
|
35
35
|
return a bool (whether the message is a termination message or not.)
|
|
36
|
-
string : str
|
|
37
|
-
The value of the termination message.
|
|
38
|
-
|
|
39
|
-
Functions
|
|
40
|
-
---------
|
|
41
|
-
validate_termination_message() -> Self
|
|
42
|
-
Validate the termination message configuration.
|
|
43
36
|
"""
|
|
44
37
|
|
|
45
38
|
type: Annotated[
|
|
@@ -27,9 +27,9 @@ class WaldiezAgentUpdateSystemMessage(WaldiezBase):
|
|
|
27
27
|
|
|
28
28
|
Attributes
|
|
29
29
|
----------
|
|
30
|
-
|
|
30
|
+
type : Literal["string", "callable"]
|
|
31
31
|
The type of the update function. Can be either a string or a callable.
|
|
32
|
-
|
|
32
|
+
content : str
|
|
33
33
|
The string template or function definition to update
|
|
34
34
|
the agent's system message. Can be a string or a Callable.
|
|
35
35
|
If the `function_type` is 'string' it will be used as a
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Optional, Union
|
|
7
7
|
|
|
8
|
-
from platformdirs import user_data_dir
|
|
9
8
|
from pydantic import Field, model_validator
|
|
10
9
|
from typing_extensions import Annotated, Self
|
|
11
10
|
|
|
@@ -78,19 +77,10 @@ class WaldiezDocAgentData(WaldiezAgentData):
|
|
|
78
77
|
The instance with validated `parsed_docs_path`.
|
|
79
78
|
"""
|
|
80
79
|
if not self.parsed_docs_path:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
parsed_docs_path = Path(data_dir) / "parsed_docs"
|
|
86
|
-
parsed_docs_path.mkdir(parents=True, exist_ok=True)
|
|
87
|
-
self.parsed_docs_path = str(parsed_docs_path.resolve())
|
|
88
|
-
resolved = Path(self.parsed_docs_path).resolve()
|
|
89
|
-
if not resolved.is_absolute():
|
|
90
|
-
self.parsed_docs_path = str(Path.cwd() / self.parsed_docs_path)
|
|
91
|
-
if not Path(self.parsed_docs_path).is_dir():
|
|
92
|
-
Path(self.parsed_docs_path).mkdir(parents=True, exist_ok=True)
|
|
93
|
-
self.parsed_docs_path = str(Path(self.parsed_docs_path).resolve())
|
|
80
|
+
self.parsed_docs_path = get_parsed_docs_path()
|
|
81
|
+
parsed_docs_path = Path(self.parsed_docs_path).resolve()
|
|
82
|
+
parsed_docs_path.mkdir(parents=True, exist_ok=True)
|
|
83
|
+
self.parsed_docs_path = str(parsed_docs_path)
|
|
94
84
|
return self
|
|
95
85
|
|
|
96
86
|
def get_query_engine(self) -> WaldiezDocAgentQueryEngine:
|
|
@@ -134,16 +124,33 @@ class WaldiezDocAgentData(WaldiezAgentData):
|
|
|
134
124
|
The parsed documents path for the document agent.
|
|
135
125
|
"""
|
|
136
126
|
if not self.parsed_docs_path:
|
|
137
|
-
|
|
138
|
-
appname="waldiez",
|
|
139
|
-
appauthor="waldiez",
|
|
140
|
-
)
|
|
141
|
-
parsed_docs_path = Path(data_dir) / "parsed_docs"
|
|
142
|
-
parsed_docs_path.mkdir(parents=True, exist_ok=True)
|
|
143
|
-
self.parsed_docs_path = str(parsed_docs_path.resolve())
|
|
144
|
-
resolved = Path(self.parsed_docs_path).resolve()
|
|
145
|
-
if not resolved.is_absolute():
|
|
146
|
-
self.parsed_docs_path = str(Path.cwd() / self.parsed_docs_path)
|
|
147
|
-
if not Path(self.parsed_docs_path).is_dir():
|
|
148
|
-
Path(self.parsed_docs_path).mkdir(parents=True, exist_ok=True)
|
|
127
|
+
self.parsed_docs_path = get_parsed_docs_path(self.parsed_docs_path)
|
|
149
128
|
return str(self.parsed_docs_path)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def get_parsed_docs_path(
|
|
132
|
+
parsed_docs_path: Optional[Union[str, Path]] = None,
|
|
133
|
+
) -> str:
|
|
134
|
+
"""Get the parsed documents path for the document agent.
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
parsed_docs_path : Optional[Union[str, Path]]
|
|
139
|
+
The path to the parsed documents.
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
str
|
|
144
|
+
The parsed documents path for the document agent.
|
|
145
|
+
"""
|
|
146
|
+
if not parsed_docs_path:
|
|
147
|
+
parsed_docs_path_str = str(Path.cwd() / "parsed_docs")
|
|
148
|
+
else:
|
|
149
|
+
parsed_docs_path_str = str(parsed_docs_path)
|
|
150
|
+
if not Path(parsed_docs_path_str).is_absolute():
|
|
151
|
+
parsed_docs_path_str = str(Path.cwd() / parsed_docs_path_str)
|
|
152
|
+
resolved_path = Path(parsed_docs_path_str).resolve()
|
|
153
|
+
if resolved_path.is_file():
|
|
154
|
+
resolved_path = resolved_path.parent
|
|
155
|
+
resolved_path.mkdir(parents=True, exist_ok=True)
|
|
156
|
+
return str(resolved_path)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# SPDX-License-Identifier: Apache-2.0.
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Extra requirements for agents."""
|
|
4
|
-
|
|
5
4
|
# pylint: disable=line-too-long
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
from typing import Set
|
|
7
7
|
|
|
8
8
|
from .agent import WaldiezAgent
|
|
9
9
|
from .rag_user_proxy import WaldiezRagUserProxy
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def get_retrievechat_extra_requirements(
|
|
13
|
-
agents:
|
|
14
|
-
) ->
|
|
13
|
+
agents: list[WaldiezAgent],
|
|
14
|
+
) -> set[str]:
|
|
15
15
|
"""Get the retrievechat extra requirements.
|
|
16
16
|
|
|
17
17
|
Parameters
|
|
@@ -21,7 +21,7 @@ def get_retrievechat_extra_requirements(
|
|
|
21
21
|
|
|
22
22
|
Returns
|
|
23
23
|
-------
|
|
24
|
-
|
|
24
|
+
set[str]
|
|
25
25
|
The retrievechat extra requirements.
|
|
26
26
|
"""
|
|
27
27
|
# https://github.com/ag2ai/ag2/blob/main/pyproject.toml
|
|
@@ -13,6 +13,7 @@ from .group_manager_data import WaldiezGroupManagerData
|
|
|
13
13
|
from .speakers import WaldiezGroupManagerSpeakers
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
# noinspection PyNestedDecorators
|
|
16
17
|
class WaldiezGroupManager(WaldiezAgent):
|
|
17
18
|
"""Group chat manager agent.
|
|
18
19
|
|
|
@@ -26,11 +27,6 @@ class WaldiezGroupManager(WaldiezAgent):
|
|
|
26
27
|
The agent type: 'group_manager' for a group manager agent
|
|
27
28
|
data : WaldiezGroupManagerData
|
|
28
29
|
The group manager agent's data.
|
|
29
|
-
|
|
30
|
-
Functions
|
|
31
|
-
---------
|
|
32
|
-
validate_transitions(agent_ids: list[str])
|
|
33
|
-
Validate the transitions.
|
|
34
30
|
"""
|
|
35
31
|
|
|
36
32
|
agent_type: Annotated[ # pyright: ignore
|
|
@@ -174,6 +170,6 @@ class WaldiezGroupManager(WaldiezAgent):
|
|
|
174
170
|
) in speakers.allowed_or_disallowed_transitions.items():
|
|
175
171
|
if agent_id not in agent_ids:
|
|
176
172
|
raise ValueError(f"Invalid agent id: {agent_id}")
|
|
177
|
-
for
|
|
178
|
-
if
|
|
173
|
+
for target_agent_id in transitions:
|
|
174
|
+
if target_agent_id not in agent_ids:
|
|
179
175
|
raise ValueError(f"Invalid agent id: {agent_id}")
|
|
@@ -75,13 +75,6 @@ class WaldiezGroupManagerSpeakers(WaldiezBase):
|
|
|
75
75
|
The type of transition rules to use if
|
|
76
76
|
if a mapping (agent => list[agents]) is used:
|
|
77
77
|
`allowed` (default) or `disallowed`
|
|
78
|
-
custom_method_string : Optional[str]
|
|
79
|
-
The custom method string.
|
|
80
|
-
|
|
81
|
-
Functions
|
|
82
|
-
---------
|
|
83
|
-
validate_group_speakers_config()
|
|
84
|
-
Validate the speakers config.
|
|
85
78
|
"""
|
|
86
79
|
|
|
87
80
|
selection_method: Annotated[
|
|
@@ -25,8 +25,6 @@ class WaldiezRagUserProxy(WaldiezAgent):
|
|
|
25
25
|
data : WaldiezRagUserProxyData
|
|
26
26
|
The RAG user agent's data.
|
|
27
27
|
See `WaldiezRagUserProxyData` for more info.
|
|
28
|
-
retrieve_config : WaldiezRagUserProxyRetrieveConfig
|
|
29
|
-
The RAG user agent's retrieve config.
|
|
30
28
|
"""
|
|
31
29
|
|
|
32
30
|
agent_type: Annotated[ # pyright: ignore
|
|
@@ -16,8 +16,6 @@ class WaldiezRagUserProxyData(WaldiezUserProxyData):
|
|
|
16
16
|
|
|
17
17
|
Attributes
|
|
18
18
|
----------
|
|
19
|
-
use_message_generator: bool
|
|
20
|
-
Whether to use the message generator in user's chats. Defaults to False.
|
|
21
19
|
retrieve_config : WaldiezRagUserProxyRetrieveConfig
|
|
22
20
|
The RAG user agent's retrieve config.
|
|
23
21
|
|
|
@@ -50,6 +50,7 @@ CUSTOM_TEXT_SPLIT_FUNCTION_TYPES = (
|
|
|
50
50
|
["str", "int", "str", "bool", "int"],
|
|
51
51
|
"list[str]",
|
|
52
52
|
)
|
|
53
|
+
# noinspection HttpUrlsUsage
|
|
53
54
|
NOT_LOCAL = (
|
|
54
55
|
"http://",
|
|
55
56
|
"https://",
|
|
@@ -162,25 +163,8 @@ class WaldiezRagUserProxyRetrieveConfig(WaldiezBase):
|
|
|
162
163
|
distance_threshold : float
|
|
163
164
|
The threshold for the distance score, only distance smaller than it
|
|
164
165
|
will be returned. Will be ignored if < 0. Default is -1.
|
|
165
|
-
embedding_function_string : Optional[str]
|
|
166
|
-
The embedding function string (if use_custom_embedding is True).
|
|
167
|
-
token_count_function_string : Optional[str]
|
|
168
|
-
The token count function string (if use_custom_token_count is True).
|
|
169
|
-
text_split_function_string : Optional[str]
|
|
170
|
-
The text split function string (if use_custom_text_split is True).
|
|
171
166
|
n_results: Optional[int]
|
|
172
167
|
The number of results to return. Default is None, which will return all
|
|
173
|
-
|
|
174
|
-
Functions
|
|
175
|
-
---------
|
|
176
|
-
validate_custom_embedding_function
|
|
177
|
-
Validate the custom embedding function.
|
|
178
|
-
validate_custom_token_count_function
|
|
179
|
-
Validate the custom token count function.
|
|
180
|
-
validate_custom_text_split_function
|
|
181
|
-
Validate the custom text split function.
|
|
182
|
-
validate_rag_user_data
|
|
183
|
-
Validate the RAG user data.
|
|
184
168
|
"""
|
|
185
169
|
|
|
186
170
|
task: Annotated[
|
|
@@ -39,11 +39,6 @@ class WaldiezRagUserProxyVectorDbConfig(WaldiezBase):
|
|
|
39
39
|
metadata : Optional[dict[str, Any]]
|
|
40
40
|
The metadata to use for the vector db.
|
|
41
41
|
Example: {"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 32}
|
|
42
|
-
|
|
43
|
-
Functions
|
|
44
|
-
---------
|
|
45
|
-
validate_vector_db_config()
|
|
46
|
-
Validate the vector db config.
|
|
47
42
|
"""
|
|
48
43
|
|
|
49
44
|
model_config = ConfigDict(
|
waldiez/models/chat/chat_data.py
CHANGED
|
@@ -57,8 +57,6 @@ class WaldiezChatData(WaldiezBase):
|
|
|
57
57
|
Whether to run the chat silently, by default False (not silent).
|
|
58
58
|
summary_args : Optional[dict[str, Any]]
|
|
59
59
|
The summary args to use in autogen.
|
|
60
|
-
handoff_condition : Optional[WaldiezHandoffCondition], optional
|
|
61
|
-
The handoff condition to use, by default None (for group chat).
|
|
62
60
|
real_source : Optional[str]
|
|
63
61
|
The real source of the chat (overrides the source).
|
|
64
62
|
real_target : Optional[str]
|
|
@@ -66,7 +66,7 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
66
66
|
@classmethod
|
|
67
67
|
def validate_summary_method(
|
|
68
68
|
cls, value: Optional[WaldiezChatSummaryMethod]
|
|
69
|
-
) ->
|
|
69
|
+
) -> WaldiezChatSummaryMethod | None:
|
|
70
70
|
"""Validate the summary method.
|
|
71
71
|
|
|
72
72
|
Parameters
|
|
@@ -76,7 +76,7 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
76
76
|
|
|
77
77
|
Returns
|
|
78
78
|
-------
|
|
79
|
-
|
|
79
|
+
WaldiezChatSummaryMethod | None
|
|
80
80
|
The validated message summary method
|
|
81
81
|
"""
|
|
82
82
|
if str(value).lower() == "none":
|
|
@@ -85,6 +85,8 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
85
85
|
return "last_msg"
|
|
86
86
|
if value == "reflectionWithLlm":
|
|
87
87
|
return "reflection_with_llm"
|
|
88
|
+
if value not in ("last_msg", "reflection_with_llm"):
|
|
89
|
+
return None
|
|
88
90
|
return value
|
|
89
91
|
|
|
90
92
|
# noinspection PyNestedDecorators
|
|
@@ -107,7 +109,7 @@ class WaldiezChatSummary(WaldiezBase):
|
|
|
107
109
|
Any
|
|
108
110
|
The serialized value.
|
|
109
111
|
"""
|
|
110
|
-
if info.by_alias
|
|
112
|
+
if info.by_alias:
|
|
111
113
|
if value == "reflection_with_llm":
|
|
112
114
|
return "reflectionWithLlm"
|
|
113
115
|
if value == "last_msg":
|
waldiez/models/common/handoff.py
CHANGED
|
@@ -27,6 +27,7 @@ __all__ = [
|
|
|
27
27
|
"WaldiezHandoffTransition",
|
|
28
28
|
"WaldiezLLMBasedCondition",
|
|
29
29
|
"WaldiezContextBasedCondition",
|
|
30
|
+
"WaldiezDefaultCondition",
|
|
30
31
|
]
|
|
31
32
|
|
|
32
33
|
|
|
@@ -39,9 +40,6 @@ class WaldiezAgentTarget(WaldiezBase):
|
|
|
39
40
|
The type of the transition target.
|
|
40
41
|
value : str
|
|
41
42
|
The agent id to transfer control to.
|
|
42
|
-
order : int
|
|
43
|
-
The order of the target in the list of targets.
|
|
44
|
-
If -1, the order is automatically determined by the json data.
|
|
45
43
|
"""
|
|
46
44
|
|
|
47
45
|
target_type: Annotated[
|
|
@@ -67,9 +65,6 @@ class WaldiezRandomAgentTarget(WaldiezBase):
|
|
|
67
65
|
The type of the transition target.
|
|
68
66
|
value : list[str]
|
|
69
67
|
A list of agent ids to randomly select from.
|
|
70
|
-
order : int
|
|
71
|
-
The order of the target in the list of targets.
|
|
72
|
-
If -1, the order is automatically determined by the json data.
|
|
73
68
|
"""
|
|
74
69
|
|
|
75
70
|
target_type: Annotated[
|
|
@@ -104,11 +99,9 @@ class WaldiezSimpleTarget(WaldiezBase):
|
|
|
104
99
|
"TerminateTarget"
|
|
105
100
|
]
|
|
106
101
|
The type of the transition target.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
target : str
|
|
111
|
-
The id of the group or nested chat to transfer control to.
|
|
102
|
+
value : list[str]
|
|
103
|
+
A list of values for the target, not actually used
|
|
104
|
+
(just for consistency with other targets).
|
|
112
105
|
"""
|
|
113
106
|
|
|
114
107
|
target_type: Annotated[
|
|
@@ -140,8 +133,6 @@ class WaldiezGroupOrNestedTarget(WaldiezBase):
|
|
|
140
133
|
The type of the transition target.
|
|
141
134
|
value : str
|
|
142
135
|
The id of the group or nested chat to transfer control to.
|
|
143
|
-
order : int
|
|
144
|
-
The order of the target in the list of targets.
|
|
145
136
|
"""
|
|
146
137
|
|
|
147
138
|
target_type: Annotated[
|
|
@@ -338,10 +329,14 @@ class WaldiezTransitionAvailability(WaldiezBase):
|
|
|
338
329
|
|
|
339
330
|
Attributes
|
|
340
331
|
----------
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
332
|
+
type : Literal["string", "expression", "none"]
|
|
333
|
+
The type of the availability condition.
|
|
334
|
+
Can be "string", "expression", or "none".
|
|
335
|
+
value : str
|
|
336
|
+
The value of the availability condition.
|
|
337
|
+
If type is "none", this value is ignored.
|
|
338
|
+
If type is "string", this is a string condition.
|
|
339
|
+
If type is "expression", this is an expression condition.
|
|
345
340
|
"""
|
|
346
341
|
|
|
347
342
|
type: Literal["string", "expression", "none"] = "none"
|
|
@@ -371,7 +366,20 @@ WaldiezHandoffTransition = Union[
|
|
|
371
366
|
|
|
372
367
|
|
|
373
368
|
class WaldiezHandoff(WaldiezBase):
|
|
374
|
-
"""Handoff class for Waldiez agents and chats.
|
|
369
|
+
"""Handoff class for Waldiez agents and chats.
|
|
370
|
+
|
|
371
|
+
Attributes
|
|
372
|
+
----------
|
|
373
|
+
target : WaldiezTransitionTarget
|
|
374
|
+
The target to transfer control to.
|
|
375
|
+
Can be an agent, group, nested chat, or simple target.
|
|
376
|
+
condition : WaldiezHandoffCondition
|
|
377
|
+
The condition to use for the handoff.
|
|
378
|
+
If not provided, the handoff will always be available.
|
|
379
|
+
available : WaldiezTransitionAvailability
|
|
380
|
+
The availability of the handoff.
|
|
381
|
+
If not provided, the handoff will always be available.
|
|
382
|
+
"""
|
|
375
383
|
|
|
376
384
|
target: Annotated[
|
|
377
385
|
WaldiezTransitionTarget,
|