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.8.8

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.8.8-cp314-cp314-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_core-0.8.8-cp314-cp314-manylinux_2_38_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

fabricatio_core-0.8.8-cp314-cp314-manylinux_2_38_aarch64.whl (12.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

fabricatio_core-0.8.8-cp314-cp314-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fabricatio_core-0.8.8-cp313-cp313-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_core-0.8.8-cp313-cp313-manylinux_2_38_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

fabricatio_core-0.8.8-cp313-cp313-manylinux_2_38_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

fabricatio_core-0.8.8-cp313-cp313-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fabricatio_core-0.8.8-cp312-cp312-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_core-0.8.8-cp312-cp312-manylinux_2_38_x86_64.whl (13.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

fabricatio_core-0.8.8-cp312-cp312-manylinux_2_38_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

fabricatio_core-0.8.8-cp312-cp312-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1388aa9fccb0b9c225a4b90851e706cb56b443767efa862439f2a4034a0d9708
MD5 475c596618d1490212b59f8cffd7a23d
BLAKE2b-256 21be5de8f402c006ed94ddcf08c40e3fe25aad54fa079119b19f5d888c325845

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp314-cp314-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: CPython 3.14, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 628d5004286cd54478af83c4baa7c407d74d7deedecd41dc684bdd210e1dd9bc
MD5 c6f79ba7aa16cf6b2efd80e59120c6b0
BLAKE2b-256 4c3a94f303baba3f4a713b18ff62c9298ad49700e3be7625aac109c01ab8446d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp314-cp314-manylinux_2_38_aarch64.whl
  • Upload date:
  • Size: 12.4 MB
  • Tags: CPython 3.14, manylinux: glibc 2.38+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 6f78dd267b06b564f99af11ded5e9965c60bd9ce476e526933e65a5f9eb0d44b
MD5 59dd306d02cd5be751d411560f1a5768
BLAKE2b-256 418844ba1d491c88f8cddabd2929b1358cc92f9d9b8a63e2e606aec48b06f621

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-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.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35caee25bd8a44979a9b946068809f5ed7b162bba71e03aa381eb063d663c954
MD5 662adeecfdab7e71bdc7e2eef641e482
BLAKE2b-256 47ffed907225df23f84b8e53e51e17ebdddc75189f088183b13bc7a31be59708

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 708ecba4e1da1615838a6d54a6cc658753205102ad315955246486dfee1453df
MD5 5ed85d17da7ffceaa9b035e37929b03c
BLAKE2b-256 f01dc7e47ede3274a6aa17fb5f5e28ceabaee0a6a261f61ccd405314e40c8df5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp313-cp313-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: CPython 3.13, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 da7b7721d9faeae82657b4d40e0f277f3652190344d1ee0214ceafc7b81278f3
MD5 2211ce13bf346888c0ecd205644b8228
BLAKE2b-256 44fd59aead0ce0df8ccfe246ffd94290c2a4ca45c547c23708bb2b03dc37df2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-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.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 04c878b8bc888594384f5bc8277e3ebcd2b53a6646f6f2e4816ccf07d27ce490
MD5 2868638c78f0f89a9fd0ff7186f34deb
BLAKE2b-256 b2e837f6308258f314020371e1fc092d2c6b276ebee6f92dcdb9bdd77e7e80f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-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.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abaee62efd0e7e3457dae6f146cd0b6b2741c7e103a2482a3d3f990d1a5c4e9f
MD5 1a5b7f95924eb9e035589739644734b8
BLAKE2b-256 b71f845e5c918a1eb97186055fee730e6613ce44df7d1befeabd5b02dd740bd3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 734c3d92c8ad9ed2ab08d82b2e87377e66432e4825be85c319e34341bf977da2
MD5 97d927dd1d76ed953ac72082c115c7f3
BLAKE2b-256 512697f1c9c17e951d6fe31371b0ca10774a8239547f07af588b262ca798238c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-cp312-cp312-manylinux_2_38_x86_64.whl
  • Upload date:
  • Size: 13.7 MB
  • Tags: CPython 3.12, manylinux: glibc 2.38+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e13bc68798d926444dea7936c983f582b46641f23ff6d51e8e0632f911f75561
MD5 58672e5d2f31e82ed2c1268b45862a9d
BLAKE2b-256 820ffc7826c9cfb182c80c577f9b6c0fe8157e6ee2142eca35d7720ee0f557d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-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.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 f603b84f60d15c2775307bf8b802221cf47c96013d0a64e6ca1043ee33b01b0b
MD5 084396a108009d210660fb3653735c73
BLAKE2b-256 9100743e9f6174fc64d2d053aa998138f9f23e272579e49541c94d061a4bc643

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.8.8-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.19 {"installer":{"name":"uv","version":"0.11.19","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.8.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 060022ec3719656a44340bf05dc376ec016ab82138497a1239345b2102ae68c0
MD5 41aa9dd743042606f99af366f278feaa
BLAKE2b-256 458d7acfaf1dff83c55db6973c07ed49f4453ff7e559baf2f03568922e27a53e

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