Skip to main content

Fabricatio Logo

MIT License Python Versions PyPI Version Ask DeepWiki PyPI Downloads (Week) PyPI Downloads Bindings: PyO3 Build Tool: uv + maturin

Build Package Ruff Lint Tests Coverage Status Documentation Status GitHub Issues GitHub Pull Requests GitHub Stars


Overview

Fabricatio is a streamlined Python library for building LLM applications using an event-based agent structure. It leverages Rust for performance-critical tasks, Handlebars for templating, and PyO3 for Python bindings.

Features

  • Event-Driven Architecture: Robust task management through an EventEmitter pattern.
  • LLM Integration & Templating: Seamlessly interact with large language models and dynamic content generation.
  • Async & Extensible: Fully asynchronous execution with easy extension via custom actions and workflows.

Installation

# install fabricatio with full capabilities.
pip install fabricatio[full]

# or with uv

uv add fabricatio[full]


# install fabricatio with only rag and rule capabilities.
pip install fabricatio[rag,rule]

# or with uv

uv add fabricatio[rag,rule]

You can download the templates from the github release manually and extract them to the work directory.

curl -L https://github.com/Whth/fabricatio/releases/download/v0.19.1/templates.tar.gz | tar -xz

Or you can use the cli tdown bundled with fabricatio to achieve the same result.

tdown download --verbose -o ./

Note: fabricatio performs template discovery across multiple sources with filename-based identification. Template resolution follows a priority hierarchy where working directory templates override templates located in <ROAMING>/fabricatio/templates.

Usage

Basic Example

"""Example of a simple hello world program using fabricatio."""

from typing import Any

# Import necessary classes from the namespace package.
from fabricatio import Action, Event, Role, Task, WorkFlow, logger


# Create an action.
class Hello(Action):
    """Action that says hello."""

    output_key: str = "task_output"

    async def _execute(self, **_) -> Any:
        ret = "Hello fabricatio!"
        logger.info("executing talk action")
        return ret


# Create the role and register the workflow.
(Role(name="talker")
 .subscribe(Event.quick_instantiate("talk"), WorkFlow(name="talk", steps=(Hello,)))
 .dispatch())

# Make a task and delegate it to the workflow registered above.
assert Task(name="say hello").delegate_blocking("talk") == "Hello fabricatio!"

Examples

For various usage scenarios, refer to the following examples:

  • Simple Chat
  • Structured Output
  • Extraction
  • Content Improvement
  • Retrieval-Augmented Generation (RAG)
  • Article Extraction
  • Propose Task
  • Code Review
  • Write Outline

(For full example details, see Examples)

Configuration

Fabricatio supports flexible configuration through multiple sources, with the following priority order: Call Arguments > ./.env > Environment Variables > ./fabricatio.toml > ./pyproject.toml > <ROMANING>/fabricatio/fabricatio.toml > Builtin Defaults.

Below is a unified view of the same configuration expressed in different formats:

Environment variables or dotenv file

FABRICATIO_LLM__SEND_TO=openai/gpt-3.5-turbo
FABRICATIO_LLM__TEMPERATURE=1.0
FABRICATIO_LLM__TOP_P=0.35
FABRICATIO_LLM__STREAM=false
FABRICATIO_LLM__MAX_COMPLETION_TOKENS=8192
FABRICATIO_DEBUG__LOG_LEVEL=INFO

fabricatio.toml file

[debug]
log_level = "DEBUG"


[llm]
send_to = "base" # send req to `base` group by default
max_completion_tokens = 32000
stream = false
temperature = 1.0
top_p = 0.35


[routing]
providers = [
    { ptype = "OpenAICompatible", key = "sk-...", name = "mm", base_url = "https://api.example.com/v1/" }
]

completion_deployments = [
    { id = "mm/a-completion-model", group = 'base', tpm = 100_000, rpm = 1000 }
]
cache_database_path = "path/to/.cache.db"

pyproject.toml file

[tool.fabricatio.debug]
log_level = "DEBUG"


[tool.fabricatio.llm]
send_to = "base" # send req to `base` group by default
max_completion_tokens = 32000
stream = false
temperature = 1.0
top_p = 0.35


[tool.fabricatio.routing]
providers = [
    { ptype = "OpenAICompatible", key = "sk-...", name = "mm", base_url = "https://api.example.com/v1/" }
]

completion_deployments = [
    { id = "mm/a-completion-model", group = 'base', tpm = 100_000, rpm = 1000 }
]
cache_database_path = "path/to/.cache.db"

Contributing

We welcome contributions from everyone! Before contributing, please read our Contributing Guide and Code of Conduct.

License

Fabricatio is licensed under the MIT License. See LICENSE for details.

Acknowledgments

Special thanks to the contributors and maintainers of:

Metadata

Release files for fabricatio 0.33.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fabricatio 0.33.4
File
fabricatio-0.33.4-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
fabricatio-0.33.4-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
fabricatio-0.33.4-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
fabricatio-0.33.4-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
fabricatio-0.33.4-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
fabricatio-0.33.4-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
fabricatio-0.33.4-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
fabricatio-0.33.4-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
fabricatio-0.33.4-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
fabricatio-0.33.4-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
fabricatio-0.33.4-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
fabricatio-0.33.4-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 29.7 MB

Release files / fabricatio-0.33.4-cp314-cp314-win_amd64.whl

