Skip to main content

An extension of fabricatio

Project description

fabricatio-character

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

Character profile generation for the Fabricatio LLM agent framework — structured persona cards with AI-driven composition and template-based rendering.


Installation

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

For the full Fabricatio suite:

pip install fabricatio[full]

Overview

fabricatio-character provides a CharacterCard model capturing a character's name, role, appearance, behavior, motivation, and flaw — six required fields that together define a complete narrative persona. The CharacterCompose capability plugs into Fabricatio's Propose pipeline to generate cards via LLM from natural-language requirements, with built-in Pydantic validation.

Generated cards are renderable through the Fabricatio template system (as_prompt()) and persistable (PersistentAble) for checkpoint/restore workflows.


Models

CharacterCard

A structured character profile. All six fields are required and non-empty.

Field Type Description
name str Identifying name, alias, or title
role str Narrative or functional role within the story
look str Visual appearance — clothing, physique, distinguishing features
act str Typical behaviors, mannerisms, speech patterns, stress reactions
want str Core motivation or deepest goal driving the character's actions
flaw str Critical weakness, moral failing, or psychological vulnerability

CharacterCard inherits:

  • SketchedAble — instantiation from natural-language descriptions via LLM
  • Named — equality by name field
  • AsPrompt — renders as a prompt string via the configured template (render_character_card_template)
  • PersistentAble — save/load to disk for workflow checkpointing

Capabilities

CharacterCompose

Mixin that extends Propose to generate CharacterCard instances from requirement strings.

from fabricatio_character.capabilities.character import CharacterCompose

class StoryAgent(CharacterCompose, ...):
    pass

compose_characters(requirements, **kwargs)

  • Accepts a single str or a list[str] of requirements
  • Returns a single CharacterCard (or None) for a string, or a list[CharacterCard | None] for multiple requirements
  • Passes **kwargs through to Fabricatio's validation layer (ValidateKwargs), enabling strict validation, retry policies, and custom post-processing
  • Delegates to Propose.propose() for LLM-driven composition

Utilities

dump_card(*card: CharacterCard) -> str

Joins one or more CharacterCard objects as prompt strings, separated by newlines. Convenience wrapper around CharacterCard.as_prompt().

from fabricatio_character.utils import dump_card

prompt = dump_card(hero, villain)

Configuration

Setting Default Description
render_character_card_template "built-in/render_character_card" Template name used when rendering a card as a prompt

Access via fabricatio_character.config.character_config, loaded through Fabricatio's CONFIG system.


Dependencies

  • fabricatio-corePropose, SketchedAble, Named, CONFIG
  • fabricatio-capabilitiesAsPrompt, PersistentAble, ValidateKwargs

Usage

Generating a Single Character

from fabricatio_character.capabilities.character import CharacterCompose

class Agent(CharacterCompose, ...):
    pass

agent = Agent()
card = await agent.compose_characters(
    "a grizzled detective haunted by an old case"
)
if card:
    print(card.as_prompt())

Batch Generation with Validation

cards = await agent.compose_characters(
    [
        "a brilliant but arrogant surgeon",
        "a quiet archivist who notices everything",
        "a cheerful smuggler with a heart of gold",
    ]
)
for c in cards:
    print(c.name, "-", c.role)

Rendering and Persistence

from fabricatio_character.utils import dump_card

# Render all cards as prompts
prompt_text = dump_card(*cards)

# Persist individual cards (via PersistentAble)
card.persist("checkpoints/characters/")

License

MIT — see LICENSE

Project details


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 Distribution

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

fabricatio_character-0.1.5-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_character-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_character-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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_character-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7748be7ec6368ac6d934e033a98982e1fa81460d975751ab0d70f493945a0271
MD5 ab651a79250b7c77f2e94611dbb3a57a
BLAKE2b-256 3f3f4776f036b650ee0b152133b27d50981f4de76e094eb124f6fd1eb89942e6

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