@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/media/index.cjs
CHANGED
|
@@ -433,14 +433,19 @@ function isModelAllowed(model) {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
function getDesignatedFallbackChain() {
|
|
436
|
-
const rawProviders = resolveApiKey2("FALLBACK_AI_PROVIDER") || resolveApiKey2("FALLBACK_AI_PROVIDERS") || resolveApiKey2("DEFAULT_AI_PROVIDER") || "nvidia,openrouter";
|
|
437
|
-
const rawModels = resolveApiKey2("FALLBACK_AI_MODEL") || resolveApiKey2("FALLBACK_AI_MODELS") || resolveApiKey2("DEFAULT_AI_MODEL") || "
|
|
436
|
+
const rawProviders = resolveApiKey2("FALLBACK_AI_PROVIDER") || resolveApiKey2("FALLBACK_AI_PROVIDERS") || resolveApiKey2("DEFAULT_AI_PROVIDER") || "9router,nvidia,openrouter";
|
|
437
|
+
const rawModels = resolveApiKey2("FALLBACK_AI_MODEL") || resolveApiKey2("FALLBACK_AI_MODELS") || resolveApiKey2("DEFAULT_AI_MODEL") || "fast-reasoning,deep-reasoning,mid-range,free-tier";
|
|
438
438
|
const providerList = rawProviders.split(",").map((p) => p.trim().toLowerCase()).filter((p) => p.length > 0 && isProviderEnabled(p));
|
|
439
439
|
const modelList = rawModels.split(",").map((m) => m.trim()).filter((m) => m.length > 0 && isModelAllowed(m));
|
|
440
440
|
const chain = [];
|
|
441
441
|
for (const provider of providerList) {
|
|
442
442
|
let providerModels = [];
|
|
443
|
-
if (provider === "
|
|
443
|
+
if (provider === "9router" || provider === "ninerouter") {
|
|
444
|
+
providerModels = modelList.filter((m) => ["fast-reasoning", "deep-reasoning", "mid-range", "free-tier"].includes(m));
|
|
445
|
+
if (providerModels.length === 0) {
|
|
446
|
+
providerModels = ["fast-reasoning", "mid-range", "free-tier"];
|
|
447
|
+
}
|
|
448
|
+
} else if (provider === "nvidia") {
|
|
444
449
|
providerModels = modelList.filter((m) => m.startsWith("nvidia/") || m.startsWith("meta/") || m.startsWith("mistralai/"));
|
|
445
450
|
if (providerModels.length === 0) {
|
|
446
451
|
providerModels = ["nvidia/nemotron-3-ultra-550b-a55b:free", "nvidia/nemotron-3.5-lightning-30b-a3b"];
|
|
@@ -711,8 +716,51 @@ Guidelines:
|
|
|
711
716
|
}))
|
|
712
717
|
];
|
|
713
718
|
const providerErrors = {};
|
|
714
|
-
const requestedModel = options.model || "
|
|
719
|
+
const requestedModel = options.model || "fast-reasoning";
|
|
715
720
|
const isNvidiaPreferred = requestedModel.startsWith("nvidia/") || Boolean(nvidiaKey && !openrouterKey) && isProviderEnabled("nvidia");
|
|
721
|
+
const ninerouterKey = resolveApiKey2("NINEROUTER_API_KEY") || resolveApiKey2("NINE_ROUTER_API_KEY");
|
|
722
|
+
if (ninerouterKey && isProviderEnabled("9router")) {
|
|
723
|
+
const rawUrl = resolveApiKey2("NINEROUTER_BASE_URL") || resolveApiKey2("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
|
|
724
|
+
const ninerouterBaseUrl = rawUrl.replace(/^["']|["']$/g, "").replace(/\/$/, "");
|
|
725
|
+
const candidateModels = [
|
|
726
|
+
options.model || "fast-reasoning",
|
|
727
|
+
"fast-reasoning",
|
|
728
|
+
"mid-range",
|
|
729
|
+
"free-tier"
|
|
730
|
+
].filter((m) => isModelAllowed(m));
|
|
731
|
+
const unique9RouterModels = Array.from(new Set(candidateModels));
|
|
732
|
+
for (const model of unique9RouterModels) {
|
|
733
|
+
try {
|
|
734
|
+
const idle = createStreamAbortController({ idleMs: 45e3, totalMs: 3e5 });
|
|
735
|
+
const res = await fetch(`${ninerouterBaseUrl}/chat/completions`, {
|
|
736
|
+
method: "POST",
|
|
737
|
+
headers: {
|
|
738
|
+
"Authorization": `Bearer ${ninerouterKey}`,
|
|
739
|
+
"Content-Type": "application/json"
|
|
740
|
+
},
|
|
741
|
+
body: JSON.stringify({
|
|
742
|
+
model,
|
|
743
|
+
messages: formattedMessages,
|
|
744
|
+
max_tokens: maxTokens,
|
|
745
|
+
temperature,
|
|
746
|
+
stream: true,
|
|
747
|
+
stream_options: { include_usage: true }
|
|
748
|
+
}),
|
|
749
|
+
signal: idle.signal
|
|
750
|
+
});
|
|
751
|
+
if (res.ok) {
|
|
752
|
+
const text = await processOpenAISSEStream(res, onChunk, idle);
|
|
753
|
+
if (text && text.trim()) return text;
|
|
754
|
+
} else {
|
|
755
|
+
const errText = await res.text().catch(() => "");
|
|
756
|
+
providerErrors[`9router_${model}`] = `HTTP ${res.status}: ${errText.slice(0, 120)}`;
|
|
757
|
+
}
|
|
758
|
+
} catch (e) {
|
|
759
|
+
providerErrors[`9router_${model}`] = e?.message || "Network error";
|
|
760
|
+
console.warn(`[9Router Stream] Failover for ${model}:`, e?.message || e);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
716
764
|
if (nvidiaKey && isProviderEnabled("nvidia")) {
|
|
717
765
|
const candidateNemotronModels = [
|
|
718
766
|
requestedModel.startsWith("nvidia/") ? requestedModel : "nvidia/nemotron-3-ultra-550b-a55b:free",
|