Metadata-Version: 2.4
Name: fabricatio
Version: 0.2.0.dev2
Summary: A LLM multi-agent framework.
Author-email: Whth <zettainspector@foxmail.com>
License: MIT License
        
        Copyright (c) 2025 Whth Yotta
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,ai,llm,multi-agent
Classifier: Framework :: AsyncIO
Classifier: Framework :: Pydantic :: 2
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: aiohttp>=3.11.11
Requires-Dist: aiomultiprocess>=0.9.1
Requires-Dist: appdirs>=1.4.4
Requires-Dist: asyncio>=3.4.3
Requires-Dist: code2prompt
Requires-Dist: gitpython>=3.1.44
Requires-Dist: litellm>=1.60.0
Requires-Dist: loguru>=0.7.3
Requires-Dist: magika>=0.5.1
Requires-Dist: orjson>=3.10.15
Requires-Dist: pybars3>=0.9.7
Requires-Dist: pydantic-settings>=2.7.1
Requires-Dist: pydantic>=2.10.6
Requires-Dist: pymitter>=1.0.0
Requires-Dist: questionary>=2.1.0
Requires-Dist: regex>=2024.11.6
Requires-Dist: rich>=13.9.4
Requires-Dist: typer>=0.15.1
Description-Content-Type: text/markdown

# Fabricatio

---

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.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
    - [Defining a Task](#defining-a-task)
    - [Creating an Action](#creating-an-action)
    - [Assigning a Role](#assigning-a-role)
    - [Logging](#logging)
- [Configuration](#configuration)
    - [LLM Configuration](#llm-configuration)
    - [Debug Configuration](#debug-configuration)
- [Examples](#examples)
    - [Simple Task Example](#simple-task-example)
    - [Complex Workflow Example](#complex-workflow-example)
- [Contributing](#contributing)
- [License](#license)

## Installation
To install Fabricatio, you can use pip:

```bash
pip install fabricatio
```

Alternatively, you can clone the repository and install it manually:

```bash
git clone https://github.com/your-repo/fabricatio.git
cd fabricatio
pip install .
```


## Usage

### Defining a Task

A task in Fabricatio is defined using the `Task` class. You can specify the name, goal, and description of the task.

```python
from fabricatio.models.task import Task

task = Task(name="say hello", goal="say hello", description="say hello to the world")
```


### Creating an Action

Actions are the building blocks of workflows. They perform specific tasks and can be asynchronous.

```python
from fabricatio import Action, logger
from fabricatio.models.task import Task

class Talk(Action):
    async def _execute(self, task_input: Task[str], **_) -> str:
        ret = "Hello fabricatio!"
        logger.info("executing talk action")
        return ret
```


### Assigning a Role

Roles in Fabricatio are responsible for executing workflows. You can define a role with a set of actions.

```python
from fabricatio.models.role import Role
from fabricatio.models.action import WorkFlow

class TestWorkflow(WorkFlow):
    pass

role = Role(name="Test Role", actions=[TestWorkflow()])
```


### Logging

Fabricatio uses Loguru for logging. You can configure the log level and file in the `config.py` file.

```python
from fabricatio.config import DebugConfig

debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
```


## Configuration

Fabricatio uses Pydantic for configuration management. You can define your settings in the `config.py` file.

### LLM Configuration

The Large Language Model (LLM) configuration is managed by the `LLMConfig` class.

```python
from fabricatio.config import LLMConfig

llm_config = LLMConfig(api_endpoint="https://api.example.com")
```


### Debug Configuration

The debug configuration is managed by the `DebugConfig` class.

```python
from fabricatio.config import DebugConfig

debug_config = DebugConfig(log_level="DEBUG", log_file="fabricatio.log")
```


## Examples

### Simple Task Example

Here is a simple example of a task that prints "Hello fabricatio!".

```python
import asyncio
from fabricatio import Action, Role, Task, WorkFlow, logger

task = Task(name="say hello", goal="say hello", description="say hello to the world")

class Talk(Action):
    async def _execute(self, task_input: Task[str], **_) -> Any:
        ret = "Hello fabricatio!"
        logger.info("executing talk action")
        return ret

class TestWorkflow(WorkFlow):
    pass

role = Role(name="Test Role", actions=[TestWorkflow()])

async def main() -> None:
    await role.act(task)

if __name__ == "__main__":
    asyncio.run(main())
```


### Complex Workflow Example

Here is a more complex example that demonstrates how to create a workflow with multiple actions.

```python
import asyncio
from fabricatio import Action, Role, Task, WorkFlow, logger

task = Task(name="complex task", goal="perform complex operations", description="a task with multiple actions")

class ActionOne(Action):
    async def _execute(self, task_input: Task[str], **_) -> Any:
        ret = "Action One executed"
        logger.info(ret)
        return ret

class ActionTwo(Action):
    async def _execute(self, task_input: Task[str], **_) -> Any:
        ret = "Action Two executed"
        logger.info(ret)
        return ret

class ComplexWorkflow(WorkFlow):
    actions = [ActionOne(), ActionTwo()]

role = Role(name="Complex Role", actions=[ComplexWorkflow()])

async def main() -> None:
    await role.act(task)

if __name__ == "__main__":
    asyncio.run(main())
```


## Contributing

Contributions to Fabricatio are welcome! Please submit a pull request with your changes.

## License

Fabricatio is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
