Skip to main content

fabricatio-capabilities

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

High-level LLM agent capabilities for structured extraction, content rating, sequence ordering, text summarization, and task dispatch. Built on fabricatio-core.

Installation

pip install fabricatio[capabilities]
# or
uv pip install fabricatio[capabilities]

For the full Fabricatio suite:

pip install fabricatio[full]

Overview

fabricatio-capabilities provides opinionated, composable mixins that give agents higher-level reasoning abilities:

  • Extract structured data from unstructured text into Pydantic models.
  • Rate content against multi-criteria rubrics, including automated criteria drafting, weighted composite scoring, and top-k selection.
  • Order sequences of items (strings or WithBriefing objects) by a requirement or by computed scores.
  • Summarize raw text into a length-bounded summary (characters, words, or sentences).
  • Propose & dispatch tasks to candidate roles based on semantic matching.
  • Patch and persist Pydantic models with type-safe update mechanisms.

Every capability is an ABC mixin — subclass alongside your agent's base to compose exactly the abilities you need.

Package Structure

fabricatio_capabilities/
 ├── capabilities/         # Mixin classes
 │   ├── extract.py        # Extract — structured extraction from text
 │   ├── rating.py         # Rating — multi-criteria rating, criteria drafting, composite scoring, best-k selection
 │   ├── rating_image.py   # RatingImage — rate attached images via a vision-capable LLM
 │   ├── summarize.py      # Summarize + LengthType — length-window-bounded summarization
 │   └── task.py           # ProposeTask, DispatchTask — task proposal and delegation
 ├── models/               # Reusable Pydantic base models
 │   ├── generic.py        # Patch, SequencePatch, PersistentAble, FinalizedDumpAble, ModelHash, UpdateFrom, etc.
 │   └── kwargs_types.py   # TypedDict kwargs: CompositeScoreKwargs, OrderStringKwargs, ReferencedKwargs
 └── config.py             # Template name configuration (CapabilitiesConfig)

Key Classes

Capabilities

Class Base Purpose
Extract Propose Extracts one or more Pydantic model instances from a string or list of strings. Uses configurable prompt templates.
Rating Propose Fine-grained rating against a manual and score range. Can draft rating manuals, criteria, and weights (Klee method AHP). Computes composite scores and picks best-k candidates.
Ordering Rating Orders a sequence of strings or WithBriefing items by a natural-language requirement or by computed composite scores.
RatingImage Rating Rates an attached image against criteria via a vision-capable LLM. Routes to the VISION variant slot by default; reuses the bounded-score model builder.
Summarize Propose Summarizes raw text into a summary whose length (chars/words/sentences) must land inside a [min, max] window — pass neither bound for unconstrained output; the default floor is 80% of the ceiling. summarize re-validates the output against the window; force_summarize iterates (feeding over-long attempts back, restarting from the raw text after under-min attempts) and falls back to the closest attempt.
ProposeTask Propose Proposes a Task object from a natural-language prompt.
DispatchTask UseLLM Dispatches a Task to the best-matching candidate Role based on briefing text and event subscriptions.

Models

Class Purpose
Patch[T] Type-safe field-level updates to a target Pydantic model. Fields present on the patch are copied onto the target. Supports JSON schema generation with reference-class documentation.
SequencePatch[T] Patch for sequences of objects carrying a tweaked list.
ProposedUpdateAble Combines SketchedAble + UpdateFrom — allows an object to be updated in-place from a proposed replacement.
FinalizedDumpAble JSON serialization with alias support and direct file writing.
PersistentAble Save to / load from a file path with BLAKE3 content hashing and JSON serialization.
ModelHash Consistent __hash__ based on model_dump_json().
UpdateFrom Abstract base for in-place updates with type-checked pre-validation.
AsPrompt Converts a model instance into an LLM prompt string.
WordCount Mixin providing word count tracking for models.

Kwargs Types

CompositeScoreKwargs, BestKwargs, OrderStringKwargs, ReferencedKwargs[T] — TypedDicts that extend ValidateKwargs with capability-specific parameters (topic, criteria, weights, manual, reference).

Configuration

All options below are read through the fabricatio configuration chain (see the Configuration Guide). Set them under the [ext.capabilities] table in fabricatio.toml, equivalently under [tool.fabricatio.ext.capabilities] in pyproject.toml, or via FABRICATIO_EXT__CAPABILITIES__<FIELD_UPPER> environment variables.

