fabricatio 0.2.0.dev0__tar.gz → 0.2.0.dev1__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 (47) hide show
  1. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/PKG-INFO +125 -8
  2. fabricatio-0.2.0.dev1/README.md +193 -0
  3. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/pyproject.toml +1 -1
  4. fabricatio-0.2.0.dev1/src/fabricatio/actions/__init__.py +5 -0
  5. fabricatio-0.2.0.dev1/src/fabricatio/actions/transmission.py +20 -0
  6. fabricatio-0.2.0.dev1/src/fabricatio/fs/__init__.py +1 -0
  7. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/action.py +18 -7
  8. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/task.py +2 -2
  9. fabricatio-0.2.0.dev0/README.md +0 -76
  10. fabricatio-0.2.0.dev0/src/fabricatio/actions/__init__.py +0 -5
  11. fabricatio-0.2.0.dev0/src/fabricatio/actions/transmission.py +0 -16
  12. fabricatio-0.2.0.dev0/tests/__init__.py +0 -0
  13. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/.github/workflows/build-package.yaml +0 -0
  14. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/.github/workflows/ruff.yaml +0 -0
  15. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/.gitignore +0 -0
  16. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/.python-version +0 -0
  17. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/LICENSE +0 -0
  18. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/examples/minor/hello_fabricatio.py +0 -0
  19. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/examples/simple_chat/chat.py +0 -0
  20. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/__init__.py +0 -0
  21. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/config.py +0 -0
  22. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/core.py +0 -0
  23. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/decorators.py +0 -0
  24. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/fs/readers.py +0 -0
  25. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/journal.py +0 -0
  26. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/events.py +0 -0
  27. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/generic.py +0 -0
  28. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/role.py +0 -0
  29. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/tool.py +0 -0
  30. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/models/utils.py +0 -0
  31. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/parser.py +0 -0
  32. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/py.typed +0 -0
  33. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/toolboxes/__init__.py +0 -0
  34. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/src/fabricatio/toolboxes/task.py +0 -0
  35. {fabricatio-0.2.0.dev0/src/fabricatio/fs → fabricatio-0.2.0.dev1/tests}/__init__.py +0 -0
  36. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/conftest.py +0 -0
  37. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_config.py +0 -0
  38. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_core.py +0 -0
  39. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_events.py +0 -0
  40. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_action.py +0 -0
  41. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_events.py +0 -0
  42. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_generic.py +0 -0
  43. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_role.py +0 -0
  44. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_tool.py +0 -0
  45. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_models/test_utils.py +0 -0
  46. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/tests/test_parser.py +0 -0
  47. {fabricatio-0.2.0.dev0 → fabricatio-0.2.0.dev1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fabricatio
3
- Version: 0.2.0.dev0
3
+ Version: 0.2.0.dev1
4
4
  Summary: A LLM multi-agent framework.
5
5
  Author-email: Whth <zettainspector@foxmail.com>
6
6
  License: MIT License
@@ -51,10 +51,51 @@ Requires-Dist: regex>=2024.11.6
51
51
  Requires-Dist: rich>=13.9.4
52
52
  Description-Content-Type: text/markdown
53
53
 
54
+ # Fabricatio
55
+
56
+ ---
57
+
58
+ 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.
59
+
60
+ ## Table of Contents
61
+
62
+ - [Installation](#installation)
63
+ - [Usage](#usage)
64
+ - [Defining a Task](#defining-a-task)
65
+ - [Creating an Action](#creating-an-action)
66
+ - [Assigning a Role](#assigning-a-role)
67
+ - [Logging](#logging)
68
+ - [Configuration](#configuration)
69
+ - [LLM Configuration](#llm-configuration)
70
+ - [Debug Configuration](#debug-configuration)
71
+ - [Examples](#examples)
72
+ - [Simple Task Example](#simple-task-example)
73
+ - [Complex Workflow Example](#complex-workflow-example)
74
+ - [Contributing](#contributing)
75
+ - [License](#license)
76
+
77
+ ## Installation
78
+ To install Fabricatio, you can use pip:
79
+
80
+ ```bash
81
+ pip install fabricatio
82
+ ```
83
+
84
+ Alternatively, you can clone the repository and install it manually:
85
+
86
+ ```bash
87
+ git clone https://github.com/your-repo/fabricatio.git
88
+ cd fabricatio
89
+ pip install .
90
+ ```
91
+
92
+
54
93
  ## Usage
55
94
 
56
95
  ### Defining a Task
57
96
 
97
+ A task in Fabricatio is defined using the `Task` class. You can specify the name, goal, and description of the task.
98
+
58
99
  ```python
59
100
  from fabricatio.models.task import Task
60
101
 
@@ -64,12 +105,14 @@ task = Task(name="say hello", goal="say hello", description="say hello to the wo
64
105
 
65
106
  ### Creating an Action
66
107
 
108
+ Actions are the building blocks of workflows. They perform specific tasks and can be asynchronous.
109
+
67
110
  ```python
68
111
  from fabricatio import Action, logger
69
112
  from fabricatio.models.task import Task
70
113
 
71
114
  class Talk(Action):
72
- async def _execute(self, task_input: Task[str], **_) -> Any:
115
+ async def _execute(self, task_input: Task[str], **_) -> str:
73
116
  ret = "Hello fabricatio!"
74
117
  logger.info("executing talk action")
75
118
  return ret
@@ -78,6 +121,8 @@ class Talk(Action):
78
121
 
79
122
  ### Assigning a Role
80
123
 
124
+ Roles in Fabricatio are responsible for executing workflows. You can define a role with a set of actions.
125
+
81
126
  ```python
82
127
  from fabricatio.models.role import Role
83
128
  from fabricatio.models.action import WorkFlow
@@ -104,19 +149,91 @@ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
104
149
 
105
150
  Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
106
151
 
152
+ ### LLM Configuration
153
+
154
+ The Large Language Model (LLM) configuration is managed by the `LLMConfig` class.
155
+
107
156
  ```python
108
- from fabricatio.config import Settings
157
+ from fabricatio.config import LLMConfig
109
158
 
110
- settings = Settings(llm=LLMConfig(api_endpoint="https://api.example.com"))
159
+ llm_config = LLMConfig(api_endpoint="https://api.example.com")
111
160
  ```
112
161
 
113
162
 
114
- ## Testing
163
+ ### Debug Configuration
115
164
 
116
- Fabricatio includes a set of tests to ensure the framework works as expected. You can run the tests using `pytest`.
165
+ The debug configuration is managed by the `DebugConfig` class.
117
166
 
118
- ```bash
119
- pytest
167
+ ```python
168
+ from fabricatio.config import DebugConfig
169
+
170
+ debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
171
+ ```
172
+
173
+
174
+ ## Examples
175
+
176
+ ### Simple Task Example
177
+
178
+ Here is a simple example of a task that prints "Hello fabricatio!".
179
+
180
+ ```python
181
+ import asyncio
182
+ from fabricatio import Action, Role, Task, WorkFlow, logger
183
+
184
+ task = Task(name="say hello", goal="say hello", description="say hello to the world")
185
+
186
+ class Talk(Action):
187
+ async def _execute(self, task_input: Task[str], **_) -> Any:
188
+ ret = "Hello fabricatio!"
189
+ logger.info("executing talk action")
190
+ return ret
191
+
192
+ class TestWorkflow(WorkFlow):
193
+ pass
194
+
195
+ role = Role(name="Test Role", actions=[TestWorkflow()])
196
+
197
+ async def main() -> None:
198
+ await role.act(task)
199
+
200
+ if __name__ == "__main__":
201
+ asyncio.run(main())
202
+ ```
203
+
204
+
205
+ ### Complex Workflow Example
206
+
207
+ Here is a more complex example that demonstrates how to create a workflow with multiple actions.
208
+
209
+ ```python
210
+ import asyncio
211
+ from fabricatio import Action, Role, Task, WorkFlow, logger
212
+
213
+ task = Task(name="complex task", goal="perform complex operations", description="a task with multiple actions")
214
+
215
+ class ActionOne(Action):
216
+ async def _execute(self, task_input: Task[str], **_) -> Any:
217
+ ret = "Action One executed"
218
+ logger.info(ret)
219
+ return ret
220
+
221
+ class ActionTwo(Action):
222
+ async def _execute(self, task_input: Task[str], **_) -> Any:
223
+ ret = "Action Two executed"
224
+ logger.info(ret)
225
+ return ret
226
+
227
+ class ComplexWorkflow(WorkFlow):
228
+ actions = [ActionOne(), ActionTwo()]
229
+
230
+ role = Role(name="Complex Role", actions=[ComplexWorkflow()])
231
+
232
+ async def main() -> None:
233
+ await role.act(task)
234
+
235
+ if __name__ == "__main__":
236
+ asyncio.run(main())
120
237
  ```
121
238
 
122
239
 
@@ -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.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fabricatio"
3
- version = "0.2.0-dev.0"
3
+ version = "0.2.0-dev.1"
4
4
  description = "A LLM multi-agent framework."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -0,0 +1,5 @@
1
+ """module for actions."""
2
+
3
+ from fabricatio.actions.transmission import PublishTask
4
+
5
+ __all__ = ["PublishTask"]
@@ -0,0 +1,20 @@
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
+
16
+ async def _execute(self, send_targets: List[EventLike], send_task: Task, **_) -> None:
17
+ """Execute the action by sending the task to the specified targets."""
18
+ logger.info(f"Sending task {send_task.name} to {send_targets}")
19
+ for target in send_targets:
20
+ await send_task.move_to(target).publish()
@@ -0,0 +1 @@
1
+ """FileSystem manipulation module for Fabricatio."""
@@ -41,7 +41,7 @@ class Action(WithBriefing, LLMUsage):
41
41
  return cxt
42
42
 
43
43
 
44
- class WorkFlow(WithBriefing, LLMUsage):
44
+ class WorkFlow[A: Type[Action] | Action](WithBriefing, LLMUsage):
45
45
  """Class that represents a workflow to be executed in a task."""
46
46
 
47
47
  _context: Queue[Dict[str, Any]] = PrivateAttr(default_factory=lambda: Queue(maxsize=1))
@@ -49,12 +49,14 @@ class WorkFlow(WithBriefing, LLMUsage):
49
49
 
50
50
  _instances: Tuple[Action, ...] = PrivateAttr(...)
51
51
 
52
- steps: Tuple[Type[Action], ...] = Field(...)
53
- """ The steps to be executed in the workflow."""
52
+ steps: Tuple[A, ...] = Field(...)
53
+ """ The steps to be executed in the workflow, actions or action classes."""
54
54
  task_input_key: str = Field(default="task_input")
55
55
  """ The key of the task input data."""
56
56
  task_output_key: str = Field(default="task_output")
57
57
  """ The key of the task output data."""
58
+ extra_init_context: Dict[str, Any] = Field(default_factory=dict, frozen=True)
59
+ """ The extra context dictionary to be used for workflow initialization."""
58
60
 
59
61
  def model_post_init(self, __context: Any) -> None:
60
62
  """Initialize the workflow by setting fallbacks for each step.
@@ -62,7 +64,11 @@ class WorkFlow(WithBriefing, LLMUsage):
62
64
  Args:
63
65
  __context: The context to be used for initialization.
64
66
  """
65
- self._instances = tuple(step() for step in self.steps)
67
+ temp = []
68
+ for step in self.steps:
69
+ temp.append(step if isinstance(step, Action) else step())
70
+ self._instances = tuple(temp)
71
+
66
72
  for step in self._instances:
67
73
  step.fallback_to(self)
68
74
 
@@ -73,13 +79,13 @@ class WorkFlow(WithBriefing, LLMUsage):
73
79
  task: The task to be served.
74
80
  """
75
81
  await task.start()
76
- await self._context.put({self.task_input_key: task})
82
+ await self._init_context()
77
83
  current_action = None
78
84
  try:
79
85
  for step in self._instances:
80
86
  logger.debug(f"Executing step: {step.name}")
81
- ctx = await self._context.get()
82
- modified_ctx = await step.act(ctx)
87
+ cxt = await self._context.get()
88
+ modified_ctx = await step.act(cxt)
83
89
  await self._context.put(modified_ctx)
84
90
  current_action = step.name
85
91
  logger.info(f"Finished executing workflow: {self.name}")
@@ -88,3 +94,8 @@ class WorkFlow(WithBriefing, LLMUsage):
88
94
  logger.error(f"Error during task: {current_action} execution: {e}") # Log the exception
89
95
  logger.error(traceback.format_exc()) # Add this line to log the traceback
90
96
  await task.fail() # Mark the task as failed
97
+
98
+ async def _init_context(self) -> None:
99
+ """Initialize the context dictionary for workflow execution."""
100
+ logger.debug(f"Initializing context for workflow: {self.name}")
101
+ await self._context.put({self.task_input_key: None, **dict(self.extra_init_context)})
@@ -11,7 +11,7 @@ from pydantic import Field, PrivateAttr
11
11
 
12
12
  from fabricatio.core import env
13
13
  from fabricatio.journal import logger
14
- from fabricatio.models.events import Event
14
+ from fabricatio.models.events import Event, EventLike
15
15
  from fabricatio.models.generic import WithBriefing, WithDependency, WithJsonExample
16
16
 
17
17
 
@@ -69,7 +69,7 @@ class Task[T](WithBriefing, WithJsonExample, WithDependency):
69
69
  """Initialize the task with a namespace event."""
70
70
  self._namespace.segments.extend(self.namespace)
71
71
 
72
- def move_to(self, new_namespace: List[str]) -> Self:
72
+ def move_to(self, new_namespace: EventLike) -> Self:
73
73
  """Move the task to a new namespace.
74
74
 
75
75
  Args:
@@ -1,76 +0,0 @@
1
- ## Usage
2
-
3
- ### Defining a Task
4
-
5
- ```python
6
- from fabricatio.models.task import Task
7
-
8
- task = Task(name="say hello", goal="say hello", description="say hello to the world")
9
- ```
10
-
11
-
12
- ### Creating an Action
13
-
14
- ```python
15
- from fabricatio import Action, logger
16
- from fabricatio.models.task import Task
17
-
18
- class Talk(Action):
19
- async def _execute(self, task_input: Task[str], **_) -> Any:
20
- ret = "Hello fabricatio!"
21
- logger.info("executing talk action")
22
- return ret
23
- ```
24
-
25
-
26
- ### Assigning a Role
27
-
28
- ```python
29
- from fabricatio.models.role import Role
30
- from fabricatio.models.action import WorkFlow
31
-
32
- class TestWorkflow(WorkFlow):
33
- pass
34
-
35
- role = Role(name="Test Role", actions=[TestWorkflow()])
36
- ```
37
-
38
-
39
- ### Logging
40
-
41
- Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.
42
-
43
- ```python
44
- from fabricatio.config import DebugConfig
45
-
46
- debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
47
- ```
48
-
49
-
50
- ## Configuration
51
-
52
- Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.
53
-
54
- ```python
55
- from fabricatio.config import Settings
56
-
57
- settings = Settings(llm=LLMConfig(api_endpoint="https://api.example.com"))
58
- ```
59
-
60
-
61
- ## Testing
62
-
63
- Fabricatio includes a set of tests to ensure the framework works as expected. You can run the tests using `pytest`.
64
-
65
- ```bash
66
- pytest
67
- ```
68
-
69
-
70
- ## Contributing
71
-
72
- Contributions to Fabricatio are welcome! Please submit a pull request with your changes.
73
-
74
- ## License
75
-
76
- Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
@@ -1,5 +0,0 @@
1
- """module for actions."""
2
-
3
- from fabricatio.actions.transmission import SendTask
4
-
5
- __all__ = ["SendTask"]
@@ -1,16 +0,0 @@
1
- from typing import List
2
-
3
- from fabricatio.journal import logger
4
- from fabricatio.models.action import Action
5
- from fabricatio.models.task import Task
6
-
7
-
8
- class SendTask(Action):
9
- """Action that sends a task to a user."""
10
-
11
- name: str = "send_task"
12
-
13
- async def _execute(self, send_targets: List[str], send_task: Task, **_) -> None:
14
- logger.info(f"Sending task {send_task.name} to {send_targets}")
15
- for target in send_targets:
16
- await send_task.publish(target)
File without changes
File without changes
File without changes