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.36.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.36.4
File
fabricatio-0.36.4-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
fabricatio-0.36.4-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
fabricatio-0.36.4-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
fabricatio-0.36.4-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
fabricatio-0.36.4-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
fabricatio-0.36.4-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
fabricatio-0.36.4-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
fabricatio-0.36.4-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
fabricatio-0.36.4-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
fabricatio-0.36.4-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
fabricatio-0.36.4-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
fabricatio-0.36.4-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 30.1 MB

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

Download URL fabricatio-0.36.4-cp314-cp314-win_amd64.whl
Size 2.2 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
993389eedab97cbe33a29e14eb81ff699569597fcc37be8151bce5955d8d7808
BLAKE2b-256 checksum
How to use checksums
a0dc65adc1bfcc5d640a1ba35d2ee7c7f305329d885cf04fad22b2e5dc49f4b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.36.4-cp314-cp314-manylinux_2_34_x86_64.whl
Size 2.8 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
36a5b58f9f214bdfe1cb98ccaf175a743bcccc875ca9cc8b115229c0ea727aa2
BLAKE2b-256 checksum
How to use checksums
1bbdc0eae24019042a62a8a10375451d65fc6e34e1684ce7f50156a35726a44d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.36.4-cp314-cp314-manylinux_2_34_aarch64.whl
Size 2.6 MB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
8ad3e1ada5151cb934227a89ca1acd987f695d87b8c93e25d2295c09be64923f
BLAKE2b-256 checksum
How to use checksums
b4de8303167e4b0c26c184fc3bbff8c50858c859d1a00ba7a6f788d3b87ef8ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp314-cp314-macosx_11_0_arm64.whl

Download URL fabricatio-0.36.4-cp314-cp314-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f7e7acc2e923541da0f38c362f16f680a8c7c232bb503adea6b457df03b6eb9f
BLAKE2b-256 checksum
How to use checksums
9c20e1e869b42ff9b829a2cfb99648135bdb333ddd60466854046da4f2150365
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp313-cp313-win_amd64.whl

Download URL fabricatio-0.36.4-cp313-cp313-win_amd64.whl
Size 2.2 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
578be8cdde7816859b248339d81408600d99df2132c6c02ccdcdd2c89eb2f8f2
BLAKE2b-256 checksum
How to use checksums
dd08025e21ef59ec26f0df8be1f6cf50720d81aafa49dd6f9abe3ffe4a31a918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.36.4-cp313-cp313-manylinux_2_34_x86_64.whl
Size 2.8 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
9c497a8ab41fd03c350969679fe0cae1cd15b78d6aaef58875cddcc3d27cecbd
BLAKE2b-256 checksum
How to use checksums
6f11bd37161b0e217ca68d0373d87af34a4e267914176e67c479a20c35a72f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.36.4-cp313-cp313-manylinux_2_34_aarch64.whl
Size 2.6 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
f50e41ab43714b1d6cecd6a9c80c9555269e74e3f6b78af8507cc6b886f179f0
BLAKE2b-256 checksum
How to use checksums
31002130b8765528f8abbb7ab89b85a03f047121f9a63540509337990b670a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp313-cp313-macosx_11_0_arm64.whl

Download URL fabricatio-0.36.4-cp313-cp313-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ecb4486122d416051b5b1ee9247617ee6c322877aa8672f6dc62cca2ba7d2ea6
BLAKE2b-256 checksum
How to use checksums
0adbeb11236bb7f1027bd77fc15756a96d44730d31cd6e43bf3de81f259f34c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp312-cp312-win_amd64.whl

Download URL fabricatio-0.36.4-cp312-cp312-win_amd64.whl
Size 2.2 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
bff03d1440ec0c9eea568bedc12f4c2808cbc7bd00d5975cf53c28cd78c76f00
BLAKE2b-256 checksum
How to use checksums
f35d525c4f7ffef01fa18c679612092a586e10f8622111c340282e36d5678c79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL fabricatio-0.36.4-cp312-cp312-manylinux_2_34_x86_64.whl
Size 2.8 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
4ab58a6eb1e0ef353c0f637c5ce7ef43e76a8765c6e9ce4bbae62e3f8380641f
BLAKE2b-256 checksum
How to use checksums
15f41c899c6fc9b3b1a1626d269f9a2d7ffda6fb6378b264f995c74ad39ffb49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL fabricatio-0.36.4-cp312-cp312-manylinux_2_34_aarch64.whl
Size 2.6 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
7a0878abcfb82ce1040cd32afebe777bb0c183f101c6fd3e918217a798d98554
BLAKE2b-256 checksum
How to use checksums
88dd36dea4d6152be15b3dfdbe5f27262ba2c8bee62b9ea8b433bd27af65207e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.4-cp312-cp312-macosx_11_0_arm64.whl

Download URL fabricatio-0.36.4-cp312-cp312-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8416b584c2967bd6fde4d186bcc6e1249cbb3762a226adbc3ea07d201a8fbf29
BLAKE2b-256 checksum
How to use checksums
03ad3fd127b8a9ef5e9e03f3686d3735dad71149a9ad79d5d07b803c61c4da18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.36.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