class_factory package

class_factory.ClassFactory module

ClassFactory Module

The ClassFactory module provides a unified interface for managing AI-powered educational content generation modules.

Supported Modules

  • BeamerBot: Automates LaTeX Beamer slide generation based on lesson materials

  • ConceptWeb: Creates concept maps showing relationships between key lesson concepts

  • QuizMaker: Generates quizzes with interactive features and similarity analysis

Key Functionalities

  1. Module Management: - Dynamic module creation via create_module() - Shared context and configurations across modules - Consistent error handling and validation

  2. Resource Management: - Centralized path handling for lesson materials - Organized output structure in ClassFactoryOutput - Automated resource loading and validation

  3. AI Integration: - Flexible LLM support (GPT-4, LLaMA, etc.) - Consistent AI interaction patterns - Shared context across operations

Output Directory Structure

ClassFactoryOutput/
├── BeamerBot/
│   └── L{lesson_no}/
├── ConceptWeb/
│   └── L{lesson_no}/
└── QuizMaker/
    └── L{lesson_no}/

Usage

from class_factory import ClassFactory
from langchain_openai import ChatOpenAI
from pathlib import Path

# Initialize factory
factory = ClassFactory(
    lesson_no=10,
    syllabus_path="path/to/syllabus.docx",
    reading_dir="path/to/readings",
    llm=ChatOpenAI(api_key="your_key")
)

# Create and use modules
slides = factory.create_module("BeamerBot").generate_slides()
concept_map = factory.create_module("ConceptWeb").build_concept_map()
quiz = factory.create_module("QuizMaker").make_a_quiz()

Dependencies

  • pathlib: Path handling

  • langchain: LLM integration

  • pyprojroot: Project directory management

  • Custom modules: BeamerBot, ConceptWeb, QuizMaker

Notes

  • BeamerBot operates on single lessons only

  • ConceptWeb and QuizMaker support lesson ranges

  • All modules inherit factory-level configurations

  • Output directories are automatically created and managed

class class_factory.ClassFactory.ClassFactory(lesson_no: int, syllabus_path: str | Path, reading_dir: str | Path, llm, project_dir: str | Path | None = None, output_dir: str | Path | None = None, slide_dir: str | Path | None = None, lesson_range: range | None = None, course_name: str = 'Political Science', verbose: bool = True, **kwargs)[source]

Bases: object

A factory class responsible for creating and managing instances of various educational modules.

ClassFactory provides a standardized interface for initializing educational modules designed for generating lesson-specific materials, such as slides, concept maps, and quizzes. Modules are dynamically created based on the specified module name, with configurations for content generation provided by the user.

Modules available for creation include: - BeamerBot: Automated LaTeX Beamer slide generation. - ConceptWeb: Concept map generation based on lesson objectives and readings. - QuizMaker: Quiz creation, hosting, and analysis.

lesson_no

The lesson number for which the module instance is created.

Type:

int

syllabus_path

Path to the syllabus file.

Type:

Path

reading_dir

Path to the directory containing lesson readings.

Type:

Path

slide_dir

Path to the directory containing lesson slides.

Type:

Path

llm

Language model instance used for content generation in modules.

project_dir

Base project directory.

Type:

Path

output_dir

Directory where outputs from modules are saved.

Type:

Path

lesson_range

Range of lessons covered by the factory instance.

Type:

range

course_name

Name of the course for which content is generated.

Type:

str

lesson_loader

Instance of LessonLoader for loading lesson-related data and objectives.

Type:

LessonLoader

By default, all module outputs are saved in a structured directory under “ClassFactoryOutput” within the project directory.

create_module(module_name: str, **kwargs)[source]

Create a specific module instance based on the provided module name.

Parameters:
  • module_name (str) – Name of the module to create. Case-insensitive options: - ‘BeamerBot’/’beamerbot’: For LaTeX slide generation - ‘ConceptWeb’/’conceptweb’: For concept map creation - ‘QuizMaker’/’quizmaker’: For quiz generation and management

  • **kwargs – Module-specific configuration options: - output_dir (Path): Custom output directory (defaults to self.output_dir) - verbose (bool): Enable detailed logging (defaults to False) - course_name (str): Override default course name - lesson_range (range): Override default lesson range - slide_dir (Path): Custom slide directory (BeamerBot only)

Returns:

The created module instance based on the provided name.

Return type:

Union[BeamerBot, ConceptMapBuilder, QuizMaker]

Raises:

ValueError – If an invalid module name is provided.

Notes

  • Each module’s output is automatically organized in a dedicated subdirectory:

ClassFactoryOutput/{ModuleName}/L{lesson_no}/ - BeamerBot operates on single lessons, while ConceptWeb and QuizMaker can handle lesson ranges

Submodules