@thanh01.pmt/curriculum-kit 1.4.26 → 1.4.27
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 +21 -0
- package/dist/ai/index.cjs +68 -5
- package/dist/ai/index.cjs.map +1 -1
- package/dist/ai/index.d.cts +4 -4
- package/dist/ai/index.d.ts +4 -4
- package/dist/ai/index.mjs +68 -6
- package/dist/ai/index.mjs.map +1 -1
- package/dist/index.cjs +69 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +69 -6
- package/dist/index.mjs.map +1 -1
- package/dist/media/index.cjs +52 -4
- package/dist/media/index.cjs.map +1 -1
- package/dist/media/index.d.cts +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.mjs +52 -4
- package/dist/media/index.mjs.map +1 -1
- package/dist/{milestoneBundleGenerator-CzSOeAzU.d.cts → milestoneBundleGenerator-CN6F1zPs.d.cts} +1 -1
- package/dist/{milestoneBundleGenerator-Bkba8OPG.d.ts → milestoneBundleGenerator-DTiJ5gIh.d.ts} +1 -1
- package/dist/pipeline/index.cjs +23 -4
- package/dist/pipeline/index.cjs.map +1 -1
- package/dist/pipeline/index.d.cts +3 -3
- package/dist/pipeline/index.d.ts +3 -3
- package/dist/pipeline/index.mjs +23 -4
- package/dist/pipeline/index.mjs.map +1 -1
- package/dist/{provider-factory-DxzOVEmh.d.cts → provider-factory-Bv-eIkhg.d.cts} +1 -1
- package/dist/{provider-factory-DxzOVEmh.d.ts → provider-factory-Bv-eIkhg.d.ts} +1 -1
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/{streamRunner-CYESG6IE.d.cts → streamRunner-kpS4MZP1.d.cts} +2 -1
- package/dist/{streamRunner-CYESG6IE.d.ts → streamRunner-kpS4MZP1.d.ts} +2 -1
- package/dist/workflow/index.cjs +67 -5
- package/dist/workflow/index.cjs.map +1 -1
- package/dist/workflow/index.d.cts +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.mjs +67 -5
- package/dist/workflow/index.mjs.map +1 -1
- package/package.json +22 -23
package/dist/ai/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as ModelResolutionOptions } from '../provider-factory-
|
|
2
|
-
export { A as AIProviderName, N as NVIDIA_MODELS, g as getAIModel } from '../provider-factory-
|
|
1
|
+
import { M as ModelResolutionOptions } from '../provider-factory-Bv-eIkhg.cjs';
|
|
2
|
+
export { A as AIProviderName, N as NVIDIA_MODELS, g as getAIModel } from '../provider-factory-Bv-eIkhg.cjs';
|
|
3
3
|
import { MilestoneInput, LessonPlan, ActivityLab, ProjectGraph, CodeLab, Worksheet, Handout, SlideDeck, TeacherGuide, Extension, CurriculumQualityReport, ProjectInstruction, SelfLab, DiagnosticQuiz } from '../schemas/index.cjs';
|
|
4
4
|
import * as ai from 'ai';
|
|
5
|
-
import { C as ChatMessage, S as StreamRunnerOptions, c as ChunkType } from '../streamRunner-
|
|
6
|
-
export { D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as runCurriculumAIInference, s as streamCurriculumAIInference } from '../streamRunner-
|
|
5
|
+
import { C as ChatMessage, S as StreamRunnerOptions, c as ChunkType } from '../streamRunner-kpS4MZP1.cjs';
|
|
6
|
+
export { D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from '../streamRunner-kpS4MZP1.cjs';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
9
|
interface LessonPromptInput {
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as ModelResolutionOptions } from '../provider-factory-
|
|
2
|
-
export { A as AIProviderName, N as NVIDIA_MODELS, g as getAIModel } from '../provider-factory-
|
|
1
|
+
import { M as ModelResolutionOptions } from '../provider-factory-Bv-eIkhg.js';
|
|
2
|
+
export { A as AIProviderName, N as NVIDIA_MODELS, g as getAIModel } from '../provider-factory-Bv-eIkhg.js';
|
|
3
3
|
import { MilestoneInput, LessonPlan, ActivityLab, ProjectGraph, CodeLab, Worksheet, Handout, SlideDeck, TeacherGuide, Extension, CurriculumQualityReport, ProjectInstruction, SelfLab, DiagnosticQuiz } from '../schemas/index.js';
|
|
4
4
|
import * as ai from 'ai';
|
|
5
|
-
import { C as ChatMessage, S as StreamRunnerOptions, c as ChunkType } from '../streamRunner-
|
|
6
|
-
export { D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as runCurriculumAIInference, s as streamCurriculumAIInference } from '../streamRunner-
|
|
5
|
+
import { C as ChatMessage, S as StreamRunnerOptions, c as ChunkType } from '../streamRunner-kpS4MZP1.js';
|
|
6
|
+
export { D as DEFAULT_ARTIFACT_STREAM_IDLE_MS, d as DEFAULT_ARTIFACT_STREAM_TOTAL_MS, F as FallbackTarget, I as IdleAbort, f as StreamAbortController, j as createIdleAbortController, h as createStreamAbortController, e as extractThoughtAndContent, g as getDesignatedFallbackChain, b as getDesignatedFallbackConfig, a as isModelAllowed, i as isProviderEnabled, r as resolveApiKey, k as runCurriculumAIInference, s as streamCurriculumAIInference } from '../streamRunner-kpS4MZP1.js';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
9
9
|
interface LessonPromptInput {
|
package/dist/ai/index.mjs
CHANGED
|
@@ -170,14 +170,19 @@ function isModelAllowed(model) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
function getDesignatedFallbackChain() {
|
|
173
|
-
const rawProviders = resolveApiKey("FALLBACK_AI_PROVIDER") || resolveApiKey("FALLBACK_AI_PROVIDERS") || resolveApiKey("DEFAULT_AI_PROVIDER") || "nvidia,openrouter";
|
|
174
|
-
const rawModels = resolveApiKey("FALLBACK_AI_MODEL") || resolveApiKey("FALLBACK_AI_MODELS") || resolveApiKey("DEFAULT_AI_MODEL") || "
|
|
173
|
+
const rawProviders = resolveApiKey("FALLBACK_AI_PROVIDER") || resolveApiKey("FALLBACK_AI_PROVIDERS") || resolveApiKey("DEFAULT_AI_PROVIDER") || "9router,nvidia,openrouter";
|
|
174
|
+
const rawModels = resolveApiKey("FALLBACK_AI_MODEL") || resolveApiKey("FALLBACK_AI_MODELS") || resolveApiKey("DEFAULT_AI_MODEL") || "fast-reasoning,deep-reasoning,mid-range,free-tier";
|
|
175
175
|
const providerList = rawProviders.split(",").map((p) => p.trim().toLowerCase()).filter((p) => p.length > 0 && isProviderEnabled(p));
|
|
176
176
|
const modelList = rawModels.split(",").map((m) => m.trim()).filter((m) => m.length > 0 && isModelAllowed(m));
|
|
177
177
|
const chain = [];
|
|
178
178
|
for (const provider of providerList) {
|
|
179
179
|
let providerModels = [];
|
|
180
|
-
if (provider === "
|
|
180
|
+
if (provider === "9router" || provider === "ninerouter") {
|
|
181
|
+
providerModels = modelList.filter((m) => ["fast-reasoning", "deep-reasoning", "mid-range", "free-tier"].includes(m));
|
|
182
|
+
if (providerModels.length === 0) {
|
|
183
|
+
providerModels = ["fast-reasoning", "mid-range", "free-tier"];
|
|
184
|
+
}
|
|
185
|
+
} else if (provider === "nvidia") {
|
|
181
186
|
providerModels = modelList.filter((m) => m.startsWith("nvidia/") || m.startsWith("meta/") || m.startsWith("mistralai/"));
|
|
182
187
|
if (providerModels.length === 0) {
|
|
183
188
|
providerModels = ["nvidia/nemotron-3-ultra-550b-a55b:free", "nvidia/nemotron-3.5-lightning-30b-a3b"];
|
|
@@ -216,7 +221,7 @@ function getDesignatedFallbackChain() {
|
|
|
216
221
|
function getDesignatedFallbackConfig() {
|
|
217
222
|
const chain = getDesignatedFallbackChain();
|
|
218
223
|
if (chain.length > 0) return chain[0];
|
|
219
|
-
return { provider: "
|
|
224
|
+
return { provider: "9router", model: "fast-reasoning" };
|
|
220
225
|
}
|
|
221
226
|
function extractThoughtAndContent(rawText) {
|
|
222
227
|
let text = rawText || "";
|
|
@@ -460,8 +465,51 @@ Guidelines:
|
|
|
460
465
|
}))
|
|
461
466
|
];
|
|
462
467
|
const providerErrors = {};
|
|
463
|
-
const requestedModel = options.model || "
|
|
468
|
+
const requestedModel = options.model || "fast-reasoning";
|
|
464
469
|
const isNvidiaPreferred = requestedModel.startsWith("nvidia/") || Boolean(nvidiaKey && !openrouterKey) && isProviderEnabled("nvidia");
|
|
470
|
+
const ninerouterKey = resolveApiKey("NINEROUTER_API_KEY") || resolveApiKey("NINE_ROUTER_API_KEY");
|
|
471
|
+
if (ninerouterKey && isProviderEnabled("9router")) {
|
|
472
|
+
const rawUrl = resolveApiKey("NINEROUTER_BASE_URL") || resolveApiKey("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
|
|
473
|
+
const ninerouterBaseUrl = rawUrl.replace(/^["']|["']$/g, "").replace(/\/$/, "");
|
|
474
|
+
const candidateModels = [
|
|
475
|
+
options.model || "fast-reasoning",
|
|
476
|
+
"fast-reasoning",
|
|
477
|
+
"mid-range",
|
|
478
|
+
"free-tier"
|
|
479
|
+
].filter((m) => isModelAllowed(m));
|
|
480
|
+
const unique9RouterModels = Array.from(new Set(candidateModels));
|
|
481
|
+
for (const model of unique9RouterModels) {
|
|
482
|
+
try {
|
|
483
|
+
const idle = createStreamAbortController({ idleMs: 45e3, totalMs: 3e5 });
|
|
484
|
+
const res = await fetch(`${ninerouterBaseUrl}/chat/completions`, {
|
|
485
|
+
method: "POST",
|
|
486
|
+
headers: {
|
|
487
|
+
"Authorization": `Bearer ${ninerouterKey}`,
|
|
488
|
+
"Content-Type": "application/json"
|
|
489
|
+
},
|
|
490
|
+
body: JSON.stringify({
|
|
491
|
+
model,
|
|
492
|
+
messages: formattedMessages,
|
|
493
|
+
max_tokens: maxTokens,
|
|
494
|
+
temperature,
|
|
495
|
+
stream: true,
|
|
496
|
+
stream_options: { include_usage: true }
|
|
497
|
+
}),
|
|
498
|
+
signal: idle.signal
|
|
499
|
+
});
|
|
500
|
+
if (res.ok) {
|
|
501
|
+
const text = await processOpenAISSEStream(res, onChunk, idle);
|
|
502
|
+
if (text && text.trim()) return text;
|
|
503
|
+
} else {
|
|
504
|
+
const errText = await res.text().catch(() => "");
|
|
505
|
+
providerErrors[`9router_${model}`] = `HTTP ${res.status}: ${errText.slice(0, 120)}`;
|
|
506
|
+
}
|
|
507
|
+
} catch (e) {
|
|
508
|
+
providerErrors[`9router_${model}`] = e?.message || "Network error";
|
|
509
|
+
console.warn(`[9Router Stream] Failover for ${model}:`, e?.message || e);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
465
513
|
if (nvidiaKey && isProviderEnabled("nvidia")) {
|
|
466
514
|
const candidateNemotronModels = [
|
|
467
515
|
requestedModel.startsWith("nvidia/") ? requestedModel : "nvidia/nemotron-3-ultra-550b-a55b:free",
|
|
@@ -828,6 +876,8 @@ async function runCurriculumAIInference(messages, projectContext, options = {},
|
|
|
828
876
|
|
|
829
877
|
// src/ai/provider-factory.ts
|
|
830
878
|
var DEFAULT_MODELS = {
|
|
879
|
+
"9router": "fast-reasoning",
|
|
880
|
+
ninerouter: "fast-reasoning",
|
|
831
881
|
nvidia: "nvidia/nemotron-3-ultra-550b-a55b:free",
|
|
832
882
|
openrouter: "@preset/coding-free",
|
|
833
883
|
alibaba: "qwen3.7-plus",
|
|
@@ -859,6 +909,15 @@ function getAIModel(options = {}) {
|
|
|
859
909
|
console.warn(`[provider-factory] Model "${resolvedModelName}" is not permitted by ALLOWED_AI_MODELS. Using designated model "${designated.model}".`);
|
|
860
910
|
resolvedModelName = designated.model;
|
|
861
911
|
}
|
|
912
|
+
if (provider === "9router" || provider === "ninerouter") {
|
|
913
|
+
const apiKey = options.apiKey || resolveApiKey("NINEROUTER_API_KEY") || resolveApiKey("NINE_ROUTER_API_KEY") || "";
|
|
914
|
+
const rawUrl = options.baseURL || resolveApiKey("NINEROUTER_BASE_URL") || resolveApiKey("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
|
|
915
|
+
const ninerouter = createOpenAI({
|
|
916
|
+
apiKey,
|
|
917
|
+
baseURL: rawUrl.replace(/^["']|["']$/g, "").trim()
|
|
918
|
+
});
|
|
919
|
+
return ninerouter.chat(resolvedModelName || "fast-reasoning");
|
|
920
|
+
}
|
|
862
921
|
if (provider === "nvidia") {
|
|
863
922
|
const apiKey = options.apiKey || process.env.NVIDIA_API_KEY || "";
|
|
864
923
|
const nvidia = createOpenAI({
|
|
@@ -927,6 +986,9 @@ function getAIModel(options = {}) {
|
|
|
927
986
|
return fallback.chat(resolvedModelName);
|
|
928
987
|
}
|
|
929
988
|
function detectDefaultProvider() {
|
|
989
|
+
if ((process.env.NINEROUTER_API_KEY || resolveApiKey("NINEROUTER_API_KEY") || resolveApiKey("NINE_ROUTER_API_KEY")) && isProviderEnabled("9router")) {
|
|
990
|
+
return "9router";
|
|
991
|
+
}
|
|
930
992
|
if (process.env.NVIDIA_API_KEY && isProviderEnabled("nvidia")) {
|
|
931
993
|
return "nvidia";
|
|
932
994
|
}
|
|
@@ -5074,6 +5136,6 @@ Guidelines:
|
|
|
5074
5136
|
return finalContent;
|
|
5075
5137
|
}
|
|
5076
5138
|
|
|
5077
|
-
export { DEFAULT_ARTIFACT_STREAM_IDLE_MS, DEFAULT_ARTIFACT_STREAM_TOTAL_MS, DEFAULT_ENABLED_PROVIDERS, LLMJudgeEngine, ModelPolicyResolver, NVIDIA_MODELS, SLIDE_CANONICAL_METHODOLOGY, activityTools, analystTools, assessorTools, auditCurriculumQualityFlow, buildActivityPrompt, buildCodeLabPrompt, buildDiagnosticQuizPrompt, buildExtensionPrompt, buildHandoutPrompt, buildHtmlDeckSlidePrompt, buildJudgePrompt, buildLessonMasterPrompt, buildMarpMarkdownSlidePrompt, buildProjectInstructionPrompt, buildSelfLabPrompt, buildSlidesPrompt, buildTeacherGuidePrompt, buildWorksheetPrompt, contentTools, createIdleAbortController, createStreamAbortController, designerTools, extractThoughtAndContent, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateProjectInstructionFlow, generateSelfLabFlow, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, getAIModel, getDesignatedFallbackChain, getDesignatedFallbackConfig, illustratorTools, isModelAllowed, isProviderEnabled, packagerTools, researcherTools, reviewerTools, runCurriculumAIInference, streamCurriculumAIInference, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLessonMasterFlow, streamSelfLabFlow, techSmeTools };
|
|
5139
|
+
export { DEFAULT_ARTIFACT_STREAM_IDLE_MS, DEFAULT_ARTIFACT_STREAM_TOTAL_MS, DEFAULT_ENABLED_PROVIDERS, LLMJudgeEngine, ModelPolicyResolver, NVIDIA_MODELS, SLIDE_CANONICAL_METHODOLOGY, activityTools, analystTools, assessorTools, auditCurriculumQualityFlow, buildActivityPrompt, buildCodeLabPrompt, buildDiagnosticQuizPrompt, buildExtensionPrompt, buildHandoutPrompt, buildHtmlDeckSlidePrompt, buildJudgePrompt, buildLessonMasterPrompt, buildMarpMarkdownSlidePrompt, buildProjectInstructionPrompt, buildSelfLabPrompt, buildSlidesPrompt, buildTeacherGuidePrompt, buildWorksheetPrompt, contentTools, createIdleAbortController, createStreamAbortController, designerTools, extractThoughtAndContent, generateActivityFlow, generateCodeLabFlow, generateDiagnosticQuizFlow, generateExtensionFlow, generateHandoutFlow, generateLessonMasterFlow, generateProjectInstructionFlow, generateSelfLabFlow, generateSlidesFlow, generateTeacherGuideFlow, generateWorksheetFlow, getAIModel, getDesignatedFallbackChain, getDesignatedFallbackConfig, illustratorTools, isModelAllowed, isProviderEnabled, packagerTools, researcherTools, resolveApiKey, reviewerTools, runCurriculumAIInference, streamCurriculumAIInference, streamCurriculumAIInferenceWithTools, streamDiagnosticQuizFlow, streamLessonMasterFlow, streamSelfLabFlow, techSmeTools };
|
|
5078
5140
|
//# sourceMappingURL=index.mjs.map
|
|
5079
5141
|
//# sourceMappingURL=index.mjs.map
|