A foundational Python library providing core components for building LLM-driven applications using an event-based agent structure.
Project description
fabricatio-core
Foundational Python library for building LLM-driven applications using an event-based agent architecture. Built on a hybrid Rust/Python foundation for performance-critical operations.
Requires Python 3.12+.
Installation
pip install fabricatio
# or
uv pip install fabricatio
For all optional extras:
pip install fabricatio[full]
Key Components
Event System (Event, EventEmitter)
Segmented event type with task-status lifecycle methods (push_running, push_finished, etc.) and glob-wildcard
(*) matching. The global EventEmitter dispatches events asynchronously with on/off/emit.
from fabricatio_core.emitter import EMITTER
from fabricatio_core.rust import Event
EMITTER.on("task::*::finished", my_handler)
LLM Routing (Router, RouterUsage)
Multi-provider router for completion, embedding, and reranking. RouterUsage provides structured LLM interaction
patterns — ask, list strings, code generation, judging, choosing — with configurable validation and fallback defaults.
from fabricatio_core.rust import ROUTER, router_usage
response = await ROUTER.completion(send_to="default", message="Hello")
result = await router_usage.choosing("Pick two items", valid_names=["a", "b", "c"], k=2)
Task Model (Task)
Pydantic-based task with lifecycle status management (Pending, Running, Finished, Failed, Cancelled),
dependency tracking, structured proposal generation from prompts, and automatic event emission on state transitions.
task = Task(name="data_ingestion", description="Ingest raw data")
task.start()
# ... execute ...
task.finish(output={"rows": 1042})
Workflow Engine (Action, WorkFlow)
Abstract action pipeline with shared context propagation. WorkFlow orchestrates sequences of Action instances,
managing input/output keys, error handling, and task lifecycle.
class ParseData(Action):
async def _execute(self, **cxt):
return parse(cxt["task_input"])
wf = WorkFlow(actions=[ParseData().to_task_output()], name="parse_pipeline")
await wf.execute(task)
Role Framework (Role)
Agent roles map event patterns to workflows. Global registry supports register_role / get_registered_role.
Roles dispatch workflows automatically when matching events are emitted.
from fabricatio_core.models.role import Role, register_role
analyst = Role(name="analyst", description="Data analysis agent")
analyst.deploy_on("data::ingested", parse_wf)
register_role(analyst)
Template Rendering (TemplateManager)
Handlebars-based template engine. Load templates from directories, render with structured data.
from fabricatio_core.rust import TEMPLATE_MANAGER
TEMPLATE_MANAGER.add_store("./templates").discover_templates()
output = TEMPLATE_MANAGER.render_template("greeting", {"name": "World"})
Capability Mixins (UseLLM, UseEmbedding, UseReranker, Propose)
Inheritable classes that add LLM querying, embedding generation, reranking, and structured proposal capabilities to
any model. All integrate with the Router for provider dispatch.
class MyAgent(UseLLM, UseEmbedding, Propose, WithBriefing):
pass
agent = MyAgent(name="helper")
answer = await agent.aask(question="What is 2+2?")
obj = await agent.propose(MyModel, prompt="Create a config object")
Text Parsing & Language Utilities (Rust)
Fast Rust-backed functions for text processing:
split_sentence_bounds/split_word_bounds— Unicode-aware text splittingsplit_into_chunks— chunk text with configurable overlaptokens_of/word_count— token and word countingblake3_hash— BLAKE3 content hashingdetect_language— language detectionis_english,is_chinese,is_japanese, etc. — language checksis_likely_text— file content type detectionCodeSnippetParser,CodeBlockParser,GenericBlockParser,JsonParser— structured block extraction from LLM outputs
Base Model Hierarchy (models.generic)
Pydantic-based abstract base classes for consistent model design: Named, Described, WithBriefing,
WithDependency, ScopedConfig (with hierarchical fallback), ProposedAble, InstantiateFromString, Display,
and more.
Decorators
cfg_on/cfg_on_async— feature-gated function executiondepend_on_external_cmd— check external binary availabilitylogging_execution_info/logging_exec_time— execution loggingonce— ensure single invocation
Configuration (Config)
Structured configuration with sub-sections for LLM, embedding, reranking, emitter, routing, templates, debug, and
deployment settings. Accessible via fabricatio_core.rust.CONFIG.
Package Structure
fabricatio-core/
├── python/fabricatio_core/
│ ├── capabilities/ - LLM, embedding, reranker, and proposal mixins
│ ├── models/ - Action, Role, Task, generic base models, kwargs types
│ ├── rust/ - PyO3 Rust extension (autogenerated stubs)
│ ├── decorators.py - cfg_on, once, logging_exec_time, etc.
│ ├── emitter.py - EventEmitter with wildcard pattern matching
│ ├── journal.py - Logger bridge to Rust logger
│ ├── utils.py - ok, cfg, override_kwargs, first_available, etc.
│ └── __init__.py - Public API surface
├── src/ - Rust sources (parser, templates, event, language, etc.)
└── pyproject.toml
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabricatio_core-0.8.10-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
138123b736137f975fcb72c0448b55e860256ac03414f6f99ff909652fd6b2f6
|
|
| MD5 |
75596f46555896efd3815dec21ec0790
|
|
| BLAKE2b-256 |
f611bf4fb0afd8db0d97f771506ee11f52c39dfa7808892f50c7df20b3780ec6
|
File details
Details for the file fabricatio_core-0.8.10-cp314-cp314-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp314-cp314-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 13.8 MB
- Tags: CPython 3.14, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c18d9621407a9d1b8ac90cee24965f516eebf675e07b88a6cee6bcf7994e05
|
|
| MD5 |
5e0d1b6472e0a5e95b3ba127769d9182
|
|
| BLAKE2b-256 |
f571dc9fb2f0c5c82fcee332e678b3c9d695fc2d25e90a0b2d177421d68c27fd
|
File details
Details for the file fabricatio_core-0.8.10-cp314-cp314-manylinux_2_38_aarch64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp314-cp314-manylinux_2_38_aarch64.whl
- Upload date:
- Size: 12.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.38+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57c6ddf116f33356f131429fd72bca84f67478822ee3c4be2c05e0060dacfd79
|
|
| MD5 |
12cc2fcf47150fdf2f73c2a5793e517d
|
|
| BLAKE2b-256 |
a45e8bb1b87067769be0290fb832668328dc70fe97c9bfcc64a50d508b6099ad
|
File details
Details for the file fabricatio_core-0.8.10-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7245873819ea2cc434cb6761bd2ae9348c216e3ed4327b8b0cf775268b2cf8
|
|
| MD5 |
54dc25f71a553ab430be4f061521ae9d
|
|
| BLAKE2b-256 |
b7417d2e03f5a3c6e6a77184914c90c37c2fba7c91d9b4791641470360489637
|
File details
Details for the file fabricatio_core-0.8.10-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daa67cbdeec47aed20c7ad52253d39dda0e6d15043733f798cc65027a747c219
|
|
| MD5 |
80da7380c98815643c30246ab6e9ebc9
|
|
| BLAKE2b-256 |
41bc529c00da942e9d038902de4e5efd953a3484e6ad8aa3252d5cf978bc9bbf
|
File details
Details for the file fabricatio_core-0.8.10-cp313-cp313-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp313-cp313-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 13.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e2d8567401248eeef5b4402565ed90407ad7868a7385ee9922a64c401edaa3a
|
|
| MD5 |
2ee1c46c024551408d4e5cedce2ba18b
|
|
| BLAKE2b-256 |
59768d48142b1a8975bba3ac66f3ce942c39c0a8411b9d08fe71a6540a653707
|
File details
Details for the file fabricatio_core-0.8.10-cp313-cp313-manylinux_2_38_aarch64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp313-cp313-manylinux_2_38_aarch64.whl
- Upload date:
- Size: 12.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.38+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a67310bff46c672932eaae6656d7ba1f0f9dd6f50a5642eb6cbb12ffb93bd8
|
|
| MD5 |
83346ff024a92b2a703d721d39431f91
|
|
| BLAKE2b-256 |
2dc1b5b63691d5143f57d6fd57ae680a02b1e75cef965f39e4136c0a518b7ee6
|
File details
Details for the file fabricatio_core-0.8.10-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d4561b513f38089361fbb35faa53eacc793eb929e33d66adb96314c89cffe53
|
|
| MD5 |
df0acef816407e068a7687f7b2a7db8d
|
|
| BLAKE2b-256 |
cf8e935ddc19a65c0130547a3019e3e4a5d70e15f7b6ac7afd032d98f6b82c94
|
File details
Details for the file fabricatio_core-0.8.10-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 12.9 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
365d64f75ed5da8ca8c2f1595a5082c2747e0a6361b8dd34ce17fac438e6ef8f
|
|
| MD5 |
7024a30122ae4ff5a38ab2ebcd505b9a
|
|
| BLAKE2b-256 |
3df1e94e9cd9bcbc0f0b032666647c3b14c2b2495015ab1b296f2e0809396845
|
File details
Details for the file fabricatio_core-0.8.10-cp312-cp312-manylinux_2_38_x86_64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp312-cp312-manylinux_2_38_x86_64.whl
- Upload date:
- Size: 13.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.38+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e95af351ce55c08fdc458c6b749bb9d815fe7178c9e983340fcb8a141ecda8ec
|
|
| MD5 |
b95a32570faf358b1dd8f0a9389d510d
|
|
| BLAKE2b-256 |
80491d995fe5d550ba3a846cd45efa72b8a09ec952c27af5b208f66ad7aeda3b
|
File details
Details for the file fabricatio_core-0.8.10-cp312-cp312-manylinux_2_38_aarch64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp312-cp312-manylinux_2_38_aarch64.whl
- Upload date:
- Size: 12.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.38+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b479157aa0772ef6c6e05b120af45c2d2b36e069ce8a0799c6c73ea8f2167c49
|
|
| MD5 |
ca36760ba2de541af69d437730eb06e7
|
|
| BLAKE2b-256 |
fe56bf8ac2dbc28485ff812b05dfc98b7c9cb06bc63bbc1ad116612744b0f1dd
|
File details
Details for the file fabricatio_core-0.8.10-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_core-0.8.10-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf648a41a80efdb1651d9274d6f112a0cb3b23f8f4d07b80001fb58c21509242
|
|
| MD5 |
877e218779c43ffa1b436b2fbe1bd9ce
|
|
| BLAKE2b-256 |
52e70fa420ab0fcbcd0da02cfa916db7be71644f51a259a254e4871577b7a484
|