Skip to main content

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

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

[ext.anki]
generate_anki_card_front_side_template = "built-in/generate_anki_card_front_side"
Option Type Default Description
generate_anki_card_front_side_template str "built-in/generate_anki_card_front_side" The template name used for generating the front side of Anki cards.
generate_anki_card_back_side_template str "built-in/generate_anki_card_back_side" The template name used for generating the back side of Anki cards.
generate_anki_card_template_template str "built-in/generate_anki_card_template" The template name used for generating Anki card types.
generate_anki_model_name_template str "built-in/generate_anki_model_name" The template name used for generating Anki model names.
generate_anki_card_template_generation_requirements_template str "built-in/generate_anki_card_template_generation_requirements" The template name used for generating Anki card template generation requirements.
generate_anki_deck_metadata_template str "built-in/generate_anki_deck_metadata" The template name used for generating Anki deck metadata.
generate_anki_model_generation_requirements_template str "built-in/generate_anki_model_generation_requirements" The template name used for generating Anki model generation requirements.
topic_analysis_assemble_template str "built-in/topic_analysis_assemble" The template name used for assembling topic analysis.
generate_topic_analysis_template str "built-in/generate_topic_analysis" The template name used for generating analysis.

Access at runtime: from fabricatio_anki.config import anki_config.

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

Metadata

Release files for fabricatio-anki 0.2.17

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

Built distributions (wheels)

Table of built distributions (wheels) for fabricatio-anki 0.2.17
File
fabricatio_anki-0.2.17-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
fabricatio_anki-0.2.17-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
fabricatio_anki-0.2.17-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details

Total release size: 61.2 MB

Release files / fabricatio_anki-0.2.17-cp314-cp314-win_amd64.whl

Download URL fabricatio_anki-0.2.17-cp314-cp314-win_amd64.whl
Size 6.5 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
829a039e99bcb6fda8aef527aa24c30c537f946f6ca292cab05ba5a73b3653de
BLAKE2b-256 checksum
How to use checksums
1fa88f47c4c629b99d62bb319379ecc2ad4f1dc3c4db72791e9041444b93843b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_x86_64.whl
Size 7.3 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7956d50efc291e464d6bd9d2e003ee4130374779a738e1544aa3e589630b7bef
BLAKE2b-256 checksum
How to use checksums
476f1442ebcf0d2990a04b52b3569bc43b353acad3ef9da50a5284e740e79f82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 files / fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL fabricatio_anki-0.2.17-cp314-cp314-manylinux_2_34_aarch64.whl
Size 6.7 MB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
bd6ae628964a7607dd457816a72bc36082240fa3a5751b4d8cabe2678a405938
BLAKE2b-256 checksum
How to use checksums
1bd2b885053c43129c00893e75aab8c283a2f06eda768190f837621a33699aa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 files / fabricatio_anki-0.2.17-cp313-cp313-win_amd64.whl

Download URL fabricatio_anki-0.2.17-cp313-cp313-win_amd64.whl
Size 6.5 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2091700c861ceb3fd90082a31d80bd31125286e2ee5de156e8fb606fa165eff9
BLAKE2b-256 checksum
How to use checksums
99405db0eba961ed54045d1914920a2e858323fc4cc8e3b2767ffd9eae9e3cd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_x86_64.whl
Size 7.3 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
4f0e7cc023f24aa74c4b9d2a450d589c8a25b31205b6dc8d1efd8c787f4653f4
BLAKE2b-256 checksum
How to use checksums
d541ece39b27654ff5e4a26ef53072c8a3127cfc3fbaa9c185689b83eff880d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 files / fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL fabricatio_anki-0.2.17-cp313-cp313-manylinux_2_34_aarch64.whl
Size 6.7 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
180fe653a84364b6f5cc8e94c6ae0071ce968f499623545c0b9e93167cf509a4
BLAKE2b-256 checksum
How to use checksums
40dd95663dbcd249990a581c3b25d850821df6ef43277819b46a12bc82328f45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 files / fabricatio_anki-0.2.17-cp312-cp312-win_amd64.whl

Download URL fabricatio_anki-0.2.17-cp312-cp312-win_amd64.whl
Size 6.5 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
e25caa34d198a7bc5358ebca5c060b15467ad03a3747afe16c252f84a113dfab
BLAKE2b-256 checksum
How to use checksums
6e08cd76958c24829d005f34da50fa4fd8cdfec5b7da1d8e87ba108b126336f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_x86_64.whl
Size 7.3 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
1738c198719e3dece5de26fca0279953420a9e395f1d67bf8949c6e5ac2a6c0c
BLAKE2b-256 checksum
How to use checksums
d92da8b494b1a7fe44eb7054e7b6c284b11ac3ce0f0cec029f86c3c964e38163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 files / fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL fabricatio_anki-0.2.17-cp312-cp312-manylinux_2_34_aarch64.whl
Size 6.7 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
46fbd4bfe17c357b9929c56741fc2a5b9a7d59fdc816018eba32b0944df460df
BLAKE2b-256 checksum
How to use checksums
22f57069d2b19916e3dcc5bf97c14d3dfb3e150dfe9881b8afd5b9123153be88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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.2.17 This release

9 release files

0.2.16

9 release files

0.2.14

9 release files

0.2.9

12 release files

0.2.8

8 release files

0.2.7

8 release files

0.2.6

8 release files

0.2.5

8 release files

0.2.4

8 release files

0.2.3

8 release files

0.2.1

8 release files

0.2.0

8 release files

0.1.4

8 release files

0.1.3

4 release files

0.1.2

4 release files

0.1.1

4 release files

0.1.0

4 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