Skip to main content

A vimtutor-inspired library for generating interactive tutorials using AI

Project description

tutorfile

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.

Quickstart

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")

XKCD Comic about Regular Expressions

From XKCD, also you after regextutor

Using Source Material

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.

Building on Existing Lessons

Load existing lessons and generate more:

from tutorfile import read_lessons_from_folder, generate_lessons, write_lessons_to_folder

# Read existing lessons
existing_lessons = read_lessons_from_folder("regextutor")

# Generate additional lessons
new_lessons = generate_lessons(
    client=client,
    model="gpt-4o",
    topic="Regular Expressions",
    topic_description="Advanced concepts",
    num_lessons=15,  # Will generate lessons 11-15
    existing_lessons=existing_lessons
)

# Write all lessons to folder
write_lessons_to_folder(new_lessons, "regex")

Installation

pip install tutorfile

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tutorfile-0.1.2.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tutorfile-0.1.2-py3-none-any.whl (69.3 kB view details)

Uploaded Python 3

File details

Details for the file tutorfile-0.1.2.tar.gz.

File metadata

  • Download URL: tutorfile-0.1.2.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.7 Darwin/23.5.0

File hashes

Hashes for tutorfile-0.1.2.tar.gz
Algorithm Hash digest
SHA256 09e53770f45282956b6a590840e276da92176460b849aaafc987780436edb5eb
MD5 d2d71f8a20f23e8ea34a175a1a196088
BLAKE2b-256 bb3b1f135442c837cb2899217b335a00b01c3ef768e7484c092ea6ec0ac555a0

See more details on using hashes here.

File details

Details for the file tutorfile-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tutorfile-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 69.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.7 Darwin/23.5.0

File hashes

Hashes for tutorfile-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f805a22ef761389f0b7b68c182713382e63a8c9026d4cd7981f4327be0cd8435
MD5 2cffc062299436572904011a49e35ec4
BLAKE2b-256 2ae6656e420d40a3cca2f7c2e8ed9e512938fe774d9eb1725768703b820ed323

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page