File size: 9,196 Bytes
94ecb74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
"""

πŸ“Š Type Definitions for Course Creator AI



Comprehensive data structures and type hints for the course generation system.

"""

from dataclasses import dataclass, field
from typing import List, Dict, Optional, Any, Union, Literal
from datetime import datetime
from enum import Enum


class DifficultyLevel(str, Enum):
    """Course difficulty levels"""
    BEGINNER = "beginner"
    INTERMEDIATE = "intermediate"
    ADVANCED = "advanced"


class LearningStyle(str, Enum):
    """Learning style preferences"""
    VISUAL = "visual"
    AUDITORY = "auditory"
    KINESTHETIC = "kinesthetic"
    READING = "reading"


class ExportFormat(str, Enum):
    """Export format options"""
    PDF = "pdf"
    JSON = "json"
    MARKDOWN = "markdown"
    HTML = "html"
    ANKI = "anki"


@dataclass
class Source:
    """Information about a content source"""
    url: str
    title: str
    author: Optional[str] = None
    date: Optional[datetime] = None
    credibility_score: float = 0.0
    content_type: str = "web"


@dataclass
class LearningObjective:
    """A specific learning objective"""
    description: str
    level: DifficultyLevel
    estimated_time: int  # minutes
    skills: List[str] = field(default_factory=list)


@dataclass
class Exercise:
    """A practice exercise"""
    title: str
    description: str
    instructions: str
    solution: Optional[str] = None
    difficulty: DifficultyLevel = DifficultyLevel.BEGINNER
    estimated_time: int = 10  # minutes


@dataclass
class CodeExample:
    """A code example with explanation"""
    title: str
    code: str
    language: str = "python"
    explanation: str = ""
    tags: List[str] = field(default_factory=list)
    difficulty: str = "intermediate"
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class Flashcard:
    """A flashcard for spaced repetition learning"""
    front: str
    back: str
    category: str
    difficulty: int = 1  # 1-5 scale
    tags: List[str] = field(default_factory=list)
    image_url: Optional[str] = None


@dataclass
class QuizQuestion:
    """A single quiz question"""
    id: str
    question: str
    question_type: str  # multiple_choice, true_false, fill_blank, short_answer
    options: List[str] = field(default_factory=list)
    correct_answer: str = ""
    explanation: str = ""
    points: int = 1
    difficulty: str = "medium"  # easy, medium, hard
    tags: List[str] = field(default_factory=list)
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class Quiz:
    """A quiz with multiple questions"""
    title: str
    questions: List[QuizQuestion] = field(default_factory=list)
    passing_score: int = 70
    time_limit: Optional[int] = None  # minutes
    difficulty: DifficultyLevel = DifficultyLevel.BEGINNER


@dataclass
class Image:
    """Generated or sourced image"""
    url: str
    caption: str
    alt_text: str
    width: Optional[int] = None
    height: Optional[int] = None
    format: str = "png"


@dataclass
class ImageAsset:
    """Represents an image asset for a course"""
    id: str
    title: str
    description: str
    image_url: str
    local_path: Optional[str] = None
    image_type: str = "illustration"  # cover, illustration, concept, diagram, infographic
    lesson_id: Optional[int] = None
    tags: List[str] = field(default_factory=list)
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class ContentSource:
    """Represents a content source for research"""
    title: str
    url: str
    content: str
    source_type: str  # web, research, documentation, model, dataset, concept
    relevance_score: float = 0.5
    credibility_score: float = 0.5
    tags: List[str] = field(default_factory=list)
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class ResearchResult:
    """Results from research conducted for a topic"""
    topic: str
    sources: List[ContentSource] = field(default_factory=list)
    key_concepts: List[str] = field(default_factory=list)
    learning_objectives: List[str] = field(default_factory=list)
    difficulty_level: str = "intermediate"
    target_audience: str = "general"
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class CourseStructure:
    """High-level course structure and planning"""
    title: str
    description: str
    difficulty_level: str = "intermediate"
    estimated_duration: float = 2.0  # hours
    prerequisites: List[str] = field(default_factory=list)
    learning_objectives: List[str] = field(default_factory=list)
    lessons: List['Lesson'] = field(default_factory=list)  # Forward reference
    tags: List[str] = field(default_factory=list)
    target_audience: str = "general"
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class Lesson:
    """A single lesson in the course"""
    title: str
    content: str
    objectives: List[LearningObjective]
    duration: int  # minutes
    exercises: List[Exercise] = field(default_factory=list)
    images: List[Image] = field(default_factory=list)
    flashcards: List[Flashcard] = field(default_factory=list)
    quiz: Optional[Quiz] = None
    prerequisites: List[str] = field(default_factory=list)
    key_concepts: List[str] = field(default_factory=list)


