zrb 1.8.11__py3-none-any.whl → 1.8.13__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.
@@ -8,6 +8,7 @@ conversation flow via XCom.
8
8
  import asyncio
9
9
 
10
10
  from zrb.context.any_context import AnyContext
11
+ from zrb.llm_config import llm_config
11
12
  from zrb.util.cli.style import stylize_bold_yellow, stylize_faint
12
13
 
13
14
 
@@ -113,11 +114,14 @@ def get_llm_ask_input_mapping(callback_ctx: AnyContext):
113
114
  A dictionary containing the input mapping for the LLM ask task.
114
115
  """
115
116
  data = callback_ctx.xcom.ask_trigger.pop()
117
+ system_prompt = callback_ctx.input.system_prompt
118
+ if system_prompt is None or system_prompt.strip() == "":
119
+ system_prompt = llm_config.default_interactive_system_prompt
116
120
  return {
117
121
  "model": callback_ctx.input.model,
118
122
  "base-url": callback_ctx.input.base_url,
119
123
  "api-key": callback_ctx.input.api_key,
120
- "system-prompt": callback_ctx.input.system_prompt,
124
+ "system-prompt": system_prompt,
121
125
  "start-new": data.get("start_new"),
122
126
  "previous-session": data.get("previous_session_name"),
123
127
  "message": data.get("message"),
zrb/config.py CHANGED
@@ -225,6 +225,10 @@ class Config:
225
225
  def LLM_SYSTEM_PROMPT(self) -> str | None:
226
226
  return os.getenv("ZRB_LLM_SYSTEM_PROMPT", None)
227
227
 
228
+ @property
229
+ def LLM_INTERACTIVE_SYSTEM_PROMPT(self) -> str | None:
230
+ return os.getenv("ZRB_LLM_INTERACTIVE_SYSTEM_PROMPT", None)
231
+
228
232
  @property
229
233
  def LLM_PERSONA(self) -> str | None:
230
234
  return os.getenv("ZRB_LLM_PERSONA", None)
zrb/llm_config.py CHANGED
@@ -17,7 +17,7 @@ DEFAULT_PERSONA = (
17
17
  "straight to the point."
18
18
  ).strip()
19
19
 
20
- DEFAULT_SYSTEM_PROMPT = (
20
+ DEFAULT_INTERACTIVE_SYSTEM_PROMPT = (
21
21
  "You have access to tools and two forms of memory:\n"
22
22
  "1. A structured summary of the immediate task (including a payload) AND "
23
23
  "the raw text of the last few turns.\n"
@@ -50,6 +50,13 @@ DEFAULT_SYSTEM_PROMPT = (
50
50
  "guess."
51
51
  ).strip()
52
52
 
53
+ DEFAULT_SYSTEM_PROMPT = (
54
+ "You are a helpful and precise expert assistant. Your goal is to "
55
+ "follow instructions carefully to provide an accurate and efficient answer. "
56
+ "Fulfill the user's request directly. Use your tools if necessary. "
57
+ "Get straight to the point."
58
+ ).strip()
59
+
53
60
  DEFAULT_SPECIAL_INSTRUCTION_PROMPT = (
54
61
  "## Technical Task Protocol\n"
55
62
  "When performing technical tasks, strictly follow this protocol.\n\n"
@@ -202,6 +209,7 @@ class LLMConfig:
202
209
  default_api_key: str | None = None,
203
210
  default_persona: str | None = None,
204
211
  default_system_prompt: str | None = None,
212
+ default_interactive_system_prompt: str | None = None,
205
213
  default_special_instruction_prompt: str | None = None,
206
214
  default_summarization_prompt: str | None = None,
207
215
  default_context_enrichment_prompt: str | None = None,
@@ -218,6 +226,7 @@ class LLMConfig:
218
226
  self._default_model_api_key = default_api_key
219
227
  self._default_persona = default_persona
220
228
  self._default_system_prompt = default_system_prompt
229
+ self._default_interactive_system_prompt = default_interactive_system_prompt
221
230
  self._default_special_instruction_prompt = default_special_instruction_prompt
222
231
  self._default_summarization_prompt = default_summarization_prompt
223
232
  self._default_context_enrichment_prompt = default_context_enrichment_prompt
@@ -282,6 +291,14 @@ class LLMConfig:
282
291
  return CFG.LLM_SYSTEM_PROMPT
283
292
  return DEFAULT_SYSTEM_PROMPT
284
293
 
294
+ @property
295
+ def default_interactive_system_prompt(self) -> str:
296
+ if self._default_interactive_system_prompt is not None:
297
+ return self._default_interactive_system_prompt
298
+ if CFG.LLM_INTERACTIVE_SYSTEM_PROMPT is not None:
299
+ return CFG.LLM_INTERACTIVE_SYSTEM_PROMPT
300
+ return DEFAULT_INTERACTIVE_SYSTEM_PROMPT
301
+
285
302
  @property
286
303
  def default_persona(self) -> str:
287
304
  if self._default_persona is not None:
@@ -358,6 +375,9 @@ class LLMConfig:
358
375
  def set_default_system_prompt(self, system_prompt: str):
359
376
  self._default_system_prompt = system_prompt
360
377
 
378
+ def set_default_interactive_system_prompt(self, interactive_system_prompt: str):
379
+ self._default_interactive_system_prompt = interactive_system_prompt
380
+
361
381
  def set_default_special_instruction_prompt(self, special_instruction_prompt: str):
362
382
  self._default_special_instruction_prompt = special_instruction_prompt
363
383
 
zrb/runner/web_app.py CHANGED
@@ -39,7 +39,7 @@ def create_web_app(
39
39
  async def lifespan(app: FastAPI):
40
40
  capitalized_group_name = CFG.ROOT_GROUP_NAME.capitalize()
41
41
  for line in CFG.BANNER.split("\n") + [
42
- f"{capitalized_group_name} Server running on http://localhost:{web_auth_config.port}"
42
+ f"{capitalized_group_name} Server running on http://localhost:{CFG.WEB_HTTP_PORT}"
43
43
  ]:
44
44
  print(line, file=sys.stderr)
45
45
  yield
@@ -8,7 +8,6 @@ from zrb.task.any_task import AnyTask
8
8
  class WebAuthConfig:
9
9
  def __init__(
10
10
  self,
11
- port: int | None = None,
12
11
  secret_key: str | None = None,
13
12
  access_token_expire_minutes: int | None = None,
14
13
  refresh_token_expire_minutes: int | None = None,
@@ -21,7 +20,6 @@ class WebAuthConfig:
21
20
  guest_accessible_tasks: list[AnyTask | str] = [],
22
21
  find_user_by_username: Callable[[str], User | None] | None = None,
23
22
  ):
24
- self._port = port
25
23
  self._secret_key = secret_key
26
24
  self._access_token_expire_minutes = access_token_expire_minutes
27
25
  self._refresh_token_expire_minutes = refresh_token_expire_minutes
@@ -35,12 +33,6 @@ class WebAuthConfig:
35
33
  self._guest_accessible_tasks = guest_accessible_tasks
36
34
  self._find_user_by_username = find_user_by_username
37
35
 
38
- @property
39
- def port(self) -> int:
40
- if self._port is not None:
41
- return self._port
42
- return CFG.WEB_HTTP_PORT
43
-
44
36
  @property
45
37
  def secret_key(self) -> str:
46
38
  if self._secret_key is not None:
@@ -129,9 +121,6 @@ class WebAuthConfig:
129
121
  return [self.default_user]
130
122
  return self._user_list + [self.super_admin, self.default_user]
131
123
 
132
- def set_port(self, port: int):
133
- self._port = port
134
-
135
124
  def set_secret_key(self, secret_key: str):
136
125
  self._secret_key = secret_key
137
126
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zrb
3
- Version: 1.8.11
3
+ Version: 1.8.13
4
4
  Summary: Your Automation Powerhouse
5
5
  Home-page: https://github.com/state-alchemists/zrb
6
6
  License: AGPL-3.0-or-later
@@ -43,20 +43,16 @@ Description-Content-Type: text/markdown
43
43
 
44
44
  # 🤖 Zrb: Your Automation Powerhouse
45
45
 
46
-
47
- **Unlock the full potential of automation in your projects!**
48
-
49
- Zrb streamlines repetitive tasks, integrates with powerful LLMs, and lets you create custom automation workflows effortlessly. Whether you’re building CI/CD pipelines, code generators, or unique automation scripts, Zrb is designed to simplify and supercharge your workflow.
50
-
46
+ Zrb simplifies the creation and execution of automation tasks. It allows you to define tasks using Python classes or functions, organize them into groups, and run them via a command-line interface or a web UI. Zrb handles task dependencies, inputs, environment variables, and inter-task communication, allowing you to focus on the logic of your automation.
51
47
 
52
48
  ## 🚀 Why Zrb?
53
49
 
54
- - **Easy Automation with Python:** Write your tasks in Python and let Zrb handle the rest.
55
- - **Seamless Integration:** Utilize built-in support for LLM tasks, command execution, and more.
56
- - **Custom Workflows:** Chain tasks, set dependencies, and build robust automation pipelines.
57
- - **Developer-Friendly:** Quick to install and get started, with clear documentation and examples.
58
- - **Web Interface:** Run Zrb as a server to make tasks accessible even to non-technical team members.
59
-
50
+ Zrb stands out by offering:
51
+ * **Python-Native Automation:** Write tasks in a familiar and powerful language.
52
+ * **LLM Integration:** Easily incorporate AI capabilities into your workflows.
53
+ * **Structured Workflows:** Define dependencies and organize tasks logically.
54
+ * **Flexible Execution:** Run tasks from the CLI or a web browser.
55
+ * **Extensibility:** Customize and build upon the Zrb framework.
60
56
 
61
57
  ## 🔥 Key Features
62
58
 
@@ -64,33 +60,44 @@ Zrb streamlines repetitive tasks, integrates with powerful LLMs, and lets you cr
64
60
  - **Task Chaining:** Easily define dependencies between tasks to create complex workflows.
65
61
  - **CLI & Server Mode:** Run tasks directly from the command line or through a user-friendly web UI.
66
62
  - **Flexible Input Handling:** Defaults, prompts, and command-line parameters to suit any workflow.
63
+ * **Environment Variables:** Manage configuration using environment variables, loaded from the system, `.env` files, or task definitions.
64
+ * **Cross-Communication (XCom):** Safely exchange small amounts of data between tasks.
67
65
  - **Extensible & Open Source:** Contribute, customize, or extend Zrb to fit your unique needs.
68
66
 
69
67
 
70
68
  # 🛠️ Installation
71
69
 
72
- Install Zrb via pip:
70
+ The easiest way to install Zrb is using pip:
73
71
 
74
72
  ```bash
75
73
  pip install zrb
76
74
  # pip install --pre zrb
77
75
  ```
78
76
 
79
- Or run our installation script to set up Zrb along with all prerequisites:
77
+ Alternatively, you can use Zrb installation script which handles prerequisites:
80
78
 
81
79
  ```bash
82
80
  bash -c "$(curl -fsSL https://raw.githubusercontent.com/state-alchemists/zrb/main/install.sh)"
83
81
  ```
84
82
 
85
- You can also [run Zrb as container](https://github.com/state-alchemists/zrb?tab=readme-ov-file#-run-zrb-as-a-container)
83
+ For more installation option like running Zrb on your **Android Device 📱** or **as a Container 🐋**, you can check the [installation and configuration guide](https://github.com/state-alchemists/zrb/blob/main/docs/installation-and-configuration/README.md).
86
84
 
87
85
  # 🍲 Quick Start: Build Your First Automation Workflow
88
86
 
89
- Zrb empowers you to create custom automation tasks using Python. This guide shows you how to define two simple tasks: one to generate a Mermaid script from your source code and another to convert that script into a PNG image.
87
+ This guide shows you how to define two simple tasks:
88
+
89
+ - One to generate a Mermaid Diagram Script from your source code.
90
+ - And another one to convert that script into a PNG image.
91
+
92
+ > **Note:** This assume you have an `OPENAI_API_KEY` and a Mermaid CLI installed (i.e., `npm install -g @mermaid-js/mermaid-cli`)
90
93
 
91
94
  ## 1. Create Your Task Definition File
92
95
 
93
- Place a file named `zrb_init.py` in a directory that's accessible from your projects. Zrb will automatically search for this file by starting in your current directory and then moving upward (i.e., checking parent directories) until it finds one. This means if you place your `zrb_init.py` in your home directory (e.g., `/home/<your-user-name>/zrb_init.py`), the tasks defined there will be available for any project.
96
+ Place a file named `zrb_init.py` in a directory that's accessible from your projects.
97
+
98
+ Zrb will automatically search for this file by starting in your current directory and then moving upward (i.e., checking parent directories) until it finds one.
99
+
100
+ This means if you place your `zrb_init.py` in your home directory (e.g., `/home/<your-user-name>/zrb_init.py`), the tasks defined there will be available for any project inside your home directory.
94
101
 
95
102
  Add the following content to your zrb_init.py:
96
103
 
@@ -145,11 +152,11 @@ make_mermaid_script >> make_mermaid_image
145
152
 
146
153
  - **Task 1 – make-script**:
147
154
 
148
- Uses an LLM to read all files in your current directory and generate a Mermaid script (e.g., `state diagram.mmd`).
155
+ Uses an LLM to read all files in your current directory and generate a [Mermaid Diagram Script](https://mermaid.js.org/) (e.g., `state diagram.mmd`).
149
156
 
150
157
  - **Task 2 – make-image**:
151
158
 
152
- Executes a command that converts the Mermaid script into a PNG image (e.g., `state diagram.png`). This task will run only after the script has been generated.
159
+ Executes a command that converts the Mermaid Diagram Script into a PNG image (e.g., `state diagram.png`). This task will run only after the script has been generated.
153
160
 
154
161
 
155
162
  ## 2. Run Your Tasks
@@ -177,14 +184,16 @@ After setting up your tasks, you can execute them from any project. For example:
177
184
 
178
185
  Zrb will prompt:
179
186
 
180
- ```bash
187
+ ```
181
188
  dir [./]:
182
189
  diagram [state diagram]:
183
190
  ```
184
191
 
185
192
  Press **Enter** to use the default value
186
193
 
187
- ![State Diagram](https://raw.githubusercontent.com/state-alchemists/zrb/main/_images/state-diagram.png)
194
+ - And you have your State Diagram ready :)
195
+
196
+ ![State Diagram](https://raw.githubusercontent.com/state-alchemists/zrb/main/_images/state-diagram.png)
188
197
 
189
198
 
190
199
  ## 3. Try Out the Web UI
@@ -199,41 +208,10 @@ Then open your browser and visit `http://localhost:21213`
199
208
 
200
209
  ![Zrb Web UI](https://raw.githubusercontent.com/state-alchemists/zrb/main/_images/zrb-web-ui.png)
201
210
 
202
-
203
- # 🐋 Run Zrb as a Container
204
-
205
- Zrb can be run in a containerized environment, offering two distinct versions to suit different needs:
206
-
207
- - **Standard Version**: Ideal for general use cases where Docker CLI access is not required.
208
- - **Dind (Docker in Docker) Version**: Includes built-in Docker commands, perfect for scenarios where you need to access the host's Docker CLI.
209
-
210
- ### Standard Version
211
-
212
- The standard version of the Zrb container is suitable for most automation tasks. To run this version, execute the following command:
213
-
214
- ```bash
215
- # Replace <host-path> and <container-path> with your desired paths
216
- docker run -v ${HOME}:/zrb-home -it --rm stalchmst/zrb:1.8.1 zrb
217
- ```
218
-
219
- ### Dind Version
220
-
221
- The Dind version is tailored for advanced use cases where Docker commands need to be executed within the container. This version allows the container to interact with the host's Docker daemon. To run the Dind version, use the command below:
222
-
223
- ```bash
224
- # Replace <host-path> and <container-path> with your desired paths
225
- docker run \
226
- -v ${HOME}:/zrb-home \
227
- -v /var/run/docker.sock:/var/run/docker.sock \
228
- -it --rm stalchmst/zrb:1.8.1-dind docker ps
229
- ```
230
-
231
- > **Note:** The Dind (Docker in Docker) version of the container is larger in size compared to the standard version due to the inclusion of Docker CLI tools. Consider this when choosing the appropriate version for your needs.
232
-
233
211
  # 🎥 Demo & Documentation
234
212
 
235
- - **Full documentation:** [Zrb Documentation](https://github.com/state-alchemists/zrb/blob/main/docs/README.md)
236
- - **Video demo:**
213
+ - **Go Further By Visiting Our Documentation:** [Zrb Documentation](https://github.com/state-alchemists/zrb/blob/main/docs/README.md)
214
+ - **Video Demo:**
237
215
 
238
216
  [![Video Title](https://img.youtube.com/vi/W7dgk96l__o/0.jpg)](https://www.youtube.com/watch?v=W7dgk96l__o)
239
217
 
@@ -9,7 +9,7 @@ zrb/builtin/git_subtree.py,sha256=7BKwOkVTWDrR0DXXQ4iJyHqeR6sV5VYRt8y_rEB0EHg,35
9
9
  zrb/builtin/group.py,sha256=t008xLM4_fgbjfZrPoi_fQAnSHIo6MOiQSCHBO4GDYU,2379
10
10
  zrb/builtin/http.py,sha256=sLqEczuSxGYXWzyJR6frGOHkPTviu4BeyroUr3-ZuAI,4322
11
11
  zrb/builtin/jwt.py,sha256=3M5uaQhJZbKQLjTUft1OwPz_JxtmK-xtkjxWjciOQho,2859
12
- zrb/builtin/llm/chat_session.py,sha256=ot2ss6yA4qIINg0nl3KJYnLag8H0eB9ggAgRGEUkZdE,6639
12
+ zrb/builtin/llm/chat_session.py,sha256=Nfn_HXAKjKeIKWQt4nfS9k0VWmrg0JhexlJKVw58WLQ,6841
13
13
  zrb/builtin/llm/history.py,sha256=cnkOyO43uiMQ9cEvmqk-pPoCk1zCAH_fwAqSgBtsjzY,3079
14
14
  zrb/builtin/llm/input.py,sha256=Nw-26uTWp2QhUgKJcP_IMHmtk-b542CCSQ_vCOjhvhM,877
15
15
  zrb/builtin/llm/llm_ask.py,sha256=QUV29gOAFKiMfJlAKbY9YfGPoxYv-4RPv6p7cWogK4U,4438
@@ -217,7 +217,7 @@ zrb/callback/callback.py,sha256=PFhCqzfxdk6IAthmXcZ13DokT62xtBzJr_ciLw6I8Zg,4030
217
217
  zrb/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
218
218
  zrb/cmd/cmd_result.py,sha256=L8bQJzWCpcYexIxHBNsXj2pT3BtLmWex0iJSMkvimOA,597
219
219
  zrb/cmd/cmd_val.py,sha256=7Doowyg6BK3ISSGBLt-PmlhzaEkBjWWm51cED6fAUOQ,1014
220
- zrb/config.py,sha256=qFtVVme30fMyi5x_mgvvULczNbORqK8ZEN8agXokXO4,10222
220
+ zrb/config.py,sha256=L4nrdO8uK1MNOJiTgywkjlYn5kX1dOsq48b5mPZ2004,10364
221
221
  zrb/content_transformer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
222
222
  zrb/content_transformer/any_content_transformer.py,sha256=v8ZUbcix1GGeDQwB6OKX_1TjpY__ksxWVeqibwa_iZA,850
223
223
  zrb/content_transformer/content_transformer.py,sha256=STl77wW-I69QaGzCXjvkppngYFLufow8ybPLSyAvlHs,2404
@@ -246,13 +246,13 @@ zrb/input/option_input.py,sha256=TQB82ko5odgzkULEizBZi0e9TIHEbIgvdP0AR3RhA74,213
246
246
  zrb/input/password_input.py,sha256=szBojWxSP9QJecgsgA87OIYwQrY2AQ3USIKdDZY6snU,1465
247
247
  zrb/input/str_input.py,sha256=NevZHX9rf1g8eMatPyy-kUX3DglrVAQpzvVpKAzf7bA,81
248
248
  zrb/input/text_input.py,sha256=6T3MngWdUs0u0ZVs5Dl11w5KS7nN1RkgrIR_zKumzPM,3695
249
- zrb/llm_config.py,sha256=pXWHp-7WcAF3s5Gec8IBqoC_l3aRvU3aGt2Yr96SxGo,16607
249
+ zrb/llm_config.py,sha256=PaOsd9i5rwq_Ry68T6tpgQ2sWdjq-SeCuw7XMaHxw7Q,17577
250
250
  zrb/llm_rate_limitter.py,sha256=uM9zmSgV10fQq1dlaDGLDrv72uLj6ldBxMoGjO2Az14,4429
251
251
  zrb/runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
252
252
  zrb/runner/cli.py,sha256=AbLTNqFy5FuyGQOWOjHZGaBC8e2yuE_Dx1sBdnisR18,6984
253
253
  zrb/runner/common_util.py,sha256=JDMcwvQ8cxnv9kQrAoKVLA40Q1omfv-u5_d5MvvwHeE,1373
254
- zrb/runner/web_app.py,sha256=pydxJakSMsopvWWzkWLtMz7NyRORiS1KHKuG0jIF6N0,2792
255
- zrb/runner/web_auth_config.py,sha256=LwEDcfH0W57Z8SQIl8i-JpVibofB72gmzjPFiwUznQs,6361
254
+ zrb/runner/web_app.py,sha256=L61fwHBKbG1BuoC8JASCUwoPYjBt2h90HtPQBpZALLs,2789
255
+ zrb/runner/web_auth_config.py,sha256=g9C5ZFrYKlhJ4MqsA1uKsd9s3kN5sJiAN9QmGkRwBfc,6100
256
256
  zrb/runner/web_route/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
257
257
  zrb/runner/web_route/docs_route.py,sha256=Ftv4BbxnF_GZs2cJwen4hV7Z_UKQassFugB_bePdrPw,543
258
258
  zrb/runner/web_route/error_page/serve_default_404.py,sha256=srQSyOHoTZLScSvSUQnzUAVFOFSO_NQ2XEQZSvPd05c,1072
@@ -390,7 +390,7 @@ zrb/util/string/name.py,sha256=SXEfxJ1-tDOzHqmSV8kvepRVyMqs2XdV_vyoh_9XUu0,1584
390
390
  zrb/util/todo.py,sha256=VGISej2KQZERpornK-8X7bysp4JydMrMUTnG8B0-liI,20708
391
391
  zrb/xcom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
392
392
  zrb/xcom/xcom.py,sha256=o79rxR9wphnShrcIushA0Qt71d_p3ZTxjNf7x9hJB78,1571
393
- zrb-1.8.11.dist-info/METADATA,sha256=BxzTycMW2mrqcOCsi4k9Z_672xnzwp4IkYPpGrKrkn8,10108
394
- zrb-1.8.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
395
- zrb-1.8.11.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
396
- zrb-1.8.11.dist-info/RECORD,,
393
+ zrb-1.8.13.dist-info/METADATA,sha256=oqzBj3hnl1XlXUSSib6obfP_75DGHvZnJCIjZIx7tJ4,9274
394
+ zrb-1.8.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
395
+ zrb-1.8.13.dist-info/entry_points.txt,sha256=-Pg3ElWPfnaSM-XvXqCxEAa-wfVI6BEgcs386s8C8v8,46
396
+ zrb-1.8.13.dist-info/RECORD,,
File without changes