This guide will take you through the steps to create custom Anki decks using Python, GPT4, and LangChain.
-
Open the
.env.examplefile, rename it to.envand add the following information:- Name of your Anki deck
- Your OpenAI API key
-
Install the core dependencies:
poetry install --without devAlternatively if you don't have Poetry installed, use the following command and execute the
.pyfiles directlypython3.11 -m venv venv && \ source venv/bin/activate && \ pip install -r requirements.txt
-
Paste the text from which you want to create Anki cards into the
input.txtfile -
To generate flashcards in CSV format:
poetry run generate-flashcards
This will automatically generate a CSV file. If you wish to create additional cards, simply add new text into the
input.txtfile and rerun thegenerate-flashcardscommand. It will append the new cards to the existing CSV. -
Convert the CSV file to an Anki deck using the following command:
poetry run generate-deck
-
The Anki deck will be created in the
decksdirectory -
Open the Anki app and import the deck using the app's import function
If you're interested in modifying or contributing to the project, follow these additional steps to set up your development environment:
-
Install all dependencies, including those required for development:
poetry install
-
Run tests and linting to ensure your modifications don't break existing functionality:
poetry run nox
This command runs predefined Nox sessions, which include running ruff and mypy as defined in the
noxfile.py