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

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

Uploaded CPython 3.14Windows x86-64

fabricatio_core-0.8.9.dev0-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.9.dev0-cp314-cp314-manylinux_2_38_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

fabricatio_core-0.8.9.dev0-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.9.dev0-cp313-cp313-manylinux_2_38_aarch64.whl (12.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

fabricatio_core-0.8.9.dev0-cp312-cp312-manylinux_2_38_x86_64.whl (13.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

fabricatio_core-0.8.9.dev0-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.9.dev0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3af52b8d544a32892587ecea00541dd0125fab381c8424a791a890810017618e
MD5 a00b21d1c10fc0298174a6e62b91ad13
BLAKE2b-256 092672b9dad469675bb66b614e0cc682944348f18cb879e89ae73f1d3be29b40

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 c9dda7fa804dfa9b2e78a47cbf064448b328aa49201c2c7da57fbfc3e9c605c0
MD5 970315da14c39acb1c5e0324c4420675
BLAKE2b-256 faedc9bda403333c0091925fea6cf00c437e1564cb959334a1ea09a61ca35f63

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp314-cp314-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.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.9.dev0-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 388bc8bfbc72d533cdc6399d8eb1068741968da9b724fe87f0daefc2836dbf30
MD5 b718c7e583ebc33693ebfbfbddfc63ce
BLAKE2b-256 c67b9921fd6040f1bc43f4649d7848b54ee5de6f4158c637f9859eb860309274

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2781f7b719af7946e6802bdb87017608b4cefe35b91246c62db702d70c3f3f7f
MD5 0d45607b343e2b75771007e46b6e23f2
BLAKE2b-256 de592545f12434d8a4870230e6ff17071bd8105beee37fa5957c990d70dcfdfb

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ebad6a63de17e809c29351dd2a84473baeb0eeae31dbb2e26ec5adeb42b774b0
MD5 7e8d5eca93765d4fc0490dc36fe9d200
BLAKE2b-256 10e49041f7774f136ebe7a063e236849e421fb0d56f1bb739aad97497afcc696

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 bba0966c896e959ede371289fb2d64a1e03dcf17359806a5607723f9ee88c017
MD5 8c016ad0ddf15895ad43c51898c76c15
BLAKE2b-256 33f1e0a492e00359e8ec0063755605d9c279346a62d7beff5b4a3a95331e0a92

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp313-cp313-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 ab1bf5533d411f2a595094bd96ff221cc3b400f2fb52c49720aa12e643033779
MD5 84a9bfe665d671550bea80e40265de80
BLAKE2b-256 60070431d47590ec7a77a67aead773e1527097af3bcc5ba307224cd84232ffff

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41669ff48881c88325f689a4d109e46d37a3ec857d798b1b2e23fa8ab9e66cdc
MD5 6fe705edf6a0c56da0cc76f198d01202
BLAKE2b-256 1d0e9d6eeaf2b0a7ec65c059aa74d137d6b3b0db798969d4dced03f3419bb39b

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 295d9e51fadb78e5667249b5aee78648b7b7a8be22a935aa6e4808d92b266ff1
MD5 39292e9f831a1a9b9144e1dd7d7047f7
BLAKE2b-256 a372c93c10481145d3f1e5786358822de27ebf7890d7d28b011321c2f2638894

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.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.9.dev0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 533410192e8257b6fb81f0abc77ea03ae07b8348177034e5c498ebfc5d6cb79f
MD5 e7e58ec5327c5dba5668206758352f6d
BLAKE2b-256 d51c6f0636854e6b1164de04a674c4d76d736e8cdcdfccbf9fb74350c6378e5d

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp312-cp312-manylinux_2_38_aarch64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 9a62f2adfd2ea9f5ea478482bea90bf2d3a306787b5ae525d0c664c6f1662dc5
MD5 33e18c7cb58b7c805b60379996e618af
BLAKE2b-256 0223837e839fb01a9b50cbdf881d35c4998f8885b5269e4a2daab811b56ae09c

See more details on using hashes here.

File details

Details for the file fabricatio_core-0.8.9.dev0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: fabricatio_core-0.8.9.dev0-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.9.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a46286c75df7a296a24c2778b4039c7ed225265536092faa17f3b272ec06e4d
MD5 f661ac6beaf8b05bb5eb95fbb6286d4f
BLAKE2b-256 cab91ccbf82818b24ad1c3a3e0bab3ea2c7fc38728cc61eae0b16aed07ce8a94

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