Metadata-Version: 2.4
Name: fabricatio-actions
Version: 0.1.9
Summary: A Python library providing foundational actions for file system operations and output management in LLM applications.
Project-URL: Homepage, https://github.com/Whth/fabricatio
Project-URL: Repository, https://github.com/Whth/fabricatio
Project-URL: Issues, https://github.com/Whth/fabricatio/issues
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
Classifier: Framework :: AsyncIO
Classifier: Framework :: Pydantic :: 2
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
Requires-Python: <3.14,>=3.12
Requires-Dist: fabricatio-capabilities
Requires-Dist: fabricatio-core
Requires-Dist: fabricatio-tool
Description-Content-Type: text/markdown

# `fabricatio-actions`

A Python library providing foundational actions for file system operations and output management in LLM applications.

## 📦 Installation

This package is part of the `fabricatio` monorepo and can be installed as an optional dependency:

```bash
pip install fabricatio[actions]
```

Or install all components:

```bash
pip install fabricatio[full]
```

## 🔍 Overview

Provides essential tools for:

### File System Operations
The file system operations in this library offer robust functionality for reading and writing files, as well as handling file paths. For example, the `ReadText` class can be used to read text files efficiently. It takes care of encoding issues and provides a simple interface for accessing the file content.

### Output Formatting and Display
Output formatting and display tools ensure that the results of operations are presented in a clear and organized manner. This includes formatting text, numbers, and other data types in a way that is easy to read and understand.

### Basic Task Execution Building Blocks
These building blocks are the foundation for creating complex tasks in LLM applications. They allow for the execution of tasks in a sequential or parallel manner, depending on the requirements of the application.

- File system operations (read/write, path handling)
- Output formatting and display
- Basic task execution building blocks

Designed to work seamlessly with Fabricatio's agent framework and other modules like `fabricatio-core`,
`fabricatio-capabilities`, and `fabricatio-improve`.

## 🧩 Usage Example

```python
# This example demonstrates how to use the ReadText class to read a file.
# First, we import the necessary classes and modules.
# The ReadText class is used to read text files.
# Role, Event, Task, and WorkFlow are part of the Fabricatio agent framework.
# asyncio is used for asynchronous programming.
from fabricatio.actions import ReadText
from fabricatio import Role, Event, Task, WorkFlow
import asyncio

(Role(name="file_reader", description="file reader role")
 .register_workflow(Event.quick_instantiate("read_text"), WorkFlow(steps=(ReadText().to_task_output(),))
                    ))


async def main():
    ret: str = await Task(name="read_file", goals=["read file"], description="read file").update_init_context(
        read_path="path/to/file"
    ).delegate("read_text")
    print(ret)


asyncio.run(main())


```

## 📁 Structure

```
### actions/
This directory contains the implementations of various actions.

#### fs.py
The `fs.py` file provides functions and classes for file system operations. It includes methods for reading and writing files, as well as handling file paths. For example, it may have a function to check if a file exists or to create a new directory.

#### output.py
The `output.py` file is responsible for output formatting and display. It contains functions to format text, numbers, and other data types in a way that is easy to read and understand.

### models/
This directory contains the data models used in the library.

#### generic.py
The `generic.py` file defines shared type definitions. These definitions are used across different parts of the library to ensure consistency in data handling.
fabricatio-actions/
├── actions/          - Action implementations
│   ├── fs.py         - File system operations
│   └── output.py     - Output formatting and display
├── models/           - Data models
│   └── generic.py    - Shared type definitions
└── __init__.py       - Package entry point
```

## 🔗 Dependencies

Core dependencies:

- `fabricatio-core` - Core interfaces and utilities
- `fabricatio-capabilities` - Base capability patterns

## 📄 License

MIT – see [LICENSE](LICENSE)

GitHub: [github.com/Whth/fabricatio](https://github.com/Whth/fabricatio)