This release is a pre-release and may not be stable for production use.
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:
fabricatioperforms 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.35.0.dev1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 29.7 MB
Release files / fabricatio-0.35.0.dev1-cp314-cp314-win_amd64.whl
| Download URL | fabricatio-0.35.0.dev1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
00002d54ccadc880998937b5934b35d224f2ff2fc2eeaae9f17439d93f2f7f4c
|
|
BLAKE2b-256 checksum How to use checksums |
14c68b04eeb719fa84ff727cfebe00d5dc9c226a06bf6929282f15e48107ea57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp314-cp314-manylinux_2_34_x86_64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
bc6b037aaeb2d9369ba6b9cf272f9c4e8e26275e060e7977a9735ccadb95affe
|
|
BLAKE2b-256 checksum How to use checksums |
6be71ec07cc1d71d5c01332acd90ffd4a872985d53c3d51adedd8f28836962e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp314-cp314-manylinux_2_34_aarch64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
47812f319ab62f9ba36ec917803a8ee00ddbfe5ce5dc35b28b72e63f02b2e968
|
|
BLAKE2b-256 checksum How to use checksums |
ada292d46f5e549c1a420d823ffef8abe582d3c0add5ce1ff02902c64feaeff2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
63e6e0ed38bd4d606c75865c1a58088ddab7fd20a53634e16f9c75bcb25f068a
|
|
BLAKE2b-256 checksum How to use checksums |
e56ae95b700dd024da1d25994699e33ada48c794566eecc5e1ac1c657088ee2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp313-cp313-win_amd64.whl
| Download URL | fabricatio-0.35.0.dev1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
494e2c7c2cbecdffff2e0182142fbb2609e8e934f9430b9e75b49f5c2b9e662a
|
|
BLAKE2b-256 checksum How to use checksums |
d83bc6e1b60ad861176e80c570d6fe54e7512ca094e6c3570d3d86183a9612d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
23277f3f4d5fd5f0748c1b32c4fb4de378c23e963b2b2341041392119528c1c5
|
|
BLAKE2b-256 checksum How to use checksums |
230a5887fd03de3cd854fd83ea45c42e3f3ba0204a1daee565a916da0a3ae625
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp313-cp313-manylinux_2_34_aarch64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
2c8e472e20d319c9b93e810d59a8219242a6bfb2a6ae0de7401e999e7c50f65d
|
|
BLAKE2b-256 checksum How to use checksums |
cb0a0d640ef853ea2fb80f8b31679e638091e9274efac79d0d8b5608370864d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
09c224d2dc1c4e6165c999900f73897c61ee1472ce83fb917727d4457941dc54
|
|
BLAKE2b-256 checksum How to use checksums |
bccd4cb290ec22f766a3dd62c0e23e2e36d562f6d7e425675ed0b2ab5d62365d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp312-cp312-win_amd64.whl
| Download URL | fabricatio-0.35.0.dev1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
73f9d7d6873ee235056caf4846bfeffbbb2f661921c7c7427083d5a35f573802
|
|
BLAKE2b-256 checksum How to use checksums |
d847af4786a7a9844fd10256e99e21a1891cd233704c434e336787910be00828
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
ded75473d6d0484b164d6a889fe923165112f05bbbd2b6bc2234ce4cb7f84e63
|
|
BLAKE2b-256 checksum How to use checksums |
79e964ea1a56e7f12889e78e7727dc1d555e2e8895c11f49a5c1d0d4fefa1856
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp312-cp312-manylinux_2_34_aarch64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
fb9ed06b029c1bafbb262ba90ce71a6082f575cda71e0c502170a3c0f40ca174
|
|
BLAKE2b-256 checksum How to use checksums |
eabb63ba3deb80c3b24b1045ba5153596ccc725c102e60abd84c08c457894104
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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.35.0.dev1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | fabricatio-0.35.0.dev1-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 |
e49f809c95ddad9c0ed15c26233d26184f453e5a7e3660e65003a6d8d93dd0fa
|
|
BLAKE2b-256 checksum How to use checksums |
459f6ec360323ddfd254b34a10a20b3f3b73fee593ce9a9ed808fae5507a091c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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}
|