File size: 7,088 Bytes
f56a29b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | /**
* Generation Types - Two-Stage Content Generation System
*
* Stage 1: User requirements + documents → Scene Outlines (per-page)
* Stage 2: Scene Outlines → Full Scenes (slide/quiz/interactive/pbl with actions)
*/
import type { ActionType } from './action';
import type { MediaGenerationRequest } from '@/lib/media/types';
// ==================== PDF Image Types ====================
/**
* Image extracted from PDF with metadata
*/
export interface PdfImage {
id: string; // e.g., "img_1", "img_2"
src: string; // base64 data URL (empty when stored in IndexedDB)
pageNumber: number; // Page number in PDF
description?: string; // Optional description for AI context
storageId?: string; // Reference to IndexedDB (session_xxx_img_1)
width?: number; // Image width (px or normalized)
height?: number; // Image height (px or normalized)
}
/**
* Image mapping for post-processing: image_id → base64 URL
*/
export type ImageMapping = Record<string, string>;
// ==================== Stage 1 Input ====================
export interface UploadedDocument {
id: string;
name: string; // Original filename
type: 'pdf' | 'docx' | 'pptx' | 'txt' | 'md' | 'image' | 'other';
size: number; // Bytes
uploadedAt: Date;
contentSummary?: string; // Placeholder for parsing
extractedTopics?: string[]; // Placeholder for parsing
pageCount?: number;
storageRef?: string;
}
/**
* Simplified user requirements for course generation
* All details (topic, duration, style, etc.) should be included in the requirement text
*/
export interface UserRequirements {
requirement: string; // Single free-form text for all user input
userNickname?: string; // Student nickname for personalization
userBio?: string; // Student background for personalization
webSearch?: boolean; // Enable web search for richer context
interactiveMode?: boolean; // Enable Interactive Mode for interactive-first generation
}
// ==================== Stage 1 Output: Scene Outlines (Simplified) ====================
/**
* Widget outline configuration for interactive scenes
* Unified for both normal and ultra modes
*/
export interface WidgetOutline {
// Common field
concept?: string;
// Type-specific fields
keyVariables?: string[]; // simulation
diagramType?: 'flowchart' | 'mindmap' | 'hierarchy' | 'system'; // diagram
language?: 'python' | 'javascript' | 'typescript' | 'java' | 'cpp'; // code
gameType?: 'quiz' | 'puzzle' | 'strategy' | 'card' | 'action'; // game
visualizationType?: 'molecular' | 'solar' | 'anatomy' | 'geometry' | 'physics' | 'custom'; // visualization3d
objects?: string[]; // visualization3d
interactions?: string[]; // visualization3d
challenge?: string; // game - description of what player does
playerControls?: string[]; // game - what player controls
nodeCount?: number; // diagram - approximate node count
challengeType?: string; // code - type of coding challenge
}
/**
* Simplified scene outline
* Gives AI more freedom, only requiring intent description and key points
*/
export interface SceneOutline {
id: string;
type: 'slide' | 'quiz' | 'interactive' | 'pbl';
title: string;
description: string; // 1-2 sentences describing the purpose
keyPoints: string[]; // 3-5 core key points
teachingObjective?: string;
estimatedDuration?: number; // seconds
order: number;
languageNote?: string; // LLM-inferred language note for this scene
// Suggested image IDs (from PDF-extracted images)
suggestedImageIds?: string[]; // e.g., ["img_1", "img_3"]
// AI-generated media requests (when PDF images are insufficient)
mediaGenerations?: MediaGenerationRequest[]; // e.g., [{ type: 'image', prompt: '...', elementId: 'gen_img_1' }]
// Quiz-specific config
quizConfig?: {
questionCount: number;
difficulty: 'easy' | 'medium' | 'hard';
questionTypes: ('single' | 'multiple' | 'text')[];
};
/**
* @deprecated Use widgetType + widgetOutline instead
* Legacy interactive config - kept for backward compatibility only
*/
interactiveConfig?: {
conceptName: string;
conceptOverview: string;
designIdea: string;
subject?: string;
};
// PBL-specific config
pblConfig?: {
projectTopic: string;
projectDescription: string;
targetSkills: string[];
issueCount?: number;
};
// Widget fields (required for type === 'interactive' in unified mode)
widgetType?: WidgetType;
widgetOutline?: WidgetOutline;
}
// ==================== Stage 3 Output: Generated Content ====================
import type { PPTElement, SlideBackground } from './slides';
import type { QuizQuestion } from './stage';
/**
* AI-generated slide content
*/
export interface GeneratedSlideContent {
elements: PPTElement[];
background?: SlideBackground;
remark?: string;
}
/**
* AI-generated quiz content
*/
export interface GeneratedQuizContent {
questions: QuizQuestion[];
}
// ==================== PBL Generation Types ====================
import type { PBLProjectConfig } from '@/lib/pbl/types';
/**
* AI-generated PBL content
*/
export interface GeneratedPBLContent {
projectConfig: PBLProjectConfig;
}
// ==================== Interactive Generation Types ====================
import type { WidgetConfig, TeacherAction, WidgetType } from './widgets';
/**
* Scientific model output from scientific modeling stage
*/
export interface ScientificModel {
core_formulas: string[];
mechanism: string[];
constraints: string[];
forbidden_errors: string[];
}
/**
* AI-generated interactive content
*/
export interface GeneratedInteractiveContent {
html: string;
scientificModel?: ScientificModel;
widgetType?: WidgetType;
widgetConfig?: WidgetConfig;
teacherActions?: TeacherAction[];
}
// ==================== Legacy Types (for compatibility) ====================
export interface SuggestedSlideElement {
type: 'text' | 'image' | 'shape' | 'chart' | 'latex' | 'line';
purpose: 'title' | 'subtitle' | 'content' | 'example' | 'diagram' | 'formula' | 'highlight';
contentHint: string;
position?: 'top' | 'center' | 'bottom' | 'left' | 'right';
chartType?: 'bar' | 'line' | 'pie' | 'radar';
textOutline?: string[];
}
export interface SuggestedQuizQuestion {
type: 'single' | 'multiple' | 'short_answer';
questionOutline: string;
suggestedOptions?: string[];
targetConceptId?: string;
difficulty: 'easy' | 'medium' | 'hard';
}
export interface SuggestedAction {
type: ActionType;
description: string;
timing?: 'start' | 'middle' | 'end' | 'after-content';
}
// ==================== Generation Session ====================
export interface GenerationProgress {
currentStage: 1 | 2 | 3;
overallProgress: number; // 0-100
stageProgress: number; // 0-100
statusMessage: string;
scenesGenerated: number;
totalScenes: number;
errors?: string[];
}
export interface GenerationSession {
id: string;
requirements: UserRequirements;
sceneOutlines?: SceneOutline[];
progress: GenerationProgress;
startedAt: Date;
completedAt?: Date;
generatedStageId?: string;
}
|