Skip to main content

An extension of fabricatio, which brings up the capability of creating fully explainned anki deck package

Project description

fabricatio-anki

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

AI-powered Anki flashcard deck generation and compilation for the Fabricatio framework. Uses LLM-driven templates to produce card layouts, model definitions, and topic analyses, then compiles them into .apkg files compatible with Anki 2.1+.

Installation

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

For the full Fabricatio suite:

pip install fabricatio[full]

Overview

The package splits into two layers:

  • Rust (fabricatio_anki.rust) — fast filesystem operations for project scaffolding, template serialization, and deck compilation via deck_loader.
  • Python (fabricatio_anki) — LLM-driven generation of deck metadata, card models, HTML/JS/CSS templates, and topic analyses, integrated with Fabricatio's Propose capability system.

Project Structure

A deck project created by create_deck_project follows this layout:

deck_project/
├── deck.yaml           # Deck metadata (name, description, author)
├── models/             # One subdirectory per note type
│   └── basic_card/
│       ├── fields.yaml # Field definitions (e.g. Front, Back)
│       └── templates/  # One subdirectory per card template
│           └── card/
│               ├── front.html
│               ├── back.html
│               └── style.css
├── data/               # CSV files with card content
│   └── basic_card.csv
└── media/              # Global images, audio, etc.

Rust Functions (fabricatio_anki.rust)

Function Description
compile_deck(path, output) Compile a deck project into an .apkg file.
create_deck_project(path, deck_name?, description?, author?, model_name?, fields?) Scaffold a new deck project with sample templates and data.
save_metadata(dir_path, name, data) Write a Python dict as YAML into a project directory.
add_csv_data(project_path, model_name, data_path) Copy a CSV file into the project's data/ directory.
save_template(dir_path, front, back, css?) Write front.html, back.html, and optional style.css for a card template.
extract_html_component(html) Parse an HTML string into (layout, js, css) by separating <script> and <style> content.
extract_content_by_tag(html, tag) Extract inner text from all occurrences of a given HTML tag.

Python Models

Model Description
Template Card template with front and back Side objects (each containing layout, js, css).
Side One face of a card — HTML layout, JavaScript, and CSS.
Model Note type with a name, field list, and list of Templates.
Deck Full deck with metadata, author, and list of Models.
ModelMetaData Patch class carrying deck-level metadata (name, description, author).
TopicAnalysis Analysis of a topic: difficulty coefficient, subjects, detailed solution, key points, summary.

Python Capabilities

GenerateDeck

LLM-driven deck generation. Extends Propose. Key methods:

Method Description
generate_deck(requirement, fields, …) Generate a complete Deck from a natural-language requirement.
generate_model(fields, requirement, …) Generate Model(s) with auto-named templates.
generate_template(fields, requirement, …) Generate Template(s) with front/back HTML, JS, and CSS.
generate_front_side(fields, requirement, …) Generate front-side Side objects.
generate_back_side(fields, requirement, …) Generate back-side Side objects.

Accepts a single requirement string or a list for batch generation. All methods pass through Fabricatio's validation system.

GenerateAnalysis

Generates structured TopicAnalysis objects from topic strings.

Method Description
generate_analysis(topic, …) Produce TopicAnalysis for one or more topics.

AppendTopicAnalysis

An Action that reads a CSV file, runs generate_analysis on each row, and appends a "Topic Analysis" column.

from fabricatio_anki.actions.topic_analysis import AppendTopicAnalysis

action = AppendTopicAnalysis(
    csv_file="questions.csv",
    output_file="questions_with_analysis.csv",
)
result = await action.execute()

Configuration