Download URL fabricatio-0.33.4-cp314-cp314-win_amd64.whl
Size 2.2 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
9e013a618acc183c3b5224eccd275eb23496b42c8a7008a0eec8d768663def0f
BLAKE2b-256 checksum
How to use checksums
9811de2b728076e55f85d8e69a5c9217b44a8ea3940ec7db66ee6f2e236b55f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.33.4-cp314-cp314-manylinux_2_34_x86_64.whl
Size 2.7 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7e3ff668730a12eb38f6debf5b32e5a0896e3dfa21ac9a3d19a83cef0a27fe63
BLAKE2b-256 checksum
How to use checksums
ab456cef002b6794f43e8a8e59e1b95d593ff2e90a51a1e271484ff1ca2a75ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.33.4-cp314-cp314-manylinux_2_34_aarch64.whl
Size 2.5 MB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
06fc8a826f25818c5106cdf6da3d6b0369cc6b476053f076afa76558f68ba8a0
BLAKE2b-256 checksum
How to use checksums
60c5eff577b1009109dadb96ebe03263f919a587489bd6cba8d4c007c1ec8c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp314-cp314-macosx_11_0_arm64.whl

Download URL fabricatio-0.33.4-cp314-cp314-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3e2dda22288896e5dbffc45aefcde28fa78c405ea4de21b8bf892ea6982130bc
BLAKE2b-256 checksum
How to use checksums
1a70f36e760b5d0b45d4e38447032b861a3bb41ccf63b45ef7822ff67acca563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp313-cp313-win_amd64.whl

Download URL fabricatio-0.33.4-cp313-cp313-win_amd64.whl
Size 2.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2c7ad28e9a8df683b4bd07f1df53f896b743a655bfa9b923969aa6a15670019c
BLAKE2b-256 checksum
How to use checksums
e74bf1c5f25f39649c5add677f41df759c9a55dba4ad5be55dd43daf155821a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.33.4-cp313-cp313-manylinux_2_34_x86_64.whl
Size 2.7 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
a57ba2c3ee435f046c4c64e3bb13140293ef5b093e6f50f378f6e0e7e5f803b2
BLAKE2b-256 checksum
How to use checksums
bbeee41410ee8c4a2c7b005ccc66bfa925cd6ef1b60e0a51cfcc2dcfc40674d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.33.4-cp313-cp313-manylinux_2_34_aarch64.whl
Size 2.5 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
5fd0495674fc08348dfd8fd4c613fdcb4c908926984a3b205028270a5c70e9e5
BLAKE2b-256 checksum
How to use checksums
0a6e569929d34cbe0f7aa45c06a0f87240ac5ddb7568a88471599d87026f574f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp313-cp313-macosx_11_0_arm64.whl

Download URL fabricatio-0.33.4-cp313-cp313-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ddc7e4f1dac2dea319241d1589be0b2fbb5416d1b637a05a6d8f99efc48a6105
BLAKE2b-256 checksum
How to use checksums
62a6ee1285c82cf25d39d80c25a3c1131ec9bed1ca574cdbd38e10842c4cbeb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp312-cp312-win_amd64.whl

Download URL fabricatio-0.33.4-cp312-cp312-win_amd64.whl
Size 2.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
777dd3e5a0f787e530c898d778324d86409ff1183ecb2b6a34e119ffb9e67882
BLAKE2b-256 checksum
How to use checksums
a5613e432a250124357c0f5c3a689dfd7733457b7d80670aaab1d8790e3908e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.33.4-cp312-cp312-manylinux_2_34_x86_64.whl
Size 2.7 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7777c592f24a6e479569555bbb6a606f516468b725d90f45674cc43bc5bd137d
BLAKE2b-256 checksum
How to use checksums
fc66de72e1a96243894b3e1fde6f2149fbf98464e266a3d9ee0bedef3e324da0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.33.4-cp312-cp312-manylinux_2_34_aarch64.whl
Size 2.5 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
af78e58840d676d5e8f415407c01e64e688dad43266159a463332feb4611dec6
BLAKE2b-256 checksum
How to use checksums
6126d2d78c0b55128a5d21d6ce3cf2cf253b6a7717858e5680b3b4ea9936690d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fabricatio-0.33.4-cp312-cp312-macosx_11_0_arm64.whl

Download URL fabricatio-0.33.4-cp312-cp312-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bdac59e35ebf60cd7cce614e90c0d342d7c533fbb749ceb5c4fc72b0decf4e1e
BLAKE2b-256 checksum
How to use checksums
2b3b5f99c7a3bde7a45935c0941ff3431ebe3386ef28cb414f7d5d528ca6b53a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.33.4 This release

12 release files

0.20.8

8 release files

0.20.5

8 release files

0.20.4

8 release files

0.20.3

8 release files

0.20.2

8 release files

0.20.1

8 release files

0.19.7

8 release files

0.19.6

8 release files

0.19.5

8 release files

0.18.0

8 release files

0.17.2

8 release files

0.17.1

8 release files

0.17.0

8 release files

0.16.2

8 release files

0.14.2

8 release files

0.14.1

8 release files

0.14.0

8 release files

0.13.0

8 release files

0.12.0

8 release files

0.11.0

8 release files

0.10.1

8 release files

0.10.0

8 release files

0.9.4

4 release files

0.9.1

4 release files

0.9.0

4 release files

0.8.3

4 release files

0.8.1

4 release files

0.8.0

3 release files

0.7.0

3 release files

0.6.7

3 release files

0.6.6

3 release files

0.6.4

5 release files

0.6.2

5 release files

0.6.1

3 release files

0.6.0

5 release files

0.5.0

5 release files

0.4.4

5 release files

0.4.0

2 release files

0.3.14

5 release files

0.2.12

3 release files

0.2.11

3 release files

0.2.9

3 release files

0.2.8

3 release files

0.2.7

3 release files

0.2.6

3 release files

0.2.5

3 release files

0.2.4

3 release files

0.2.3

3 release files

0.2.2

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page