learngraph 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -21
- package/README.md +165 -3
- package/dist/cjs/llm/adapters/anthropic.js +124 -0
- package/dist/cjs/llm/adapters/anthropic.js.map +1 -0
- package/dist/cjs/llm/adapters/base.js +100 -0
- package/dist/cjs/llm/adapters/base.js.map +1 -0
- package/dist/cjs/llm/adapters/index.js +22 -0
- package/dist/cjs/llm/adapters/index.js.map +1 -0
- package/dist/cjs/llm/adapters/ollama.js +149 -0
- package/dist/cjs/llm/adapters/ollama.js.map +1 -0
- package/dist/cjs/llm/adapters/openai.js +126 -0
- package/dist/cjs/llm/adapters/openai.js.map +1 -0
- package/dist/cjs/llm/index.js +34 -5
- package/dist/cjs/llm/index.js.map +1 -1
- package/dist/cjs/llm/orchestrator.js +219 -0
- package/dist/cjs/llm/orchestrator.js.map +1 -0
- package/dist/cjs/llm/prompts.js +367 -0
- package/dist/cjs/llm/prompts.js.map +1 -0
- package/dist/cjs/parsers/base.js +189 -0
- package/dist/cjs/parsers/base.js.map +1 -0
- package/dist/cjs/parsers/demo.js +159 -0
- package/dist/cjs/parsers/demo.js.map +1 -0
- package/dist/cjs/parsers/extractor.js +191 -0
- package/dist/cjs/parsers/extractor.js.map +1 -0
- package/dist/cjs/parsers/index.js +43 -4
- package/dist/cjs/parsers/index.js.map +1 -1
- package/dist/cjs/parsers/json.js +157 -0
- package/dist/cjs/parsers/json.js.map +1 -0
- package/dist/cjs/parsers/markdown.js +168 -0
- package/dist/cjs/parsers/markdown.js.map +1 -0
- package/dist/cjs/parsers/samples.js +139 -0
- package/dist/cjs/parsers/samples.js.map +1 -0
- package/dist/cjs/storage/base.js +231 -0
- package/dist/cjs/storage/base.js.map +1 -0
- package/dist/cjs/storage/errors.js +128 -0
- package/dist/cjs/storage/errors.js.map +1 -0
- package/dist/cjs/storage/index.js +92 -5
- package/dist/cjs/storage/index.js.map +1 -1
- package/dist/cjs/storage/levelgraph.js +855 -0
- package/dist/cjs/storage/levelgraph.js.map +1 -0
- package/dist/cjs/storage/memory.js +447 -0
- package/dist/cjs/storage/memory.js.map +1 -0
- package/dist/cjs/storage/neo4j.js +866 -0
- package/dist/cjs/storage/neo4j.js.map +1 -0
- package/dist/cjs/storage/seeds.js +565 -0
- package/dist/cjs/storage/seeds.js.map +1 -0
- package/dist/cjs/types/llm.js +8 -0
- package/dist/cjs/types/llm.js.map +1 -0
- package/dist/cjs/types/parser.js +8 -0
- package/dist/cjs/types/parser.js.map +1 -0
- package/dist/esm/llm/adapters/anthropic.js +119 -0
- package/dist/esm/llm/adapters/anthropic.js.map +1 -0
- package/dist/esm/llm/adapters/base.js +95 -0
- package/dist/esm/llm/adapters/base.js.map +1 -0
- package/dist/esm/llm/adapters/index.js +10 -0
- package/dist/esm/llm/adapters/index.js.map +1 -0
- package/dist/esm/llm/adapters/ollama.js +144 -0
- package/dist/esm/llm/adapters/ollama.js.map +1 -0
- package/dist/esm/llm/adapters/openai.js +121 -0
- package/dist/esm/llm/adapters/openai.js.map +1 -0
- package/dist/esm/llm/index.js +12 -6
- package/dist/esm/llm/index.js.map +1 -1
- package/dist/esm/llm/orchestrator.js +214 -0
- package/dist/esm/llm/orchestrator.js.map +1 -0
- package/dist/esm/llm/prompts.js +360 -0
- package/dist/esm/llm/prompts.js.map +1 -0
- package/dist/esm/parsers/base.js +179 -0
- package/dist/esm/parsers/base.js.map +1 -0
- package/dist/esm/parsers/demo.js +154 -0
- package/dist/esm/parsers/demo.js.map +1 -0
- package/dist/esm/parsers/extractor.js +187 -0
- package/dist/esm/parsers/extractor.js.map +1 -0
- package/dist/esm/parsers/index.js +24 -5
- package/dist/esm/parsers/index.js.map +1 -1
- package/dist/esm/parsers/json.js +153 -0
- package/dist/esm/parsers/json.js.map +1 -0
- package/dist/esm/parsers/markdown.js +164 -0
- package/dist/esm/parsers/markdown.js.map +1 -0
- package/dist/esm/parsers/samples.js +136 -0
- package/dist/esm/parsers/samples.js.map +1 -0
- package/dist/esm/storage/base.js +221 -0
- package/dist/esm/storage/base.js.map +1 -0
- package/dist/esm/storage/errors.js +116 -0
- package/dist/esm/storage/errors.js.map +1 -0
- package/dist/esm/storage/index.js +71 -6
- package/dist/esm/storage/index.js.map +1 -1
- package/dist/esm/storage/levelgraph.js +818 -0
- package/dist/esm/storage/levelgraph.js.map +1 -0
- package/dist/esm/storage/memory.js +443 -0
- package/dist/esm/storage/memory.js.map +1 -0
- package/dist/esm/storage/neo4j.js +829 -0
- package/dist/esm/storage/neo4j.js.map +1 -0
- package/dist/esm/storage/seeds.js +561 -0
- package/dist/esm/storage/seeds.js.map +1 -0
- package/dist/esm/types/llm.js +7 -0
- package/dist/esm/types/llm.js.map +1 -0
- package/dist/esm/types/parser.js +7 -0
- package/dist/esm/types/parser.js.map +1 -0
- package/dist/types/llm/adapters/anthropic.d.ts +21 -0
- package/dist/types/llm/adapters/anthropic.d.ts.map +1 -0
- package/dist/types/llm/adapters/base.d.ts +46 -0
- package/dist/types/llm/adapters/base.d.ts.map +1 -0
- package/dist/types/llm/adapters/index.d.ts +11 -0
- package/dist/types/llm/adapters/index.d.ts.map +1 -0
- package/dist/types/llm/adapters/ollama.d.ts +30 -0
- package/dist/types/llm/adapters/ollama.d.ts.map +1 -0
- package/dist/types/llm/adapters/openai.d.ts +22 -0
- package/dist/types/llm/adapters/openai.d.ts.map +1 -0
- package/dist/types/llm/index.d.ts +5 -0
- package/dist/types/llm/index.d.ts.map +1 -1
- package/dist/types/llm/orchestrator.d.ts +35 -0
- package/dist/types/llm/orchestrator.d.ts.map +1 -0
- package/dist/types/llm/prompts.d.ts +269 -0
- package/dist/types/llm/prompts.d.ts.map +1 -0
- package/dist/types/parsers/base.d.ts +39 -0
- package/dist/types/parsers/base.d.ts.map +1 -0
- package/dist/types/parsers/demo.d.ts +87 -0
- package/dist/types/parsers/demo.d.ts.map +1 -0
- package/dist/types/parsers/extractor.d.ts +43 -0
- package/dist/types/parsers/extractor.d.ts.map +1 -0
- package/dist/types/parsers/index.d.ts +10 -0
- package/dist/types/parsers/index.d.ts.map +1 -1
- package/dist/types/parsers/json.d.ts +71 -0
- package/dist/types/parsers/json.d.ts.map +1 -0
- package/dist/types/parsers/markdown.d.ts +43 -0
- package/dist/types/parsers/markdown.d.ts.map +1 -0
- package/dist/types/parsers/samples.d.ts +27 -0
- package/dist/types/parsers/samples.d.ts.map +1 -0
- package/dist/types/storage/base.d.ts +39 -0
- package/dist/types/storage/base.d.ts.map +1 -0
- package/dist/types/storage/errors.d.ts +74 -0
- package/dist/types/storage/errors.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +50 -2
- package/dist/types/storage/index.d.ts.map +1 -1
- package/dist/types/storage/levelgraph.d.ts +92 -0
- package/dist/types/storage/levelgraph.d.ts.map +1 -0
- package/dist/types/storage/memory.d.ts +70 -0
- package/dist/types/storage/memory.d.ts.map +1 -0
- package/dist/types/storage/neo4j.d.ts +88 -0
- package/dist/types/storage/neo4j.d.ts.map +1 -0
- package/dist/types/storage/seeds.d.ts +27 -0
- package/dist/types/storage/seeds.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/llm.d.ts +298 -0
- package/dist/types/types/llm.d.ts.map +1 -0
- package/dist/types/types/parser.d.ts +208 -0
- package/dist/types/types/parser.d.ts.map +1 -0
- package/package.json +4 -2
- package/scripts/postinstall.js +68 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Prompts for LLM-based educational tasks
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DECOMPOSITION_SCHEMA = exports.BLOOM_ANALYSIS_SCHEMA = exports.PREREQUISITE_SCHEMA = exports.EXTRACTION_SCHEMA = exports.SYSTEM_PROMPTS = void 0;
|
|
9
|
+
exports.buildExtractionPrompt = buildExtractionPrompt;
|
|
10
|
+
exports.buildPrerequisitePrompt = buildPrerequisitePrompt;
|
|
11
|
+
exports.buildBloomPrompt = buildBloomPrompt;
|
|
12
|
+
exports.buildDecompositionPrompt = buildDecompositionPrompt;
|
|
13
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
14
|
+
// System Prompts
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
exports.SYSTEM_PROMPTS = {
|
|
17
|
+
skillExtraction: `You are an expert educational curriculum analyst specializing in competency-based education and learning science.
|
|
18
|
+
|
|
19
|
+
Your task is to analyze curriculum content and extract discrete, measurable skills that learners should master.
|
|
20
|
+
|
|
21
|
+
For each skill you identify:
|
|
22
|
+
1. Name: A concise, action-oriented name (e.g., "Calculate derivative of polynomial")
|
|
23
|
+
2. Description: A clear explanation of what mastery of this skill looks like
|
|
24
|
+
3. Bloom's Level: Classify using Bloom's Taxonomy (remember, understand, apply, analyze, evaluate, create)
|
|
25
|
+
4. Difficulty: Estimate difficulty on a 0-1 scale based on cognitive complexity
|
|
26
|
+
5. Threshold Concept: Identify if this is a transformative "gateway" skill that changes understanding
|
|
27
|
+
6. Estimated Time: How long a typical learner needs to achieve mastery
|
|
28
|
+
|
|
29
|
+
Focus on:
|
|
30
|
+
- Observable, measurable outcomes
|
|
31
|
+
- Skills that can be assessed
|
|
32
|
+
- Appropriate granularity (not too broad, not too narrow)
|
|
33
|
+
- Clear prerequisite relationships
|
|
34
|
+
|
|
35
|
+
Bloom's Level Guidelines:
|
|
36
|
+
- remember (0.20): Recall facts, terms, basic concepts
|
|
37
|
+
- understand (0.35): Explain ideas, interpret, summarize
|
|
38
|
+
- apply (0.50): Use information in new situations, solve problems
|
|
39
|
+
- analyze (0.65): Draw connections, organize, compare, contrast
|
|
40
|
+
- evaluate (0.80): Justify decisions, make judgments, critique
|
|
41
|
+
- create (0.90): Produce new work, design, construct`,
|
|
42
|
+
prerequisiteInference: `You are an expert in learning science and curriculum design, specializing in prerequisite mapping and learning path optimization.
|
|
43
|
+
|
|
44
|
+
Your task is to analyze skills and infer prerequisite relationships between them.
|
|
45
|
+
|
|
46
|
+
For each prerequisite relationship:
|
|
47
|
+
1. Identify which skill must be learned first (source/prerequisite)
|
|
48
|
+
2. Identify which skill depends on it (target/dependent)
|
|
49
|
+
3. Classify the relationship type:
|
|
50
|
+
- hard: Absolutely required - cannot learn target without source
|
|
51
|
+
- soft: Strongly beneficial but not strictly required
|
|
52
|
+
- recommended: Helpful for optimal learning path
|
|
53
|
+
4. Estimate strength (0-1): How critical is this prerequisite?
|
|
54
|
+
5. Provide clear reasoning for the relationship
|
|
55
|
+
|
|
56
|
+
Consider:
|
|
57
|
+
- Bloom's level progression (lower levels typically prerequisite to higher)
|
|
58
|
+
- Conceptual dependencies (foundational concepts before advanced)
|
|
59
|
+
- Skill hierarchies within domains
|
|
60
|
+
- Transfer of learning between related skills
|
|
61
|
+
- Avoid circular dependencies`,
|
|
62
|
+
bloomAnalysis: `You are an expert in Bloom's Taxonomy and educational assessment design.
|
|
63
|
+
|
|
64
|
+
Analyze the given text and determine its cognitive level according to Bloom's Taxonomy:
|
|
65
|
+
|
|
66
|
+
1. remember - Recall facts and basic concepts
|
|
67
|
+
Verbs: define, identify, list, name, recall, recognize, state
|
|
68
|
+
|
|
69
|
+
2. understand - Explain ideas or concepts
|
|
70
|
+
Verbs: describe, explain, interpret, summarize, classify, compare
|
|
71
|
+
|
|
72
|
+
3. apply - Use information in new situations
|
|
73
|
+
Verbs: apply, calculate, solve, demonstrate, implement, use
|
|
74
|
+
|
|
75
|
+
4. analyze - Draw connections among ideas
|
|
76
|
+
Verbs: analyze, compare, contrast, differentiate, examine, organize
|
|
77
|
+
|
|
78
|
+
5. evaluate - Justify a decision or course of action
|
|
79
|
+
Verbs: evaluate, assess, critique, judge, justify, recommend
|
|
80
|
+
|
|
81
|
+
6. create - Produce new or original work
|
|
82
|
+
Verbs: create, design, develop, construct, formulate, produce
|
|
83
|
+
|
|
84
|
+
Provide:
|
|
85
|
+
- The Bloom's level
|
|
86
|
+
- Confidence score (0-1)
|
|
87
|
+
- Key indicators (verbs/phrases) that led to this classification
|
|
88
|
+
- Brief reasoning`,
|
|
89
|
+
curriculumDecomposition: `You are an expert curriculum designer and learning scientist.
|
|
90
|
+
|
|
91
|
+
Your task is to decompose curriculum content into a structured skill graph suitable for adaptive learning systems.
|
|
92
|
+
|
|
93
|
+
Process:
|
|
94
|
+
1. Identify the overall learning goals and outcomes
|
|
95
|
+
2. Break down content into discrete, measurable skills
|
|
96
|
+
3. Classify each skill by Bloom's level and difficulty
|
|
97
|
+
4. Identify threshold concepts (transformative gateway skills)
|
|
98
|
+
5. Map prerequisite relationships between skills
|
|
99
|
+
6. Ensure appropriate granularity for personalized learning
|
|
100
|
+
|
|
101
|
+
Output a complete skill graph with:
|
|
102
|
+
- Skills: Name, description, Bloom's level, difficulty, estimated time
|
|
103
|
+
- Prerequisites: Source skill, target skill, type, strength, reasoning
|
|
104
|
+
|
|
105
|
+
Principles:
|
|
106
|
+
- Every skill should be assessable
|
|
107
|
+
- Skills should be at appropriate granularity (15-45 min to master)
|
|
108
|
+
- Clear progression from foundational to advanced
|
|
109
|
+
- Identify threshold concepts that unlock new understanding
|
|
110
|
+
- Consider both hard prerequisites (required) and soft (beneficial)`,
|
|
111
|
+
};
|
|
112
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
113
|
+
// JSON Schemas for Structured Output
|
|
114
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
115
|
+
exports.EXTRACTION_SCHEMA = {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
skills: {
|
|
119
|
+
type: 'array',
|
|
120
|
+
items: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
properties: {
|
|
123
|
+
name: { type: 'string', description: 'Concise, action-oriented skill name' },
|
|
124
|
+
description: { type: 'string', description: 'What mastery of this skill looks like' },
|
|
125
|
+
bloomLevel: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
|
|
128
|
+
description: "Bloom's Taxonomy level",
|
|
129
|
+
},
|
|
130
|
+
difficulty: {
|
|
131
|
+
type: 'number',
|
|
132
|
+
minimum: 0,
|
|
133
|
+
maximum: 1,
|
|
134
|
+
description: 'Difficulty on 0-1 scale',
|
|
135
|
+
},
|
|
136
|
+
confidence: {
|
|
137
|
+
type: 'number',
|
|
138
|
+
minimum: 0,
|
|
139
|
+
maximum: 1,
|
|
140
|
+
description: 'Confidence in this extraction',
|
|
141
|
+
},
|
|
142
|
+
isThresholdConcept: {
|
|
143
|
+
type: 'boolean',
|
|
144
|
+
description: 'Is this a transformative gateway skill?',
|
|
145
|
+
},
|
|
146
|
+
estimatedMinutes: {
|
|
147
|
+
type: 'number',
|
|
148
|
+
description: 'Estimated time to master in minutes',
|
|
149
|
+
},
|
|
150
|
+
keywords: {
|
|
151
|
+
type: 'array',
|
|
152
|
+
items: { type: 'string' },
|
|
153
|
+
description: 'Associated keywords/concepts',
|
|
154
|
+
},
|
|
155
|
+
reasoning: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
description: 'Why this skill was extracted',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
required: ['name', 'description', 'bloomLevel', 'difficulty', 'confidence'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
warnings: {
|
|
164
|
+
type: 'array',
|
|
165
|
+
items: { type: 'string' },
|
|
166
|
+
description: 'Any warnings or notes about the extraction',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
required: ['skills'],
|
|
170
|
+
};
|
|
171
|
+
exports.PREREQUISITE_SCHEMA = {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
prerequisites: {
|
|
175
|
+
type: 'array',
|
|
176
|
+
items: {
|
|
177
|
+
type: 'object',
|
|
178
|
+
properties: {
|
|
179
|
+
sourceId: { type: 'string', description: 'ID of the prerequisite skill' },
|
|
180
|
+
targetId: { type: 'string', description: 'ID of the dependent skill' },
|
|
181
|
+
strength: {
|
|
182
|
+
type: 'number',
|
|
183
|
+
minimum: 0,
|
|
184
|
+
maximum: 1,
|
|
185
|
+
description: 'How critical is this prerequisite (0-1)',
|
|
186
|
+
},
|
|
187
|
+
type: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
enum: ['hard', 'soft', 'recommended'],
|
|
190
|
+
description: 'Type of prerequisite relationship',
|
|
191
|
+
},
|
|
192
|
+
confidence: {
|
|
193
|
+
type: 'number',
|
|
194
|
+
minimum: 0,
|
|
195
|
+
maximum: 1,
|
|
196
|
+
description: 'Confidence in this inference',
|
|
197
|
+
},
|
|
198
|
+
reasoning: {
|
|
199
|
+
type: 'string',
|
|
200
|
+
description: 'Why this prerequisite relationship exists',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
required: ['sourceId', 'targetId', 'strength', 'type', 'confidence', 'reasoning'],
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
required: ['prerequisites'],
|
|
208
|
+
};
|
|
209
|
+
exports.BLOOM_ANALYSIS_SCHEMA = {
|
|
210
|
+
type: 'object',
|
|
211
|
+
properties: {
|
|
212
|
+
level: {
|
|
213
|
+
type: 'string',
|
|
214
|
+
enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
|
|
215
|
+
description: "Detected Bloom's level",
|
|
216
|
+
},
|
|
217
|
+
confidence: {
|
|
218
|
+
type: 'number',
|
|
219
|
+
minimum: 0,
|
|
220
|
+
maximum: 1,
|
|
221
|
+
description: 'Confidence in detection',
|
|
222
|
+
},
|
|
223
|
+
indicators: {
|
|
224
|
+
type: 'array',
|
|
225
|
+
items: { type: 'string' },
|
|
226
|
+
description: 'Key verbs/phrases indicating this level',
|
|
227
|
+
},
|
|
228
|
+
reasoning: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'Explanation for the classification',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
required: ['level', 'confidence', 'indicators', 'reasoning'],
|
|
234
|
+
};
|
|
235
|
+
exports.DECOMPOSITION_SCHEMA = {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
title: { type: 'string', description: 'Course/curriculum title' },
|
|
239
|
+
skills: {
|
|
240
|
+
type: 'array',
|
|
241
|
+
items: {
|
|
242
|
+
type: 'object',
|
|
243
|
+
properties: {
|
|
244
|
+
id: { type: 'string', description: 'Unique skill identifier' },
|
|
245
|
+
name: { type: 'string' },
|
|
246
|
+
description: { type: 'string' },
|
|
247
|
+
bloomLevel: {
|
|
248
|
+
type: 'string',
|
|
249
|
+
enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
|
|
250
|
+
},
|
|
251
|
+
difficulty: { type: 'number', minimum: 0, maximum: 1 },
|
|
252
|
+
isThresholdConcept: { type: 'boolean' },
|
|
253
|
+
estimatedMinutes: { type: 'number' },
|
|
254
|
+
keywords: { type: 'array', items: { type: 'string' } },
|
|
255
|
+
},
|
|
256
|
+
required: ['id', 'name', 'description', 'bloomLevel', 'difficulty'],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
prerequisites: {
|
|
260
|
+
type: 'array',
|
|
261
|
+
items: {
|
|
262
|
+
type: 'object',
|
|
263
|
+
properties: {
|
|
264
|
+
sourceId: { type: 'string' },
|
|
265
|
+
targetId: { type: 'string' },
|
|
266
|
+
strength: { type: 'number', minimum: 0, maximum: 1 },
|
|
267
|
+
type: { type: 'string', enum: ['hard', 'soft', 'recommended'] },
|
|
268
|
+
reasoning: { type: 'string' },
|
|
269
|
+
},
|
|
270
|
+
required: ['sourceId', 'targetId', 'strength', 'type'],
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
warnings: {
|
|
274
|
+
type: 'array',
|
|
275
|
+
items: { type: 'string' },
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
required: ['title', 'skills', 'prerequisites'],
|
|
279
|
+
};
|
|
280
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
281
|
+
// Prompt Builders
|
|
282
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
283
|
+
/**
|
|
284
|
+
* Build a skill extraction prompt
|
|
285
|
+
*/
|
|
286
|
+
function buildExtractionPrompt(content, options) {
|
|
287
|
+
let prompt = `Analyze the following curriculum content and extract all discrete, measurable skills.\n\n`;
|
|
288
|
+
if (options?.domain) {
|
|
289
|
+
prompt += `Domain: ${options.domain}\n`;
|
|
290
|
+
}
|
|
291
|
+
if (options?.gradeLevel) {
|
|
292
|
+
prompt += `Target Audience: ${options.gradeLevel}\n`;
|
|
293
|
+
}
|
|
294
|
+
if (options?.context) {
|
|
295
|
+
prompt += `Additional Context: ${options.context}\n`;
|
|
296
|
+
}
|
|
297
|
+
prompt += `\n--- CURRICULUM CONTENT ---\n${content}\n--- END CONTENT ---\n\n`;
|
|
298
|
+
prompt += `Extract all skills from this content. For each skill, provide name, description, Bloom's level, difficulty (0-1), and identify if it's a threshold concept.`;
|
|
299
|
+
return prompt;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Build a prerequisite inference prompt
|
|
303
|
+
*/
|
|
304
|
+
function buildPrerequisitePrompt(skills, options) {
|
|
305
|
+
let prompt = `Analyze the following skills and infer prerequisite relationships between them.\n\n`;
|
|
306
|
+
if (options?.domain) {
|
|
307
|
+
prompt += `Domain: ${options.domain}\n`;
|
|
308
|
+
}
|
|
309
|
+
prompt += `\n--- SKILLS ---\n`;
|
|
310
|
+
for (const skill of skills) {
|
|
311
|
+
prompt += `ID: ${skill.id}\n`;
|
|
312
|
+
prompt += `Name: ${skill.name}\n`;
|
|
313
|
+
prompt += `Description: ${skill.description}\n`;
|
|
314
|
+
prompt += `Bloom's Level: ${skill.bloomLevel}\n`;
|
|
315
|
+
prompt += `Difficulty: ${skill.difficulty}\n\n`;
|
|
316
|
+
}
|
|
317
|
+
prompt += `--- END SKILLS ---\n\n`;
|
|
318
|
+
prompt += `For each prerequisite relationship you identify:\n`;
|
|
319
|
+
prompt += `1. Specify sourceId (prerequisite) and targetId (dependent)\n`;
|
|
320
|
+
prompt += `2. Classify as hard, soft, or recommended\n`;
|
|
321
|
+
prompt += `3. Provide strength (0-1) and reasoning\n`;
|
|
322
|
+
if (options?.inferTransitive === false) {
|
|
323
|
+
prompt += `\nNote: Only infer direct prerequisites, not transitive ones.`;
|
|
324
|
+
}
|
|
325
|
+
return prompt;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Build a Bloom's analysis prompt
|
|
329
|
+
*/
|
|
330
|
+
function buildBloomPrompt(text, context) {
|
|
331
|
+
let prompt = `Analyze the following text and determine its Bloom's Taxonomy level.\n\n`;
|
|
332
|
+
if (context) {
|
|
333
|
+
prompt += `Context: ${context}\n\n`;
|
|
334
|
+
}
|
|
335
|
+
prompt += `--- TEXT ---\n${text}\n--- END TEXT ---\n\n`;
|
|
336
|
+
prompt += `Classify this text according to Bloom's Taxonomy (remember, understand, apply, analyze, evaluate, create).`;
|
|
337
|
+
return prompt;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Build a curriculum decomposition prompt
|
|
341
|
+
*/
|
|
342
|
+
function buildDecompositionPrompt(content, options) {
|
|
343
|
+
let prompt = `Decompose the following curriculum into a complete skill graph.\n\n`;
|
|
344
|
+
if (options?.title) {
|
|
345
|
+
prompt += `Course Title: ${options.title}\n`;
|
|
346
|
+
}
|
|
347
|
+
if (options?.domain) {
|
|
348
|
+
prompt += `Domain: ${options.domain}\n`;
|
|
349
|
+
}
|
|
350
|
+
if (options?.gradeLevel) {
|
|
351
|
+
prompt += `Target Audience: ${options.gradeLevel}\n`;
|
|
352
|
+
}
|
|
353
|
+
if (options?.context) {
|
|
354
|
+
prompt += `Additional Context: ${options.context}\n`;
|
|
355
|
+
}
|
|
356
|
+
if (options?.maxDepth) {
|
|
357
|
+
prompt += `Maximum Skill Hierarchy Depth: ${options.maxDepth}\n`;
|
|
358
|
+
}
|
|
359
|
+
prompt += `\n--- CURRICULUM CONTENT ---\n${content}\n--- END CONTENT ---\n\n`;
|
|
360
|
+
prompt += `Create a complete skill graph with:\n`;
|
|
361
|
+
prompt += `1. All discrete, measurable skills with unique IDs\n`;
|
|
362
|
+
prompt += `2. Bloom's level and difficulty for each skill\n`;
|
|
363
|
+
prompt += `3. Prerequisite relationships between skills\n`;
|
|
364
|
+
prompt += `4. Identify threshold concepts that unlock understanding\n`;
|
|
365
|
+
return prompt;
|
|
366
|
+
}
|
|
367
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/llm/prompts.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAgSH,sDAwBC;AAKD,0DAuCC;AAKD,4CAWC;AAKD,4DAoCC;AAzZD,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEnE,QAAA,cAAc,GAAG;IAC5B,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;qDAwBkC;IAEnD,qBAAqB,EAAE;;;;;;;;;;;;;;;;;;;8BAmBK;IAE5B,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BC;IAEhB,uBAAuB,EAAE;;;;;;;;;;;;;;;;;;;;;oEAqByC;CACnE,CAAC;AAEF,gFAAgF;AAChF,qCAAqC;AACrC,gFAAgF;AAEnE,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;oBAC5E,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,W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;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CACtC,OAAe,EACf,OAMC;IAED,IAAI,MAAM,GAAG,qEAAqE,CAAC;IAEnF,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,iBAAiB,OAAO,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IACD,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,WAAW,OAAO,CAAC,MAAM,IAAI,CAAC;IAC1C,CAAC;IACD,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,MAAM,IAAI,oBAAoB,OAAO,CAAC,UAAU,IAAI,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,uBAAuB,OAAO,CAAC,OAAO,IAAI,CAAC;IACvD,CAAC;IACD,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;QACtB,MAAM,IAAI,kCAAkC,OAAO,CAAC,QAAQ,IAAI,CAAC;IACnE,CAAC;IAED,MAAM,IAAI,iCAAiC,OAAO,2BAA2B,CAAC;IAC9E,MAAM,IAAI,uCAAuC,CAAC;IAClD,MAAM,IAAI,sDAAsD,CAAC;IACjE,MAAM,IAAI,kDAAkD,CAAC;IAC7D,MAAM,IAAI,gDAAgD,CAAC;IAC3D,MAAM,IAAI,4DAA4D,CAAC;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base parser utilities
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEFAULT_PARSE_OPTIONS = void 0;
|
|
9
|
+
exports.extractTime = extractTime;
|
|
10
|
+
exports.isObjectiveLine = isObjectiveLine;
|
|
11
|
+
exports.cleanText = cleanText;
|
|
12
|
+
exports.objectiveToSkillName = objectiveToSkillName;
|
|
13
|
+
exports.createObjective = createObjective;
|
|
14
|
+
exports.createEmptyResult = createEmptyResult;
|
|
15
|
+
exports.calculateStats = calculateStats;
|
|
16
|
+
const bloom_js_1 = require("../types/bloom.js");
|
|
17
|
+
/**
|
|
18
|
+
* Default parse options
|
|
19
|
+
*/
|
|
20
|
+
exports.DEFAULT_PARSE_OPTIONS = {
|
|
21
|
+
detectBloom: true,
|
|
22
|
+
extractTime: true,
|
|
23
|
+
suggestNames: true,
|
|
24
|
+
includeRaw: false,
|
|
25
|
+
sectionHeaders: [
|
|
26
|
+
'module',
|
|
27
|
+
'chapter',
|
|
28
|
+
'unit',
|
|
29
|
+
'week',
|
|
30
|
+
'section',
|
|
31
|
+
'part',
|
|
32
|
+
'lesson',
|
|
33
|
+
'topic',
|
|
34
|
+
],
|
|
35
|
+
objectiveMarkers: [
|
|
36
|
+
'students will be able to',
|
|
37
|
+
'learners will',
|
|
38
|
+
'by the end of this',
|
|
39
|
+
'learning objectives',
|
|
40
|
+
'objectives:',
|
|
41
|
+
'learning outcomes',
|
|
42
|
+
'outcomes:',
|
|
43
|
+
'lo:',
|
|
44
|
+
'swbat',
|
|
45
|
+
'•',
|
|
46
|
+
'-',
|
|
47
|
+
'*',
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Common time patterns in syllabi
|
|
52
|
+
* Note: Decimal hours pattern must come before integer hours pattern
|
|
53
|
+
*/
|
|
54
|
+
const TIME_PATTERNS = [
|
|
55
|
+
/(\d+)\s*(?:min(?:ute)?s?|mins?)/i,
|
|
56
|
+
/(\d+\.\d+)\s*(?:hour?s?|hrs?)/i,
|
|
57
|
+
/(\d+)\s*(?:hour?s?|hrs?)/i,
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Extract estimated time from text
|
|
61
|
+
*/
|
|
62
|
+
function extractTime(text) {
|
|
63
|
+
for (const pattern of TIME_PATTERNS) {
|
|
64
|
+
const match = text.match(pattern);
|
|
65
|
+
if (match && match[1]) {
|
|
66
|
+
const value = parseFloat(match[1]);
|
|
67
|
+
if (pattern.source.includes('hour')) {
|
|
68
|
+
return Math.round(value * 60);
|
|
69
|
+
}
|
|
70
|
+
return Math.round(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Detect if a line is a learning objective
|
|
77
|
+
*/
|
|
78
|
+
function isObjectiveLine(line, markers) {
|
|
79
|
+
const lower = line.toLowerCase().trim();
|
|
80
|
+
return markers.some((marker) => lower.includes(marker.toLowerCase()));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Clean and normalize text
|
|
84
|
+
*/
|
|
85
|
+
function cleanText(text) {
|
|
86
|
+
return text
|
|
87
|
+
.replace(/\s+/g, ' ')
|
|
88
|
+
.replace(/^\s*[-•*]\s*/, '')
|
|
89
|
+
.replace(/^\d+\.\s*/, '')
|
|
90
|
+
.trim();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate a skill name from an objective
|
|
94
|
+
*/
|
|
95
|
+
function objectiveToSkillName(objective) {
|
|
96
|
+
const cleaned = cleanText(objective);
|
|
97
|
+
// Remove common prefixes
|
|
98
|
+
const prefixes = [
|
|
99
|
+
/^students will be able to\s+/i,
|
|
100
|
+
/^learners will\s+/i,
|
|
101
|
+
/^by the end of this [\w\s]+,?\s*/i,
|
|
102
|
+
/^the student will\s+/i,
|
|
103
|
+
/^understand\s+/i,
|
|
104
|
+
/^learn\s+/i,
|
|
105
|
+
];
|
|
106
|
+
let result = cleaned;
|
|
107
|
+
for (const prefix of prefixes) {
|
|
108
|
+
result = result.replace(prefix, '');
|
|
109
|
+
}
|
|
110
|
+
// Capitalize first letter
|
|
111
|
+
result = result.charAt(0).toUpperCase() + result.slice(1);
|
|
112
|
+
// Truncate if too long
|
|
113
|
+
if (result.length > 80) {
|
|
114
|
+
result = result.substring(0, 77) + '...';
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a learning objective from text
|
|
120
|
+
*/
|
|
121
|
+
function createObjective(text, section, week) {
|
|
122
|
+
const cleaned = cleanText(text);
|
|
123
|
+
const bloomLevel = (0, bloom_js_1.detectBloomLevel)(cleaned);
|
|
124
|
+
const objective = {
|
|
125
|
+
text: cleaned,
|
|
126
|
+
bloomLevel,
|
|
127
|
+
bloomConfidence: bloomLevel ? 0.8 : 0,
|
|
128
|
+
suggestedName: objectiveToSkillName(cleaned),
|
|
129
|
+
};
|
|
130
|
+
if (section !== undefined) {
|
|
131
|
+
objective.section = section;
|
|
132
|
+
}
|
|
133
|
+
if (week !== undefined) {
|
|
134
|
+
objective.week = week;
|
|
135
|
+
}
|
|
136
|
+
return objective;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create empty parse result
|
|
140
|
+
*/
|
|
141
|
+
function createEmptyResult(source, format) {
|
|
142
|
+
return {
|
|
143
|
+
metadata: {
|
|
144
|
+
source,
|
|
145
|
+
format,
|
|
146
|
+
parsedAt: new Date().toISOString(),
|
|
147
|
+
},
|
|
148
|
+
modules: [],
|
|
149
|
+
topics: [],
|
|
150
|
+
objectives: [],
|
|
151
|
+
warnings: [],
|
|
152
|
+
stats: {
|
|
153
|
+
moduleCount: 0,
|
|
154
|
+
topicCount: 0,
|
|
155
|
+
objectiveCount: 0,
|
|
156
|
+
bloomDetectedCount: 0,
|
|
157
|
+
durationMs: 0,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Calculate parse statistics
|
|
163
|
+
*/
|
|
164
|
+
function calculateStats(result, startTime) {
|
|
165
|
+
let objectiveCount = result.objectives.length;
|
|
166
|
+
let bloomDetectedCount = result.objectives.filter((o) => o.bloomLevel).length;
|
|
167
|
+
for (const topic of result.topics) {
|
|
168
|
+
objectiveCount += topic.objectives.length;
|
|
169
|
+
bloomDetectedCount += topic.objectives.filter((o) => o.bloomLevel).length;
|
|
170
|
+
}
|
|
171
|
+
for (const mod of result.modules) {
|
|
172
|
+
objectiveCount += mod.objectives.length;
|
|
173
|
+
bloomDetectedCount += mod.objectives.filter((o) => o.bloomLevel).length;
|
|
174
|
+
for (const topic of mod.topics) {
|
|
175
|
+
objectiveCount += topic.objectives.length;
|
|
176
|
+
bloomDetectedCount += topic.objectives.filter((o) => o.bloomLevel).length;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const topicCount = result.topics.length +
|
|
180
|
+
result.modules.reduce((sum, m) => sum + m.topics.length, 0);
|
|
181
|
+
return {
|
|
182
|
+
moduleCount: result.modules.length,
|
|
183
|
+
topicCount,
|
|
184
|
+
objectiveCount,
|
|
185
|
+
bloomDetectedCount,
|
|
186
|
+
durationMs: Date.now() - startTime,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/parsers/base.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA0DH,kCAYC;AAKD,0CAGC;AAKD,8BAMC;AAKD,oDA2BC;AAKD,0CAuBC;AAKD,8CAsBC;AAKD,wCA6BC;AAzMD,gDAAqD;AAErD;;GAEG;AACU,QAAA,qBAAqB,GAA2B;IAC3D,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,KAAK;IACjB,cAAc,EAAE;QACd,QAAQ;QACR,SAAS;QACT,MAAM;QACN,MAAM;QACN,SAAS;QACT,MAAM;QACN,QAAQ;QACR,OAAO;KACR;IACD,gBAAgB,EAAE;QAChB,0BAA0B;QAC1B,eAAe;QACf,oBAAoB;QACpB,qBAAqB;QACrB,aAAa;QACb,mBAAmB;QACnB,WAAW;QACX,KAAK;QACL,OA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