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

Uploaded CPython 3.14Windows x86-64

fabricatio_anki-0.2.16-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.16-cp314-cp314-manylinux_2_34_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.13Windows x86-64

fabricatio_anki-0.2.16-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.16-cp313-cp313-manylinux_2_34_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

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

Uploaded CPython 3.12Windows x86-64

fabricatio_anki-0.2.16-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.16-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.16-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.21 {"installer":{"name":"uv","version":"0.11.21","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.16-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3a68b4bea7ec7963e16913d1cd9157a3c79bd05611ce9da85caeb5b8b31e54a0
MD5 e1d5d73e60de73140c506c26143e134d
BLAKE2b-256 29711574704ecbcee42767dc7dc01832ced55f7efc413b968b7bf752df916ddc

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.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_anki-0.2.16-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ca329a9a223e21c08b0adc612c5d1406f456dd86c9fc22951d1beee9040af132
MD5 d1039264cec4ed57685b12014373484a
BLAKE2b-256 d5494462a8ec32b5f09a8ef7245609a94ca23f7a1485e0c5802bbe371ab74eb0

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-cp314-cp314-manylinux_2_34_aarch64.whl
  • Upload date:
  • Size: 7.0 MB
  • Tags: CPython 3.14, manylinux: glibc 2.34+ ARM64
  • 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_anki-0.2.16-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 6abfe743ade77c57f7952556fa1d209a6533e703e9fb0c6dd01f03a924302ac5
MD5 d5d79ce20c362edd0bfa08040567147a
BLAKE2b-256 4f5fcde69668cc84096a41c5ff0cdc5bcd49b7b881045d4a421c68694f0913a5

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.21 {"installer":{"name":"uv","version":"0.11.21","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.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 efe62e8d46e887168280bbb589c70649209aba68961ee3a348983ff709a5af9d
MD5 7a68a8d9f783a41a7f10437ef27bbd9c
BLAKE2b-256 8a1a01533340667487ca196c3f9857459c820e9d560b266f5c4ae9361119195f

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.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_anki-0.2.16-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3ed4150da3f7a2736ee9ba37e2bb2ce58886890e71c101511b18c76783a8c10f
MD5 98b462caa3615edc0aa8f2f14c83c050
BLAKE2b-256 87e765701c78a45f468f84b2d813c34d3679c91a55cf0aea7ed72adc8e1f70b7

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.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_anki-0.2.16-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 0aeeb438e50294af6cc7f35f704e8cb5f1ec6eb4c18190433f8b2408f00ccea0
MD5 c192978e2a8692eb9629e3b8dd4fd072
BLAKE2b-256 7611b1169b25e1e8f344669abd73200ea876069bc0d7dfeda5c1d0491b0b183e

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.21 {"installer":{"name":"uv","version":"0.11.21","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.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f4b24e0b0a532d6e969c42047eac7a64b3bc21deab5d5410319a11f5d1b59403
MD5 2b07c8248646e4720900d67d6e00e86b
BLAKE2b-256 a1b3c92233f1412c2da26fd6349cbc0fb8dc73ed03a7c276a772553d5fd981e8

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.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_anki-0.2.16-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 af1460c8781ef0d91f2dfd3b9639b0f819e2ef0612c381ac4a3d10ea95ae656e
MD5 f5761f0214ae7361083f1bad0ba13043
BLAKE2b-256 e7d0866f22d12b700e76b5c9aa1e52b6fee4df86f9991298ba0e38c05738281b

See more details on using hashes here.

File details

Details for the file fabricatio_anki-0.2.16-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

  • Download URL: fabricatio_anki-0.2.16-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.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_anki-0.2.16-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 bb4ecbaa31daff638ddcf4d2f68cd78beb3e63255188ff9eb68ed5b5b18c2f80
MD5 339299b50ce11900be55bcb12623d6bb
BLAKE2b-256 d342a6d41b8d79bb08d81385b45711dcd48001bcd8107acb83f8552279caf019

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