https://github.com/oresttokovenko/gpt-anki
Using Python, GPT4 and LangChain to Generate Custom Anki Decks
https://github.com/oresttokovenko/gpt-anki
anki anki-flashcards chatgpt chatgpt-api genanki
Last synced: 3 months ago
JSON representation
Using Python, GPT4 and LangChain to Generate Custom Anki Decks
- Host: GitHub
- URL: https://github.com/oresttokovenko/gpt-anki
- Owner: oresttokovenko
- Created: 2023-04-03T04:52:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T17:28:01.000Z (about 1 year ago)
- Last Synced: 2025-01-17T21:52:02.778Z (4 months ago)
- Topics: anki, anki-flashcards, chatgpt, chatgpt-api, genanki
- Language: Python
- Homepage: https://www.oresttokovenko.com/blog/anki-python
- Size: 378 KB
- Stars: 30
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Generating Custom Anki Decks with Python, GPT4, and LangChain
This guide will take you through the steps to create custom Anki decks using Python, GPT4, and LangChain.
## Installation and Setup
1. Open the `.env.example` file, rename it to `.env` and add the following information:
- Name of your Anki deck
- Your OpenAI API key2. Install the core dependencies:
```
poetry install --without dev
```
Alternatively if you don't have Poetry installed, use the following command and execute the `.py` files directly
```
python3.11 -m venv venv && \
source venv/bin/activate && \
pip install -r requirements.txt
```## Usage
1. Paste the text from which you want to create Anki cards into the `input.txt` file
2. To generate flashcards in CSV format:
```shell
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.txt` file and rerun the `generate-flashcards` command. It will append the new cards to the existing CSV.
3. Convert the CSV file to an Anki deck using the following command:
```shell
poetry run generate-deck
```4. The Anki deck will be created in the `decks` directory
5. Open the Anki app and import the deck using the app's import function
## For Contributors
If you're interested in modifying or contributing to the project, follow these additional steps to set up your development environment:
1. Install all dependencies, including those required for development:
```shell
poetry install
```2. Run tests and linting to ensure your modifications don't break existing functionality:
```shell
poetry run nox
```This command runs predefined Nox sessions, which include running ruff and mypy as defined in the `noxfile.py`