[ext.capabilities]
extract_template = "built-in/extract"
as_prompt_template = "built-in/as_prompt"
dispatch_task_template = "built-in/dispatch_task"
rate_fine_grind_template = "built-in/rate_fine_grind"
rate_image_template = "built-in/rate_image"
draft_rating_manual_template = "built-in/draft_rating_manual"
draft_rating_criteria_template = "built-in/draft_rating_criteria"
extract_reasons_from_examples_template = "built-in/extract_reasons_from_examples"
extract_criteria_from_reasons_template = "built-in/extract_criteria_from_reasons"
draft_rating_weights_klee_template = "built-in/draft_rating_weights_klee"
order_string_template = "built-in/order_string"
order_briefed_template = "built-in/order_briefed"
summarize_template = "built-in/summarize"
Option Type Default Description
extract_template str "built-in/extract" The name of the extract template which will be used to extract model from string.
as_prompt_template str "built-in/as_prompt" The name of the as prompt template which will be used to convert a string to a prompt.
dispatch_task_template str "built-in/dispatch_task" The name of the dispatch task template which will be used to dispatch a task.
rate_fine_grind_template str "built-in/rate_fine_grind" The name of the rate fine grind template which will be used to rate fine grind.
rate_image_template str "built-in/rate_image" The name of the rate image template which will be used to rate an attached image via a vision-capable model.
draft_rating_manual_template str "built-in/draft_rating_manual" The name of the draft rating manual template which will be used to draft rating manual.
draft_rating_criteria_template str "built-in/draft_rating_criteria" The name of the draft rating criteria template which will be used to draft rating criteria.
extract_reasons_from_examples_template str "built-in/extract_reasons_from_examples" The name of the extract reasons from examples template which will be used to extract reasons from examples.
extract_criteria_from_reasons_template str "built-in/extract_criteria_from_reasons" The name of the extract criteria from reasons template which will be used to extract criteria from reasons.
draft_rating_weights_klee_template str "built-in/draft_rating_weights_klee" The name of the draft rating weights klee template which will be used to draft rating weights with Klee method.
order_string_template str "built-in/order_string" The name of the order string template which will be used to order string.
order_briefed_template str "built-in/order_briefed" The name of the order briefed template which will be used to order briefed.
summarize_template str "built-in/summarize" The name of the summarize template which will be used to summarize raw text into a length-bounded summary.

Usage

Structured Extraction

from pydantic import BaseModel
from fabricatio_capabilities.capabilities.extract import Extract

class Person(BaseModel):
    name: str
    age: int

class MyAgent(Extract, YourBaseAgent):
    ...

agent = MyAgent()
person = await agent.extract(Person, "Alice is 30 years old.")
assert person.name == "Alice"

Multi-Criteria Rating

from fabricatio_capabilities.capabilities.rating import Rating

class MyAgent(Rating, YourBaseAgent):
    ...

agent = MyAgent()
manual = await agent.draft_rating_manual("essay quality", {"clarity", "argument"})
scores = await agent.rate("The essay is well-structured.", manual, (0.0, 10.0))

Text Summarization

from fabricatio_capabilities.capabilities.summarize import LengthType, Summarize

class MyAgent(Summarize, YourBaseAgent):
    ...

caption = await agent.summarize(
    raw,
    max_length=200,                # box width, in length_type units
    min_length=160,                # optional floor; default = 80% of max_length
    requirement="keep the key facts and the formal tone",
    length_type=LengthType.Chars,  # Chars (default), Words, or Sentences
)

The output is validated to land inside the [min_length, max_length] window (measured after stripping); out-of-window responses are retried and, after three failed attempts, the method returns None. Bounds are optional: pass neither max_length nor min_length for unconstrained summarization, or pass only min_length for a floor with no ceiling.

When a single pass keeps missing the window, force_summarize feeds each oversized output back as the input of the next pass and restarts from the raw text after under-min outputs (max_iterations=5 by default); if the window stays unreachable it returns the attempt closest to the window:

summary = await agent.force_summarize(
    raw,
    max_length=200,
    requirement="keep the key facts and the formal tone",
    max_iterations=5,
)

Sequence Ordering

from fabricatio_capabilities.capabilities.order import Ordering

class MyAgent(Ordering, YourBaseAgent):
    ...

agent = MyAgent()
ordered = await agent.order(
    ["clean kitchen", "buy groceries", "pay bills"],
    "by urgency",
)

Task Dispatch

from fabricatio_capabilities.capabilities.task import ProposeTask, DispatchTask

class MyAgent(ProposeTask, DispatchTask, YourBaseAgent):
    ...

agent = MyAgent()
task = await agent.propose_task("Summarize this document.")
result = await agent.dispatch_task(task, candidates={role_a, role_b})

Patching Models

from pydantic import BaseModel
from fabricatio_capabilities.models.generic import Patch

class User(BaseModel):
    name: str
    age: int
    email: str = ""

class UserPatch(Patch[User], BaseModel):
    name: str | None = None
    email: str | None = None

user = User(name="Alice", age=30)
patch = UserPatch(name="Bob")
updated = patch.apply(user)
assert updated.name == "Bob" and updated.age == 30

Dependencies

  • fabricatio-core — core interfaces (Propose, UseLLM, Task, Role, TEMPLATE_MANAGER)
  • orjson — fast JSON serialization
  • pydantic — model validation and schema generation
  • more-itertools — utility iterators

License

MIT — see LICENSE

Metadata

Release files for fabricatio-capabilities 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fabricatio-capabilities 0.7.0
File Interpreter ABI Platform
fabricatio_capabilities-0.7.0-py3-none-any.whl Python 3 none any Details

Release files / fabricatio_capabilities-0.7.0-py3-none-any.whl

Download URL fabricatio_capabilities-0.7.0-py3-none-any.whl
Size 36.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cf1e59eb3cf1510a68e580da2007b6572d3fd6b7c55eaa8cd575ad36ec0064a
BLAKE2b-256 checksum
How to use checksums
aa1b65a0d10677d4ac3fc20c278499ace951e1d1b3264a3d13472d60696e07e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","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}

Release history Release notifications | RSS feed

This release

0.7.0 This release

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.4.0

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.5

1 release file

0.2.4

8 release files

0.2.3

8 release files

0.2.2

4 release files

0.2.1

4 release files

0.2.0

4 release files

0.1.10

3 release files

0.1.9

3 release files

0.1.8

3 release files

0.1.7

4 release files

0.1.6

4 release files

0.1.5

4 release files

0.1.4

4 release files

0.1.2

4 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page