fabricatio 0.2.0.dev18__tar.gz → 0.2.0.dev20__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.
Files changed (89) hide show
  1. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/.github/workflows/build-package.yaml +1 -1
  2. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/.github/workflows/tests.yaml +2 -2
  3. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/Cargo.lock +54 -0
  4. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/Cargo.toml +3 -0
  5. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/PKG-INFO +118 -9
  6. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/README.md +116 -8
  7. fabricatio-0.2.0.dev20/examples/llm_usages/llm_usage.py +60 -0
  8. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/examples/propose_task/propose.py +2 -2
  9. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/pyproject.toml +4 -1
  10. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/__init__.py +5 -0
  11. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/_rust.pyi +18 -18
  12. fabricatio-0.2.0.dev20/python/fabricatio/_rust_instances.py +8 -0
  13. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/actions/communication.py +1 -1
  14. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/config.py +30 -1
  15. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/fs/curd.py +7 -1
  16. fabricatio-0.2.0.dev20/python/fabricatio/fs/readers.py +24 -0
  17. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/journal.py +7 -2
  18. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/action.py +15 -10
  19. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/advanced.py +5 -5
  20. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/events.py +2 -2
  21. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/generic.py +22 -8
  22. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/role.py +16 -5
  23. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/task.py +30 -9
  24. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/usages.py +35 -16
  25. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/parser.py +2 -1
  26. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/toolboxes/__init__.py +2 -0
  27. fabricatio-0.2.0.dev20/src/hash.rs +17 -0
  28. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/src/lib.rs +2 -1
  29. fabricatio-0.2.0.dev20/src/templates.rs +98 -0
  30. fabricatio-0.2.0.dev20/templates/built-in/dependencies.hbs +17 -0
  31. fabricatio-0.2.0.dev20/templates/built-in/task_briefing.hbs +8 -0
  32. fabricatio-0.2.0.dev20/templates.tar.gz +0 -0
  33. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/tests/test_config.py +22 -2
  34. fabricatio-0.2.0.dev20/tests/test_models/test_action.py +115 -0
  35. fabricatio-0.2.0.dev20/tests/test_models/test_role.py +93 -0
  36. fabricatio-0.2.0.dev20/tests/test_models/test_task.py +100 -0
  37. fabricatio-0.2.0.dev20/tests/test_models/test_tool.py +64 -0
  38. fabricatio-0.2.0.dev20/tests/test_models/test_usages.py +198 -0
  39. fabricatio-0.2.0.dev20/uv.lock +1868 -0
  40. fabricatio-0.2.0.dev18/examples/llm_usages/llm_usage.py +0 -41
  41. fabricatio-0.2.0.dev18/python/fabricatio/_rust_instances.py +0 -4
  42. fabricatio-0.2.0.dev18/python/fabricatio/fs/readers.py +0 -7
  43. fabricatio-0.2.0.dev18/src/templates.rs +0 -112
  44. fabricatio-0.2.0.dev18/templates.tar.gz +0 -0
  45. fabricatio-0.2.0.dev18/tests/test_models/test_action.py +0 -53
  46. fabricatio-0.2.0.dev18/tests/test_models/test_role.py +0 -34
  47. fabricatio-0.2.0.dev18/tests/test_models/test_task.py +0 -32
  48. fabricatio-0.2.0.dev18/tests/test_models/test_tool.py +0 -34
  49. fabricatio-0.2.0.dev18/tests/test_models/test_usages.py +0 -20
  50. fabricatio-0.2.0.dev18/uv.lock +0 -1857
  51. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/.github/workflows/ruff.yaml +0 -0
  52. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/.gitignore +0 -0
  53. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/.python-version +0 -0
  54. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/LICENSE +0 -0
  55. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/Makefile +0 -0
  56. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/examples/minor/hello_fabricatio.py +0 -0
  57. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/examples/simple_chat/chat.py +0 -0
  58. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/actions/__init__.py +0 -0
  59. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/actions/transmission.py +0 -0
  60. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/core.py +0 -0
  61. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/decorators.py +0 -0
  62. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/fs/__init__.py +0 -0
  63. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/kwargs_types.py +0 -0
  64. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/tool.py +0 -0
  65. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/models/utils.py +0 -0
  66. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/py.typed +0 -0
  67. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/toolboxes/arithmetic.py +0 -0
  68. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/toolboxes/fs.py +0 -0
  69. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/python/fabricatio/toolboxes/task.py +0 -0
  70. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/binary-exploitation-ctf-solver.hbs +0 -0
  71. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/claude-xml.hbs +0 -0
  72. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/clean-up-code.hbs +0 -0
  73. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/cryptography-ctf-solver.hbs +0 -0
  74. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/document-the-code.hbs +0 -0
  75. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/draft_tool_usage_code.hbs +0 -0
  76. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/find-security-vulnerabilities.hbs +0 -0
  77. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/fix-bugs.hbs +0 -0
  78. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/improve-performance.hbs +0 -0
  79. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/make_choice.hbs +0 -0
  80. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/make_judgment.hbs +0 -0
  81. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/propose_task.hbs +0 -0
  82. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/refactor.hbs +0 -0
  83. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/reverse-engineering-ctf-solver.hbs +0 -0
  84. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/web-ctf-solver.hbs +0 -0
  85. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/write-git-commit.hbs +0 -0
  86. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/write-github-pull-request.hbs +0 -0
  87. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/templates/built-in/write-github-readme.hbs +0 -0
  88. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/tests/test_models/test_advanced.py +0 -0
  89. {fabricatio-0.2.0.dev18 → fabricatio-0.2.0.dev20}/tests/test_models/test_generic.py +0 -0
