waldiez 0.5.3__py3-none-any.whl → 0.5.5__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 +3 -27
- waldiez/exporter.py +0 -13
- waldiez/exporting/agent/exporter.py +38 -0
- waldiez/exporting/agent/extras/__init__.py +2 -0
- waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
- waldiez/exporting/agent/extras/group_member_extras.py +3 -2
- waldiez/exporting/agent/processor.py +113 -15
- waldiez/exporting/chats/processor.py +2 -21
- waldiez/exporting/chats/utils/common.py +66 -1
- waldiez/exporting/chats/utils/group.py +6 -3
- waldiez/exporting/chats/utils/nested.py +1 -1
- waldiez/exporting/chats/utils/sequential.py +25 -9
- waldiez/exporting/chats/utils/single.py +8 -6
- waldiez/exporting/core/context.py +0 -12
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
- waldiez/exporting/core/extras/base.py +20 -17
- waldiez/exporting/core/extras/path_resolver.py +39 -41
- waldiez/exporting/core/extras/serializer.py +16 -1
- waldiez/exporting/core/protocols.py +17 -0
- waldiez/exporting/core/types.py +6 -9
- waldiez/exporting/flow/execution_generator.py +56 -21
- waldiez/exporting/flow/exporter.py +1 -4
- waldiez/exporting/flow/factory.py +0 -9
- waldiez/exporting/flow/file_generator.py +6 -0
- waldiez/exporting/flow/orchestrator.py +27 -21
- waldiez/exporting/flow/utils/__init__.py +0 -2
- waldiez/exporting/flow/utils/common.py +15 -96
- waldiez/exporting/flow/utils/importing.py +4 -0
- waldiez/io/mqtt.py +33 -14
- waldiez/io/redis.py +18 -13
- waldiez/io/structured.py +9 -4
- waldiez/io/utils.py +32 -0
- waldiez/io/ws.py +8 -2
- waldiez/models/__init__.py +6 -0
- waldiez/models/agents/__init__.py +8 -0
- waldiez/models/agents/agent/agent.py +136 -38
- waldiez/models/agents/agent/agent_type.py +3 -2
- waldiez/models/agents/agents.py +10 -0
- waldiez/models/agents/doc_agent/__init__.py +13 -0
- waldiez/models/agents/doc_agent/doc_agent.py +126 -0
- waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
- waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
- waldiez/models/flow/flow.py +13 -2
- waldiez/models/model/__init__.py +2 -2
- waldiez/models/model/_aws.py +75 -0
- waldiez/models/model/_llm.py +516 -0
- waldiez/models/model/_price.py +30 -0
- waldiez/models/model/model.py +45 -2
- waldiez/models/model/model_data.py +2 -83
- waldiez/models/tool/predefined/_duckduckgo.py +123 -0
- waldiez/models/tool/predefined/_google.py +31 -9
- waldiez/models/tool/predefined/_perplexity.py +161 -0
- waldiez/models/tool/predefined/_searxng.py +152 -0
- waldiez/models/tool/predefined/_tavily.py +46 -9
- waldiez/models/tool/predefined/_wikipedia.py +26 -6
- waldiez/models/tool/predefined/_youtube.py +36 -8
- waldiez/models/tool/predefined/registry.py +6 -0
- waldiez/models/waldiez.py +12 -0
- waldiez/runner.py +177 -408
- waldiez/running/__init__.py +2 -4
- waldiez/running/base_runner.py +100 -112
- waldiez/running/environment.py +29 -4
- waldiez/running/post_run.py +0 -1
- waldiez/running/protocol.py +36 -48
- waldiez/running/run_results.py +5 -5
- waldiez/running/standard_runner.py +429 -0
- waldiez/running/timeline_processor.py +0 -82
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/METADATA +59 -62
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/RECORD +74 -64
- waldiez/running/import_runner.py +0 -437
- waldiez/running/subprocess_runner.py +0 -104
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/WHEEL +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/entry_points.txt +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
# flake8: noqa: E501
|
|
5
5
|
"""Common utils for the final generatio."""
|
|
6
6
|
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
|
|
9
7
|
from waldiez.models import Waldiez
|
|
10
8
|
|
|
11
9
|
from ...core import FILE_HEADER
|
|
@@ -16,7 +14,6 @@ from .linting import (
|
|
|
16
14
|
get_pyright_ignore_comment,
|
|
17
15
|
)
|
|
18
16
|
|
|
19
|
-
RETURN_TYPE_HINT = "Union[ChatResult, list[ChatResult], dict[int, ChatResult]]"
|
|
20
17
|
GENERATED_WITH = "🧩 generated with ❤️ by Waldiez."
|
|
21
18
|
|
|
22
19
|
|
|
@@ -105,21 +102,34 @@ Tags: {", ".join(tags)}
|
|
|
105
102
|
"""'''
|
|
106
103
|
|
|
107
104
|
|
|
108
|
-
def main_doc_string() -> str:
|
|
105
|
+
def main_doc_string(is_async: bool) -> str:
|
|
109
106
|
"""Generate the docstring for the main function.
|
|
110
107
|
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
is_async : bool
|
|
111
|
+
Whether the main function is asynchronous.
|
|
112
|
+
|
|
111
113
|
Returns
|
|
112
114
|
-------
|
|
113
115
|
str
|
|
114
116
|
The docstring for the main function.
|
|
115
117
|
"""
|
|
118
|
+
return_type_hint = (
|
|
119
|
+
"AsyncRunResponseProtocol" if is_async else "RunResponseProtocol"
|
|
120
|
+
)
|
|
116
121
|
return f'''"""Start chatting.
|
|
117
122
|
|
|
118
123
|
Returns
|
|
119
124
|
-------
|
|
120
|
-
{
|
|
125
|
+
{return_type_hint}
|
|
121
126
|
The result of the chat session, which can be a single ChatResult,
|
|
122
127
|
a list of ChatResults, or a dictionary mapping integers to ChatResults.
|
|
128
|
+
|
|
129
|
+
Raises
|
|
130
|
+
------
|
|
131
|
+
RuntimeError
|
|
132
|
+
If the chat session fails.
|
|
123
133
|
"""'''
|
|
124
134
|
|
|
125
135
|
|
|
@@ -207,94 +217,3 @@ if not hasattr(np, "_no_pep50_warning"):
|
|
|
207
217
|
setattr(np, "_no_pep50_warning", _np_no_nep50_warning) # noqa
|
|
208
218
|
'''
|
|
209
219
|
return content
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
def get_set_io_stream(
|
|
213
|
-
use_structured_io: bool,
|
|
214
|
-
is_async: bool,
|
|
215
|
-
uploads_root: Path | None,
|
|
216
|
-
) -> str:
|
|
217
|
-
"""Get the content to set structured IO.
|
|
218
|
-
|
|
219
|
-
Parameters
|
|
220
|
-
----------
|
|
221
|
-
use_structured_io : bool
|
|
222
|
-
Whether to use structured IO or not.
|
|
223
|
-
is_async : bool
|
|
224
|
-
Whether the flow is async or not.
|
|
225
|
-
uploads_root : Path | None
|
|
226
|
-
The uploads root, to get user-uploaded files, by default None.
|
|
227
|
-
|
|
228
|
-
Returns
|
|
229
|
-
-------
|
|
230
|
-
str
|
|
231
|
-
The content to set structured IO.
|
|
232
|
-
"""
|
|
233
|
-
if use_structured_io:
|
|
234
|
-
return get_set_structured_io_stream(
|
|
235
|
-
is_async=is_async,
|
|
236
|
-
uploads_root=uploads_root,
|
|
237
|
-
)
|
|
238
|
-
return get_patch_default_io_stream(is_async)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
def get_set_structured_io_stream(
|
|
242
|
-
is_async: bool,
|
|
243
|
-
uploads_root: Path | None,
|
|
244
|
-
) -> str:
|
|
245
|
-
"""Get the content to set structured IO.
|
|
246
|
-
|
|
247
|
-
Parameters
|
|
248
|
-
----------
|
|
249
|
-
is_async : bool
|
|
250
|
-
Whether the flow is async or not.
|
|
251
|
-
uploads_root : Path | None
|
|
252
|
-
The uploads root, to get user-uploaded files, by default None.
|
|
253
|
-
|
|
254
|
-
Returns
|
|
255
|
-
-------
|
|
256
|
-
str
|
|
257
|
-
The content to set structured IO.
|
|
258
|
-
"""
|
|
259
|
-
upload_root_arg = f'r"{uploads_root}"' if uploads_root else "None"
|
|
260
|
-
return f"""
|
|
261
|
-
# set structured IO
|
|
262
|
-
try:
|
|
263
|
-
# pylint: disable=import-outside-toplevel
|
|
264
|
-
from autogen.io import IOStream
|
|
265
|
-
from waldiez.io import StructuredIOStream
|
|
266
|
-
stream = StructuredIOStream(
|
|
267
|
-
is_async={is_async},
|
|
268
|
-
uploads_root={upload_root_arg}
|
|
269
|
-
)
|
|
270
|
-
IOStream.set_default(stream)
|
|
271
|
-
except BaseException: # pylint: disable=broad-exception-caught
|
|
272
|
-
# allow running the flow without structured IO
|
|
273
|
-
pass
|
|
274
|
-
"""
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
def get_patch_default_io_stream(is_async: bool) -> str:
|
|
278
|
-
"""Get the content to patch the default IO stream.
|
|
279
|
-
|
|
280
|
-
Parameters
|
|
281
|
-
----------
|
|
282
|
-
is_async : bool
|
|
283
|
-
Whether the flow is async or not.
|
|
284
|
-
|
|
285
|
-
Returns
|
|
286
|
-
-------
|
|
287
|
-
str
|
|
288
|
-
The content to patch the default IO stream.
|
|
289
|
-
"""
|
|
290
|
-
# copy from waldiez/running/patch_io_stream.py
|
|
291
|
-
return f"""
|
|
292
|
-
# patch the default IOStream
|
|
293
|
-
try:
|
|
294
|
-
# pylint: disable=import-outside-toplevel
|
|
295
|
-
from waldiez.running.patch_io_stream import patch_io_stream
|
|
296
|
-
patch_io_stream(is_async={is_async})
|
|
297
|
-
except BaseException: # pylint: disable=broad-exception-caught
|
|
298
|
-
# allow running the flow without patching the IOStream
|
|
299
|
-
pass
|
|
300
|
-
"""
|
|
@@ -21,6 +21,7 @@ TYPING_IMPORT_NAMES = [
|
|
|
21
21
|
"Annotated",
|
|
22
22
|
"Any",
|
|
23
23
|
"Callable",
|
|
24
|
+
"Coroutine",
|
|
24
25
|
"Dict",
|
|
25
26
|
"List",
|
|
26
27
|
"Optional",
|
|
@@ -37,6 +38,9 @@ COMMON_AUTOGEN_IMPORTS = [
|
|
|
37
38
|
"from autogen import ChatResult",
|
|
38
39
|
"from autogen import GroupChat",
|
|
39
40
|
"from autogen import runtime_logging",
|
|
41
|
+
"from autogen.events import BaseEvent",
|
|
42
|
+
"from autogen.io.run_response import RunResponseProtocol",
|
|
43
|
+
"from autogen.io.run_response import AsyncRunResponseProtocol",
|
|
40
44
|
]
|
|
41
45
|
|
|
42
46
|
|
waldiez/io/mqtt.py
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
|
|
4
4
|
# flake8: noqa: E501
|
|
5
|
-
# pylint: disable=too-many-try-statements,broad-exception-caught
|
|
6
|
-
# pylint: disable=line-too-long,unused-argument
|
|
7
|
-
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
5
|
+
# pylint: disable=too-many-try-statements,broad-exception-caught
|
|
6
|
+
# pylint: disable=line-too-long,duplicate-code,unused-argument
|
|
7
|
+
# pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
8
|
+
# pylint: disable=too-many-locals,too-many-instance-attributes
|
|
8
9
|
|
|
9
10
|
"""An MQTT I/O stream for handling print and input messages."""
|
|
10
11
|
|
|
@@ -351,9 +352,13 @@ class MqttIOStream(IOStream):
|
|
|
351
352
|
}
|
|
352
353
|
LOG.debug("MQTT log: %s", payload)
|
|
353
354
|
print_message = PrintMessage(data=buf)
|
|
354
|
-
|
|
355
|
-
payload=print_message.model_dump(mode="json")
|
|
356
|
-
|
|
355
|
+
try:
|
|
356
|
+
payload = print_message.model_dump(mode="json")
|
|
357
|
+
except Exception:
|
|
358
|
+
payload = print_message.model_dump(
|
|
359
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
360
|
+
)
|
|
361
|
+
self._print_to_common_output(payload=payload)
|
|
357
362
|
|
|
358
363
|
def _handle_input_response(self, payload: str) -> None:
|
|
359
364
|
"""Handle input response message."""
|
|
@@ -463,7 +468,12 @@ class MqttIOStream(IOStream):
|
|
|
463
468
|
Additional keyword arguments.
|
|
464
469
|
"""
|
|
465
470
|
print_message = PrintMessage.create(*args, **kwargs)
|
|
466
|
-
|
|
471
|
+
try:
|
|
472
|
+
payload = print_message.model_dump(mode="json")
|
|
473
|
+
except Exception:
|
|
474
|
+
payload = print_message.model_dump(
|
|
475
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
476
|
+
)
|
|
467
477
|
self._print(payload)
|
|
468
478
|
|
|
469
479
|
def send(self, message: BaseMessage) -> None:
|
|
@@ -476,11 +486,16 @@ class MqttIOStream(IOStream):
|
|
|
476
486
|
"""
|
|
477
487
|
try:
|
|
478
488
|
message_dump = message.model_dump(mode="json")
|
|
479
|
-
except Exception
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
489
|
+
except Exception:
|
|
490
|
+
try:
|
|
491
|
+
message_dump = message.model_dump(
|
|
492
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
493
|
+
)
|
|
494
|
+
except Exception as e:
|
|
495
|
+
message_dump = {
|
|
496
|
+
"error": str(e),
|
|
497
|
+
"type": message.__class__.__name__,
|
|
498
|
+
}
|
|
484
499
|
|
|
485
500
|
message_type = message_dump.get("type", None)
|
|
486
501
|
if not message_type: # pragma: no cover
|
|
@@ -523,8 +538,12 @@ class MqttIOStream(IOStream):
|
|
|
523
538
|
prompt=prompt,
|
|
524
539
|
password=password,
|
|
525
540
|
)
|
|
526
|
-
|
|
527
|
-
|
|
541
|
+
try:
|
|
542
|
+
payload = input_request.model_dump(mode="json")
|
|
543
|
+
except Exception: # pragma: no cover
|
|
544
|
+
payload = input_request.model_dump(
|
|
545
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
546
|
+
)
|
|
528
547
|
payload["task_id"] = self.task_id
|
|
529
548
|
payload["password"] = str(password).lower()
|
|
530
549
|
|
waldiez/io/redis.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
|
|
4
4
|
# flake8: noqa: E501
|
|
5
|
-
# pylint: disable=too-many-try-statements,broad-exception-caught
|
|
5
|
+
# pylint: disable=too-many-try-statements,broad-exception-caught
|
|
6
|
+
# pylint: disable=line-too-long,duplicate-code
|
|
6
7
|
|
|
7
8
|
"""A Redis I/O stream for handling print and input messages."""
|
|
8
9
|
|
|
@@ -29,8 +30,8 @@ except ImportError as error: # pragma: no cover
|
|
|
29
30
|
raise ImportError(
|
|
30
31
|
"Redis client not installed. Please install redis-py with `pip install redis`."
|
|
31
32
|
) from error
|
|
33
|
+
from autogen.events import BaseEvent # type: ignore
|
|
32
34
|
from autogen.io import IOStream # type: ignore
|
|
33
|
-
from autogen.messages import BaseMessage # type: ignore
|
|
34
35
|
|
|
35
36
|
from .models import (
|
|
36
37
|
PrintMessage,
|
|
@@ -39,7 +40,7 @@ from .models import (
|
|
|
39
40
|
UserInputRequest,
|
|
40
41
|
UserResponse,
|
|
41
42
|
)
|
|
42
|
-
from .utils import gen_id, now
|
|
43
|
+
from .utils import gen_id, get_message_dump, now
|
|
43
44
|
|
|
44
45
|
if TYPE_CHECKING:
|
|
45
46
|
Redis = redis.Redis[bytes]
|
|
@@ -217,7 +218,12 @@ class RedisIOStream(IOStream):
|
|
|
217
218
|
Additional keyword arguments.
|
|
218
219
|
"""
|
|
219
220
|
print_message = PrintMessage.create(*args, **kwargs)
|
|
220
|
-
|
|
221
|
+
try:
|
|
222
|
+
payload = print_message.model_dump(mode="json")
|
|
223
|
+
except Exception: # pragma: no cover
|
|
224
|
+
payload = print_message.model_dump(
|
|
225
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
226
|
+
)
|
|
221
227
|
self._print(payload)
|
|
222
228
|
|
|
223
229
|
def input(
|
|
@@ -249,7 +255,12 @@ class RedisIOStream(IOStream):
|
|
|
249
255
|
prompt=prompt,
|
|
250
256
|
password=password,
|
|
251
257
|
)
|
|
252
|
-
|
|
258
|
+
try:
|
|
259
|
+
payload = input_request.model_dump(mode="json")
|
|
260
|
+
except Exception: # pragma: no cover
|
|
261
|
+
payload = input_request.model_dump(
|
|
262
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
263
|
+
)
|
|
253
264
|
payload["password"] = str(password).lower()
|
|
254
265
|
payload["task_id"] = self.task_id
|
|
255
266
|
LOG.debug("Requesting input via Pub/Sub: %s", payload)
|
|
@@ -278,7 +289,7 @@ class RedisIOStream(IOStream):
|
|
|
278
289
|
self._print(payload)
|
|
279
290
|
return user_input
|
|
280
291
|
|
|
281
|
-
def send(self, message:
|
|
292
|
+
def send(self, message: BaseEvent) -> None:
|
|
282
293
|
"""Send a structured message to Redis.
|
|
283
294
|
|
|
284
295
|
Parameters
|
|
@@ -286,13 +297,7 @@ class RedisIOStream(IOStream):
|
|
|
286
297
|
message : dict[str, Any]
|
|
287
298
|
The message to send.
|
|
288
299
|
"""
|
|
289
|
-
|
|
290
|
-
message_dump = message.model_dump(mode="json")
|
|
291
|
-
except Exception as e: # pragma: no cover
|
|
292
|
-
message_dump = {
|
|
293
|
-
"type": "error",
|
|
294
|
-
"error": str(e),
|
|
295
|
-
}
|
|
300
|
+
message_dump = get_message_dump(message)
|
|
296
301
|
message_type = message_dump.get("type", None)
|
|
297
302
|
if not message_type:
|
|
298
303
|
message_type = message.__class__.__name__
|
waldiez/io/structured.py
CHANGED
|
@@ -24,6 +24,7 @@ from .models import (
|
|
|
24
24
|
from .utils import (
|
|
25
25
|
gen_id,
|
|
26
26
|
get_image,
|
|
27
|
+
get_message_dump,
|
|
27
28
|
is_json_dumped,
|
|
28
29
|
now,
|
|
29
30
|
try_parse_maybe_serialized,
|
|
@@ -83,7 +84,7 @@ class StructuredIOStream(IOStream):
|
|
|
83
84
|
flush = kwargs.get("flush", True)
|
|
84
85
|
payload_type = kwargs.get("type", "print")
|
|
85
86
|
payload["type"] = payload_type
|
|
86
|
-
print(json.dumps(payload), flush=flush)
|
|
87
|
+
print(json.dumps(payload, default=str), flush=flush)
|
|
87
88
|
|
|
88
89
|
def input(self, prompt: str = "", *, password: bool = False) -> str:
|
|
89
90
|
"""Structured input from stdin.
|
|
@@ -133,7 +134,7 @@ class StructuredIOStream(IOStream):
|
|
|
133
134
|
return user_response
|
|
134
135
|
|
|
135
136
|
# noinspection PyMethodMayBeStatic
|
|
136
|
-
# pylint: disable=no-self-use
|
|
137
|
+
# pylint: disable=no-self-use,broad-exception-caught
|
|
137
138
|
def send(self, message: BaseEvent) -> None:
|
|
138
139
|
"""Structured sending of a BaseEvent.
|
|
139
140
|
|
|
@@ -142,7 +143,7 @@ class StructuredIOStream(IOStream):
|
|
|
142
143
|
message : BaseEvent
|
|
143
144
|
The message to send.
|
|
144
145
|
"""
|
|
145
|
-
message_dump = message
|
|
146
|
+
message_dump = get_message_dump(message)
|
|
146
147
|
if message_dump.get("type") == "text":
|
|
147
148
|
content_block = message_dump.get("content")
|
|
148
149
|
if (
|
|
@@ -154,7 +155,11 @@ class StructuredIOStream(IOStream):
|
|
|
154
155
|
content_block["content"] = try_parse_maybe_serialized(
|
|
155
156
|
inner_content
|
|
156
157
|
)
|
|
157
|
-
print(
|
|
158
|
+
print(
|
|
159
|
+
json.dumps(message_dump, default=str),
|
|
160
|
+
flush=True,
|
|
161
|
+
file=sys.stdout,
|
|
162
|
+
)
|
|
158
163
|
|
|
159
164
|
# noinspection PyMethodMayBeStatic
|
|
160
165
|
# pylint: disable=no-self-use
|
waldiez/io/utils.py
CHANGED
|
@@ -11,6 +11,7 @@ from pathlib import Path
|
|
|
11
11
|
from typing import Any, Literal, Union
|
|
12
12
|
|
|
13
13
|
from autogen.agentchat.contrib.img_utils import get_pil_image # type: ignore
|
|
14
|
+
from autogen.events import BaseEvent # type: ignore
|
|
14
15
|
|
|
15
16
|
MessageType = Literal[
|
|
16
17
|
"input_request",
|
|
@@ -182,3 +183,34 @@ def try_parse_maybe_serialized(value: str) -> Any:
|
|
|
182
183
|
except Exception:
|
|
183
184
|
pass # Try next parser
|
|
184
185
|
return value # Return original if all parsing fails
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def get_message_dump(
|
|
189
|
+
message: BaseEvent,
|
|
190
|
+
) -> dict[str, Any]:
|
|
191
|
+
"""Get the message dump.
|
|
192
|
+
|
|
193
|
+
Parameters
|
|
194
|
+
----------
|
|
195
|
+
message : BaseEvent
|
|
196
|
+
The message to dump.
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
dict[str, Any]
|
|
201
|
+
The dumped message.
|
|
202
|
+
"""
|
|
203
|
+
# pylint: disable=broad-exception-caught
|
|
204
|
+
try:
|
|
205
|
+
message_dump = message.model_dump(mode="json")
|
|
206
|
+
except Exception:
|
|
207
|
+
try:
|
|
208
|
+
message_dump = message.model_dump(
|
|
209
|
+
serialize_as_any=True, mode="json", fallback=str
|
|
210
|
+
)
|
|
211
|
+
except Exception as e:
|
|
212
|
+
message_dump = {
|
|
213
|
+
"error": str(e),
|
|
214
|
+
"type": message.__class__.__name__,
|
|
215
|
+
}
|
|
216
|
+
return message_dump
|
waldiez/io/ws.py
CHANGED
|
@@ -19,7 +19,12 @@ from ._ws import (
|
|
|
19
19
|
is_websocket_available,
|
|
20
20
|
)
|
|
21
21
|
from .models import UserResponse
|
|
22
|
-
from .utils import
|
|
22
|
+
from .utils import (
|
|
23
|
+
get_message_dump,
|
|
24
|
+
is_json_dumped,
|
|
25
|
+
now,
|
|
26
|
+
try_parse_maybe_serialized,
|
|
27
|
+
)
|
|
23
28
|
|
|
24
29
|
LOG = logging.getLogger(__name__)
|
|
25
30
|
|
|
@@ -137,7 +142,7 @@ class AsyncWebsocketsIOStream(IOStream):
|
|
|
137
142
|
message : BaseEvent
|
|
138
143
|
The message to send.
|
|
139
144
|
"""
|
|
140
|
-
message_dump = message
|
|
145
|
+
message_dump = get_message_dump(message)
|
|
141
146
|
|
|
142
147
|
if message_dump.get("type") == "text":
|
|
143
148
|
content_block = message_dump.get("content")
|
|
@@ -150,6 +155,7 @@ class AsyncWebsocketsIOStream(IOStream):
|
|
|
150
155
|
content_block["content"] = try_parse_maybe_serialized(
|
|
151
156
|
inner_content
|
|
152
157
|
)
|
|
158
|
+
message_dump["content"] = content_block
|
|
153
159
|
|
|
154
160
|
json_dump = json.dumps(message_dump, ensure_ascii=False)
|
|
155
161
|
|
waldiez/models/__init__.py
CHANGED
|
@@ -29,6 +29,9 @@ from .agents import (
|
|
|
29
29
|
WaldiezCaptainAgent,
|
|
30
30
|
WaldiezCaptainAgentData,
|
|
31
31
|
WaldiezCaptainAgentLibEntry,
|
|
32
|
+
WaldiezDocAgent,
|
|
33
|
+
WaldiezDocAgentData,
|
|
34
|
+
WaldiezDocAgentQueryEngine,
|
|
32
35
|
WaldiezGroupManager,
|
|
33
36
|
WaldiezGroupManagerData,
|
|
34
37
|
WaldiezGroupManagerSpeakers,
|
|
@@ -150,6 +153,8 @@ __all__ = [
|
|
|
150
153
|
"WaldiezContextBasedTransition",
|
|
151
154
|
"WaldiezContextStrLLMCondition",
|
|
152
155
|
"WaldiezDefaultCondition",
|
|
156
|
+
"WaldiezDocAgent",
|
|
157
|
+
"WaldiezDocAgentData",
|
|
153
158
|
"WaldiezExpressionContextCondition",
|
|
154
159
|
"WaldiezFlow",
|
|
155
160
|
"WaldiezFlowData",
|
|
@@ -171,6 +176,7 @@ __all__ = [
|
|
|
171
176
|
"WaldiezModelAWS",
|
|
172
177
|
"WaldiezModelData",
|
|
173
178
|
"WaldiezModelPrice",
|
|
179
|
+
"WaldiezDocAgentQueryEngine",
|
|
174
180
|
"WaldiezRagUserProxy",
|
|
175
181
|
"WaldiezRagUserProxyChunkMode",
|
|
176
182
|
"WaldiezRagUserProxyData",
|
|
@@ -25,6 +25,11 @@ from .captain import (
|
|
|
25
25
|
WaldiezCaptainAgentData,
|
|
26
26
|
WaldiezCaptainAgentLibEntry,
|
|
27
27
|
)
|
|
28
|
+
from .doc_agent import (
|
|
29
|
+
WaldiezDocAgent,
|
|
30
|
+
WaldiezDocAgentData,
|
|
31
|
+
WaldiezDocAgentQueryEngine,
|
|
32
|
+
)
|
|
28
33
|
from .extra_requirements import (
|
|
29
34
|
get_captain_agent_extra_requirements,
|
|
30
35
|
get_retrievechat_extra_requirements,
|
|
@@ -99,6 +104,8 @@ __all__ = [
|
|
|
99
104
|
"WaldiezCaptainAgent",
|
|
100
105
|
"WaldiezCaptainAgentData",
|
|
101
106
|
"WaldiezCaptainAgentLibEntry",
|
|
107
|
+
"WaldiezDocAgent",
|
|
108
|
+
"WaldiezDocAgentData",
|
|
102
109
|
"WaldiezRagUserProxy",
|
|
103
110
|
"WaldiezRagUserProxyData",
|
|
104
111
|
"WaldiezRagUserProxyModels",
|
|
@@ -107,6 +114,7 @@ __all__ = [
|
|
|
107
114
|
"WaldiezReasoningAgentReasonConfig",
|
|
108
115
|
"WaldiezUserProxy",
|
|
109
116
|
"WaldiezUserProxyData",
|
|
117
|
+
"WaldiezDocAgentQueryEngine",
|
|
110
118
|
"WaldiezRagUserProxyRetrieveConfig",
|
|
111
119
|
"WaldiezRagUserProxyTask",
|
|
112
120
|
"WaldiezRagUserProxyChunkMode",
|