Skip to main content

A foundational Python library providing core components for building LLM-driven applications using an event-based agent structure.

Project description

fabricatio-core

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

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 splitting
  • split_into_chunks — chunk text with configurable overlap
  • tokens_of / word_count — token and word counting
  • blake3_hash — BLAKE3 content hashing
  • detect_language — language detection
  • is_english, is_chinese, is_japanese, etc. — language checks
  • is_likely_text — file content type detection
  • CodeSnippetParser, 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 execution
  • depend_on_external_cmd — check external binary availability
  • logging_execution_info / logging_exec_time — execution logging
  • once — 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

This version

0.9.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_core-0.9.1-cp314-cp314-win_amd64.whl (12.4 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_x86_64.whl (13.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

fabricatio_core-0.9.1-cp314-cp314-macosx_11_0_arm64.whl (12.3 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_core-0.9.1-cp313-cp313-win_amd64.whl (12.4 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_x86_64.whl (13.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

fabricatio_core-0.9.1-cp313-cp313-macosx_11_0_arm64.whl (12.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_core-0.9.1-cp312-cp312-win_amd64.whl (12.4 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_x86_64.whl (13.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

fabricatio_core-0.9.1-cp312-cp312-macosx_11_0_arm64.whl (12.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file fabricatio_core-0.9.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e81ecff7fe51867beab775656acb9ed9c6d52fc6614466ef177c638b3c950ccf
MD5 1279794ef5af0c3a2186f78d97ca7962
BLAKE2b-256 13fbd30d64658849e0462d9b673bc499bfe02d61ac617640cde116d5ba6216d0

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.3 MB
  • Tags: CPython 3.14, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 5c7a5a8820f79affb4632341b41318d7a9f1ebca578311edddc0d8b176f98a0a
MD5 fa6d37f7d5af59b8846a28efd522bada
BLAKE2b-256 0405d576219d590d812d2270423b93ec589ce342e548d04aeb0d2ff78e4aa80a

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_aarch64.whl
  • Upload date:
  • Size: 12.1 MB
  • Tags: CPython 3.14, manylinux: glibc 2.38+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 d62a45ac92b10040bd1d65b0ed420d391d19f879e485440d74cd2add13bea9cb
MD5 1cd3f221a3621df4e73be092d9cb0294
BLAKE2b-256 f96bfcf58cb7df8179781d2626607aade7bef20f0c65323524b8fd9cfe2ed6ce

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp314-cp314-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.14, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77eee182fa6f9ecdcaabaaae81b11eb10c78f0fca2983945d2def85c44f5451b
MD5 b0e54f983d12d130cb8ae165bc37670c
BLAKE2b-256 3b9019818989e2672889ca00847d836ac9824e6cfe22c15b5646f1d65c726996

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9db3fb0b03429d2e475ba7ad928f1a20ab7c383fd3125809149433c2c94529f9
MD5 e2deda54b6a0df2120d67ec35bfb42f4
BLAKE2b-256 888afddb127540887a98bffcfd4d0dde8db5b8ee1fc305aca714c912bfefeab4

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.3 MB
  • Tags: CPython 3.13, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 c045d5d6897597602497fd2f90fa48f6ae32abd41aa12ac611c47ad9baa639c4
MD5 d24de74735e811f2e89d387c03e9c248
BLAKE2b-256 7277bb9aed08ea0c7a46ef585f1e7ebc986781734ede56a42d738e2d64c55c55

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_aarch64.whl
  • Upload date:
  • Size: 12.1 MB
  • Tags: CPython 3.13, manylinux: glibc 2.38+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 986760ca0f6f21e952d5810d6f7fb7377d65ccfdc3df0bd95c58b380eda7d7fe
MD5 2040af4f9182e68bb4426a7a3b0e3405
BLAKE2b-256 6939201cb2408476e8eb0005420f16099de6995f9479204e2d63f3a45d79b8ab

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8d8b69afb8f091733533c7c6df5852e89e2fe34855ef661ce59a5d3353b2ccf
MD5 61dfd66da1297562a977434c9b4cbc77
BLAKE2b-256 57d00df6ea9e549845ed638c0e7b98e936185f5c37b65dc790e63b53808d2662

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a2a65ac61386d5e341f08f36ba3c8b6efb1db529c0b9bff52d7cbfb1d6df397
MD5 0ec8c68312623d384bdcdaaa766971b7
BLAKE2b-256 bbd2bd0d31f952e7308f8389c95de2f4de24b146109848ab0677efb3f8f266a2

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.3 MB
  • Tags: CPython 3.12, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 cb63c1ed88798348af134414862c93cb3c057eed5311331295a6b454277cdf3a
MD5 2a440cb239713d9e3b021f01e12b63f5
BLAKE2b-256 1162342171d46a3da46cad7a75bb05e9ba126e2c2cbf284f3bdfe6eb871b1f78

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_aarch64.whl
  • Upload date:
  • Size: 12.1 MB
  • Tags: CPython 3.12, manylinux: glibc 2.38+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 fac2b0f826a485d834a6e5a88e2800a4d54a6c50e6efe6a3d086d7e9ac971669
MD5 64c263781076bc5af4d13df094d43c96
BLAKE2b-256 ad3990be1212d222d51107c4ffbf88c5789d7f2b41d5f28197ed7fc822ff49a1

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.9.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.1-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.3 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for fabricatio_core-0.9.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2397bf0ba2c53ab75987c401cf81d1759460752b91b6307ae095b6b68efabbb
MD5 85639c534aa0139709de97593538d616
BLAKE2b-256 aea25c1e6343abf502af608f2291b34959d5136e8dc6fddb199437cbad0ee466

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page