@@ -49,7 +49,7 @@ jobs:
49
49
  rustup default nightly
50
50
  - name: Install deps
51
51
  run: |
52
- uv sync --no-install-project --all-extras
52
+ uv sync --no-install-project --all-extras --index https://pypi.org/simple
53
53
  - name: Build
54
54
  run: |
55
55
  make
@@ -22,8 +22,8 @@ jobs:
22
22
 
23
23
  - name: Install deps
24
24
  run: |
25
- uv sync
26
-
25
+ uv sync --no-install-project --all-extras --index https://pypi.org/simple
26
+ make dev
27
27
  - name: Build
28
28
  run: |
29
29
  pytest tests
@@ -67,6 +67,18 @@ dependencies = [
67
67
  "windows-sys 0.59.0",
68
68
  ]
69
69
 
70
+ [[package]]
71
+ name = "arrayref"
72
+ version = "0.3.9"
73
+ source = "registry+https://github.com/rust-lang/crates.io-index"
74
+ checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
75
+
76
+ [[package]]
77
+ name = "arrayvec"
78
+ version = "0.7.6"
79
+ source = "registry+https://github.com/rust-lang/crates.io-index"
80
+ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
81
+
70
82
  [[package]]
71
83
  name = "atomic-waker"
72
84
  version = "1.1.2"
@@ -106,6 +118,20 @@ version = "2.8.0"
106
118
  source = "registry+https://github.com/rust-lang/crates.io-index"
107
119
  checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
108
120
 
121
+ [[package]]
122
+ name = "blake3"
123
+ version = "1.6.0"
124
+ source = "registry+https://github.com/rust-lang/crates.io-index"
125
+ checksum = "1230237285e3e10cde447185e8975408ae24deaa67205ce684805c25bc0c7937"
126
+ dependencies = [
127
+ "arrayref",
128
+ "arrayvec",
129
+ "cc",
130
+ "cfg-if",
131
+ "constant_time_eq",
132
+ "memmap2",
133
+ ]
134
+
109
135
  [[package]]
110
136
  name = "block-buffer"
111
137
  version = "0.10.4"
@@ -188,6 +214,12 @@ version = "1.0.3"
188
214
  source = "registry+https://github.com/rust-lang/crates.io-index"
189
215
  checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
190
216
 
217
+ [[package]]
218
+ name = "constant_time_eq"
219
+ version = "0.3.1"
220
+ source = "registry+https://github.com/rust-lang/crates.io-index"
221
+ checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
222
+
191
223
  [[package]]
192
224
  name = "core-foundation"
193
225
  version = "0.9.4"
