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

Uploaded CPython 3.14Windows x86-64

fabricatio_core-0.9.0-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.0-cp314-cp314-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

fabricatio_core-0.9.0-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.0-cp313-cp313-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

fabricatio_core-0.9.0-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.0-cp312-cp312-manylinux_2_38_aarch64.whl (12.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ ARM64

fabricatio_core-0.9.0-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.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 391970aaae60c644b98510f09589cb1b1ebcb0b0fe07c4564f4130f743a6951b
MD5 9675391a56bdfc0c624f072d6a5070ac
BLAKE2b-256 ca7c32789820f1e564ec587eccbecc331c7dec3890290ec73e3a656a5ded633b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 468333bf4da68aae54d2e1b3757cff89e8cfeee9472ecbc526736e2b91334861
MD5 83177b7d47d3dbfc82be82bae5fe95b2
BLAKE2b-256 6ea07a73b33189a6a50668f6373349de78cdb9b1705b14b26c8b6b33a0c55114

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp314-cp314-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 ed81e1b1efe96d86ae49c4494ca78271dcf9f5303ccb6a4fa34dfc56818ad054
MD5 f2edcfe5fd362729495261ad99fbd1d7
BLAKE2b-256 ce5740a9b7e9c5c4f67a4b6ee57d828786df88b38bd68198c4e8c63dd7035713

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a65b3390e8e32445f211add2385e8ef65e3c3392a7e2a33dea79e1acfcb10ecf
MD5 99d6780a020199c9e02069462c84361b
BLAKE2b-256 a02625bacd5f9ee30ecf329aeace55b0621759615ec13d7b11084a58ec5033de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c20b42b5f16edfc25292597eede40dc38276e86eaae5a2ceef4c0f9bcbb0106a
MD5 550a960a2d29de62b9b103966516fc88
BLAKE2b-256 8d0a9c530dbabe8c1269af7700109fa887b092f9be3977a05fbb96bd14f06677

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 4ac2fff4808cbe7e5e8c130812e7bf41efe1e6d7efae963560daa2eb73ba5260
MD5 b276c668361deceed2d94928604fefd2
BLAKE2b-256 0460dd7852ff94b0d8fb844b7a140bbd3588f19e564fb1be555c4f30e4d0943e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.24 {"installer":{"name":"uv","version":"0.11.24","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.0-cp313-cp313-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 6eee91fda51ee51d71faa5c28e5e9e4b45f789b1adc5ce3a9280f2a98ed1f0b9
MD5 b16aaa2b2dd70766348d613632df44cf
BLAKE2b-256 33f81f3f8509bc51f731b497a6a4c86a6b4c93b37e98bca14c2b747c4e5f0101

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 014db06f69a44ec5a4c2c0763f80cfa6e7d94eece2eadc71a205c14b79d9a735
MD5 70166854d30967c7f6ce866463232308
BLAKE2b-256 0eee202f92ea975d102d92d21ab0729b1746c33f514237ea9778f13647e25dd8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fe0a6483882224202dac1cc6c9db339e1c2f0eafbf044d5a4cc707e1290e0109
MD5 032a0cee22f7bb77edf866c5f4806bda
BLAKE2b-256 6f60b0c2566a3f3b5aacff19acf7fda08b345bcdeb9b5a0b20c5ff7dec92894a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 fe6d426df57efa6fa5bda12931d3e6c51a1e3e4913f579d9fc93eefee5d04833
MD5 58ac4473db025f09afab6191305ab7b2
BLAKE2b-256 efb93792484227ea653645ac3dc293d6be02df52a33bebed2267a63b9e8195b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp312-cp312-manylinux_2_38_aarch64.whl
Algorithm Hash digest
SHA256 ef81132570d0d5199662c391b823d6fc99b79da78adaf5ec0441676233922f68
MD5 a6447bb267647b527289f3f15773164f
BLAKE2b-256 0953369e311404aea17224bfc32e9f67bb40bde2aec745679332cd523463fc7b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fabricatio_core-0.9.0-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.23 {"installer":{"name":"uv","version":"0.11.23","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.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03e4a40d8e092c38f13e7f8e154e8fee036299ea28fda1b8e67022a8204c38ce
MD5 1e6d2070d3ee1c4f9b1a8d6330a4259a
BLAKE2b-256 1e0e238c3e518bdc14b70b9c843c382c771118ba6405371425bdc2c5d460cb37

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