Skip to content

gaivrt/AnkiCardProducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnkiCardProducer

AnkiCardProducer is an intelligent, high-performance tool designed to convert deep learning textbooks (PDF or Markdown) into high-quality Anki flashcards. It leverages modern LLMs (like Gemini/OpenAI) to generate rigorous, bilingual (Chinese/English) Q&A pairs, preserving technical terminology and mathematical formatting.

Key Features

  • Multimodal Input:
    • PDF Parsing: Robustly converts PDF textbooks to Markdown, preserving structure, tables, and extracting images.
    • Markdown Support: Directly processes existing Markdown files.
  • LLM-Driven Generation:
    • Uses advanced models (Gemini 1.5/2.0, GPT-4) for context-aware flashcard generation.
    • Generates Chinese explanations while strictly referencing English technical terms.
  • High Performance:
    • Parallel Processing: Multi-threaded LLM requests for rapid generation.
    • Resume Capability: Tracks progress at the section level. If interrupted (API limits, network issues), simply re-run to resume exactly where you left off.
  • Smart Image Handling:
    • Extracts figures from PDFs.
    • Uploads to Cloudflare R2 (optional) or handles local references.
    • Filters out small decorative icons.

Prerequisites

  • Python 3.8+
  • An LLM API Key (Google Gemini or OpenAI compatible)
  • (Optional) Cloudflare R2 credentials for image hosting.

Installation

  1. Clone the repository:

    git clone https://github.com/gaivrt/AnkiCardProducer.git
    cd AnkiCardProducer
  2. Install dependencies:

    pip install -r requirements.txt
  3. Configuration: Copy .env.example to .env and configure your keys:

    # LLM Settings
    OPENAI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/
    OPENAI_API_KEY=your_api_key_here
    MODEL_NAME=openai:gemini-1.5-pro
    
    # R2 / S3 Settings (Optional)
    R2_ENDPOINT_URL=https://...
    R2_ACCESS_KEY_ID=...
    R2_SECRET_ACCESS_KEY=...
    R2_BUCKET_NAME=...
    R2_PUBLIC_URL=...

Usage

1. Generate Flashcards from Markdown

If you already have a Markdown version of your book:

python src/main.py --mode md --files "path/to/book.md" --prompt src/prompts/deep_learning.txt --output output/dl_cards.csv

2. Generate Flashcards from PDF

This will first convert the PDF to Markdown (extracting images) and then generate cards:

python src/main.py --mode pdf --files "path/to/book.pdf" --prompt src/prompts/deep_learning.txt --output output/dl_cards.csv

3. Output

The tool generates a CSV file in output/ ready for import into Anki (or further processing).

  • Format: Front, Back, Image, Tag

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages