fabricatio 0.2.6.dev0__cp312-cp312-win_amd64.whl → 0.2.6.dev2__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.
- fabricatio/__init__.py +6 -6
- fabricatio/_rust.cp312-win_amd64.pyd +0 -0
- fabricatio/_rust_instances.py +1 -1
- fabricatio/capabilities/correct.py +115 -0
- fabricatio/capabilities/rag.py +3 -3
- fabricatio/capabilities/rating.py +8 -8
- fabricatio/capabilities/review.py +53 -16
- fabricatio/capabilities/task.py +2 -2
- fabricatio/config.py +14 -5
- fabricatio/fs/__init__.py +2 -2
- fabricatio/fs/readers.py +1 -1
- fabricatio/journal.py +0 -7
- fabricatio/models/action.py +2 -2
- fabricatio/models/generic.py +14 -6
- fabricatio/models/kwargs_types.py +13 -2
- fabricatio/models/role.py +2 -2
- fabricatio/models/task.py +2 -2
- fabricatio/models/usages.py +26 -6
- fabricatio/models/utils.py +21 -0
- fabricatio/parser.py +13 -5
- {fabricatio-0.2.6.dev0.data → fabricatio-0.2.6.dev2.data}/scripts/tdown.exe +0 -0
- fabricatio-0.2.6.dev2.dist-info/METADATA +432 -0
- fabricatio-0.2.6.dev2.dist-info/RECORD +42 -0
- fabricatio-0.2.6.dev0.dist-info/METADATA +0 -312
- fabricatio-0.2.6.dev0.dist-info/RECORD +0 -41
- {fabricatio-0.2.6.dev0.dist-info → fabricatio-0.2.6.dev2.dist-info}/WHEEL +0 -0
- {fabricatio-0.2.6.dev0.dist-info → fabricatio-0.2.6.dev2.dist-info}/licenses/LICENSE +0 -0
@@ -1,312 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: fabricatio
|
3
|
-
Version: 0.2.6.dev0
|
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: json-repair>=0.39.1
|
15
|
-
Requires-Dist: litellm>=1.60.0
|
16
|
-
Requires-Dist: loguru>=0.7.3
|
17
|
-
Requires-Dist: magika>=0.5.1
|
18
|
-
Requires-Dist: more-itertools>=10.6.0
|
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: pymilvus>=2.5.4 ; extra == 'rag'
|
27
|
-
Requires-Dist: fabricatio[rag] ; extra == 'full'
|
28
|
-
Provides-Extra: rag
|
29
|
-
Provides-Extra: full
|
30
|
-
License-File: LICENSE
|
31
|
-
Summary: A LLM multi-agent framework.
|
32
|
-
Keywords: ai,agents,multi-agent,llm,pyo3
|
33
|
-
Author-email: Whth <zettainspector@foxmail.com>
|
34
|
-
Requires-Python: >=3.12, <3.13
|
35
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
36
|
-
Project-URL: Homepage, https://github.com/Whth/fabricatio
|
37
|
-
Project-URL: Repository, https://github.com/Whth/fabricatio
|
38
|
-
Project-URL: Issues, https://github.com/Whth/fabricatio/issues
|
39
|
-
|
40
|
-
# Fabricatio
|
41
|
-
|
42
|
-

|
43
|
-

|
44
|
-

