File size: 3,713 Bytes
2077d8b 970f1a9 2bc1f40 2077d8b 729864f 1d85a18 aee77fd 06f924e 2077d8b 970f1a9 f6427c1 970f1a9 edb3b14 f6427c1 509b428 edb3b14 509b428 f6427c1 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 f6427c1 509b428 f6427c1 509b428 970f1a9 509b428 f6427c1 970f1a9 f6427c1 509b428 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 970f1a9 509b428 970f1a9 d09f6aa f6427c1 509b428 f6427c1 509b428 f6427c1 509b428 edb3b14 970f1a9 509b428 970f1a9 509b428 ee05e09 509b428 ee05e09 970f1a9 d09f6aa 970f1a9 509b428 |
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 139 140 141 142 143 |
---
title: AnkiGen
emoji: π
app_file: app.py
requirements: requirements.txt
python_version: 3.12
sdk: gradio
sdk_version: 5.49.1
---
# 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 or from provided text/URLs
- AI-powered auto-configuration (intelligently determines topics, card counts, and models)
- Create structured learning paths for complex topics
- 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_core.cli -p "Basic SQL"
# Custom settings
uv run python -m ankigen_core.cli -p "React Hooks" \
--topics 5 \
--cards-per-topic 8 \
--output hooks.apkg
# Export to CSV
uv run python -m ankigen_core.cli -p "Docker basics" \
--format csv \
-o docker.csv
# Skip confirmation prompt
uv run python -m ankigen_core.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-4.1` or `gpt-4.1-nano`)
- `-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. Select a generation mode:
- Single Subject: Generate cards for a specific topic
- Learning Path: Create a structured learning curriculum
- From Text: Generate cards from pasted text
- From Web: Generate cards from a URL
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/`: 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
- `learning_path.py`: Learning path analysis
- `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_core 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) |