@@ -369,8 +401,11 @@ dependencies = [
369
401
  name = "fabricatio"
370
402
  version = "0.0.0"
371
403
  dependencies = [
404
+ "blake3",
372
405
  "handlebars",
373
406
  "pyo3",
407
+ "pythonize",
408
+ "serde_json",
374
409
  "walkdir",
375
410
  ]
376
411
 
@@ -910,6 +945,15 @@ version = "2.7.4"
910
945
  source = "registry+https://github.com/rust-lang/crates.io-index"
911
946
  checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
912
947
 
948
+ [[package]]
949
+ name = "memmap2"
950
+ version = "0.9.5"
951
+ source = "registry+https://github.com/rust-lang/crates.io-index"
952
+ checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
953
+ dependencies = [
954
+ "libc",
955
+ ]
956
+
913
957
  [[package]]
914
958
  name = "memoffset"
915
959
  version = "0.9.1"
@@ -1189,6 +1233,16 @@ dependencies = [
1189
1233
  "syn",
1190
1234
  ]
1191
1235
 
1236
+ [[package]]
1237
+ name = "pythonize"
1238
+ version = "0.23.0"
1239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1240
+ checksum = "91a6ee7a084f913f98d70cdc3ebec07e852b735ae3059a1500db2661265da9ff"
1241
+ dependencies = [
1242
+ "pyo3",
1243
+ "serde",
1244
+ ]
1245
+
1192
1246
  [[package]]
1193
1247
  name = "quote"
1194
1248
  version = "1.0.38"
@@ -6,8 +6,11 @@ edition = "2024"
6
6
  crate-type = ["cdylib"]
7
7
 
8
8
  [dependencies]
9
+ blake3 = "1.6.0"
9
10
  handlebars = "6.3.1"
10
11
  pyo3 = { version = "0.23.4", features = ["extension-module"] }
12
+ pythonize = "0.23.0"
13
+ serde_json = "1.0.138"
11
14
  walkdir = "2.5.0"
12
15
 
13
16
  [workspace]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.0.dev18
3
+ Version: 0.2.0.dev20
4
4
  Classifier: License :: OSI Approved :: MIT License
5
5
  Classifier: Programming Language :: Rust
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -10,6 +10,7 @@ Classifier: Framework :: Pydantic :: 2
10
10
  Classifier: Typing :: Typed
11
11
  Requires-Dist: appdirs>=1.4.4
12
12
  Requires-Dist: asyncio>=3.4.3
13
+ Requires-Dist: asyncstdlib>=3.13.0
13
14
  Requires-Dist: code2prompt
14
15
  Requires-Dist: gitpython>=3.1.44
15
16
  Requires-Dist: litellm>=1.60.0
@@ -47,26 +48,28 @@ Fabricatio is a powerful framework designed to facilitate the creation and manag
47
48
 
48
49
  - [Installation](#installation)
49
50
  - [Usage](#usage)
50
- - [Defining a Task](#defining-a-task)
51
- - [Creating an Action](#creating-an-action)
52
- - [Assigning a Role](#assigning-a-role)
53
- - [Logging](#logging)
51
+ - [Defining a Task](#defining-a-task)
52
+ - [Creating an Action](#creating-an-action)
53
+ - [Assigning a Role](#assigning-a-role)
54
+ - [Logging](#logging)
54
55
  - [Configuration](#configuration)
55
- - [LLM Configuration](#llm-configuration)
56
- - [Debug Configuration](#debug-configuration)
56
+ - [LLM Configuration](#llm-configuration)
57
+ - [Debug Configuration](#debug-configuration)
57
58
  - [Examples](#examples)
58
- - [Simple Task Example](#simple-task-example)
59
- - [Complex Workflow Example](#complex-workflow-example)
59
+ - [Simple Task Example](#simple-task-example)
60
+ - [Complex Workflow Example](#complex-workflow-example)
60
61
  - [Contributing](#contributing)
61
62
  - [License](#license)
62
63
 
63
64
  ## Installation
65
+
64
66
  To install Fabricatio, you can use pip:
65
67
 
66
68
  ```bash
67
69
  pip install fabricatio
68
70
  ```
69
71
 
72
+
70
73
  Alternatively, you can clone the repository and install it manually:
71
74
 
72
75
  ```bash
@@ -231,3 +234,109 @@ Contributions to Fabricatio are welcome! Please submit a pull request with your
231
234
 
232
235
  Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
233
236
 
237
+ ---
238
+
239
+ ### Additional Features and Modules
240
+
241
+ #### Advanced Models and Functionalities
242
+
243
+ The `advanced.py` module provides advanced models and functionalities for handling complex tasks and workflows.
244
+
245
+ ```python
246
+ from fabricatio.models.advanced import ProposeTask, HandleTask
247
+
248
+ class ProposeTaskExample(ProposeTask):
249
+ pass
250
+
251
+ class HandleTaskExample(HandleTask):
252
+ pass
253
+ ```
254
+
255
+
256
+ #### Toolboxes
257
+
258
+ Fabricatio includes various toolboxes for different types of operations. For example, the `arithmetic.py` toolbox provides arithmetic operations.
259
+
260
+ ```python
261
+ from fabricatio.toolboxes.arithmetic import add, subtract, multiply, divide
262
+
263
+ result = add(1, 2)
264
+ print(result) # Output: 3
265
+ ```
266
+
267
+
268
+ #### File System Operations
269
+
270
+ The `fs.py` toolbox offers tools for file system operations such as copying, moving, deleting files, and creating directories.
271
+
272
+ ```python
273
+ from fabricatio.toolboxes.fs import copy_file, move_file, delete_file, create_directory
274
+
275
+ copy_file("source.txt", "destination.txt")
276
+ move_file("old_location.txt", "new_location.txt")
277
+ delete_file("file_to_delete.txt")
278
+ create_directory("new_directory")
279
+ ```
280
+
281
+
282
+ #### Logging Setup
283
+
284
+ The logging setup in Fabricatio is handled by the `journal.py` module, which configures Loguru for logging.
285
+
286
+ ```python
287
+ from fabricatio.journal import logger
288
+
289
+ logger.debug("This is a debug message.")
290
+ logger.info("This is an info message.")
291
+ logger.success("This is a success message.")
292
+ logger.warning("This is a warning message.")
293
+ logger.error("This is an error message.")
294
+ logger.critical("This is a critical message.")
295
+ ```
296
+
297
+
298
+ #### Configuration Management
299
+
300
+ The configuration management in Fabricatio is handled by the `config.py` module, which uses Pydantic for defining and validating configurations.
301
+
302
+ ```python
303
+ from fabricatio.config import Settings, LLMConfig, DebugConfig
304
+
305
+ settings = Settings()
306
+ llm_config = LLMConfig(api_endpoint="https://api.example.com")
307
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
308
+ ```
309
+
310
+
311
+ #### Testing
312
+
313
+ Fabricatio includes a suite of test cases to ensure the stability and correctness of the codebase. The tests are located in the `tests` directory and cover various modules and functionalities.
314
+
315
+ ```python
316
+ # Example of a test case for the config module
317
+ import pytest
318
+ from fabricatio.config import DebugConfig
319
+
320
+ def test_debug_config_initialization():
321
+ temp_log_file = "fabricatio.log"
322
+ debug_config = DebugConfig(log_level="DEBUG", log_file=temp_log_file)
323
+ assert debug_config.log_level == "DEBUG"
324
+ assert str(debug_config.log_file) == temp_log_file
325
+ ```
326
+
327
+
328
+ ---
329
+
330
+ ### Conclusion
331
+
332
+ Fabricatio is a versatile and powerful framework for managing tasks, actions, and workflows. It provides a robust set of tools and features to facilitate task automation and orchestration. Whether you're building a simple script or a complex application, Fabricatio has the capabilities to meet your needs.
333
+
334
+ For more detailed information and examples, please refer to the [official documentation](https://fabricatio.readthedocs.io).
335
+
336
+ ---
337
+
338
+ If you have any questions or need further assistance, feel free to reach out to the community or open an issue on the GitHub repository.
339
+
340
+ Happy coding!
341
+
342
+
@@ -8,26 +8,28 @@ Fabricatio is a powerful framework designed to facilitate the creation and manag
8
8
 
9
9
  - [Installation](#installation)
10
10
  - [Usage](#usage)
11
- - [Defining a Task](#defining-a-task)
12
- - [Creating an Action](#creating-an-action)
13
- - [Assigning a Role](#assigning-a-role)
14
- - [Logging](#logging)
11
+ - [Defining a Task](#defining-a-task)
12
+ - [Creating an Action](#creating-an-action)
13
+ - [Assigning a Role](#assigning-a-role)
14
+ - [Logging](#logging)
15
15
  - [Configuration](#configuration)
16
- - [LLM Configuration](#llm-configuration)
17
- - [Debug Configuration](#debug-configuration)
16
+ - [LLM Configuration](#llm-configuration)
17
+ - [Debug Configuration](#debug-configuration)
18
18
  - [Examples](#examples)
19
- - [Simple Task Example](#simple-task-example)
20
- - [Complex Workflow Example](#complex-workflow-example)
19
+ - [Simple Task Example](#simple-task-example)
20
+ - [Complex Workflow Example](#complex-workflow-example)
21
21
  - [Contributing](#contributing)
22
22
  - [License](#license)
23
23
 
24
24
  ## Installation
25
+
25
26
  To install Fabricatio, you can use pip:
26
27
 
27
28
  ```bash
28
29
  pip install fabricatio
29
30
  ```
30
31
 
32
+
31
33
  Alternatively, you can clone the repository and install it manually:
32
34
 
33
35
  ```bash
@@ -191,3 +193,109 @@ Contributions to Fabricatio are welcome! Please submit a pull request with your
191
193
  ## License
192
194
 
193
195
  Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
196
+
197
+ ---
198
+
199
+ ### Additional Features and Modules
200
+
201
+ #### Advanced Models and Functionalities
202
+
203
+ The `advanced.py` module provides advanced models and functionalities for handling complex tasks and workflows.
204
+
205
+ ```python
206
+ from fabricatio.models.advanced import ProposeTask, HandleTask
207
+
208
+ class ProposeTaskExample(ProposeTask):
209
+ pass
210
+
211
+ class HandleTaskExample(HandleTask):
212
+ pass
213
+ ```
214
+
215
+
216
+ #### Toolboxes
217
+
218
+ Fabricatio includes various toolboxes for different types of operations. For example, the `arithmetic.py` toolbox provides arithmetic operations.
219
+
220
+ ```python
221
+ from fabricatio.toolboxes.arithmetic import add, subtract, multiply, divide
222
+
223
+ result = add(1, 2)
224
+ print(result) # Output: 3
225
+ ```
226
+
227
+
228
+ #### File System Operations
229
+
230
+ The `fs.py` toolbox offers tools for file system operations such as copying, moving, deleting files, and creating directories.
231
+
232
+ ```python
233
+ from fabricatio.toolboxes.fs import copy_file, move_file, delete_file, create_directory
234
+
235
+ copy_file("source.txt", "destination.txt")
236
+ move_file("old_location.txt", "new_location.txt")
237
+ delete_file("file_to_delete.txt")
238
+ create_directory("new_directory")
239
+ ```
240
+
241
+
242
+ #### Logging Setup
243
+
244
+ The logging setup in Fabricatio is handled by the `journal.py` module, which configures Loguru for logging.
245
+
246
+ ```python
247
+ from fabricatio.journal import logger
248
+
249
+ logger.debug("This is a debug message.")
250
+ logger.info("This is an info message.")
251
+ logger.success("This is a success message.")
252
+ logger.warning("This is a warning message.")
253
+ logger.error("This is an error message.")
254
+ logger.critical("This is a critical message.")
255
+ ```
256
+
257
+
258
+ #### Configuration Management
259
+
260
+ The configuration management in Fabricatio is handled by the `config.py` module, which uses Pydantic for defining and validating configurations.
261
+
262
+ ```python
263
+ from fabricatio.config import Settings, LLMConfig, DebugConfig
264
+
265
+ settings = Settings()
266
+ llm_config = LLMConfig(api_endpoint="https://api.example.com")
267
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
268
+ ```
269
+
270
+
271
+ #### Testing
272
+
273
+ Fabricatio includes a suite of test cases to ensure the stability and correctness of the codebase. The tests are located in the `tests` directory and cover various modules and functionalities.
274
+
275
+ ```python
276
+ # Example of a test case for the config module
277
+ import pytest
278
+ from fabricatio.config import DebugConfig
279
+
280
+ def test_debug_config_initialization():
281
+ temp_log_file = "fabricatio.log"
282
+ debug_config = DebugConfig(log_level="DEBUG", log_file=temp_log_file)
283
+ assert debug_config.log_level == "DEBUG"
284
+ assert str(debug_config.log_file) == temp_log_file
285
+ ```
286
+
287
+
288
+ ---
289
+
290
+ ### Conclusion
291
+
292
+ Fabricatio is a versatile and powerful framework for managing tasks, actions, and workflows. It provides a robust set of tools and features to facilitate task automation and orchestration. Whether you're building a simple script or a complex application, Fabricatio has the capabilities to meet your needs.
293
+
294
+ For more detailed information and examples, please refer to the [official documentation](https://fabricatio.readthedocs.io).
295
+
296
+ ---
297
+
298
+ If you have any questions or need further assistance, feel free to reach out to the community or open an issue on the GitHub repository.
299
+
300
+ Happy coding!
301
+
@@ -0,0 +1,60 @@
1
+ """Example of using the library."""
2
+
3
+ import asyncio
4
+
5
+ from fabricatio import Action, Role, Task, WorkFlow
6
+ from fabricatio.journal import logger
7
+ from fabricatio.models.events import Event
8
+ from fabricatio.parser import PythonCapture
9
+
10
+
11
+ class WriteCode(Action):
12
+ """Action that says hello to the world."""
13
+
14
+ name: str = "write code"
15
+ output_key: str = "task_output"
16
+
17
+ async def _execute(self, task_input: Task[str], **_) -> str:
18
+ return await self.aask_validate(
19
+ task_input.briefing,
20
+ validator=PythonCapture.capture,
21
+ )
22
+
23
+
24
+ class WriteDocumentation(Action):
25
+ """Action that says hello to the world."""
26
+
27
+ name: str = "write documentation"
28
+ description: str = "write documentation for the code in markdown format"
29
+ output_key: str = "task_output"
30
+
31
+ async def _execute(self, task_input: Task[str], **_) -> str:
32
+ return await self.aask(task_input.briefing, task_input.dependencies_prompt)
33
+
34
+
35
+ async def main() -> None:
36
+ """Main function."""
37
+ role = Role(
38
+ name="Coder",
39
+ description="A python coder who can write code and documentation",
40
+ registry={
41
+ Event.instantiate_from("coding.*").push("pending"): WorkFlow(name="write code", steps=(WriteCode,)),
42
+ Event.instantiate_from("doc.*").push("pending"): WorkFlow(
43
+ name="write documentation", steps=(WriteDocumentation,)
44
+ ),
45
+ },
46
+ )
47
+
48
+ prompt = "write a python cli app which can add a list of numbers writen in a file together,with detailed google style documentation."
49
+
50
+ proposed_task = await role.propose(prompt)
51
+ code = await proposed_task.move_to("coding").delegate()
52
+ logger.success(f"Code: \n{code}")
53
+
54
+ proposed_task = await role.propose(f"{code} \n\n write Readme.md file for the code.")
55
+ doc = await proposed_task.move_to("doc").delegate()
56
+ logger.success(f"Documentation: \n{doc}")
57
+
58
+
59
+ if __name__ == "__main__":
60
+ asyncio.run(main())
@@ -14,7 +14,7 @@ class Talk(Action):
14
14
  name: str = "talk"
15
15
  output_key: str = "task_output"
16
16
 
17
- async def _execute(self, task_input: Task[str], **_) -> Any:
17
+ async def _execute(self, **_) -> Any:
18
18
  ret = "Hello fabricatio!"
19
19
  logger.info("executing talk action")
20
20
  return ret
@@ -25,7 +25,7 @@ async def main() -> None:
25
25
  role = Role(
26
26
  name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(Talk,))}
27
27
  )
28
- logger.info(Task.json_example())
28
+ logger.info(f"Task example:\n{Task.json_example()}")
29
29
  logger.info(f"proposed task: {await role.propose('write a rust clap cli that can download a html page')}")
30
30
 
31
31
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.0-dev.18"
3
+ version = "0.2.0-dev.20"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -29,6 +29,7 @@ requires-python = ">=3.12"
29
29
  dependencies = [
30
30
  "appdirs>=1.4.4",
31
31
  "asyncio>=3.4.3",
32
+ "asyncstdlib>=3.13.0",
32
33
  "code2prompt",
33
34
  "gitpython>=3.1.44",
34
35
  "litellm>=1.60.0",
@@ -137,6 +138,8 @@ addopts = "-ra -q"
137
138
  testpaths = [
138
139
  "tests",
139
140
  ]
141
+ asyncio_mode = "auto"
142
+ asyncio_default_fixture_loop_scope = "function"
140
143
 
141
144
  [tool.uv.sources]
142
145
  code2prompt = { git = "https://github.com/mufeedvh/code2prompt", rev = "d157ee84827458bd6816142e213886487d28bd3d" }
@@ -11,6 +11,7 @@ from fabricatio.models.task import Task
11
11
  from fabricatio.models.tool import ToolBox
12
12
  from fabricatio.models.utils import Message, Messages
13
13
  from fabricatio.parser import Capture, CodeBlockCapture, JsonCapture, PythonCapture
14
+ from fabricatio.toolboxes import arithmetic_toolbox, basic_toolboxes, fs_toolbox, task_toolbox
14
15
 
15
16
  __all__ = [
16
17
  "Action",
@@ -25,8 +26,12 @@ __all__ = [
25
26
  "Task",
26
27
  "ToolBox",
27
28
  "WorkFlow",
29
+ "arithmetic_toolbox",
30
+ "basic_toolboxes",
28
31
  "env",
32
+ "fs_toolbox",
29
33
  "logger",
30
34
  "magika",
35
+ "task_toolbox",
31
36
  "template_manager",
32
37
  ]
@@ -2,40 +2,30 @@ from pathlib import Path
2
2
  from typing import Any, Dict, List, Optional
3
3
 
4
4
  class TemplateManager:
5
- def __init__(self, template_dirs: List[Path], suffix: Optional[str] = None) -> None:
5
+ """TemplateManager class for managing handlebars templates."""
6
+ def __init__(
7
+ self, template_dirs: List[Path], suffix: Optional[str] = None, active_loading: Optional[bool] = None
8
+ ) -> None:
6
9
  """Initialize the template manager.
7
10
 
8
11
  Args:
9
12
  template_dirs (List[Path]): A list of paths to directories containing templates.
10
- suffix (str, optional): The suffix of template files. None means 'hbs' suffix .
13
+ suffix (str, optional): The suffix of template files. None means 'hbs' suffix.
14
+ active_loading (bool, optional): Whether to enable active loading of templates.
11
15
  """
12
16
 
13
17
  @property
14
18
  def template_count(self) -> int:
15
19
  """Get the number of templates discovered."""
16
20
 
17
- @property
18
- def templates(self) -> List[str]:
19
- """Get a list of template names."""
20
-
21
- def get_template(self, name: str) -> str:
22
- """Get a template by name.
23
-
24
- Args:
25
- name (str): The name of the template to retrieve.
26
-
27
- Returns:
28
- str: The template content.
29
- """
30
-
31
- def get_template_source(self, name: str) -> str:
21
+ def get_template_source(self, name: str) -> Optional[str]:
32
22
  """Get the source path of a template by name.
33
23
 
34
24
  Args:
35
25
  name (str): The name of the template to retrieve.
36
26
 
37
27
  Returns:
38
- str: The source path of the template.
28
+ Optional[str]: The source path of the template.
39
29
  """
40
30
 
41
31
  def discover_templates(self) -> None:
@@ -51,3 +41,13 @@ class TemplateManager:
51
41
  Returns:
52
42
  str: The rendered template.
53
43
  """
44
+
45
+ def blake3_hash(content: bytes) -> str:
46
+ """Calculate the BLAKE3 hash of the given data.
47
+
48
+ Args:
49
+ content (bytes): The data to hash.
50
+
51
+ Returns:
52
+ str: The BLAKE3 hash of the data.
53
+ """
@@ -0,0 +1,8 @@
1
+ from fabricatio._rust import TemplateManager
2
+ from fabricatio.config import configs
3
+
4
+ template_manager = TemplateManager(
5
+ template_dirs=configs.templates.template_dir,
6
+ suffix=configs.templates.template_suffix,
7
+ active_loading=configs.templates.active_loading,
8
+ )
@@ -12,4 +12,4 @@ class Talk(Action):
12
12
 
13
13
  async def _execute(self, task_input: Task[str], **_) -> str:
14
14
  """Execute the action."""
15
- return await self.aask(task_input.briefing, system_message=task_input.generate_prompt())
15
+ return await self.aask(task_input.briefing, system_message=task_input.dependencies_prompt())