File size: 3,458 Bytes
2077d8b 970f1a9 2bc1f40 2077d8b 729864f 1d85a18 aee77fd f403842 2077d8b 970f1a9 f6427c1 970f1a9 2eb64de f6427c1 509b428 edb3b14 509b428 f6427c1 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 f6427c1 509b428 f6427c1 509b428 970f1a9 509b428 f6427c1 970f1a9 f6427c1 f5605ad f6427c1 f5605ad f6427c1 f5605ad f6427c1 f5605ad f6427c1 c467eef f6427c1 509b428 970f1a9 509b428 970f1a9 2eb64de 970f1a9 509b428 970f1a9 509b428 970f1a9 d09f6aa f6427c1 f5605ad f6427c1 509b428 f6427c1 509b428 edb3b14 970f1a9 509b428 970f1a9 509b428 ee05e09 509b428 f5605ad 509b428 ee05e09 970f1a9 d09f6aa 970f1a9 509b428 c467eef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | ---
title: AnkiGen
emoji: 📚
app_file: app.py
requirements: requirements.txt
python_version: 3.12
sdk: gradio
sdk_version: 6.9.0
---
# AnkiGen - Anki Card Generator
AnkiGen generates Anki flashcards using OpenAI's GPT models. Available as both a web interface (Gradio) and command-line tool, it creates CSV and `.apkg` deck files with intelligent auto-configuration.
## Features
- Generate Anki cards for various subjects with automatic topic decomposition
- AI-powered auto-configuration (intelligently determines topics, card counts, and models)
- Export to CSV or `.apkg` format with default styling
- Customizable number of topics and cards per topic
- Built-in quality review system
- **CLI for quick terminal-based generation**
- **Web interface for interactive use**
## Installation
Preferred usage: [uv](https://github.com/astral-sh/uv)
1. Clone this repository:
```bash
git clone https://github.com/brickfrog/ankigen.git
cd ankigen
uv venv
source .venv/bin/activate
```
2. Install dependencies:
```bash
# Base installation (web interface)
uv pip install -e .
# With CLI support
uv pip install -e ".[cli]"
```
3. Set up your OpenAI API key:
```bash
export OPENAI_API_KEY="your_api_key_here"
```
## Usage
### CLI (Quick & Direct)
Generate flashcards directly from your terminal with intelligent auto-configuration:
```bash
# Quick generation (auto-detects best settings)
uv run python -m ankigen.cli -p "Basic SQL"
# Custom settings
uv run python -m ankigen.cli -p "React Hooks" \
--topics 5 \
--cards-per-topic 8 \
--output hooks.apkg
# Export to CSV
uv run python -m ankigen.cli -p "Docker basics" \
--format csv \
-o docker.csv
# Skip confirmation prompt
uv run python -m ankigen.cli -p "Python Lists" --no-confirm
```
**CLI Options:**
- `-p, --prompt`: Subject/topic (required)
- `--topics`: Number of topics (auto-detected if omitted)
- `--cards-per-topic`: Cards per topic (auto-detected if omitted)
- `--model`: Model choice (`gpt-5.2-auto`, `gpt-5.2-instant`, or `gpt-5.2-thinking`)
- `-o, --output`: Output file path
- `--format`: Export format (`apkg` or `csv`)
- `--no-confirm`: Skip confirmation prompt
### Web Interface (Interactive)
1. Run the application:
```bash
uv run python app.py
```
2. Open your browser to `http://127.0.0.1:7860`
3. Enter a subject and optionally click "Auto-fill" to configure settings
4. Configure parameters and click "Generate Cards"
5. Export results as CSV or `.apkg` file
## Project Structure
- `app.py`: Main Gradio web application
- `ankigen/`: Core logic modules
- `cli.py`: Command-line interface
- `agents/`: Agent system implementation
- `card_generator.py`: Card generation orchestration
- `auto_config.py`: AI-powered auto-configuration
- `exporters.py`: CSV and `.apkg` export functionality
- `models.py`: Data structures
- `tests/`: Unit and integration tests
## Development
1. Install development dependencies:
```bash
uv pip install -e ".[dev]"
```
2. Run tests:
```bash
uv run pytest tests/
```
3. Run with coverage:
```bash
uv run pytest --cov=ankigen tests/
```
## License
BSD 2-Clause License
## Acknowledgments
- Gradio library for the web interface
- OpenAI for GPT models
- Card design principles from ["An Opinionated Guide to Using Anki Correctly"](https://www.lesswrong.com/posts/7Q7DPSk4iGFJd8DRk/an-opinionated-guide-to-using-anki-correctly)
|