|
45
|
-
|
46
|
-
## Overview
|
47
|
-
|
48
|
-
Fabricatio is a Python library designed for building LLM (Large Language Model) applications using an event-based agent structure. It integrates Rust for performance-critical tasks, utilizes Handlebars for templating, and employs PyO3 for Python bindings.
|
49
|
-
|
50
|
-
## Features
|
51
|
-
|
52
|
-
- **Event-Based Architecture**: Utilizes an EventEmitter pattern for robust task management.
|
53
|
-
- **LLM Integration**: Supports interactions with large language models for intelligent task processing.
|
54
|
-
- **Templating Engine**: Uses Handlebars for dynamic content generation.
|
55
|
-
- **Toolboxes**: Provides predefined toolboxes for common operations like file manipulation and arithmetic.
|
56
|
-
- **Async Support**: Fully asynchronous for efficient execution.
|
57
|
-
- **Extensible**: Easy to extend with custom actions, workflows, and tools.
|
58
|
-
|
59
|
-
## Installation
|
60
|
-
|
61
|
-
### Using UV (Recommended)
|
62
|
-
|
63
|
-
To install Fabricatio using `uv` (a package manager for Python):
|
64
|
-
|
65
|
-
```bash
|
66
|
-
# Install uv if not already installed
|
67
|
-
pip install uv
|
68
|
-
|
69
|
-
# Clone the repository
|
70
|
-
git clone https://github.com/Whth/fabricatio.git
|
71
|
-
cd fabricatio
|
72
|
-
|
73
|
-
# Install the package in development mode with uv
|
74
|
-
uv --with-editable . maturin develop --uv -r
|
75
|
-
```
|
76
|
-
|
77
|
-
|
78
|
-
### Building Distribution
|
79
|
-
|
80
|
-
For production builds:
|
81
|
-
|
82
|
-
```bash
|
83
|
-
# Build distribution packages
|
84
|
-
make bdist
|
85
|
-
```
|
86
|
-
|
87
|
-
|
88
|
-
This will generate distribution files in the `dist` directory.
|
89
|
-
|
90
|
-
## Usage
|
91
|
-
|
92
|
-
### Basic Example
|
93
|
-
|
94
|
-
#### Simple Hello World Program
|
95
|
-
|
96
|
-
```python
|
97
|
-
import asyncio
|
98
|
-
from fabricatio import Action, Role, Task, logger, WorkFlow
|
99
|
-
from typing import Any
|
100
|
-
|
101
|
-
class Hello(Action):
|
102
|
-
name: str = "hello"
|
103
|
-
output_key: str = "task_output"
|
104
|
-
|
105
|
-
async def _execute(self, task_input: Task[str], **_) -> Any:
|
106
|
-
ret = "Hello fabricatio!"
|
107
|
-
logger.info("executing talk action")
|
108
|
-
return ret
|
109
|
-
|
110
|
-
async def main() -> None:
|
111
|
-
role = Role(
|
112
|
-
name="talker",
|
113
|
-
description="talker role",
|
114
|
-
registry={Task.pending_label: WorkFlow(name="talk", steps=(Hello,))}
|
115
|
-
)
|
116
|
-
|
117
|
-
task = Task(name="say hello", goals="say hello", description="say hello to the world")
|
118
|
-
result = await task.delegate()
|
119
|
-
logger.success(f"Result: {result}")
|
120
|
-
|
121
|
-
if __name__ == "__main__":
|
122
|
-
asyncio.run(main())
|
123
|
-
```
|
124
|
-
|
125
|
-
|
126
|
-
### Advanced Examples
|
127
|
-
|
128
|
-
#### Writing and Dumping Code
|
129
|
-
|
130
|
-
```python
|
131
|
-
import asyncio
|
132
|
-
from fabricatio import Action, Event, PythonCapture, Role, Task, ToolBox, WorkFlow, fs_toolbox, logger
|
133
|
-
|
134
|
-
|
135
|
-
class WriteCode(Action):
|
136
|
-
name: str = "write code"
|
137
|
-
output_key: str = "source_code"
|
138
|
-
|
139
|
-
async def _execute(self, task_input: Task[str], **_) -> str:
|
140
|
-
return await self.aask_validate(task_input.briefing, validator=PythonCapture.capture)
|
141
|
-
|
142
|
-
|
143
|
-
class DumpCode(Action):
|
144
|
-
name: str = "dump code"
|
145
|
-
description: str = "Dump code to file system"
|
146
|
-
toolboxes: set[ToolBox] = {fs_toolbox}
|
147
|
-
output_key: str = "task_output"
|
148
|
-
|
149
|
-
async def _execute(self, task_input: Task, source_code: str, **_) -> Any:
|
150
|
-
path = await self.handle_fin_grind(task_input, {"source_code": source_code})
|
151
|
-
return path[0] if path else None
|
152
|
-
|
153
|
-
|
154
|
-
async def main() -> None:
|
155
|
-
role = Role(
|
156
|
-
name="Coder",
|
157
|
-
description="A python coder who can write and document code",
|
158
|
-
registry={
|
159
|
-
Event.instantiate_from("coding.*").push("pending"): WorkFlow(
|
160
|
-
name="write code", steps=(WriteCode, DumpCode)
|
161
|
-
)
|
162
|
-
}
|
163
|
-
)
|
164
|
-
|
165
|
-
prompt = "write a Python CLI app which prints 'hello world' n times with detailed Google-style docstring. Write the source code to `cli.py`."
|
166
|
-
proposed_task = await role.propose_task(prompt)
|
167
|
-
path = await proposed_task.move_to("coding").delegate()
|
168
|
-
logger.success(f"Code Path: {path}")
|
169
|
-
|
170
|
-
|
171
|
-
if __name__ == "__main__":
|
172
|
-
asyncio.run(main())
|
173
|
-
```
|
174
|
-
|
175
|
-
|
176
|
-
### Template Management and Rendering
|
177
|
-
|
178
|
-
```python
|
179
|
-
from fabricatio._rust_instances import template_manager
|
180
|
-
|
181
|
-
template_name = "claude-xml.hbs"
|
182
|
-
data = {
|
183
|
-
"absolute_code_path": "/path/to/project",
|
184
|
-
"source_tree": "source tree content",
|
185
|
-
"files": [{"path": "file1.py", "code": "print('Hello')"}],
|
186
|
-
}
|
187
|
-
|
188
|
-
rendered_template = template_manager.render_template(template_name, data)
|
189
|
-
print(rendered_template)
|
190
|
-
```
|
191
|
-
|
192
|
-
|
193
|
-
### Handling Security Vulnerabilities
|
194
|
-
|
195
|
-
```python
|
196
|
-
from fabricatio.models.usages import ToolBoxUsage
|
197
|
-
from fabricatio.models.task import Task
|
198
|
-
|
199
|
-
toolbox_usage = ToolBoxUsage()
|
200
|
-
|
201
|
-
async def handle_security_vulnerabilities():
|
202
|
-
task = Task(
|
203
|
-
name="Security Check",
|
204
|
-
goals=["Identify security vulnerabilities"],
|
205
|
-
description="Perform a thorough security review on the project.",
|
206
|
-
dependencies=["./src/main.py"]
|
207
|
-
)
|
208
|
-
|
209
|
-
vulnerabilities = await toolbox_usage.gather_tools_fine_grind(task)
|
210
|
-
for vulnerability in vulnerabilities:
|
211
|
-
print(f"Found vulnerability: {vulnerability.name}")
|
212
|
-
```
|
213
|
-
|
214
|
-
|
215
|
-
### Managing CTF Challenges
|
216
|
-
|
217
|
-
```python
|
218
|
-
import asyncio
|
219
|
-
|
220
|
-
from fabricatio.models.usages import ToolBoxUsage
|
221
|
-
from fabricatio.models.task import Task
|
222
|
-
|
223
|
-
toolbox_usage = ToolBoxUsage()
|
224
|
-
|
225
|
-
async def solve_ctf_challenge(challenge_name: str, challenge_description: str, files: list[str]):
|
226
|
-
task = Task(
|
227
|
-
name=challenge_name,
|
228
|
-
goals=[f"Solve {challenge_name} challenge"],
|
229
|
-
description=challenge_description,
|
230
|
-
dependencies=files
|
231
|
-
)
|
232
|
-
|
233
|
-
solution = await toolbox_usage.gather_tools_fine_grind(task)
|
234
|
-
print(f"Challenge Solved: {solution}")
|
235
|
-
|
236
|
-
if __name__ == "__main__":
|
237
|
-
asyncio.run(
|
238
|
-
solve_ctf_challenge("Binary Exploitation", "CTF Binary Exploitation Challenge", ["./challenges/binary_exploit"]))
|
239
|
-
```
|
240
|
-
|
241
|
-
|
242
|
-
## Configuration
|
243
|
-
|
244
|
-
The configuration for Fabricatio is managed via environment variables or TOML files. The default configuration file (`config.toml`) can be overridden by specifying a custom path.
|
245
|
-
|
246
|
-
Example `config.toml`:
|
247
|
-
|
248
|
-
```toml
|
249
|
-
[llm]
|
250
|
-
api_endpoint = "https://api.openai.com"
|
251
|
-
api_key = "your_openai_api_key"
|
252
|
-
timeout = 300
|
253
|
-
max_retries = 3
|
254
|
-
model = "gpt-3.5-turbo"
|
255
|
-
temperature = 1.0
|
256
|
-
stop_sign = ["\n\n\n", "User:"]
|
257
|
-
top_p = 0.35
|
258
|
-
generation_count = 1
|
259
|
-
stream = false
|
260
|
-
max_tokens = 8192
|
261
|
-
```
|
262
|
-
|
263
|
-
|
264
|
-
## Development Setup
|
265
|
-
|
266
|
-
To set up a development environment for Fabricatio:
|
267
|
-
|
268
|
-
1. **Clone the Repository**:
|
269
|
-
```bash
|
270
|
-
git clone https://github.com/Whth/fabricatio.git
|
271
|
-
cd fabricatio
|
272
|
-
```
|
273
|
-
|
274
|
-
|
275
|
-
2. **Install Dependencies**:
|
276
|
-
```bash
|
277
|
-
uv --with-editable . maturin develop --uv -r
|
278
|
-
```
|
279
|
-
|
280
|
-
|
281
|
-
3. **Run Tests**:
|
282
|
-
```bash
|
283
|
-
make test
|
284
|
-
```
|
285
|
-
|
286
|
-
|
287
|
-
4. **Build Documentation**:
|
288
|
-
```bash
|
289
|
-
make docs
|
290
|
-
```
|
291
|
-
|
292
|
-
|
293
|
-
## Contributing
|
294
|
-
|
295
|
-
Contributions are welcome! Please follow these guidelines when contributing:
|
296
|
-
|
297
|
-
1. Fork the repository.
|
298
|
-
2. Create your feature branch (`git checkout -b feature/new-feature`).
|
299
|
-
3. Commit your changes (`git commit -am 'Add new feature'`).
|
300
|
-
4. Push to the branch (`git push origin feature/new-feature`).
|
301
|
-
5. Create a new Pull Request.
|
302
|
-
|
303
|
-
## License
|
304
|
-
|
305
|
-
Fabricatio is licensed under the MIT License. See [LICENSE](LICENSE) for more details.
|
306
|
-
|
307
|
-
## Acknowledgments
|
308
|
-
|
309
|
-
Special thanks to the contributors and maintainers of:
|
310
|
-
- [PyO3](https://github.com/PyO3/pyo3)
|
311
|
-
- [Maturin](https://github.com/PyO3/maturin)
|
312
|
-
- [Handlebars.rs](https://github.com/sunng87/handlebars-rust)
|
@@ -1,41 +0,0 @@
|
|
1
|
-
fabricatio-0.2.6.dev0.dist-info/METADATA,sha256=0rCWeinWl5uI8bzZhMeRORs5dJ8sWa5z5zpoy3Lnj6A,8896
|
2
|
-
fabricatio-0.2.6.dev0.dist-info/WHEEL,sha256=tpW5AN9B-9qsM9WW2FXG2r193YXiqexDadpKp0A2daI,96
|
3
|
-
fabricatio-0.2.6.dev0.dist-info/licenses/LICENSE,sha256=do7J7EiCGbq0QPbMAL_FqLYufXpHnCnXBOuqVPwSV8Y,1088
|
4
|
-
fabricatio/actions/article.py,sha256=yzRwgc203vI3MW_oWyFybDxTz6kaBBvUgN2zOJJ9Amc,2825
|
5
|
-
fabricatio/actions/output.py,sha256=KSSLvEvXsA10ACN2mbqGo98QwKLVUAoMUJNKYk6HhGc,645
|
6
|
-
fabricatio/actions/rag.py,sha256=GpT7YlqOYznZyaT-6Y84_33HtZGT-5s71ZK8iroQA9g,813
|
7
|
-
fabricatio/capabilities/propose.py,sha256=y3kge5g6bb8HYuV8e9h4MdqOMTlsfAIZpqE_cagWPTY,1593
|
8
|
-
fabricatio/capabilities/rag.py,sha256=YYaabej-f6a7gBRbJRcJ_Fj89BloNCw0sHOPqs_W8Bk,15773
|
9
|
-
fabricatio/capabilities/rating.py,sha256=0Xrfp_AW9u2ltHnZXxz3Pt3fr8fMsO0QiFadegh49IU,14406
|
10
|
-
fabricatio/capabilities/review.py,sha256=4FbM8dO-JSPnu22I1lykM9y1gzBtXI5Wj33KtzvULWU,9757
|
11
|
-
fabricatio/capabilities/task.py,sha256=hvyZtgkBdrZmuxGqTe-ZkGp2LjymPNE1RK7Y-ztDb7M,4607
|
12
|
-
fabricatio/config.py,sha256=rh8OkGwvuM0-bkZGqhVjMt7-hpdD-rz3Ai7OucrbbWY,15784
|
13
|
-
fabricatio/core.py,sha256=VQ_JKgUGIy2gZ8xsTBZCdr_IP7wC5aPg0_bsOmjQ588,6458
|
14
|
-
fabricatio/decorators.py,sha256=uzsP4tFKQNjDHBkofsjjoJA0IUAaYOtt6YVedoyOqlo,6551
|
15
|
-
fabricatio/fs/curd.py,sha256=N6l2MncjrFfnXBRtteRouXp5Rjy8EAKC_i29_G-zz98,4618
|
16
|
-
fabricatio/fs/readers.py,sha256=RNWx4T2XXigeprJOxw8YjHfyGlrCtB5MVz01Gw9lvw4,1202
|
17
|
-
fabricatio/fs/__init__.py,sha256=uk4yIlz43Yl2mQZ5QuoMstg0DaIQV9h6XXxU4SbdWpY,588
|
18
|
-
fabricatio/journal.py,sha256=pCpIFk-IOsDmCcjx1fOsWDDxjkeAGYgu2OrFnuItwcA,801
|
19
|
-
fabricatio/models/action.py,sha256=onNzHqb7QaqAQ9dtVKf85DWHiJaGeK9gORi_pT7B5Wc,6445
|
20
|
-
fabricatio/models/events.py,sha256=QvlnS8FEELg6KNabcJMeh2GV_y0ZBzKOPphcteKYWYU,4183
|
21
|
-
fabricatio/models/extra.py,sha256=O8ncZVsaNmlR5f8c_b2HJc-yVZQ2YhB6ddDbfT0Ysh4,7412
|
22
|
-
fabricatio/models/generic.py,sha256=LnXmwdZ8Rjx_lanWOz0T1NsBsFRXfXqubYNzsCvLEH0,13808
|
23
|
-
fabricatio/models/kwargs_types.py,sha256=RKD_EXMlz4vuVpGzB9y5qDotSHNOKjk6R0EI4BoNaCg,4282
|
24
|
-
fabricatio/models/role.py,sha256=M9JVDmLLvJhY3G0hHMdcs1ywJ0eoAb6CLYbzhv-l_8s,1839
|
25
|
-
fabricatio/models/task.py,sha256=sbC0EAZC4rPL2GCJ9i9GlFcZUJ96g39SQ2QP8bbgdqs,10492
|
26
|
-
fabricatio/models/tool.py,sha256=4b-v4WIC_LuLOKzzXL9bvKXr8vmGZ8O2uAFv5-1KRA0,7052
|
27
|
-
fabricatio/models/usages.py,sha256=dpMIIoYGRyer97sSP2sQVpihLl2C3REtUMDVZum0DQw,27825
|
28
|
-
fabricatio/models/utils.py,sha256=QI3bYrKBbzLbKvyzVrZXGcWq3trOOTE-hQAC_WNvjMg,4457
|
29
|
-
fabricatio/parser.py,sha256=pwYAoLbWYXtABcnV3s5GdBM0Ngczq-r7n0jKSnpdAxE,5838
|
30
|
-
fabricatio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
fabricatio/toolboxes/arithmetic.py,sha256=WLqhY-Pikv11Y_0SGajwZx3WhsLNpHKf9drzAqOf_nY,1369
|
32
|
-
fabricatio/toolboxes/fs.py,sha256=l4L1CVxJmjw9Ld2XUpIlWfV0_Fu_2Og6d3E13I-S4aE,736
|
33
|
-
fabricatio/toolboxes/__init__.py,sha256=KBJi5OG_pExscdlM7Bnt_UF43j4I3Lv6G71kPVu4KQU,395
|
34
|
-
fabricatio/workflows/articles.py,sha256=RebdC_BzSXC-xsck5I9ccC_XIgfhtoeM8FZuhtVDn3U,580
|
35
|
-
fabricatio/workflows/rag.py,sha256=-YYp2tlE9Vtfgpg6ROpu6QVO8j8yVSPa6yDzlN3qVxs,520
|
36
|
-
fabricatio/_rust.pyi,sha256=pI747rOciunGuQZDvfC3O0A6pLyOiaHSa3A5kHuQO0E,3169
|
37
|
-
fabricatio/_rust_instances.py,sha256=RybIzB2kCoMeU_1kMm2JTz1ka8i524hAra66joDf--s,314
|
38
|
-
fabricatio/__init__.py,sha256=22KLRAVoJZUrK7gsDjU1NfiLCnZtV-qgx6TO2YMbuH8,1930
|
39
|
-
fabricatio/_rust.cp312-win_amd64.pyd,sha256=AhBvJkNL2zAztAgKdFMhVjnek1VBtetgCX3CCusrM-4,1815552
|
40
|
-
fabricatio-0.2.6.dev0.data/scripts/tdown.exe,sha256=FfiaaE9jKm61UyaQHNF7u-QJc8JQhi9btQjn1ySnQ28,3395072
|
41
|
-
fabricatio-0.2.6.dev0.dist-info/RECORD,,
|
File without changes
|
File without changes
|