@dataclass
class CourseMetadata:
    """Metadata about the course"""
    created_at: datetime
    topic: str
    difficulty: DifficultyLevel
    estimated_duration: int  # total minutes
    sources: List[Source]
    word_count: int
    lesson_count: int
    flashcard_count: int
    image_count: int
    target_audience: str = "general"
    prerequisites: List[str] = field(default_factory=list)
    learning_outcomes: List[str] = field(default_factory=list)


@dataclass
class Course:
    """Complete course structure"""
    title: str
    description: str
    lessons: List[Lesson]
    metadata: CourseMetadata
    flashcards: List[Flashcard] = field(default_factory=list)
    images: List[Image] = field(default_factory=list)
    summary: str = ""
    glossary: Dict[str, str] = field(default_factory=dict)
    resources: List[Source] = field(default_factory=list)


@dataclass
class ResearchData:
    """Research data collected for course generation"""
    topic: str
    sources: List[Source]
    key_concepts: List[str]
    content_outline: Dict[str, Any]
    related_topics: List[str] = field(default_factory=list)
    expert_quotes: List[str] = field(default_factory=list)
    statistics: List[str] = field(default_factory=list)


@dataclass
class CourseOutline:
    """High-level course structure"""
    title: str
    description: str
    difficulty: DifficultyLevel
    lesson_titles: List[str]
    learning_objectives: List[LearningObjective]
    estimated_duration: int
    prerequisites: List[str] = field(default_factory=list)


@dataclass
class GenerationOptions:
    """Options for course generation"""
    difficulty: DifficultyLevel = DifficultyLevel.BEGINNER
    lesson_count: int = 5
    include_audio: bool = False
    include_images: bool = True
    include_flashcards: bool = True
    include_quizzes: bool = True
    learning_style: LearningStyle = LearningStyle.VISUAL
    max_lesson_duration: int = 30  # minutes
    export_formats: List[ExportFormat] = field(default_factory=list)


@dataclass
class ExportResult:
    """Result of an export operation"""
    format: ExportFormat
    success: bool
    file_path: Optional[str] = None
    download_url: Optional[str] = None
    error_message: Optional[str] = None
    metadata: Dict[str, Any] = field(default_factory=dict)


@dataclass
class ProgressUpdate:
    """Progress update during course generation"""
    stage: str
    progress: float  # 0.0 to 1.0
    message: str
    details: Optional[Dict[str, Any]] = None
    timestamp: datetime = field(default_factory=datetime.now)


# LLM Provider Types
LLMProvider = Literal["openai", "anthropic", "google", "openai_compatible"]


@dataclass
class LLMConfig:
    """Configuration for LLM providers"""
    provider: LLMProvider
    model: str
    api_key: str
    temperature: float = 0.7
    max_tokens: Optional[int] = None
    timeout: int = 60

# API Response Types
@dataclass
class APIResponse:
    """Standard API response structure"""
    success: bool
    data: Optional[Any] = None
    error: Optional[str] = None
    metadata: Dict[str, Any] = field(default_factory=dict)


# Validation Types
@dataclass
class ValidationResult:
    """Result of content validation"""
    is_valid: bool
    score: float  # 0.0 to 1.0
    issues: List[str] = field(default_factory=list)
    suggestions: List[str] = field(default_factory=list)


# Stream Types for real-time updates
@dataclass
class StreamChunk:
    """Chunk of streaming data"""
    type: Literal["text", "tool_call", "progress", "error"]
    content: str
    metadata: Dict[str, Any] = field(default_factory=dict)