waldiez 0.1.7__tar.gz → 0.1.9__tar.gz
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-0.1.7 → waldiez-0.1.9}/PKG-INFO +83 -51
- waldiez-0.1.9/README.md +170 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/pyproject.toml +27 -25
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/_version.py +1 -1
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/chroma_utils.py +5 -6
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/chats/nested.py +2 -12
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/logging_utils.py +1 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/path_check.py +8 -5
- waldiez-0.1.9/waldiez/io/__init__.py +142 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/nested_chat.py +4 -8
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/waldiez.py +5 -8
- waldiez-0.1.7/README.md +0 -135
- waldiez-0.1.7/waldiez/io/__init__.py +0 -181
- waldiez-0.1.7/waldiez/io/stream/__init__.py +0 -7
- waldiez-0.1.7/waldiez/io/stream/consumer.py +0 -139
- waldiez-0.1.7/waldiez/io/stream/provider.py +0 -343
- waldiez-0.1.7/waldiez/io/stream/server.py +0 -438
- {waldiez-0.1.7 → waldiez-0.1.9}/.gitignore +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/LICENSE +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/__main__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/cli.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporter.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/agent.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/agent_skills.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/code_execution.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/group_manager.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/llm_config.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/mongo_utils.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/pgvector_utils.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/qdrant_utils.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/rag_user.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/rag_user/vector_db.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/teachability.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/agents/termination_message.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/chats/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/chats/chats.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/chats/helpers.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/flow/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/flow/def_main.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/flow/flow.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/models/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/skills/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/comments.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/importing.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/method_utils.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/naming.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/exporting/utils/object_string.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/agent.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/agent_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/code_execution.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/linked_skill.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/teachability.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agent/termination_message.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/agents.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/assistant/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/assistant/assistant.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/assistant/assistant_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/group_manager/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/group_manager/group_manager.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/group_manager/group_manager_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/group_manager/speakers.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/rag_user/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/rag_user/rag_user.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/rag_user/rag_user_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/rag_user/retrieve_config.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/rag_user/vector_db_config.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/user_proxy/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/user_proxy/user_proxy.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/agents/user_proxy/user_proxy_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/chat.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/chat_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/chat_message.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/chat_nested.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/chat/chat_summary.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/common/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/common/base.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/common/method_utils.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/flow/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/flow/flow.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/flow/flow_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/model/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/model/model.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/model/model_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/skill/__init__.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/skill/skill.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/models/skill/skill_data.py +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/py.typed +0 -0
- {waldiez-0.1.7 → waldiez-0.1.9}/waldiez/runner.py +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: waldiez
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: waldiez
|
|
5
|
-
Project-URL: homepage, https://waldiez.github.io/
|
|
6
|
-
Project-URL: repository, https://github.com/waldiez/
|
|
5
|
+
Project-URL: homepage, https://waldiez.github.io/waldiez/
|
|
6
|
+
Project-URL: repository, https://github.com/waldiez/waldiez.git
|
|
7
7
|
Author-email: Panagiotis Kasnesis <pkasnesis@thingenious.io>, Lazaros Toumanidis <laztoum@protonmail.com>
|
|
8
|
-
License-File: LICENSE
|
|
9
8
|
Classifier: Development Status :: 3 - Alpha
|
|
10
9
|
Classifier: Intended Audience :: Developers
|
|
11
10
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -17,28 +16,26 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Requires-Python: <3.13,>=3.10
|
|
20
|
-
Requires-Dist:
|
|
19
|
+
Requires-Dist: ag2==0.3.2
|
|
21
20
|
Requires-Dist: jupytext
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist:
|
|
34
|
-
Requires-Dist:
|
|
35
|
-
Requires-Dist:
|
|
36
|
-
Requires-Dist:
|
|
37
|
-
Requires-Dist:
|
|
38
|
-
Requires-Dist:
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist: pymongo==4.10.1; extra == 'autogen-extras'
|
|
41
|
-
Requires-Dist: qdrant-client==1.12.1; extra == 'autogen-extras'
|
|
21
|
+
Provides-Extra: ag2-extras
|
|
22
|
+
Requires-Dist: ag2[anthropic]==0.3.2; extra == 'ag2-extras'
|
|
23
|
+
Requires-Dist: ag2[bedrock]==0.3.2; extra == 'ag2-extras'
|
|
24
|
+
Requires-Dist: ag2[gemini]==0.3.2; extra == 'ag2-extras'
|
|
25
|
+
Requires-Dist: ag2[groq]==0.3.2; extra == 'ag2-extras'
|
|
26
|
+
Requires-Dist: ag2[mistral]==0.3.2; extra == 'ag2-extras'
|
|
27
|
+
Requires-Dist: ag2[retrievechat-mongodb]==0.3.2; extra == 'ag2-extras'
|
|
28
|
+
Requires-Dist: ag2[retrievechat-pgvector]==0.3.2; extra == 'ag2-extras'
|
|
29
|
+
Requires-Dist: ag2[retrievechat-qdrant]==0.3.2; extra == 'ag2-extras'
|
|
30
|
+
Requires-Dist: ag2[retrievechat]==0.3.2; extra == 'ag2-extras'
|
|
31
|
+
Requires-Dist: ag2[together]==0.3.2; extra == 'ag2-extras'
|
|
32
|
+
Requires-Dist: ag2[websurfer]==0.3.2; extra == 'ag2-extras'
|
|
33
|
+
Requires-Dist: chromadb==0.5.3; extra == 'ag2-extras'
|
|
34
|
+
Requires-Dist: fastembed==0.4.2; extra == 'ag2-extras'
|
|
35
|
+
Requires-Dist: pgvector>=0.2.5; extra == 'ag2-extras'
|
|
36
|
+
Requires-Dist: psycopg[binary]>=3.1.18; extra == 'ag2-extras'
|
|
37
|
+
Requires-Dist: pymongo==4.10.1; extra == 'ag2-extras'
|
|
38
|
+
Requires-Dist: qdrant-client==1.12.1; extra == 'ag2-extras'
|
|
42
39
|
Provides-Extra: dev
|
|
43
40
|
Requires-Dist: autoflake==2.3.1; extra == 'dev'
|
|
44
41
|
Requires-Dist: bandit==1.7.10; extra == 'dev'
|
|
@@ -50,7 +47,7 @@ Requires-Dist: pre-commit==4.0.1; extra == 'dev'
|
|
|
50
47
|
Requires-Dist: pydocstyle==6.3.0; extra == 'dev'
|
|
51
48
|
Requires-Dist: pylint==3.3.1; extra == 'dev'
|
|
52
49
|
Requires-Dist: python-dotenv==1.0.1; extra == 'dev'
|
|
53
|
-
Requires-Dist: ruff==0.7.
|
|
50
|
+
Requires-Dist: ruff==0.7.4; extra == 'dev'
|
|
54
51
|
Requires-Dist: types-pyyaml==6.0.12; extra == 'dev'
|
|
55
52
|
Requires-Dist: yamllint==1.35.1; extra == 'dev'
|
|
56
53
|
Provides-Extra: docs
|
|
@@ -58,11 +55,11 @@ Requires-Dist: mdx-include==1.4.2; extra == 'docs'
|
|
|
58
55
|
Requires-Dist: mdx-truly-sane-lists==1.3; extra == 'docs'
|
|
59
56
|
Requires-Dist: mkdocs-jupyter==0.25.1; extra == 'docs'
|
|
60
57
|
Requires-Dist: mkdocs-macros-plugin==1.3.7; extra == 'docs'
|
|
61
|
-
Requires-Dist: mkdocs-material==9.5.
|
|
58
|
+
Requires-Dist: mkdocs-material==9.5.45; extra == 'docs'
|
|
62
59
|
Requires-Dist: mkdocs-minify-html-plugin==0.2.3; extra == 'docs'
|
|
63
60
|
Requires-Dist: mkdocs==1.6.1; extra == 'docs'
|
|
64
61
|
Requires-Dist: mkdocstrings-python==1.12.2; extra == 'docs'
|
|
65
|
-
Requires-Dist: mkdocstrings[crystal,python]==0.
|
|
62
|
+
Requires-Dist: mkdocstrings[crystal,python]==0.27.0; extra == 'docs'
|
|
66
63
|
Provides-Extra: test
|
|
67
64
|
Requires-Dist: pytest-cov==6.0.0; extra == 'test'
|
|
68
65
|
Requires-Dist: pytest-html==4.1.1; extra == 'test'
|
|
@@ -74,20 +71,20 @@ Description-Content-Type: text/markdown
|
|
|
74
71
|
|
|
75
72
|
# Waldiez
|
|
76
73
|
|
|
77
|
-
 [](https://coveralls.io/github/waldiez/waldiez) [](https://badge.fury.io/py/waldiez)
|
|
78
75
|
|
|
79
76
|
Translate a Waldiez flow:
|
|
80
77
|
|
|
81
|
-

|
|
82
79
|
|
|
83
|
-
To a python script or a jupyter notebook with the corresponding [
|
|
80
|
+
To a python script or a jupyter notebook with the corresponding [ag2](https://github.com/ag2ai/ag2/) agents and chats.
|
|
84
81
|
|
|
85
82
|
## Features
|
|
86
83
|
|
|
87
84
|
- Export .waldiez flows to .py or .ipynb
|
|
88
85
|
- Run a .waldiez flow
|
|
89
86
|
- Include a `logs` folder with the logs of the flow in csv format
|
|
90
|
-
- Provide a custom [IOSStream](https://
|
|
87
|
+
- Provide a custom [IOSStream](https://ag2ai.github.io/ag2/docs/reference/io/base#iostream) to handle input and output.
|
|
91
88
|
|
|
92
89
|
## Installation
|
|
93
90
|
|
|
@@ -100,7 +97,7 @@ python -m pip install waldiez
|
|
|
100
97
|
From the repository:
|
|
101
98
|
|
|
102
99
|
```bash
|
|
103
|
-
python -m pip install git+https://github.com/waldiez/
|
|
100
|
+
python -m pip install git+https://github.com/waldiez/waldiez.git
|
|
104
101
|
```
|
|
105
102
|
|
|
106
103
|
## Usage
|
|
@@ -119,13 +116,13 @@ waldiez /path/to/a/flow.waldiez --output /path/to/an/output/flow[.py] [--force]
|
|
|
119
116
|
```shell
|
|
120
117
|
CONTAINER_COMMAND=docker # or podman
|
|
121
118
|
# pull the image
|
|
122
|
-
$CONTAINER_COMMAND pull waldiez/
|
|
119
|
+
$CONTAINER_COMMAND pull waldiez/waldiez
|
|
123
120
|
# Export a Waldiez flow to a python script or a jupyter notebook
|
|
124
121
|
$CONTAINER_COMMAND run \
|
|
125
122
|
--rm \
|
|
126
123
|
-v /path/to/a/flow.waldiez:/flow.waldiez \
|
|
127
124
|
-v /path/to/an/output:/output \
|
|
128
|
-
waldiez/
|
|
125
|
+
waldiez/waldiez --export /flow.waldiez --output /output/flow[.py|.ipynb]
|
|
129
126
|
|
|
130
127
|
# with selinux and/or podman, you might get permission (or file not found) errors, so you can try:
|
|
131
128
|
$CONTAINER_COMMAND run \
|
|
@@ -134,12 +131,12 @@ $CONTAINER_COMMAND run \
|
|
|
134
131
|
-v /path/to/an/output:/output \
|
|
135
132
|
--userns=keep-id \
|
|
136
133
|
--security-opt label=disable \
|
|
137
|
-
waldiez/
|
|
134
|
+
waldiez/waldiez --export /flow.waldiez --output /output/flow[.py|.ipynb]
|
|
138
135
|
```
|
|
139
136
|
|
|
140
137
|
```shell
|
|
141
138
|
# Export and run the script
|
|
142
|
-
$CONTAINER_COMMAND run --rm -v /path/to/a/flow.waldiez:/flow.waldiez -v /path/to/an/output:/output waldiez/
|
|
139
|
+
$CONTAINER_COMMAND run --rm -v /path/to/a/flow.waldiez:/flow.waldiez -v /path/to/an/output:/output waldiez/waldiez /flow.waldiez --output /output/output[.py]
|
|
143
140
|
```
|
|
144
141
|
|
|
145
142
|
### As a library
|
|
@@ -170,40 +167,75 @@ runner.run(output_path=output_path)
|
|
|
170
167
|
|
|
171
168
|
```python
|
|
172
169
|
# Run the flow with a custom IOStream
|
|
170
|
+
# In case the standard 'input' and 'print' functions cannot be used
|
|
171
|
+
import time
|
|
172
|
+
import threading
|
|
173
|
+
|
|
174
|
+
from typing import Any
|
|
175
|
+
|
|
173
176
|
from waldiez import WaldiezRunner
|
|
174
177
|
from waldiez.io import WaldiezIOStream
|
|
175
178
|
|
|
176
179
|
flow_path = "/path/to/a/flow.waldiez"
|
|
177
180
|
output_path = "/path/to/an/output.py"
|
|
178
181
|
|
|
179
|
-
def print_function(*values, **args) -> None:
|
|
180
|
-
"""A custom print function."""
|
|
181
|
-
print(values)
|
|
182
182
|
|
|
183
|
-
def
|
|
184
|
-
"""
|
|
185
|
-
|
|
183
|
+
def custom_print_function(*args: Any, sep: str = " ", **kwargs: Any) -> None:
|
|
184
|
+
"""Custom print function."""
|
|
185
|
+
print(*args, sep=sep, **kwargs)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# Custom input handler
|
|
189
|
+
class InputProcessorWrapper:
|
|
190
|
+
"""Wrapper input processor.
|
|
191
|
+
|
|
192
|
+
To manage the interaction between the custom input processor and IOStream.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
def __init__(self):
|
|
196
|
+
self.stream = None # Placeholder for the WaldiezIOStream instance
|
|
197
|
+
self.lock = threading.Lock() # Ensure thread-safe operations
|
|
198
|
+
|
|
199
|
+
def custom_input_processor(self, prompt: str) -> None:
|
|
200
|
+
"""Simulate external input and send it back to the IOStream."""
|
|
201
|
+
def external_input_simulation():
|
|
202
|
+
with self.lock: # Ensure thread-safe access
|
|
203
|
+
time.sleep(2) # Simulate delay for network input
|
|
204
|
+
if self.stream:
|
|
205
|
+
self.stream.set_input("Simulated external input")
|
|
206
|
+
else:
|
|
207
|
+
raise RuntimeError("Stream reference not set!")
|
|
186
208
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
209
|
+
threading.Thread(target=external_input_simulation, daemon=True).start()
|
|
210
|
+
|
|
211
|
+
def set_stream(self, stream: "WaldiezIOStream"):
|
|
212
|
+
"""Set the WaldiezIOStream instance."""
|
|
213
|
+
with self.lock: # Ensure thread-safe setting of the stream
|
|
214
|
+
self.stream = stream
|
|
215
|
+
|
|
216
|
+
processor_wrapper = InputProcessorWrapper()
|
|
217
|
+
|
|
218
|
+
stream = WaldiezIOStream(
|
|
190
219
|
input_timeout=30,
|
|
220
|
+
print_function=
|
|
221
|
+
on_prompt_input=processor_wrapper.custom_input_processor,
|
|
191
222
|
)
|
|
223
|
+
|
|
224
|
+
# Link the processor wrapper to the WaldiezIOStream instance
|
|
225
|
+
processor_wrapper.set_stream(custom_stream)
|
|
226
|
+
|
|
192
227
|
with WaldiezIOStream.set_default(io_stream):
|
|
193
228
|
runner = WaldiezRunner.load(flow_path)
|
|
194
229
|
runner.run(stream=io_stream, output_path=output_path)
|
|
195
230
|
|
|
196
|
-
io_stream.close()
|
|
197
|
-
|
|
198
231
|
```
|
|
199
232
|
|
|
200
233
|
### Tools
|
|
201
234
|
|
|
202
|
-
- [
|
|
235
|
+
- [ag2 (formerly AutoGen)](https://github.com/ag2ai/ag2)
|
|
203
236
|
- [juptytext](https://github.com/mwouts/jupytext)
|
|
204
|
-
- [twisted](https://github.com/twisted/twisted)
|
|
205
237
|
- [pydantic](https://github.com/pydantic/pydantic)
|
|
206
238
|
|
|
207
239
|
## License
|
|
208
240
|
|
|
209
|
-
This project is licensed under the MIT License - see the [LICENSE](https://github.com/waldiez/
|
|
241
|
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/waldiez/waldiez/blob/main/LICENSE) file for details.
|
waldiez-0.1.9/README.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Waldiez
|
|
2
|
+
|
|
3
|
+
 [](https://coveralls.io/github/waldiez/waldiez) [](https://badge.fury.io/py/waldiez)
|
|
4
|
+
|
|
5
|
+
Translate a Waldiez flow:
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
To a python script or a jupyter notebook with the corresponding [ag2](https://github.com/ag2ai/ag2/) agents and chats.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Export .waldiez flows to .py or .ipynb
|
|
14
|
+
- Run a .waldiez flow
|
|
15
|
+
- Include a `logs` folder with the logs of the flow in csv format
|
|
16
|
+
- Provide a custom [IOSStream](https://ag2ai.github.io/ag2/docs/reference/io/base#iostream) to handle input and output.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
On PyPI:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m pip install waldiez
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
From the repository:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m pip install git+https://github.com/waldiez/waldiez.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### CLI
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Export a Waldiez flow to a python script or a jupyter notebook
|
|
38
|
+
waldiez --export /path/to/a/flow.waldiez --output /path/to/an/output/flow[.py|.ipynb]
|
|
39
|
+
# Export and run the script, optionally force generation if the output file already exists
|
|
40
|
+
waldiez /path/to/a/flow.waldiez --output /path/to/an/output/flow[.py] [--force]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Using docker/podman
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
CONTAINER_COMMAND=docker # or podman
|
|
47
|
+
# pull the image
|
|
48
|
+
$CONTAINER_COMMAND pull waldiez/waldiez
|
|
49
|
+
# Export a Waldiez flow to a python script or a jupyter notebook
|
|
50
|
+
$CONTAINER_COMMAND run \
|
|
51
|
+
--rm \
|
|
52
|
+
-v /path/to/a/flow.waldiez:/flow.waldiez \
|
|
53
|
+
-v /path/to/an/output:/output \
|
|
54
|
+
waldiez/waldiez --export /flow.waldiez --output /output/flow[.py|.ipynb]
|
|
55
|
+
|
|
56
|
+
# with selinux and/or podman, you might get permission (or file not found) errors, so you can try:
|
|
57
|
+
$CONTAINER_COMMAND run \
|
|
58
|
+
--rm \
|
|
59
|
+
-v /path/to/a/flow.waldiez:/flow.waldiez \
|
|
60
|
+
-v /path/to/an/output:/output \
|
|
61
|
+
--userns=keep-id \
|
|
62
|
+
--security-opt label=disable \
|
|
63
|
+
waldiez/waldiez --export /flow.waldiez --output /output/flow[.py|.ipynb]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
# Export and run the script
|
|
68
|
+
$CONTAINER_COMMAND run --rm -v /path/to/a/flow.waldiez:/flow.waldiez -v /path/to/an/output:/output waldiez/waldiez /flow.waldiez --output /output/output[.py]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### As a library
|
|
72
|
+
|
|
73
|
+
#### Export a flow
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
# Export a Waldiez flow to a python script or a jupyter notebook
|
|
77
|
+
from waldiez import WaldiezExporter
|
|
78
|
+
flow_path = "/path/to/a/flow.waldiez"
|
|
79
|
+
output_path = "/path/to/an/output.py" # or .ipynb
|
|
80
|
+
exporter = WaldiezExporter.load(flow_path)
|
|
81
|
+
exporter.export(output_path)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### Run a flow
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
# Run a flow
|
|
88
|
+
from waldiez import WaldiezRunner
|
|
89
|
+
flow_path = "/path/to/a/flow.waldiez"
|
|
90
|
+
output_path = "/path/to/an/output.py"
|
|
91
|
+
runner = WaldiezRunner.load(flow_path)
|
|
92
|
+
runner.run(output_path=output_path)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### Run a flow with a custom IOStream
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# Run the flow with a custom IOStream
|
|
99
|
+
# In case the standard 'input' and 'print' functions cannot be used
|
|
100
|
+
import time
|
|
101
|
+
import threading
|
|
102
|
+
|
|
103
|
+
from typing import Any
|
|
104
|
+
|
|
105
|
+
from waldiez import WaldiezRunner
|
|
106
|
+
from waldiez.io import WaldiezIOStream
|
|
107
|
+
|
|
108
|
+
flow_path = "/path/to/a/flow.waldiez"
|
|
109
|
+
output_path = "/path/to/an/output.py"
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def custom_print_function(*args: Any, sep: str = " ", **kwargs: Any) -> None:
|
|
113
|
+
"""Custom print function."""
|
|
114
|
+
print(*args, sep=sep, **kwargs)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# Custom input handler
|
|
118
|
+
class InputProcessorWrapper:
|
|
119
|
+
"""Wrapper input processor.
|
|
120
|
+
|
|
121
|
+
To manage the interaction between the custom input processor and IOStream.
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
def __init__(self):
|
|
125
|
+
self.stream = None # Placeholder for the WaldiezIOStream instance
|
|
126
|
+
self.lock = threading.Lock() # Ensure thread-safe operations
|
|
127
|
+
|
|
128
|
+
def custom_input_processor(self, prompt: str) -> None:
|
|
129
|
+
"""Simulate external input and send it back to the IOStream."""
|
|
130
|
+
def external_input_simulation():
|
|
131
|
+
with self.lock: # Ensure thread-safe access
|
|
132
|
+
time.sleep(2) # Simulate delay for network input
|
|
133
|
+
if self.stream:
|
|
134
|
+
self.stream.set_input("Simulated external input")
|
|
135
|
+
else:
|
|
136
|
+
raise RuntimeError("Stream reference not set!")
|
|
137
|
+
|
|
138
|
+
threading.Thread(target=external_input_simulation, daemon=True).start()
|
|
139
|
+
|
|
140
|
+
def set_stream(self, stream: "WaldiezIOStream"):
|
|
141
|
+
"""Set the WaldiezIOStream instance."""
|
|
142
|
+
with self.lock: # Ensure thread-safe setting of the stream
|
|
143
|
+
self.stream = stream
|
|
144
|
+
|
|
145
|
+
processor_wrapper = InputProcessorWrapper()
|
|
146
|
+
|
|
147
|
+
stream = WaldiezIOStream(
|
|
148
|
+
input_timeout=30,
|
|
149
|
+
print_function=
|
|
150
|
+
on_prompt_input=processor_wrapper.custom_input_processor,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# Link the processor wrapper to the WaldiezIOStream instance
|
|
154
|
+
processor_wrapper.set_stream(custom_stream)
|
|
155
|
+
|
|
156
|
+
with WaldiezIOStream.set_default(io_stream):
|
|
157
|
+
runner = WaldiezRunner.load(flow_path)
|
|
158
|
+
runner.run(stream=io_stream, output_path=output_path)
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Tools
|
|
163
|
+
|
|
164
|
+
- [ag2 (formerly AutoGen)](https://github.com/ag2ai/ag2)
|
|
165
|
+
- [juptytext](https://github.com/mwouts/jupytext)
|
|
166
|
+
- [pydantic](https://github.com/pydantic/pydantic)
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/waldiez/waldiez/blob/main/LICENSE) file for details.
|
|
@@ -22,13 +22,12 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
24
|
"jupytext",
|
|
25
|
-
"
|
|
26
|
-
"twisted==24.10.0",
|
|
25
|
+
"ag2==0.3.2"
|
|
27
26
|
]
|
|
28
27
|
|
|
29
28
|
[project.urls]
|
|
30
|
-
homepage = 'https://waldiez.github.io/
|
|
31
|
-
repository = 'https://github.com/waldiez/
|
|
29
|
+
homepage = 'https://waldiez.github.io/waldiez/'
|
|
30
|
+
repository = 'https://github.com/waldiez/waldiez.git'
|
|
32
31
|
|
|
33
32
|
[tool.hatch.build.targets.sdist]
|
|
34
33
|
packages = ["waldiez", "waldiez.*"]
|
|
@@ -50,27 +49,27 @@ dev = [
|
|
|
50
49
|
'pydocstyle==6.3.0',
|
|
51
50
|
'pylint==3.3.1',
|
|
52
51
|
'python-dotenv==1.0.1',
|
|
53
|
-
'ruff==0.7.
|
|
52
|
+
'ruff==0.7.4',
|
|
54
53
|
'types-PyYAML==6.0.12',
|
|
55
54
|
'yamllint==1.35.1',
|
|
56
55
|
]
|
|
57
|
-
|
|
58
|
-
'chromadb==0.5.
|
|
59
|
-
'fastembed==0.4.
|
|
60
|
-
'pgvector
|
|
61
|
-
'psycopg[binary]>=3.
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'
|
|
72
|
-
'
|
|
73
|
-
'
|
|
56
|
+
ag2_extras =[
|
|
57
|
+
'chromadb==0.5.3',
|
|
58
|
+
'fastembed==0.4.2',
|
|
59
|
+
'pgvector>=0.2.5',
|
|
60
|
+
'psycopg[binary]>=3.1.18',
|
|
61
|
+
'ag2[retrievechat]==0.3.2',
|
|
62
|
+
'ag2[retrievechat-pgvector]==0.3.2',
|
|
63
|
+
'ag2[retrievechat-mongodb]==0.3.2',
|
|
64
|
+
'ag2[retrievechat-qdrant]==0.3.2',
|
|
65
|
+
'ag2[gemini]==0.3.2',
|
|
66
|
+
'ag2[together]==0.3.2',
|
|
67
|
+
'ag2[anthropic]==0.3.2',
|
|
68
|
+
'ag2[mistral]==0.3.2',
|
|
69
|
+
'ag2[groq]==0.3.2',
|
|
70
|
+
'ag2[bedrock]==0.3.2',
|
|
71
|
+
'ag2[websurfer]==0.3.2',
|
|
72
|
+
'ag2[together]==0.3.2',
|
|
74
73
|
'pymongo==4.10.1',
|
|
75
74
|
'qdrant-client==1.12.1',
|
|
76
75
|
]
|
|
@@ -88,9 +87,9 @@ docs = [
|
|
|
88
87
|
'mkdocs==1.6.1',
|
|
89
88
|
'mkdocs-jupyter==0.25.1',
|
|
90
89
|
'mkdocs-macros-plugin==1.3.7',
|
|
91
|
-
'mkdocs-material==9.5.
|
|
90
|
+
'mkdocs-material==9.5.45',
|
|
92
91
|
'mkdocs-minify-html-plugin==0.2.3',
|
|
93
|
-
'mkdocstrings[crystal,python]==0.
|
|
92
|
+
'mkdocstrings[crystal,python]==0.27.0',
|
|
94
93
|
'mkdocstrings-python==1.12.2'
|
|
95
94
|
]
|
|
96
95
|
|
|
@@ -278,6 +277,9 @@ filterwarnings = [
|
|
|
278
277
|
#
|
|
279
278
|
# autogen/logger/logger_utils.py:9: DeprecationWarning:
|
|
280
279
|
# datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version
|
|
280
|
+
#
|
|
281
|
+
# DeprecationWarning:
|
|
282
|
+
# reactor.stop cannot be used inside unit tests
|
|
281
283
|
"ignore::DeprecationWarning",
|
|
282
284
|
]
|
|
283
285
|
python_files = [
|
|
@@ -291,7 +293,7 @@ addopts = """
|
|
|
291
293
|
--exitfirst \
|
|
292
294
|
--durations=10 \
|
|
293
295
|
--color=yes \
|
|
294
|
-
--timeout=
|
|
296
|
+
--timeout=120
|
|
295
297
|
"""
|
|
296
298
|
|
|
297
299
|
|
|
@@ -32,9 +32,9 @@ def _get_chroma_client_string(agent: WaldiezRagUser) -> Tuple[str, str]:
|
|
|
32
32
|
# SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes
|
|
33
33
|
# in position 2-3: truncated \UXXXXXXXX escape
|
|
34
34
|
local_path = Path(agent.retrieve_config.db_config.local_storage_path)
|
|
35
|
-
client_str += f'PersistentClient(path=r"{local_path}")'
|
|
35
|
+
client_str += f'PersistentClient(path=r"{local_path}", settings=Settings(anonymized_telemetry=False))'
|
|
36
36
|
else:
|
|
37
|
-
client_str += "Client()"
|
|
37
|
+
client_str += "Client(Settings(anonymized_telemetry=False))"
|
|
38
38
|
return client_str, to_import
|
|
39
39
|
|
|
40
40
|
|
|
@@ -97,11 +97,11 @@ def get_chroma_db_args(
|
|
|
97
97
|
- The custom embedding function.
|
|
98
98
|
- Any additional content to be used before the `kwargs` string.
|
|
99
99
|
"""
|
|
100
|
-
client_str,
|
|
100
|
+
client_str, client_to_import = _get_chroma_client_string(agent)
|
|
101
101
|
embedding_function_arg, to_import_embedding, embedding_function_body = (
|
|
102
102
|
_get_chroma_embedding_function_string(agent, agent_name)
|
|
103
103
|
)
|
|
104
|
-
to_import = {
|
|
104
|
+
to_import = {client_to_import, "from chromadb.config import Settings"}
|
|
105
105
|
if to_import_embedding:
|
|
106
106
|
to_import.add(to_import_embedding)
|
|
107
107
|
kwarg_string = (
|
|
@@ -109,8 +109,7 @@ def get_chroma_db_args(
|
|
|
109
109
|
f" embedding_function={embedding_function_arg},\n"
|
|
110
110
|
)
|
|
111
111
|
# The RAG example:
|
|
112
|
-
# https://
|
|
113
|
-
# notebooks/agentchat_groupchat_RAG
|
|
112
|
+
# https://ag2ai.github.io/ag2/docs/notebooks/agentchat_groupchat_RAG/
|
|
114
113
|
# raises `InvalidCollectionException`: Collection groupchat does not exist.
|
|
115
114
|
# https://github.com/chroma-core/chroma/issues/861
|
|
116
115
|
# https://github.com/microsoft/autogen/issues/3551#issuecomment-2366930994
|
|
@@ -14,7 +14,6 @@ from .helpers import escape_summary_args_quotes
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def get_nested_chat_trigger_agent_names(
|
|
17
|
-
all_chats: List[WaldiezChat],
|
|
18
17
|
nested_chat: WaldiezAgentNestedChat,
|
|
19
18
|
agent_names: Dict[str, str],
|
|
20
19
|
) -> str:
|
|
@@ -22,8 +21,6 @@ def get_nested_chat_trigger_agent_names(
|
|
|
22
21
|
|
|
23
22
|
Parameters
|
|
24
23
|
----------
|
|
25
|
-
all_chats : List[WaldiezChat]
|
|
26
|
-
All the chats in the flow.
|
|
27
24
|
nested_chat : WaldiezAgentNestedChat
|
|
28
25
|
The nested chat.
|
|
29
26
|
agent_names : Dict[str, str]
|
|
@@ -34,14 +31,7 @@ def get_nested_chat_trigger_agent_names(
|
|
|
34
31
|
str
|
|
35
32
|
The trigger agent names.
|
|
36
33
|
"""
|
|
37
|
-
|
|
38
|
-
for message in nested_chat.triggered_by:
|
|
39
|
-
waldiez_chat = next(chat for chat in all_chats if chat.id == message.id)
|
|
40
|
-
if message.is_reply:
|
|
41
|
-
trigger_agent_ids.append(waldiez_chat.target)
|
|
42
|
-
else:
|
|
43
|
-
trigger_agent_ids.append(waldiez_chat.source)
|
|
44
|
-
agents = [agent_names[agent_id] for agent_id in trigger_agent_ids]
|
|
34
|
+
agents = [agent_names[agent_id] for agent_id in nested_chat.triggered_by]
|
|
45
35
|
trigger_string = f'{[", ".join(agents)]}'
|
|
46
36
|
return trigger_string.replace("'", '"')
|
|
47
37
|
|
|
@@ -228,7 +218,7 @@ def export_nested_chat(
|
|
|
228
218
|
use_suffix = len(agent.data.nested_chats) > 1
|
|
229
219
|
for index, entry in enumerate(agent.data.nested_chats):
|
|
230
220
|
trigger_names = get_nested_chat_trigger_agent_names(
|
|
231
|
-
|
|
221
|
+
nested_chat=entry, agent_names=agent_names
|
|
232
222
|
)
|
|
233
223
|
chat_queue, extra_methods = get_nested_chat_queue(
|
|
234
224
|
nested_chat=entry,
|
|
@@ -14,6 +14,7 @@ get_sqlite_to_csv_call_string
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
# Check issue:
|
|
17
|
+
# Also check if in ag2 this still applies
|
|
17
18
|
# https://github.com/microsoft/autogen/issues/2286
|
|
18
19
|
# we cannot log new agents if they have code_execution enabled
|
|
19
20
|
# we get `Path` is not JSON serializable (on code_executor)
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
from pathlib import Path
|
|
5
|
+
from typing import Optional
|
|
5
6
|
|
|
6
7
|
# pylint: disable=broad-except
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
def
|
|
10
|
+
def _check_local_path(string: str) -> Optional[Path]:
|
|
10
11
|
"""Check if a string is a local path.
|
|
11
12
|
|
|
12
13
|
Parameters
|
|
@@ -21,9 +22,11 @@ def _is_local_path(string: str) -> bool:
|
|
|
21
22
|
"""
|
|
22
23
|
try:
|
|
23
24
|
path = Path(string).resolve()
|
|
24
|
-
return path.exists()
|
|
25
25
|
except Exception: # pragma: no cover
|
|
26
|
-
return
|
|
26
|
+
return None
|
|
27
|
+
if path.exists():
|
|
28
|
+
return path
|
|
29
|
+
return None
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
def get_path_string(string: str) -> str:
|
|
@@ -41,8 +44,8 @@ def get_path_string(string: str) -> str:
|
|
|
41
44
|
"""
|
|
42
45
|
# On windows, we get paths like "C:\path\to\file"
|
|
43
46
|
# if so, let's try to avoid invalid escape sequences
|
|
44
|
-
if not
|
|
47
|
+
if not _check_local_path(string):
|
|
45
48
|
return string
|
|
46
49
|
if os.name == "nt": # pragma: no cover
|
|
47
50
|
return f"r'{string}'"
|
|
48
|
-
return f"
|
|
51
|
+
return f"{Path(string).resolve()}"
|