learngraph 0.2.0 → 0.4.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.
Files changed (76) hide show
  1. package/README.md +82 -1
  2. package/dist/cjs/llm/adapters/anthropic.js +124 -0
  3. package/dist/cjs/llm/adapters/anthropic.js.map +1 -0
  4. package/dist/cjs/llm/adapters/base.js +100 -0
  5. package/dist/cjs/llm/adapters/base.js.map +1 -0
  6. package/dist/cjs/llm/adapters/gemini.js +156 -0
  7. package/dist/cjs/llm/adapters/gemini.js.map +1 -0
  8. package/dist/cjs/llm/adapters/index.js +33 -0
  9. package/dist/cjs/llm/adapters/index.js.map +1 -0
  10. package/dist/cjs/llm/adapters/mediapipe.js +290 -0
  11. package/dist/cjs/llm/adapters/mediapipe.js.map +1 -0
  12. package/dist/cjs/llm/adapters/ollama.js +149 -0
  13. package/dist/cjs/llm/adapters/ollama.js.map +1 -0
  14. package/dist/cjs/llm/adapters/openai.js +126 -0
  15. package/dist/cjs/llm/adapters/openai.js.map +1 -0
  16. package/dist/cjs/llm/adapters/openrouter.js +190 -0
  17. package/dist/cjs/llm/adapters/openrouter.js.map +1 -0
  18. package/dist/cjs/llm/index.js +42 -5
  19. package/dist/cjs/llm/index.js.map +1 -1
  20. package/dist/cjs/llm/orchestrator.js +219 -0
  21. package/dist/cjs/llm/orchestrator.js.map +1 -0
  22. package/dist/cjs/llm/prompts.js +367 -0
  23. package/dist/cjs/llm/prompts.js.map +1 -0
  24. package/dist/cjs/types/llm.js +8 -0
  25. package/dist/cjs/types/llm.js.map +1 -0
  26. package/dist/esm/llm/adapters/anthropic.js +119 -0
  27. package/dist/esm/llm/adapters/anthropic.js.map +1 -0
  28. package/dist/esm/llm/adapters/base.js +95 -0
  29. package/dist/esm/llm/adapters/base.js.map +1 -0
  30. package/dist/esm/llm/adapters/gemini.js +151 -0
  31. package/dist/esm/llm/adapters/gemini.js.map +1 -0
  32. package/dist/esm/llm/adapters/index.js +13 -0
  33. package/dist/esm/llm/adapters/index.js.map +1 -0
  34. package/dist/esm/llm/adapters/mediapipe.js +252 -0
  35. package/dist/esm/llm/adapters/mediapipe.js.map +1 -0
  36. package/dist/esm/llm/adapters/ollama.js +144 -0
  37. package/dist/esm/llm/adapters/ollama.js.map +1 -0
  38. package/dist/esm/llm/adapters/openai.js +121 -0
  39. package/dist/esm/llm/adapters/openai.js.map +1 -0
  40. package/dist/esm/llm/adapters/openrouter.js +185 -0
  41. package/dist/esm/llm/adapters/openrouter.js.map +1 -0
  42. package/dist/esm/llm/index.js +12 -6
  43. package/dist/esm/llm/index.js.map +1 -1
  44. package/dist/esm/llm/orchestrator.js +214 -0
  45. package/dist/esm/llm/orchestrator.js.map +1 -0
  46. package/dist/esm/llm/prompts.js +360 -0
  47. package/dist/esm/llm/prompts.js.map +1 -0
  48. package/dist/esm/types/llm.js +7 -0
  49. package/dist/esm/types/llm.js.map +1 -0
  50. package/dist/types/llm/adapters/anthropic.d.ts +21 -0
  51. package/dist/types/llm/adapters/anthropic.d.ts.map +1 -0
  52. package/dist/types/llm/adapters/base.d.ts +46 -0
  53. package/dist/types/llm/adapters/base.d.ts.map +1 -0
  54. package/dist/types/llm/adapters/gemini.d.ts +30 -0
  55. package/dist/types/llm/adapters/gemini.d.ts.map +1 -0
  56. package/dist/types/llm/adapters/index.d.ts +14 -0
  57. package/dist/types/llm/adapters/index.d.ts.map +1 -0
  58. package/dist/types/llm/adapters/mediapipe.d.ts +113 -0
  59. package/dist/types/llm/adapters/mediapipe.d.ts.map +1 -0
  60. package/dist/types/llm/adapters/ollama.d.ts +30 -0
  61. package/dist/types/llm/adapters/ollama.d.ts.map +1 -0
  62. package/dist/types/llm/adapters/openai.d.ts +22 -0
  63. package/dist/types/llm/adapters/openai.d.ts.map +1 -0
  64. package/dist/types/llm/adapters/openrouter.d.ts +58 -0
  65. package/dist/types/llm/adapters/openrouter.d.ts.map +1 -0
  66. package/dist/types/llm/index.d.ts +5 -0
  67. package/dist/types/llm/index.d.ts.map +1 -1
  68. package/dist/types/llm/orchestrator.d.ts +35 -0
  69. package/dist/types/llm/orchestrator.d.ts.map +1 -0
  70. package/dist/types/llm/prompts.d.ts +269 -0
  71. package/dist/types/llm/prompts.d.ts.map +1 -0
  72. package/dist/types/types/index.d.ts +1 -0
  73. package/dist/types/types/index.d.ts.map +1 -1
  74. package/dist/types/types/llm.d.ts +337 -0
  75. package/dist/types/types/llm.d.ts.map +1 -0
  76. package/package.json +6 -2