AnkiConfig (loaded from Fabricatio's config system under the anki key) controls which templates are used during generation. Each field names a built-in/… template in the template manager. Override via configuration to swap in custom generation prompts.

Usage Example

from fabricatio_anki.rust import create_deck_project, compile_deck, add_csv_data
from pathlib import Path

# 1. Scaffold a project
create_deck_project(
    Path("./my_deck"),
    deck_name="French Vocabulary",
    description="Essential French words for beginners",
    author="Language Team",
    model_name="french_vocab",
    fields=["French", "English", "Pronunciation", "Example"],
)

# 2. Add your CSV data
add_csv_data(Path("./my_deck"), "french_vocab", Path("./words.csv"))

# 3. Compile to .apkg
compile_deck(Path("./my_deck"), Path("./french_vocab.apkg"))

For LLM-driven generation via GenerateDeck:

from fabricatio_anki.capabilities.generate_deck import GenerateDeck

gen = GenerateDeck()
deck = await gen.generate_deck(
    "Create a deck for learning Japanese JLPT N5 vocabulary",
    fields=["Kanji", "Reading", "Meaning", "Example Sentence"],
)
# deck is a Deck with auto-generated models and templates

Dependencies

  • fabricatio-core — core interfaces and utilities
  • fabricatio-capabilities — capability framework (Propose)
  • deck_loader (Rust) — Anki deck serialization and project management

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 Distributions

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

fabricatio_anki-0.2.15.dev0-cp314-cp314-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.14Windows x86-64

fabricatio_anki-0.2.15.dev0-cp314-cp314-manylinux_2_34_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

fabricatio_anki-0.2.15.dev0-cp313-cp313-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.13Windows x86-64

fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

fabricatio_anki-0.2.15.dev0-cp312-cp312-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.12Windows x86-64

fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 6.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_anki-0.2.15.dev0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 2cc88277b9b2d43714d29b8db2963b50d9f802ad63760dc6a6e0125ac4f85eb6
MD5 f001a65bf133ec0ed5b9354c3c44c39d
BLAKE2b-256 25cf672c3f6379da0ef970be4bbf7b9ee7247eb0b1c234c188868d392d55b985

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp314-cp314-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ 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_anki-0.2.15.dev0-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 041c57680595cf6c9ae1901787bdd1d30de43b1c7768eacec0390fec5e019d3b
MD5 03b2c3999f37ccbcb86049b5b8860329
BLAKE2b-256 3614af500cdd568fbfd16e3de374de6204ee068affd6fe599fd2424412a55abb

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 6.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_anki-0.2.15.dev0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 49f48a3a43e674873385da46b2bfb574c6620dc0361f91d87f7482f629926187
MD5 2b201335f7e05b94e25dde285478fb72
BLAKE2b-256 7e172b2ca6c2ecf5cc7bcf51edd4ab64fa7b0438e4e06dbf9c0e07786f60dff8

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ 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_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 14ab48c74397f32c4280137859c5b75c30fd434f183b0d6633c2b4da3afb93af
MD5 457a2e35b3423e5b6b5c3d9958fbccd1
BLAKE2b-256 ef3e873e07351458c3bc8e0e2dae5b840cead8ca9e263f5461446a28e9b68825

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 7.0 MB
  • Tags: CPython 3.13, manylinux: glibc 2.34+ 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_anki-0.2.15.dev0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 54b2ab27b2ddcfd99ced9bf5b54a731f4336e233a7dd5369506391b1ed7361a5
MD5 e6c8ed22f4ae8e60d6d939cdb8154eeb
BLAKE2b-256 b3dd143d793b9950b3f7459e50e38deaba72eff67a178af3bd94840c30681292

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 6.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_anki-0.2.15.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c584993090fe0e8814ffe5f6547f7fb2e37e7e7e43763e1daef9b192d430d41f
MD5 66466546e1f80e06006a74a1813824d5
BLAKE2b-256 1ffde175045a9efdbda46d323cce8a960c7d5b79398a38334f43100cf4bbe074

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_x86_64.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ 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_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f9c7e69d516df5cd77b597ce63e471fe6a857d0db2f66ee5b449ec62c52a6fe4
MD5 e3f4658eccdfb86af9acbe0208a8fa1e
BLAKE2b-256 58c3b45b39931643e0bf6f816825f877882b909b69844778a9a2b12c674f7545

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 7.0 MB
  • Tags: CPython 3.12, manylinux: glibc 2.34+ 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_anki-0.2.15.dev0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 0172d2c2c8e8419df19e07e4163f57b58307b57b29b3164140cee0ce473ebe12
MD5 bf965db5d6345260376b594eca8199f6
BLAKE2b-256 54e48a5fc72205a5a9bc54bd02e186182390a4625ebeabdee5ca5a5efe82e196

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