fabricatio 0.2.0.dev0__tar.gz → 0.2.0.dev2__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.
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/.github/workflows/build-package.yaml +5 -1
- fabricatio-0.2.0.dev2/.github/workflows/tests.yaml +32 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/PKG-INFO +127 -8
- fabricatio-0.2.0.dev2/README.md +193 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/examples/minor/hello_fabricatio.py +4 -4
- fabricatio-0.2.0.dev2/examples/simple_chat/chat.py +31 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/pyproject.toml +18 -10
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/__init__.py +10 -2
- fabricatio-0.2.0.dev2/src/fabricatio/actions/__init__.py +5 -0
- fabricatio-0.2.0.dev2/src/fabricatio/actions/communication.py +13 -0
- fabricatio-0.2.0.dev2/src/fabricatio/actions/transmission.py +32 -0
- fabricatio-0.2.0.dev2/src/fabricatio/bin/template_download.py +92 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/config.py +5 -1
- fabricatio-0.2.0.dev2/src/fabricatio/fs/__init__.py +5 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/action.py +50 -13
- fabricatio-0.2.0.dev2/src/fabricatio/models/role.py +25 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/task.py +32 -4
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/tool.py +4 -6
- fabricatio-0.2.0.dev2/src/fabricatio/templates.py +39 -0
- fabricatio-0.2.0.dev2/templates/built-in/binary-exploitation-ctf-solver.hbs +54 -0
- fabricatio-0.2.0.dev2/templates/built-in/claude-xml.hbs +36 -0
- fabricatio-0.2.0.dev2/templates/built-in/clean-up-code.hbs +38 -0
- fabricatio-0.2.0.dev2/templates/built-in/cryptography-ctf-solver.hbs +43 -0
- fabricatio-0.2.0.dev2/templates/built-in/document-the-code.hbs +30 -0
- fabricatio-0.2.0.dev2/templates/built-in/find-security-vulnerabilities.hbs +47 -0
- fabricatio-0.2.0.dev2/templates/built-in/fix-bugs.hbs +43 -0
- fabricatio-0.2.0.dev2/templates/built-in/improve-performance.hbs +42 -0
- fabricatio-0.2.0.dev2/templates/built-in/refactor.hbs +49 -0
- fabricatio-0.2.0.dev2/templates/built-in/reverse-engineering-ctf-solver.hbs +55 -0
- fabricatio-0.2.0.dev2/templates/built-in/web-ctf-solver.hbs +49 -0
- fabricatio-0.2.0.dev2/templates/built-in/write-git-commit.hbs +28 -0
- fabricatio-0.2.0.dev2/templates/built-in/write-github-pull-request.hbs +58 -0
- fabricatio-0.2.0.dev2/templates/built-in/write-github-readme.hbs +34 -0
- fabricatio-0.2.0.dev2/tests/test_config.py +18 -0
- fabricatio-0.2.0.dev2/tests/test_core.py +56 -0
- fabricatio-0.2.0.dev2/tests/test_decorators.py +23 -0
- fabricatio-0.2.0.dev2/tests/test_events.py +41 -0
- fabricatio-0.2.0.dev2/tests/test_examples.py +30 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_action.py +41 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_communication.py +19 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_events.py +27 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_generic.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_llm_usage.py +21 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_propose_task.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_role.py +23 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_role_with_actions.py +23 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_task.py +40 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_template_manager.py +29 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/tests/test_models/test_tool.py +4 -10
- fabricatio-0.2.0.dev2/tests/test_models/test_transmission.py +29 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_utils.py +12 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_briefing.py +17 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_briefing_and_json_example.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_briefing_and_llm_usage.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_briefing_and_llm_usage_and_json_example.py +29 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency.py +19 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_briefing.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_briefing_and_json_example.py +29 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_briefing_and_llm_usage.py +25 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_json_example.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_llm_usage.py +22 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_dependency_and_llm_usage_and_json_example.py +25 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_with_json_example.py +17 -0
- fabricatio-0.2.0.dev2/tests/test_models/test_workflow.py +30 -0
- fabricatio-0.2.0.dev2/tests/test_parser.py +9 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/uv.lock +64 -5
- fabricatio-0.2.0.dev0/README.md +0 -76
- fabricatio-0.2.0.dev0/src/fabricatio/actions/__init__.py +0 -5
- fabricatio-0.2.0.dev0/src/fabricatio/actions/transmission.py +0 -16
- fabricatio-0.2.0.dev0/src/fabricatio/models/role.py +0 -50
- fabricatio-0.2.0.dev0/tests/__init__.py +0 -0
- fabricatio-0.2.0.dev0/tests/conftest.py +0 -8
- fabricatio-0.2.0.dev0/tests/test_config.py +0 -29
- fabricatio-0.2.0.dev0/tests/test_core.py +0 -94
- fabricatio-0.2.0.dev0/tests/test_events.py +0 -49
- fabricatio-0.2.0.dev0/tests/test_models/test_action.py +0 -58
- fabricatio-0.2.0.dev0/tests/test_models/test_events.py +0 -29
- fabricatio-0.2.0.dev0/tests/test_models/test_generic.py +0 -25
- fabricatio-0.2.0.dev0/tests/test_models/test_role.py +0 -15
- fabricatio-0.2.0.dev0/tests/test_models/test_utils.py +0 -19
- fabricatio-0.2.0.dev0/tests/test_parser.py +0 -13
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/.github/workflows/ruff.yaml +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/.gitignore +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/.python-version +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/LICENSE +0 -0
- /fabricatio-0.2.0.dev0/examples/simple_chat/chat.py → /fabricatio-0.2.0.dev2/examples/propose_task/propose.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/core.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/decorators.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/fs/readers.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/journal.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/events.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/generic.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/models/utils.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/parser.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/py.typed +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/toolboxes/__init__.py +0 -0
- {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev2}/src/fabricatio/toolboxes/task.py +0 -0
- {fabricatio-0.2.0.dev0/src/fabricatio/fs → fabricatio-0.2.0.dev2/tests}/__init__.py +0 -0
@@ -46,7 +46,10 @@ jobs:
|
|
46
46
|
echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
|
47
47
|
fi
|
48
48
|
shell: bash
|
49
|
-
|
49
|
+
- name: Packing templates
|
50
|
+
if: ${{ steps.check_version_change.outputs.VERSION_CHANGED == 'true' }}
|
51
|
+
run: |
|
52
|
+
tar -czf templates.tar.gz templates
|
50
53
|
|
51
54
|
- name: Create Release and upload assets
|
52
55
|
if: ${{ steps.check_version_change.outputs.VERSION_CHANGED == 'true' }}
|
@@ -57,6 +60,7 @@ jobs:
|
|
57
60
|
name: ${{ steps.get_version.outputs.CURRENT_VERSION }}
|
58
61
|
files: |
|
59
62
|
dist/*
|
63
|
+
templates.tar.gz
|
60
64
|
env:
|
61
65
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
62
66
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
runs-on: windows-latest
|
14
|
+
steps:
|
15
|
+
- name: Checkout repository
|
16
|
+
uses: actions/checkout@v4
|
17
|
+
|
18
|
+
- name: Install the latest version of uv
|
19
|
+
uses: astral-sh/setup-uv@v5
|
20
|
+
with:
|
21
|
+
version: "latest"
|
22
|
+
|
23
|
+
- name: Install deps
|
24
|
+
run: |
|
25
|
+
uv sync
|
26
|
+
|
27
|
+
- name: Build
|
28
|
+
run: |
|
29
|
+
pytest tests
|
30
|
+
|
31
|
+
|
32
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fabricatio
|
3
|
-
Version: 0.2.0.
|
3
|
+
Version: 0.2.0.dev2
|
4
4
|
Summary: A LLM multi-agent framework.
|
5
5
|
Author-email: Whth <zettainspector@foxmail.com>
|
6
6
|
License: MIT License
|
@@ -43,18 +43,61 @@ Requires-Dist: litellm>=1.60.0
|
|
43
43
|
Requires-Dist: loguru>=0.7.3
|
44
44
|
Requires-Dist: magika>=0.5.1
|
45
45
|
Requires-Dist: orjson>=3.10.15
|
46
|
+
Requires-Dist: pybars3>=0.9.7
|
46
47
|
Requires-Dist: pydantic-settings>=2.7.1
|
47
48
|
Requires-Dist: pydantic>=2.10.6
|
48
49
|
Requires-Dist: pymitter>=1.0.0
|
49
50
|
Requires-Dist: questionary>=2.1.0
|
50
51
|
Requires-Dist: regex>=2024.11.6
|
51
52
|
Requires-Dist: rich>=13.9.4
|
53
|
+
Requires-Dist: typer>=0.15.1
|
52
54
|
Description-Content-Type: text/markdown
|
53
55
|
|
56
|
+
# Fabricatio
|
57
|
+
|
58
|
+
---
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
## Table of Contents
|
63
|
+
|
64
|
+
- [Installation](#installation)
|
65
|
+
- [Usage](#usage)
|
66
|
+
- [Defining a Task](#defining-a-task)
|
67
|
+
- [Creating an Action](#creating-an-action)
|
68
|
+
- [Assigning a Role](#assigning-a-role)
|
69
|
+
- [Logging](#logging)
|
70
|
+
- [Configuration](#configuration)
|
71
|
+
- [LLM Configuration](#llm-configuration)
|
72
|
+
- [Debug Configuration](#debug-configuration)
|
73
|
+
- [Examples](#examples)
|
74
|
+
- [Simple Task Example](#simple-task-example)
|
75
|
+
- [Complex Workflow Example](#complex-workflow-example)
|
76
|
+
- [Contributing](#contributing)
|
77
|
+
- [License](#license)
|
78
|
+
|
79
|
+
## Installation
|
80
|
+
To install Fabricatio, you can use pip:
|
81
|
+
|
82
|
+
```bash
|
83
|
+
pip install fabricatio
|
84
|
+
```
|
85
|
+
|
86
|
+
Alternatively, you can clone the repository and install it manually:
|
87
|
+
|
88
|
+
```bash
|
89
|
+
git clone https://github.com/your-repo/fabricatio.git
|
90
|
+
cd fabricatio
|
91
|
+
pip install .
|
92
|
+
```
|
93
|
+
|
94
|
+
|
54
95
|
## Usage
|
55
96
|
|
56
97
|
### Defining a Task
|
57
98
|
|
99
|
+
A task in Fabricatio is defined using the `Task` class. You can specify the name, goal, and description of the task.
|
100
|
+
|
58
101
|
```python
|
59
102
|
from fabricatio.models.task import Task
|
60
103
|
|
@@ -64,12 +107,14 @@ task = Task(name="say hello", goal="say hello", description="say hello to the wo
|
|
64
107
|
|
65
108
|
### Creating an Action
|
66
109
|
|
110
|
+
Actions are the building blocks of workflows. They perform specific tasks and can be asynchronous.
|
111
|
+
|
67
112
|
```python
|
68
113
|
from fabricatio import Action, logger
|
69
114
|
from fabricatio.models.task import Task
|
70
115
|
|
71
116
|
class Talk(Action):
|
72
|
-
async def _execute(self, task_input: Task[str], **_) ->
|
117
|
+
async def _execute(self, task_input: Task[str], **_) -> str:
|
73
118
|
ret = "Hello fabricatio!"
|
74
119
|
logger.info("executing talk action")
|
75
120
|
return ret
|
@@ -78,6 +123,8 @@ class Talk(Action):
|
|
78
123
|
|
79
124
|
### Assigning a Role
|
80
125
|
|
126
|
+
Roles in Fabricatio are responsible for executing workflows. You can define a role with a set of actions.
|
127
|
+
|
81
128
|
```python
|
82
129
|
from fabricatio.models.role import Role
|
83
130
|
from fabricatio.models.action import WorkFlow
|
@@ -104,19 +151,91 @@ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
|
|
104
151
|
|
105
152
|
Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
|
106
153
|
|
154
|
+
### LLM Configuration
|
155
|
+
|
156
|
+
The Large Language Model (LLM) configuration is managed by the `LLMConfig` class.
|
157
|
+
|
107
158
|
```python
|
108
|
-
from fabricatio.config import
|
159
|
+
from fabricatio.config import LLMConfig
|
109
160
|
|
110
|
-
|
161
|
+
llm_config = LLMConfig(api_endpoint="https://api.example.com")
|
111
162
|
```
|
112
163
|
|
113
164
|
|
114
|
-
|
165
|
+
### Debug Configuration
|
115
166
|
|
116
|
-
|
167
|
+
The debug configuration is managed by the `DebugConfig` class.
|
117
168
|
|
118
|
-
```
|
119
|
-
|
169
|
+
```python
|
170
|
+
from fabricatio.config import DebugConfig
|
171
|
+
|
172
|
+
debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
## Examples
|
177
|
+
|
178
|
+
### Simple Task Example
|
179
|
+
|
180
|
+
Here is a simple example of a task that prints "Hello fabricatio!".
|
181
|
+
|
182
|
+
```python
|
183
|
+
import asyncio
|
184
|
+
from fabricatio import Action, Role, Task, WorkFlow, logger
|
185
|
+
|
186
|
+
task = Task(name="say hello", goal="say hello", description="say hello to the world")
|
187
|
+
|
188
|
+
class Talk(Action):
|
189
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
190
|
+
ret = "Hello fabricatio!"
|
191
|
+
logger.info("executing talk action")
|
192
|
+
return ret
|
193
|
+
|
194
|
+
class TestWorkflow(WorkFlow):
|
195
|
+
pass
|
196
|
+
|
197
|
+
role = Role(name="Test Role", actions=[TestWorkflow()])
|
198
|
+
|
199
|
+
async def main() -> None:
|
200
|
+
await role.act(task)
|
201
|
+
|
202
|
+
if __name__ == "__main__":
|
203
|
+
asyncio.run(main())
|
204
|
+
```
|
205
|
+
|
206
|
+
|
207
|
+
### Complex Workflow Example
|
208
|
+
|
209
|
+
Here is a more complex example that demonstrates how to create a workflow with multiple actions.
|
210
|
+
|
211
|
+
```python
|
212
|
+
import asyncio
|
213
|
+
from fabricatio import Action, Role, Task, WorkFlow, logger
|
214
|
+
|
215
|
+
task = Task(name="complex task", goal="perform complex operations", description="a task with multiple actions")
|
216
|
+
|
217
|
+
class ActionOne(Action):
|
218
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
219
|
+
ret = "Action One executed"
|
220
|
+
logger.info(ret)
|
221
|
+
return ret
|
222
|
+
|
223
|
+
class ActionTwo(Action):
|
224
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
225
|
+
ret = "Action Two executed"
|
226
|
+
logger.info(ret)
|
227
|
+
return ret
|
228
|
+
|
229
|
+
class ComplexWorkflow(WorkFlow):
|
230
|
+
actions = [ActionOne(), ActionTwo()]
|
231
|
+
|
232
|
+
role = Role(name="Complex Role", actions=[ComplexWorkflow()])
|
233
|
+
|
234
|
+
async def main() -> None:
|
235
|
+
await role.act(task)
|
236
|
+
|
237
|
+
if __name__ == "__main__":
|
238
|
+
asyncio.run(main())
|
120
239
|
```
|
121
240
|
|
122
241
|
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# Fabricatio
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## Table of Contents
|
8
|
+
|
9
|
+
- [Installation](#installation)
|
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)
|
15
|
+
- [Configuration](#configuration)
|
16
|
+
- [LLM Configuration](#llm-configuration)
|
17
|
+
- [Debug Configuration](#debug-configuration)
|
18
|
+
- [Examples](#examples)
|
19
|
+
- [Simple Task Example](#simple-task-example)
|
20
|
+
- [Complex Workflow Example](#complex-workflow-example)
|
21
|
+
- [Contributing](#contributing)
|
22
|
+
- [License](#license)
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
To install Fabricatio, you can use pip:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
pip install fabricatio
|
29
|
+
```
|
30
|
+
|
31
|
+
Alternatively, you can clone the repository and install it manually:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
git clone https://github.com/your-repo/fabricatio.git
|
35
|
+
cd fabricatio
|
36
|
+
pip install .
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
### Defining a Task
|
43
|
+
|
44
|
+
A task in Fabricatio is defined using the `Task` class. You can specify the name, goal, and description of the task.
|
45
|
+
|
46
|
+
```python
|
47
|
+
from fabricatio.models.task import Task
|
48
|
+
|
49
|
+
task = Task(name="say hello", goal="say hello", description="say hello to the world")
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
### Creating an Action
|
54
|
+
|
55
|
+
Actions are the building blocks of workflows. They perform specific tasks and can be asynchronous.
|
56
|
+
|
57
|
+
```python
|
58
|
+
from fabricatio import Action, logger
|
59
|
+
from fabricatio.models.task import Task
|
60
|
+
|
61
|
+
class Talk(Action):
|
62
|
+
async def _execute(self, task_input: Task[str], **_) -> str:
|
63
|
+
ret = "Hello fabricatio!"
|
64
|
+
logger.info("executing talk action")
|
65
|
+
return ret
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
### Assigning a Role
|
70
|
+
|
71
|
+
Roles in Fabricatio are responsible for executing workflows. You can define a role with a set of actions.
|
72
|
+
|
73
|
+
```python
|
74
|
+
from fabricatio.models.role import Role
|
75
|
+
from fabricatio.models.action import WorkFlow
|
76
|
+
|
77
|
+
class TestWorkflow(WorkFlow):
|
78
|
+
pass
|
79
|
+
|
80
|
+
role = Role(name="Test Role", actions=[TestWorkflow()])
|
81
|
+
```
|
82
|
+
|
83
|
+
|
84
|
+
### Logging
|
85
|
+
|
86
|
+
Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
|
87
|
+
|
88
|
+
```python
|
89
|
+
from fabricatio.config import DebugConfig
|
90
|
+
|
91
|
+
debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
|
92
|
+
```
|
93
|
+
|
94
|
+
|
95
|
+
## Configuration
|
96
|
+
|
97
|
+
Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
|
98
|
+
|
99
|
+
### LLM Configuration
|
100
|
+
|
101
|
+
The Large Language Model (LLM) configuration is managed by the `LLMConfig` class.
|
102
|
+
|
103
|
+
```python
|
104
|
+
from fabricatio.config import LLMConfig
|
105
|
+
|
106
|
+
llm_config = LLMConfig(api_endpoint="https://api.example.com")
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
### Debug Configuration
|
111
|
+
|
112
|
+
The debug configuration is managed by the `DebugConfig` class.
|
113
|
+
|
114
|
+
```python
|
115
|
+
from fabricatio.config import DebugConfig
|
116
|
+
|
117
|
+
debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
|
118
|
+
```
|
119
|
+
|
120
|
+
|
121
|
+
## Examples
|
122
|
+
|
123
|
+
### Simple Task Example
|
124
|
+
|
125
|
+
Here is a simple example of a task that prints "Hello fabricatio!".
|
126
|
+
|
127
|
+
```python
|
128
|
+
import asyncio
|
129
|
+
from fabricatio import Action, Role, Task, WorkFlow, logger
|
130
|
+
|
131
|
+
task = Task(name="say hello", goal="say hello", description="say hello to the world")
|
132
|
+
|
133
|
+
class Talk(Action):
|
134
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
135
|
+
ret = "Hello fabricatio!"
|
136
|
+
logger.info("executing talk action")
|
137
|
+
return ret
|
138
|
+
|
139
|
+
class TestWorkflow(WorkFlow):
|
140
|
+
pass
|
141
|
+
|
142
|
+
role = Role(name="Test Role", actions=[TestWorkflow()])
|
143
|
+
|
144
|
+
async def main() -> None:
|
145
|
+
await role.act(task)
|
146
|
+
|
147
|
+
if __name__ == "__main__":
|
148
|
+
asyncio.run(main())
|
149
|
+
```
|
150
|
+
|
151
|
+
|
152
|
+
### Complex Workflow Example
|
153
|
+
|
154
|
+
Here is a more complex example that demonstrates how to create a workflow with multiple actions.
|
155
|
+
|
156
|
+
```python
|
157
|
+
import asyncio
|
158
|
+
from fabricatio import Action, Role, Task, WorkFlow, logger
|
159
|
+
|
160
|
+
task = Task(name="complex task", goal="perform complex operations", description="a task with multiple actions")
|
161
|
+
|
162
|
+
class ActionOne(Action):
|
163
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
164
|
+
ret = "Action One executed"
|
165
|
+
logger.info(ret)
|
166
|
+
return ret
|
167
|
+
|
168
|
+
class ActionTwo(Action):
|
169
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
170
|
+
ret = "Action Two executed"
|
171
|
+
logger.info(ret)
|
172
|
+
return ret
|
173
|
+
|
174
|
+
class ComplexWorkflow(WorkFlow):
|
175
|
+
actions = [ActionOne(), ActionTwo()]
|
176
|
+
|
177
|
+
role = Role(name="Complex Role", actions=[ComplexWorkflow()])
|
178
|
+
|
179
|
+
async def main() -> None:
|
180
|
+
await role.act(task)
|
181
|
+
|
182
|
+
if __name__ == "__main__":
|
183
|
+
asyncio.run(main())
|
184
|
+
```
|
185
|
+
|
186
|
+
|
187
|
+
## Contributing
|
188
|
+
|
189
|
+
Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
|
190
|
+
|
191
|
+
## License
|
192
|
+
|
193
|
+
Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
|
@@ -6,10 +6,10 @@ from fabricatio import Action, Role, Task, WorkFlow, logger
|
|
6
6
|
task = Task(name="say hello", goal="say hello", description="say hello to the world")
|
7
7
|
|
8
8
|
|
9
|
-
class
|
10
|
-
"""Action that says hello
|
9
|
+
class Hello(Action):
|
10
|
+
"""Action that says hello."""
|
11
11
|
|
12
|
-
name: str = "
|
12
|
+
name: str = "hello"
|
13
13
|
output_key: str = "task_output"
|
14
14
|
|
15
15
|
async def _execute(self, task_input: Task[str], **_) -> Any:
|
@@ -20,7 +20,7 @@ class Talk(Action):
|
|
20
20
|
|
21
21
|
async def main() -> None:
|
22
22
|
"""Main function."""
|
23
|
-
Role(name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(
|
23
|
+
Role(name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(Hello,))})
|
24
24
|
|
25
25
|
logger.success(f"Result: {await task.delegate()}")
|
26
26
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import asyncio
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from fabricatio import Action, Role, Task, WorkFlow, logger
|
5
|
+
|
6
|
+
task = Task(name="say hello", goal="say hello", description="say hello to the world")
|
7
|
+
|
8
|
+
|
9
|
+
class Talk(Action):
|
10
|
+
"""Action that says hello to the world."""
|
11
|
+
|
12
|
+
name: str = "talk"
|
13
|
+
output_key: str = "task_output"
|
14
|
+
|
15
|
+
async def _execute(self, task_input: Task[str], **_) -> Any:
|
16
|
+
ret = "Hello fabricatio!"
|
17
|
+
logger.info("executing talk action")
|
18
|
+
return ret
|
19
|
+
|
20
|
+
|
21
|
+
async def main() -> None:
|
22
|
+
"""Main function."""
|
23
|
+
role = Role(
|
24
|
+
name="talker", description="talker role", registry={task.pending_label: WorkFlow(name="talk", steps=(Talk,))}
|
25
|
+
)
|
26
|
+
logger.info(Task.json_example())
|
27
|
+
logger.info(f"proposed task: {await role.propose('say hello to Jhon')}")
|
28
|
+
|
29
|
+
|
30
|
+
if __name__ == "__main__":
|
31
|
+
asyncio.run(main())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "fabricatio"
|
3
|
-
version = "0.2.0-dev.
|
3
|
+
version = "0.2.0-dev.2"
|
4
4
|
description = "A LLM multi-agent framework."
|
5
5
|
readme = "README.md"
|
6
6
|
license = { file = "LICENSE" }
|
@@ -21,6 +21,9 @@ keywords = [
|
|
21
21
|
"multi-agent",
|
22
22
|
"llm",
|
23
23
|
]
|
24
|
+
|
25
|
+
|
26
|
+
|
24
27
|
requires-python = ">=3.12"
|
25
28
|
dependencies = [
|
26
29
|
"aiohttp>=3.11.11",
|
@@ -33,15 +36,18 @@ dependencies = [
|
|
33
36
|
"loguru>=0.7.3",
|
34
37
|
"magika>=0.5.1",
|
35
38
|
"orjson>=3.10.15",
|
39
|
+
"pybars3>=0.9.7",
|
36
40
|
"pydantic>=2.10.6",
|
37
41
|
"pydantic-settings>=2.7.1",
|
38
42
|
"pymitter>=1.0.0",
|
39
43
|
"questionary>=2.1.0",
|
40
44
|
"regex>=2024.11.6",
|
41
45
|
"rich>=13.9.4",
|
46
|
+
"typer>=0.15.1",
|
42
47
|
]
|
43
48
|
|
44
|
-
|
49
|
+
[project.scripts]
|
50
|
+
templates = "fabricatio.bin.template_download:download_and_extract"
|
45
51
|
|
46
52
|
[build-system]
|
47
53
|
requires = ["hatchling"]
|
@@ -60,15 +66,17 @@ dev = [
|
|
60
66
|
"pytest-xdist>=3.6.1",
|
61
67
|
"ruff>=0.9.4",
|
62
68
|
"uv>=0.5.29",
|
63
|
-
|
64
|
-
cli = [
|
65
|
-
"typer>=0.15.1",
|
69
|
+
"viztracer>=1.0.2",
|
66
70
|
]
|
67
71
|
rag = [
|
68
72
|
"faiss-cpu>=1.10.0",
|
69
73
|
"pymilvus>=2.5.4",
|
70
74
|
]
|
71
75
|
|
76
|
+
full = [
|
77
|
+
{ group = "rag" },
|
78
|
+
]
|
79
|
+
|
72
80
|
|
73
81
|
[tool.ruff]
|
74
82
|
include = ["pyproject.toml", "src/fabricatio/*.py", "examples/*.py"]
|
@@ -129,15 +137,15 @@ testpaths = [
|
|
129
137
|
code2prompt = { git = "https://github.com/mufeedvh/code2prompt" }
|
130
138
|
|
131
139
|
[[tool.uv.index]]
|
132
|
-
url = "https://mirrors.
|
133
|
-
default = true
|
140
|
+
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
|
134
141
|
|
135
142
|
[[tool.uv.index]]
|
136
|
-
url = "https://mirrors.
|
143
|
+
url = "https://mirrors.huaweicloud.com/repository/pypi/simple"
|
137
144
|
|
138
145
|
[[tool.uv.index]]
|
139
|
-
url = "https://mirrors.
|
146
|
+
url = "https://mirrors.aliyun.com/pypi/simple/"
|
140
147
|
|
141
148
|
[[tool.uv.index]]
|
142
|
-
url = "https://mirrors.
|
149
|
+
url = "https://mirrors.bfsu.edu.cn/pypi/web/simple"
|
150
|
+
default = true
|
143
151
|
|
@@ -1,24 +1,32 @@
|
|
1
1
|
"""Fabricatio is a Python library for building llm app using event-based agent structure."""
|
2
2
|
|
3
3
|
from fabricatio.core import env
|
4
|
+
from fabricatio.fs import magika
|
4
5
|
from fabricatio.journal import logger
|
5
6
|
from fabricatio.models.action import Action, WorkFlow
|
6
7
|
from fabricatio.models.events import Event
|
7
8
|
from fabricatio.models.role import Role
|
8
9
|
from fabricatio.models.task import Task
|
9
10
|
from fabricatio.models.tool import ToolBox
|
10
|
-
from fabricatio.models.utils import Messages
|
11
|
-
from fabricatio.parser import Capture
|
11
|
+
from fabricatio.models.utils import Message, Messages
|
12
|
+
from fabricatio.parser import Capture, CodeBlockCapture, JsonCapture, PythonCapture
|
13
|
+
from fabricatio.templates import templates_manager
|
12
14
|
|
13
15
|
__all__ = [
|
14
16
|
"Action",
|
15
17
|
"Capture",
|
18
|
+
"CodeBlockCapture",
|
16
19
|
"Event",
|
20
|
+
"JsonCapture",
|
21
|
+
"Message",
|
17
22
|
"Messages",
|
23
|
+
"PythonCapture",
|
18
24
|
"Role",
|
19
25
|
"Task",
|
20
26
|
"ToolBox",
|
21
27
|
"WorkFlow",
|
22
28
|
"env",
|
23
29
|
"logger",
|
30
|
+
"magika",
|
31
|
+
"templates_manager",
|
24
32
|
]
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from fabricatio.models.action import Action
|
2
|
+
from fabricatio.models.task import Task
|
3
|
+
|
4
|
+
|
5
|
+
class Talk(Action):
|
6
|
+
"""Action that says hello to the world."""
|
7
|
+
|
8
|
+
name: str = "talk"
|
9
|
+
output_key: str = "talk_response"
|
10
|
+
|
11
|
+
async def _execute(self, task_input: Task[str], **_) -> str:
|
12
|
+
"""Execute the action."""
|
13
|
+
return await self.aask(task_input.briefing, system_message=task_input.generate_prompt())
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from typing import List
|
2
|
+
|
3
|
+
from fabricatio.journal import logger
|
4
|
+
from fabricatio.models.action import Action
|
5
|
+
from fabricatio.models.events import EventLike
|
6
|
+
from fabricatio.models.task import Task
|
7
|
+
|
8
|
+
|
9
|
+
class PublishTask(Action):
|
10
|
+
"""An action that publishes a task to a list of targets."""
|
11
|
+
|
12
|
+
name: str = "publish_task"
|
13
|
+
"""The name of the action."""
|
14
|
+
description: str = "Publish a task to a list of targets."
|
15
|
+
"""The description of the action."""
|
16
|
+
|
17
|
+
async def _execute(self, send_targets: List[EventLike], send_task: Task, **_) -> None:
|
18
|
+
"""Execute the action by sending the task to the specified targets."""
|
19
|
+
logger.info(f"Sending task {send_task.name} to {send_targets}")
|
20
|
+
for target in send_targets:
|
21
|
+
await send_task.move_to(target).publish()
|
22
|
+
|
23
|
+
|
24
|
+
class CycleTask(Action):
|
25
|
+
"""An action that cycles a task through a list of targets."""
|
26
|
+
|
27
|
+
name: str = "cycle_task"
|
28
|
+
"""The name of the action."""
|
29
|
+
description: str = "Cycle a task through a list of targets"
|
30
|
+
|
31
|
+
async def _execute(self, task_input: Task, **_) -> None:
|
32
|
+
"""Execute the action by cycling the task through the specified targets."""
|