fabricatio 0.2.0__cp312-cp312-win_amd64.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.
@@ -0,0 +1,17 @@
1
+ """Contains the built-in toolboxes for the Fabricatio package."""
2
+
3
+ from typing import Set
4
+
5
+ from fabricatio.models.tool import ToolBox
6
+ from fabricatio.toolboxes.arithmetic import arithmetic_toolbox
7
+ from fabricatio.toolboxes.fs import fs_toolbox
8
+ from fabricatio.toolboxes.task import task_toolbox
9
+
10
+ basic_toolboxes: Set[ToolBox] = {task_toolbox, arithmetic_toolbox}
11
+
12
+ __all__ = [
13
+ "arithmetic_toolbox",
14
+ "basic_toolboxes",
15
+ "fs_toolbox",
16
+ "task_toolbox",
17
+ ]
@@ -0,0 +1,62 @@
1
+ """Arithmetic tools for Fabricatio."""
2
+
3
+ from fabricatio.models.tool import ToolBox
4
+
5
+ arithmetic_toolbox = ToolBox(name="ArithmeticToolBox", description="A toolbox for arithmetic operations.")
6
+
7
+
8
+ @arithmetic_toolbox.collect_tool
9
+ def add(a: float, b: float) -> float:
10
+ """Add two numbers.
11
+
12
+ Args:
13
+ a (float): The first number.
14
+ b (float): The second number.
15
+
16
+ Returns:
17
+ float: The sum of the two numbers.
18
+ """
19
+ return a + b
20
+
21
+
22
+ @arithmetic_toolbox.collect_tool
23
+ def subtract(a: float, b: float) -> float:
24
+ """Subtract two numbers.
25
+
26
+ Args:
27
+ a (float): The first number.
28
+ b (float): The second number.
29
+
30
+ Returns:
31
+ float: The result of subtracting b from a.
32
+ """
33
+ return a - b
34
+
35
+
36
+ @arithmetic_toolbox.collect_tool
37
+ def multiply(a: float, b: float) -> float:
38
+ """Multiply two numbers.
39
+
40
+ Args:
41
+ a (float): The first number.
42
+ b (float): The second number.
43
+
44
+ Returns:
45
+ float: The product of the two numbers.
46
+ """
47
+ return a * b
48
+
49
+
50
+ @arithmetic_toolbox.collect_tool
51
+ def divide(a: float, b: float) -> float:
52
+ """Divide two numbers.
53
+
54
+ Args:
55
+ a (float): The numerator.
56
+ b (float): The denominator (must not be zero).
57
+
58
+ Returns:
59
+ float: The result of dividing a by b.
60
+
61
+ """
62
+ return a / b
@@ -0,0 +1,15 @@
1
+ """File system tool box."""
2
+
3
+ from fabricatio.fs.curd import copy_file, create_directory, delete_directory, delete_file, dump_text, move_file, tree
4
+ from fabricatio.models.tool import ToolBox
5
+
6
+ fs_toolbox = (
7
+ ToolBox(name="FsToolBox", description="A toolbox for basic file system operations.")
8
+ .add_tool(dump_text)
9
+ .add_tool(copy_file)
10
+ .add_tool(move_file)
11
+ .add_tool(delete_file)
12
+ .add_tool(tree)
13
+ .add_tool(delete_directory)
14
+ .add_tool(create_directory)
15
+ )
@@ -0,0 +1,6 @@
1
+ """This module contains the toolbox for tasks management."""
2
+
3
+ from fabricatio.models.task import Task
4
+ from fabricatio.models.tool import ToolBox
5
+
6
+ task_toolbox = ToolBox(name="TaskToolBox", description="A toolbox for tasks management.").add_tool(Task.simple_task)
Binary file
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: fabricatio
3
+ Version: 0.2.0
4
+ Classifier: License :: OSI Approved :: MIT License
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Programming Language :: Python :: 3.12
7
+ Classifier: Programming Language :: Python :: Implementation :: CPython
8
+ Classifier: Framework :: AsyncIO
9
+ Classifier: Framework :: Pydantic :: 2
10
+ Classifier: Typing :: Typed
11
+ Requires-Dist: appdirs>=1.4.4
12
+ Requires-Dist: asyncio>=3.4.3
13
+ Requires-Dist: asyncstdlib>=3.13.0
14
+ Requires-Dist: code2prompt
15
+ Requires-Dist: gitpython>=3.1.44
16
+ Requires-Dist: litellm>=1.60.0
17
+ Requires-Dist: loguru>=0.7.3
18
+ Requires-Dist: magika>=0.5.1
19
+ Requires-Dist: orjson>=3.10.15
20
+ Requires-Dist: pydantic>=2.10.6
21
+ Requires-Dist: pydantic-settings>=2.7.1
22
+ Requires-Dist: pymitter>=1.0.0
23
+ Requires-Dist: questionary>=2.1.0
24
+ Requires-Dist: regex>=2024.11.6
25
+ Requires-Dist: rich>=13.9.4
26
+ Requires-Dist: faiss-cpu>=1.10.0 ; extra == 'rag'
27
+ Requires-Dist: pymilvus>=2.5.4 ; extra == 'rag'
28
+ Requires-Dist: fabricatio[rag] ; extra == 'full'
29
+ Provides-Extra: rag
30
+ Provides-Extra: full
31
+ License-File: LICENSE
32
+ Summary: A LLM multi-agent framework.
33
+ Keywords: ai,agents,multi-agent,llm,pyo3
34
+ Author-email: Whth <zettainspector@foxmail.com>
35
+ Requires-Python: >=3.12
36
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
37
+ Project-URL: Homepage, https://github.com/Whth/fabricatio
38
+ Project-URL: Repository, https://github.com/Whth/fabricatio
39
+ Project-URL: Issues, https://github.com/Whth/fabricatio/issues
40
+
41
+ # Fabricatio
42
+
43
+ ---
44
+
45
+ Fabricatio is a powerful framework designed to facilitate the creation and management of tasks, actions, and workflows. It leverages modern Python features and libraries to provide a robust and flexible environment for building applications that require task automation and orchestration.
46
+
47
+ ## Table of Contents
48
+
49
+ - [Installation](#installation)
50
+ - [Usage](#usage)
51
+ - [Defining a Task](#defining-a-task)
52
+ - [Creating an Action](#creating-an-action)
53
+ - [Assigning a Role](#assigning-a-role)
54
+ - [Logging](#logging)
55
+ - [Configuration](#configuration)
56
+ - [LLM Configuration](#llm-configuration)
57
+ - [Debug Configuration](#debug-configuration)
58
+ - [Examples](#examples)
59
+ - [Simple Task Example](#simple-task-example)
60
+ - [Complex Workflow Example](#complex-workflow-example)
61
+ - [Contributing](#contributing)
62
+ - [License](#license)
63
+
64
+ ## Installation
65
+
66
+ To install Fabricatio, you can use pip:
67
+
68
+ ```bash
69
+ pip install fabricatio
70
+ ```
71
+
72
+
73
+ Alternatively, you can clone the repository and install it manually:
74
+
75
+ ```bash
76
+ git clone https://github.com/your-repo/fabricatio.git
77
+ cd fabricatio
78
+ pip install .
79
+ ```
80
+
81
+
82
+ ## Usage
83
+
84
+ ### Defining a Task
85
+
86
+ A task in Fabricatio is defined using the `Task` class. You can specify the name, goal, and description of the task.
87
+
88
+ ```python
89
+ from fabricatio.models.task import Task
90
+
91
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
92
+ ```
93
+
94
+
95
+ ### Creating an Action
96
+
97
+ Actions are the building blocks of workflows. They perform specific tasks and can be asynchronous.
98
+
99
+ ```python
100
+ from fabricatio import Action, logger
101
+ from fabricatio.models.task import Task
102
+
103
+ class Talk(Action):
104
+ async def _execute(self, task_input: Task[str], **_) -> str:
105
+ ret = "Hello fabricatio!"
106
+ logger.info("executing talk action")
107
+ return ret
108
+ ```
109
+
110
+
111
+ ### Assigning a Role
112
+
113
+ Roles in Fabricatio are responsible for executing workflows. You can define a role with a set of actions.
114
+
115
+ ```python
116
+ from fabricatio.models.role import Role
117
+ from fabricatio.models.action import WorkFlow
118
+
119
+ class TestWorkflow(WorkFlow):
120
+ pass
121
+
122
+ role = Role(name="Test Role", actions=[TestWorkflow()])
123
+ ```
124
+
125
+
126
+ ### Logging
127
+
128
+ Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
129
+
130
+ ```python
131
+ from fabricatio.config import DebugConfig
132
+
133
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
134
+ ```
135
+
136
+
137
+ ## Configuration
138
+
139
+ Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
140
+
141
+ ### LLM Configuration
142
+
143
+ The Large Language Model (LLM) configuration is managed by the `LLMConfig` class.
144
+
145
+ ```python
146
+ from fabricatio.config import LLMConfig
147
+
148
+ llm_config = LLMConfig(api_endpoint="https://api.example.com")
149
+ ```
150
+
151
+
152
+ ### Debug Configuration
153
+
154
+ The debug configuration is managed by the `DebugConfig` class.
155
+
156
+ ```python
157
+ from fabricatio.config import DebugConfig
158
+
159
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
160
+ ```
161
+
162
+
163
+ ## Examples
164
+
165
+ ### Simple Task Example
166
+
167
+ Here is a simple example of a task that prints "Hello fabricatio!".
168
+
169
+ ```python
170
+ import asyncio
171
+ from fabricatio import Action, Role, Task, WorkFlow, logger
172
+
173
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
174
+
175
+ class Talk(Action):
176
+ async def _execute(self, task_input: Task[str], **_) -> Any:
177
+ ret = "Hello fabricatio!"
178
+ logger.info("executing talk action")
179
+ return ret
180
+
181
+ class TestWorkflow(WorkFlow):
182
+ pass
183
+
184
+ role = Role(name="Test Role", actions=[TestWorkflow()])
185
+
186
+ async def main() -> None:
187
+ await role.act(task)
188
+
189
+ if __name__ == "__main__":
190
+ asyncio.run(main())
191
+ ```
192
+
193
+
194
+ ### Complex Workflow Example
195
+
196
+ Here is a more complex example that demonstrates how to create a workflow with multiple actions.
197
+
198
+ ```python
199
+ import asyncio
200
+ from fabricatio import Action, Role, Task, WorkFlow, logger
201
+
202
+ task = Task(name="complex task", goal="perform complex operations", description="a task with multiple actions")
203
+
204
+ class ActionOne(Action):
205
+ async def _execute(self, task_input: Task[str], **_) -> Any:
206
+ ret = "Action One executed"
207
+ logger.info(ret)
208
+ return ret
209
+
210
+ class ActionTwo(Action):
211
+ async def _execute(self, task_input: Task[str], **_) -> Any:
212
+ ret = "Action Two executed"
213
+ logger.info(ret)
214
+ return ret
215
+
216
+ class ComplexWorkflow(WorkFlow):
217
+ actions = [ActionOne(), ActionTwo()]
218
+
219
+ role = Role(name="Complex Role", actions=[ComplexWorkflow()])
220
+
221
+ async def main() -> None:
222
+ await role.act(task)
223
+
224
+ if __name__ == "__main__":
225
+ asyncio.run(main())
226
+ ```
227
+
228
+
229
+ ## Contributing
230
+
231
+ Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
232
+
233
+ ## License
234
+
235
+ Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
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
+
@@ -0,0 +1,35 @@
1
+ fabricatio-0.2.0.dist-info/METADATA,sha256=TDbPeQPnN7H9QpWnZp2lnaEnFVfDQYjD7RsDTHEeVGE,9658
2
+ fabricatio-0.2.0.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
3
+ fabricatio-0.2.0.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
4
+ fabricatio/actions/communication.py,sha256=NZxIIncKgJSDyBrqNebUtH_haqtxHa8ld2TZxT3CMdU,429
5
+ fabricatio/actions/transmission.py,sha256=xpvKqbXqgpi1BWy-vUUvmd8NZ1GhRNfsYUBp-l2jLyk,862
6
+ fabricatio/actions/__init__.py,sha256=eFmFVPQvtNgFynIXBVr3eP-vWQDWCPng60YY5LXvZgg,115
7
+ fabricatio/config.py,sha256=9wmISu5xOtC6C-bC_2pIK2iQMHs8Ah6VP7gnS4bHzRk,10259
8
+ fabricatio/core.py,sha256=yQK2ZrbPYDJOaNDp0Bky3muTkB-ZaQ1ld_Qfflm2dY0,5938
9
+ fabricatio/decorators.py,sha256=y-NFno3d_wxM0CAipsA7oRDeacYnbtVMnr9iQpTSptU,6492
10
+ fabricatio/fs/curd.py,sha256=faMstgGUiQ4k2AW3OXfvvWWTldTtKXco7QINYaMjmyA,3981
11
+ fabricatio/fs/readers.py,sha256=eDL9QhKEd6xfJBZaiwraObpGJWWpUd9NVYHoIvWgVqY,551
12
+ fabricatio/fs/__init__.py,sha256=lWcKYg0v3mv2LnnSegOQaTtlVDODU0vtw_s6iKU5IqQ,122
13
+ fabricatio/journal.py,sha256=siqimKF0M_QaaOCMxtjr_BJVNyUIAQWILzE9Q4T6-7c,781
14
+ fabricatio/models/action.py,sha256=1V3upL79e3ekyGXA4bSY70N60yeL0aWak7ZPBVsFE3A,5652
15
+ fabricatio/models/advanced.py,sha256=xAt0rgxzpw-gw-1LwRhvIbYKoNI8kzzcYPvcL7Q1z1U,5027
16
+ fabricatio/models/events.py,sha256=mrihNEFgQ5o7qFWja1z_qX8dnaTLwPBoJdVlzxQV5oM,2719
17
+ fabricatio/models/generic.py,sha256=rvrAUlW-mtHBkHUXmH7aNm9lpTbLLbKr9cWZk3lFTpc,4160
18
+ fabricatio/models/kwargs_types.py,sha256=lSZAxOnhFdQwRkm-NrbJVMSyBbfdeuVNx807LvJpEOo,901
19
+ fabricatio/models/role.py,sha256=RPdOcjmM6KNyH310Vx4524JQG94P5sXl_3doSrRpiKQ,1802
20
+ fabricatio/models/task.py,sha256=qaN1LuGGfrtuIWKPqpPimoyniYnIVRcj7NeCdIVm4Rw,9185
21
+ fabricatio/models/tool.py,sha256=m0wM1XmlvYvcrDvdKrX7qCIaxbzp5iUlG1ljc_uL5FE,7002
22
+ fabricatio/models/usages.py,sha256=JwVanhu5v87LUbnPjwFPriFI5O3HG4SppesYvYLAb50,23636
23
+ fabricatio/models/utils.py,sha256=i_kpcQpct04mQFk1nbcVGV-pl1YThWu4Qk3wbewzKkc,2535
24
+ fabricatio/parser.py,sha256=ruCnb6gqnvZBNKxeWSGv3zqy492hbMpI-7rz_LjcPCA,3521
25
+ fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
27
+ fabricatio/toolboxes/fs.py,sha256=YkNgon5-bvCiPVEND9971W-6wj8btKNL6nGry2otn9I,498
28
+ fabricatio/toolboxes/task.py,sha256=kU4a501awIDV7GwNDuSlK3_Ym-5OhCp5sS-insTmUmQ,269
29
+ fabricatio/toolboxes/__init__.py,sha256=b13KmASO8q5fBLwew964fn9oH86ER5g-S1PgA4fZ_xs,482
30
+ fabricatio/_rust.pyi,sha256=0wCqtwWkVxxoqprvk8T27T8QYKIAKHS7xgsmdMNjQKc,1756
31
+ fabricatio/_rust_instances.py,sha256=dl0-yZ4UvT5g20tQgnPJpmqtkjFGXNG_YK4eLfi_ugQ,279
32
+ fabricatio/__init__.py,sha256=opIrN8lGyT-h2If4Qez0bRuWBa3uIT9GsM9CZy7_XJ0,1100
33
+ fabricatio/_rust.cp312-win_amd64.pyd,sha256=UwUSgbb9eSitA_ZpsqGeM1RdNPjI-kht03jtrD_-Nrk,1260544
34
+ fabricatio-0.2.0.data/scripts/tdown.exe,sha256=_vcAM4aXctQ5Net-OjI909_Ni9_ZnVMcUOafECCRb9A,3396608
35
+ fabricatio-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.8.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Whth Yotta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.