@@ -0,0 +1,360 @@
1
+ /**
2
+ * Prompts for LLM-based educational tasks
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ // ─────────────────────────────────────────────────────────────────────────────
7
+ // System Prompts
8
+ // ─────────────────────────────────────────────────────────────────────────────
9
+ export const SYSTEM_PROMPTS = {
10
+ skillExtraction: `You are an expert educational curriculum analyst specializing in competency-based education and learning science.
11
+
12
+ Your task is to analyze curriculum content and extract discrete, measurable skills that learners should master.
13
+
14
+ For each skill you identify:
15
+ 1. Name: A concise, action-oriented name (e.g., "Calculate derivative of polynomial")
16
+ 2. Description: A clear explanation of what mastery of this skill looks like
17
+ 3. Bloom's Level: Classify using Bloom's Taxonomy (remember, understand, apply, analyze, evaluate, create)
18
+ 4. Difficulty: Estimate difficulty on a 0-1 scale based on cognitive complexity
19
+ 5. Threshold Concept: Identify if this is a transformative "gateway" skill that changes understanding
20
+ 6. Estimated Time: How long a typical learner needs to achieve mastery
21
+
22
+ Focus on:
23
+ - Observable, measurable outcomes
24
+ - Skills that can be assessed
25
+ - Appropriate granularity (not too broad, not too narrow)
26
+ - Clear prerequisite relationships
27
+
28
+ Bloom's Level Guidelines:
29
+ - remember (0.20): Recall facts, terms, basic concepts
30
+ - understand (0.35): Explain ideas, interpret, summarize
31
+ - apply (0.50): Use information in new situations, solve problems
32
+ - analyze (0.65): Draw connections, organize, compare, contrast
33
+ - evaluate (0.80): Justify decisions, make judgments, critique
34
+ - create (0.90): Produce new work, design, construct`,
35
+ prerequisiteInference: `You are an expert in learning science and curriculum design, specializing in prerequisite mapping and learning path optimization.
36
+
37
+ Your task is to analyze skills and infer prerequisite relationships between them.
38
+
39
+ For each prerequisite relationship:
40
+ 1. Identify which skill must be learned first (source/prerequisite)
41
+ 2. Identify which skill depends on it (target/dependent)
42
+ 3. Classify the relationship type:
43
+ - hard: Absolutely required - cannot learn target without source
44
+ - soft: Strongly beneficial but not strictly required
45
+ - recommended: Helpful for optimal learning path
46
+ 4. Estimate strength (0-1): How critical is this prerequisite?
47
+ 5. Provide clear reasoning for the relationship
48
+
49
+ Consider:
50
+ - Bloom's level progression (lower levels typically prerequisite to higher)
51
+ - Conceptual dependencies (foundational concepts before advanced)
52
+ - Skill hierarchies within domains
53
+ - Transfer of learning between related skills
54
+ - Avoid circular dependencies`,
55
+ bloomAnalysis: `You are an expert in Bloom's Taxonomy and educational assessment design.
56
+
57
+ Analyze the given text and determine its cognitive level according to Bloom's Taxonomy:
58
+
59
+ 1. remember - Recall facts and basic concepts
60
+ Verbs: define, identify, list, name, recall, recognize, state
61
+
62
+ 2. understand - Explain ideas or concepts
63
+ Verbs: describe, explain, interpret, summarize, classify, compare
64
+
65
+ 3. apply - Use information in new situations
66
+ Verbs: apply, calculate, solve, demonstrate, implement, use
67
+
68
+ 4. analyze - Draw connections among ideas
69
+ Verbs: analyze, compare, contrast, differentiate, examine, organize
70
+
71
+ 5. evaluate - Justify a decision or course of action
72
+ Verbs: evaluate, assess, critique, judge, justify, recommend
73
+
74
+ 6. create - Produce new or original work
75
+ Verbs: create, design, develop, construct, formulate, produce
76
+
77
+ Provide:
78
+ - The Bloom's level
79
+ - Confidence score (0-1)
80
+ - Key indicators (verbs/phrases) that led to this classification
81
+ - Brief reasoning`,
82
+ curriculumDecomposition: `You are an expert curriculum designer and learning scientist.
83
+
84
+ Your task is to decompose curriculum content into a structured skill graph suitable for adaptive learning systems.
85
+
86
+ Process:
87
+ 1. Identify the overall learning goals and outcomes
88
+ 2. Break down content into discrete, measurable skills
89
+ 3. Classify each skill by Bloom's level and difficulty
90
+ 4. Identify threshold concepts (transformative gateway skills)
91
+ 5. Map prerequisite relationships between skills
92
+ 6. Ensure appropriate granularity for personalized learning
93
+
94
+ Output a complete skill graph with:
95
+ - Skills: Name, description, Bloom's level, difficulty, estimated time
96
+ - Prerequisites: Source skill, target skill, type, strength, reasoning
97
+
98
+ Principles:
99
+ - Every skill should be assessable
100
+ - Skills should be at appropriate granularity (15-45 min to master)
101
+ - Clear progression from foundational to advanced
102
+ - Identify threshold concepts that unlock new understanding
103
+ - Consider both hard prerequisites (required) and soft (beneficial)`,
104
+ };
105
+ // ─────────────────────────────────────────────────────────────────────────────
106
+ // JSON Schemas for Structured Output
107
+ // ─────────────────────────────────────────────────────────────────────────────
108
+ export const EXTRACTION_SCHEMA = {
109
+ type: 'object',
110
+ properties: {
111
+ skills: {
112
+ type: 'array',
113
+ items: {
114
+ type: 'object',
115
+ properties: {
116
+ name: { type: 'string', description: 'Concise, action-oriented skill name' },
117
+ description: { type: 'string', description: 'What mastery of this skill looks like' },
118
+ bloomLevel: {
119
+ type: 'string',
120
+ enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
121
+ description: "Bloom's Taxonomy level",
122
+ },
123
+ difficulty: {
124
+ type: 'number',
125
+ minimum: 0,
126
+ maximum: 1,
127
+ description: 'Difficulty on 0-1 scale',
128
+ },
129
+ confidence: {
130
+ type: 'number',
131
+ minimum: 0,
132
+ maximum: 1,
133
+ description: 'Confidence in this extraction',
134
+ },
135
+ isThresholdConcept: {
136
+ type: 'boolean',
137
+ description: 'Is this a transformative gateway skill?',
138
+ },
139
+ estimatedMinutes: {
140
+ type: 'number',
141
+ description: 'Estimated time to master in minutes',
142
+ },
143
+ keywords: {
144
+ type: 'array',
145
+ items: { type: 'string' },
146
+ description: 'Associated keywords/concepts',
147
+ },
148
+ reasoning: {
149
+ type: 'string',
150
+ description: 'Why this skill was extracted',
151
+ },
152
+ },
153
+ required: ['name', 'description', 'bloomLevel', 'difficulty', 'confidence'],
154
+ },
155
+ },
156
+ warnings: {
157
+ type: 'array',
158
+ items: { type: 'string' },
159
+ description: 'Any warnings or notes about the extraction',
160
+ },
161
+ },
162
+ required: ['skills'],
163
+ };
164
+ export const PREREQUISITE_SCHEMA = {
165
+ type: 'object',
166
+ properties: {
167
+ prerequisites: {
168
+ type: 'array',
169
+ items: {
170
+ type: 'object',
171
+ properties: {
172
+ sourceId: { type: 'string', description: 'ID of the prerequisite skill' },
173
+ targetId: { type: 'string', description: 'ID of the dependent skill' },
174
+ strength: {
175
+ type: 'number',
176
+ minimum: 0,
177
+ maximum: 1,
178
+ description: 'How critical is this prerequisite (0-1)',
179
+ },
180
+ type: {
181
+ type: 'string',
182
+ enum: ['hard', 'soft', 'recommended'],
183
+ description: 'Type of prerequisite relationship',
184
+ },
185
+ confidence: {
186
+ type: 'number',
187
+ minimum: 0,
188
+ maximum: 1,
189
+ description: 'Confidence in this inference',
190
+ },
191
+ reasoning: {
192
+ type: 'string',
193
+ description: 'Why this prerequisite relationship exists',
194
+ },
195
+ },
196
+ required: ['sourceId', 'targetId', 'strength', 'type', 'confidence', 'reasoning'],
197
+ },
198
+ },
199
+ },
200
+ required: ['prerequisites'],
201
+ };
202
+ export const BLOOM_ANALYSIS_SCHEMA = {
203
+ type: 'object',
204
+ properties: {
205
+ level: {
206
+ type: 'string',
207
+ enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
208
+ description: "Detected Bloom's level",
209
+ },
210
+ confidence: {
211
+ type: 'number',
212
+ minimum: 0,
213
+ maximum: 1,
214
+ description: 'Confidence in detection',
215
+ },
216
+ indicators: {
217
+ type: 'array',
218
+ items: { type: 'string' },
219
+ description: 'Key verbs/phrases indicating this level',
220
+ },
221
+ reasoning: {
222
+ type: 'string',
223
+ description: 'Explanation for the classification',
224
+ },
225
+ },
226
+ required: ['level', 'confidence', 'indicators', 'reasoning'],
227
+ };
228
+ export const DECOMPOSITION_SCHEMA = {
229
+ type: 'object',
230
+ properties: {
231
+ title: { type: 'string', description: 'Course/curriculum title' },
232
+ skills: {
233
+ type: 'array',
234
+ items: {
235
+ type: 'object',
236
+ properties: {
237
+ id: { type: 'string', description: 'Unique skill identifier' },
238
+ name: { type: 'string' },
239
+ description: { type: 'string' },
240
+ bloomLevel: {
241
+ type: 'string',
242
+ enum: ['remember', 'understand', 'apply', 'analyze', 'evaluate', 'create'],
243
+ },
244
+ difficulty: { type: 'number', minimum: 0, maximum: 1 },
245
+ isThresholdConcept: { type: 'boolean' },
246
+ estimatedMinutes: { type: 'number' },
247
+ keywords: { type: 'array', items: { type: 'string' } },
248
+ },
249
+ required: ['id', 'name', 'description', 'bloomLevel', 'difficulty'],
250
+ },
251
+ },
252
+ prerequisites: {
253
+ type: 'array',
254
+ items: {
255
+ type: 'object',
256
+ properties: {
257
+ sourceId: { type: 'string' },
258
+ targetId: { type: 'string' },
259
+ strength: { type: 'number', minimum: 0, maximum: 1 },
260
+ type: { type: 'string', enum: ['hard', 'soft', 'recommended'] },
261
+ reasoning: { type: 'string' },
262
+ },
263
+ required: ['sourceId', 'targetId', 'strength', 'type'],
264
+ },
265
+ },
266
+ warnings: {
267
+ type: 'array',
268
+ items: { type: 'string' },
269
+ },
270
+ },
271
+ required: ['title', 'skills', 'prerequisites'],
272
+ };
273
+ // ─────────────────────────────────────────────────────────────────────────────
274
+ // Prompt Builders
275
+ // ─────────────────────────────────────────────────────────────────────────────
276
+ /**
277
+ * Build a skill extraction prompt
278
+ */
279
+ export function buildExtractionPrompt(content, options) {
280
+ let prompt = `Analyze the following curriculum content and extract all discrete, measurable skills.\n\n`;
281
+ if (options?.domain) {
282
+ prompt += `Domain: ${options.domain}\n`;
283
+ }
284
+ if (options?.gradeLevel) {
285
+ prompt += `Target Audience: ${options.gradeLevel}\n`;
286
+ }
287
+ if (options?.context) {
288
+ prompt += `Additional Context: ${options.context}\n`;
289
+ }
290
+ prompt += `\n--- CURRICULUM CONTENT ---\n${content}\n--- END CONTENT ---\n\n`;
291
+ 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.`;
292
+ return prompt;
293
+ }
294
+ /**
295
+ * Build a prerequisite inference prompt
296
+ */
297
+ export function buildPrerequisitePrompt(skills, options) {
298
+ let prompt = `Analyze the following skills and infer prerequisite relationships between them.\n\n`;
299
+ if (options?.domain) {
300
+ prompt += `Domain: ${options.domain}\n`;
301
+ }
302
+ prompt += `\n--- SKILLS ---\n`;
303
+ for (const skill of skills) {
304
+ prompt += `ID: ${skill.id}\n`;
305
+ prompt += `Name: ${skill.name}\n`;
306
+ prompt += `Description: ${skill.description}\n`;
307
+ prompt += `Bloom's Level: ${skill.bloomLevel}\n`;
308
+ prompt += `Difficulty: ${skill.difficulty}\n\n`;
309
+ }
310
+ prompt += `--- END SKILLS ---\n\n`;
311
+ prompt += `For each prerequisite relationship you identify:\n`;
312
+ prompt += `1. Specify sourceId (prerequisite) and targetId (dependent)\n`;
313
+ prompt += `2. Classify as hard, soft, or recommended\n`;
314
+ prompt += `3. Provide strength (0-1) and reasoning\n`;
315
+ if (options?.inferTransitive === false) {
316
+ prompt += `\nNote: Only infer direct prerequisites, not transitive ones.`;
317
+ }
318
+ return prompt;
319
+ }
320
+ /**
321
+ * Build a Bloom's analysis prompt
322
+ */
323
+ export function buildBloomPrompt(text, context) {
324
+ let prompt = `Analyze the following text and determine its Bloom's Taxonomy level.\n\n`;
325
+ if (context) {
326
+ prompt += `Context: ${context}\n\n`;
327
+ }
328
+ prompt += `--- TEXT ---\n${text}\n--- END TEXT ---\n\n`;
329
+ prompt += `Classify this text according to Bloom's Taxonomy (remember, understand, apply, analyze, evaluate, create).`;
330
+ return prompt;
331
+ }
332
+ /**
333
+ * Build a curriculum decomposition prompt
334
+ */
335
+ export function buildDecompositionPrompt(content, options) {
336
+ let prompt = `Decompose the following curriculum into a complete skill graph.\n\n`;
337
+ if (options?.title) {
338
+ prompt += `Course Title: ${options.title}\n`;
339
+ }
340
+ if (options?.domain) {
341
+ prompt += `Domain: ${options.domain}\n`;
342
+ }
343
+ if (options?.gradeLevel) {
344
+ prompt += `Target Audience: ${options.gradeLevel}\n`;
345
+ }
346
+ if (options?.context) {
347
+ prompt += `Additional Context: ${options.context}\n`;
348
+ }
349
+ if (options?.maxDepth) {
350
+ prompt += `Maximum Skill Hierarchy Depth: ${options.maxDepth}\n`;
351
+ }
352
+ prompt += `\n--- CURRICULUM CONTENT ---\n${content}\n--- END CONTENT ---\n\n`;
353
+ prompt += `Create a complete skill graph with:\n`;
354
+ prompt += `1. All discrete, measurable skills with unique IDs\n`;
355
+ prompt += `2. Bloom's level and difficulty for each skill\n`;
356
+ prompt += `3. Prerequisite relationships between skills\n`;
357
+ prompt += `4. Identify threshold concepts that unlock understanding\n`;
358
+ return prompt;
359
+ }
360
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/llm/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,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;AAEhF,MAAM,CAAC,MAAM,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,qCAAq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tC,CAAC;IAED,MAAM,IAAI,iBAAiB,IAAI,wBAAwB,CAAC;IACxD,MAAM,IAAI,4GAA4G,CAAC;IAEvH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,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,7 @@
1
+ /**
2
+ * LLM provider types for skill extraction and prerequisite inference
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=llm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.js","sourceRoot":"","sources":["../../../src/types/llm.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Anthropic adapter for LLM integration
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { LLMProvider, AnthropicConfig, CompletionRequest, CompletionResponse } from '../../types/llm.js';
7
+ import { BaseLLMAdapter } from './base.js';
8
+ /**
9
+ * Anthropic adapter for Claude models
10
+ */
11
+ export declare class AnthropicAdapter extends BaseLLMAdapter {
12
+ private readonly baseUrl;
13
+ constructor(config: AnthropicConfig);
14
+ get provider(): LLMProvider;
15
+ complete(request: CompletionRequest): Promise<CompletionResponse>;
16
+ }
17
+ /**
18
+ * Create an Anthropic adapter from environment variables
19
+ */
20
+ export declare function createAnthropicAdapter(model?: string, overrides?: Partial<AnthropicConfig>): AnthropicAdapter;
21
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../../src/llm/adapters/anthropic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAA4B,MAAM,WAAW,CAAC;AAiCrE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,eAAe;IAKnC,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAEK,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyGxE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,SAA+B,EACpC,SAAS,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GACnC,gBAAgB,CAclB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Base adapter class for LLM providers
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { LLMProvider, LLMConfig, LLMAdapter, CompletionRequest, CompletionResponse } from '../../types/llm.js';
7
+ /**
8
+ * LLM-related errors
9
+ */
10
+ export declare class LLMError extends Error {
11
+ readonly code: LLMErrorCode;
12
+ readonly provider: LLMProvider;
13
+ readonly cause?: Error | undefined;
14
+ constructor(message: string, code: LLMErrorCode, provider: LLMProvider, cause?: Error | undefined);
15
+ }
16
+ export type LLMErrorCode = 'NOT_CONFIGURED' | 'API_ERROR' | 'RATE_LIMIT' | 'INVALID_RESPONSE' | 'TIMEOUT' | 'NETWORK_ERROR' | 'PARSE_ERROR';
17
+ /**
18
+ * Default configuration values
19
+ */
20
+ export declare const DEFAULT_CONFIG: {
21
+ maxTokens: number;
22
+ temperature: number;
23
+ timeout: number;
24
+ retries: number;
25
+ };
26
+ /**
27
+ * Abstract base class for LLM adapters
28
+ */
29
+ export declare abstract class BaseLLMAdapter implements LLMAdapter {
30
+ protected config: LLMConfig;
31
+ constructor(config: LLMConfig);
32
+ abstract get provider(): LLMProvider;
33
+ get model(): string;
34
+ abstract complete(request: CompletionRequest): Promise<CompletionResponse>;
35
+ isConfigured(): boolean;
36
+ getConfig(): Omit<LLMConfig, 'apiKey'>;
37
+ /**
38
+ * Retry a function with exponential backoff
39
+ */
40
+ protected withRetry<T>(fn: () => Promise<T>, maxRetries?: number): Promise<T>;
41
+ /**
42
+ * Parse JSON from LLM response, handling common issues
43
+ */
44
+ protected parseJSON<T>(content: string): T;
45
+ }
46
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/llm/adapters/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAGf,IAAI,EAAE,YAAY;aAClB,QAAQ,EAAE,WAAW;aACrB,KAAK,CAAC,EAAE,KAAK;gBAH7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,WAAW,EACrB,KAAK,CAAC,EAAE,KAAK,YAAA;CAKhC;AAED,MAAM,MAAM,YAAY,GACpB,gBAAgB,GAChB,WAAW,GACX,YAAY,GACZ,kBAAkB,GAClB,SAAS,GACT,eAAe,GACf,aAAa,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC;AAEF;;GAEG;AACH,8BAAsB,cAAe,YAAW,UAAU;IACxD,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;gBAEhB,MAAM,EAAE,SAAS;IAO7B,QAAQ,KAAK,QAAQ,IAAI,WAAW,CAAC;IAErC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAE1E,YAAY,IAAI,OAAO;IAOvB,SAAS,IAAI,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;IAKtC;;OAEG;cACa,SAAS,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,SAAgD,GACzD,OAAO,CAAC,CAAC,CAAC;IA2Bb;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;CAgB3C"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Google Gemini LLM adapter
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { LLMProvider, GeminiConfig, CompletionRequest, CompletionResponse } from '../../types/llm.js';
7
+ import { BaseLLMAdapter } from './base.js';
8
+ /**
9
+ * Adapter for Google Gemini models
10
+ *
11
+ * Supports:
12
+ * - gemini-2.0-flash-exp
13
+ * - gemini-1.5-pro
14
+ * - gemini-1.5-flash
15
+ * - gemini-1.0-pro
16
+ */
17
+ export declare class GeminiAdapter extends BaseLLMAdapter {
18
+ private readonly baseUrl;
19
+ constructor(config: GeminiConfig);
20
+ get provider(): LLMProvider;
21
+ complete(request: CompletionRequest): Promise<CompletionResponse>;
22
+ private buildRequest;
23
+ private executeRequest;
24
+ private parseResponse;
25
+ }
26
+ /**
27
+ * Create a Gemini adapter from environment variables
28
+ */
29
+ export declare function createGeminiAdapter(model?: string, overrides?: Partial<GeminiConfig>): GeminiAdapter;
30
+ //# sourceMappingURL=gemini.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../../src/llm/adapters/gemini.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAY,MAAM,WAAW,CAAC;AAsCrD;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,YAAY;IAOhC,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAEK,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2BvE,OAAO,CAAC,YAAY;YAgCN,cAAc;IAyC5B,OAAO,CAAC,aAAa;CA6CtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,SAAyB,EAC9B,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAChC,aAAa,CAkBf"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * LLM adapter exports
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { BaseLLMAdapter, LLMError, DEFAULT_CONFIG } from './base.js';
7
+ export type { LLMErrorCode } from './base.js';
8
+ export { OpenAIAdapter, createOpenAIAdapter } from './openai.js';
9
+ export { AnthropicAdapter, createAnthropicAdapter } from './anthropic.js';
10
+ export { OllamaAdapter, createOllamaAdapter } from './ollama.js';
11
+ export { GeminiAdapter, createGeminiAdapter } from './gemini.js';
12
+ export { OpenRouterAdapter, createOpenRouterAdapter, OPENROUTER_MODELS } from './openrouter.js';
13
+ export { MediaPipeAdapter, createMediaPipeAdapter, MEDIAPIPE_MODELS } from './mediapipe.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/llm/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * MediaPipe LLM Inference adapter for local Gemma models
3
+ *
4
+ * This adapter integrates with Google's MediaPipe LLM Inference Task API
5
+ * to run Gemma models locally using WebGPU acceleration.
6
+ *
7
+ * Supported models:
8
+ * - Gemma 2B / 7B
9
+ * - Gemma 2 2B
10
+ * - Gemma 3n (2B, 4B parameters)
11
+ *
12
+ * Requirements:
13
+ * - WebGPU-capable browser or Node.js with WebGPU support
14
+ * - @mediapipe/tasks-genai package
15
+ * - Downloaded model weights (.bin file)
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import type { LLMProvider, MediaPipeConfig, CompletionRequest, CompletionResponse } from '../../types/llm.js';
20
+ import { BaseLLMAdapter } from './base.js';
21
+ /**
22
+ * Gemma model variants for MediaPipe
23
+ */
24
+ export declare const MEDIAPIPE_MODELS: {
25
+ readonly 'gemma-2b': "gemma-2b-it-gpu-int4.bin";
26
+ readonly 'gemma-7b': "gemma-7b-it-gpu-int8.bin";
27
+ readonly 'gemma2-2b': "gemma2-2b-it-gpu-int4.bin";
28
+ readonly 'gemma3n-e2b': "gemma-3n-E2B-it-int4.task";
29
+ readonly 'gemma3n-e4b': "gemma-3n-E4B-it-int4.task";
30
+ };
31
+ /**
32
+ * Adapter for MediaPipe LLM Inference API
33
+ *
34
+ * Runs Gemma models locally using WebGPU acceleration.
35
+ * The adapter lazily loads the model on first use.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { MediaPipeAdapter } from 'learngraph/llm';
40
+ *
41
+ * const adapter = new MediaPipeAdapter({
42
+ * provider: 'mediapipe',
43
+ * model: 'gemma3n-e2b',
44
+ * modelPath: '/models/gemma-3n-E2B-it-int4.task',
45
+ * });
46
+ *
47
+ * // Use with orchestrator
48
+ * const orchestrator = createOrchestrator(adapter);
49
+ * ```
50
+ */
51
+ export declare class MediaPipeAdapter extends BaseLLMAdapter {
52
+ private inference;
53
+ private readonly modelPath;
54
+ private readonly randomSeed?;
55
+ private readonly topK;
56
+ private readonly loraRanks?;
57
+ private initPromise;
58
+ constructor(config: MediaPipeConfig);
59
+ get provider(): LLMProvider;
60
+ /**
61
+ * Check if MediaPipe is configured (model path exists)
62
+ */
63
+ isConfigured(): boolean;
64
+ /**
65
+ * Initialize the MediaPipe LLM Inference engine
66
+ * Called automatically on first request
67
+ */
68
+ initialize(): Promise<void>;
69
+ private doInitialize;
70
+ /**
71
+ * Load MediaPipe library dynamically
72
+ */
73
+ private loadMediaPipe;
74
+ complete(request: CompletionRequest): Promise<CompletionResponse>;
75
+ /**
76
+ * Build a prompt string from chat messages
77
+ * Uses Gemma's instruction format
78
+ */
79
+ private buildPrompt;
80
+ /**
81
+ * Parse the generated response
82
+ */
83
+ private parseGeneratedResponse;
84
+ /**
85
+ * Close the inference engine and release resources
86
+ */
87
+ close(): void;
88
+ }
89
+ /**
90
+ * Create a MediaPipe adapter for local Gemma models
91
+ *
92
+ * @param modelPath - Path to the model file (.bin or .task)
93
+ * @param model - Model identifier (for reference)
94
+ * @param overrides - Additional configuration options
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // Using a Gemma 3n model
99
+ * const adapter = createMediaPipeAdapter(
100
+ * '/models/gemma-3n-E2B-it-int4.task',
101
+ * 'gemma3n-e2b'
102
+ * );
103
+ *
104
+ * // With custom options
105
+ * const adapter = createMediaPipeAdapter(
106
+ * '/models/gemma2-2b-it-gpu-int4.bin',
107
+ * 'gemma2-2b',
108
+ * { maxTokens: 2048, temperature: 0.5 }
109
+ * );
110
+ * ```
111
+ */
112
+ export declare function createMediaPipeAdapter(modelPath: string, model?: string, overrides?: Partial<Omit<MediaPipeConfig, 'provider' | 'modelPath'>>): MediaPipeAdapter;
113
+ //# sourceMappingURL=mediapipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediapipe.d.ts","sourceRoot":"","sources":["../../../../src/llm/adapters/mediapipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAY,MAAM,WAAW,CAAC;AAoCrD;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,WAAW,CAA8B;gBAErC,MAAM,EAAE,eAAe;IAYnC,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED;;OAEG;IACH,YAAY,IAAI,OAAO;IAIvB;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAcnB,YAAY;IAuC1B;;OAEG;YACW,aAAa;IAarB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqCvE;;;OAGG;IACH,OAAO,CAAC,WAAW;IA6BnB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6B9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAOd;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,KAAK,SAAY,EACjB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC,GACnE,gBAAgB,CASlB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Ollama adapter for local LLM integration
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { LLMProvider, OllamaConfig, CompletionRequest, CompletionResponse } from '../../types/llm.js';
7
+ import { BaseLLMAdapter } from './base.js';
8
+ /**
9
+ * Ollama adapter for local models
10
+ */
11
+ export declare class OllamaAdapter extends BaseLLMAdapter {
12
+ private readonly baseUrl;
13
+ constructor(config: OllamaConfig);
14
+ get provider(): LLMProvider;
15
+ isConfigured(): boolean;
16
+ complete(request: CompletionRequest): Promise<CompletionResponse>;
17
+ /**
18
+ * Check if Ollama is available
19
+ */
20
+ isAvailable(): Promise<boolean>;
21
+ /**
22
+ * List available models
23
+ */
24
+ listModels(): Promise<string[]>;
25
+ }
26
+ /**
27
+ * Create an Ollama adapter
28
+ */
29
+ export declare function createOllamaAdapter(model?: string, overrides?: Partial<OllamaConfig>): OllamaAdapter;
30
+ //# sourceMappingURL=ollama.d.ts.map