Inspired by vimtutor, tutorfile lets you build text-based interactive tutorials using AI. It generates step-by-step lessons that emphasize learning by doing, with each concept building on previous ones through hands-on practice.
Like any LLM output, tutorfile’s lessons can contain inaccuracies. Exercise particular caution with unfamiliar topics or subjects that may be outside LLMs’ reliable knowledge base. To improve accuracy, you can provide source material and enable strict adherence mode.
import openai from tutorfile import generate_lessons, write_lessons_to_folder client = openai.OpenAI() # Create an interactive regex tutorial lessons = generate_lessons( client=client, model="gpt-4o", topic="Regular Expressions", topic_description=""" Lessons on regular expressions using Python's re module and interactivity through IPython """, num_lessons=10 ) write_lessons_to_folder(lessons, "regex")
From XKCD, also you after regextutor
You can provide source material to ensure accuracy:
with open('source_document.txt', 'r') as f: source_text = f.read() lessons = generate_lessons( client=client, model="gpt-4o", topic="Topic", topic_description="Description", source_text=source_text, strict_source_text_adherence=True )
Extensive source material can cause the prompt for the LLM to exceed the available context, leading to potential errors.
The strict_source_text_adherence argument defaults to False. True means the LLM will be asked to exclusively use the text from source_text to inform lessons.
Load existing lessons and generate more:
from tutorfile import read_lessons_from_folder, generate_lessons, write_lessons_to_
1 Comment
cdbyr
I found myself looking for vimtutor-like text-based tutorials, and threw this together to make them easy to make, with or without the benefit of source material. I don’t think the prompt instructions are totally final yet – feel free to reach out if you run into issues or have suggestions.