@thanh01.pmt/curriculum-kit 1.4.25 → 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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ai/index.cjs +68 -5
  3. package/dist/ai/index.cjs.map +1 -1
  4. package/dist/ai/index.d.cts +4 -4
  5. package/dist/ai/index.d.ts +4 -4
  6. package/dist/ai/index.mjs +68 -6
  7. package/dist/ai/index.mjs.map +1 -1
  8. package/dist/index.cjs +71 -6
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +5 -5
  11. package/dist/index.d.ts +5 -5
  12. package/dist/index.mjs +71 -7
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/media/index.cjs +52 -4
  15. package/dist/media/index.cjs.map +1 -1
  16. package/dist/media/index.d.cts +1 -1
  17. package/dist/media/index.d.ts +1 -1
  18. package/dist/media/index.mjs +52 -4
  19. package/dist/media/index.mjs.map +1 -1
  20. package/dist/{milestoneBundleGenerator-CzSOeAzU.d.cts → milestoneBundleGenerator-CN6F1zPs.d.cts} +1 -1
  21. package/dist/{milestoneBundleGenerator-Bkba8OPG.d.ts → milestoneBundleGenerator-DTiJ5gIh.d.ts} +1 -1
  22. package/dist/pipeline/index.cjs +23 -4
  23. package/dist/pipeline/index.cjs.map +1 -1
  24. package/dist/pipeline/index.d.cts +3 -3
  25. package/dist/pipeline/index.d.ts +3 -3
  26. package/dist/pipeline/index.mjs +23 -4
  27. package/dist/pipeline/index.mjs.map +1 -1
  28. package/dist/{provider-factory-DxzOVEmh.d.cts → provider-factory-Bv-eIkhg.d.cts} +1 -1
  29. package/dist/{provider-factory-DxzOVEmh.d.ts → provider-factory-Bv-eIkhg.d.ts} +1 -1
  30. package/dist/storage/index.d.cts +2 -2
  31. package/dist/storage/index.d.ts +2 -2
  32. package/dist/{streamRunner-CYESG6IE.d.cts → streamRunner-kpS4MZP1.d.cts} +2 -1
  33. package/dist/{streamRunner-CYESG6IE.d.ts → streamRunner-kpS4MZP1.d.ts} +2 -1
  34. package/dist/workflow/index.cjs +67 -5
  35. package/dist/workflow/index.cjs.map +1 -1
  36. package/dist/workflow/index.d.cts +1 -1
  37. package/dist/workflow/index.d.ts +1 -1
  38. package/dist/workflow/index.mjs +67 -5
  39. package/dist/workflow/index.mjs.map +1 -1
  40. package/package.json +22 -23
@@ -1,4 +1,4 @@
1
- import { S as StreamRunnerOptions } from '../streamRunner-CYESG6IE.cjs';
1
+ import { S as StreamRunnerOptions } from '../streamRunner-kpS4MZP1.cjs';
2
2
 
3
3
  /**
4
4
  * Media Types — image generation, image search, video search cho học liệu.
@@ -1,4 +1,4 @@
1
- import { S as StreamRunnerOptions } from '../streamRunner-CYESG6IE.js';
1
+ import { S as StreamRunnerOptions } from '../streamRunner-kpS4MZP1.js';
2
2
 
3
3
  /**
4
4
  * Media Types — image generation, image search, video search cho học liệu.
@@ -426,14 +426,19 @@ function isModelAllowed(model) {
426
426
  });
427
427
  }
428
428
  function getDesignatedFallbackChain() {
429
- const rawProviders = resolveApiKey2("FALLBACK_AI_PROVIDER") || resolveApiKey2("FALLBACK_AI_PROVIDERS") || resolveApiKey2("DEFAULT_AI_PROVIDER") || "nvidia,openrouter";
430
- const rawModels = resolveApiKey2("FALLBACK_AI_MODEL") || resolveApiKey2("FALLBACK_AI_MODELS") || resolveApiKey2("DEFAULT_AI_MODEL") || "nvidia/nemotron-3-ultra-550b-a55b:free,@preset/coding-free,deepseek/deepseek-chat:free";
429
+ const rawProviders = resolveApiKey2("FALLBACK_AI_PROVIDER") || resolveApiKey2("FALLBACK_AI_PROVIDERS") || resolveApiKey2("DEFAULT_AI_PROVIDER") || "9router,nvidia,openrouter";
430
+ const rawModels = resolveApiKey2("FALLBACK_AI_MODEL") || resolveApiKey2("FALLBACK_AI_MODELS") || resolveApiKey2("DEFAULT_AI_MODEL") || "fast-reasoning,deep-reasoning,mid-range,free-tier";
431
431
  const providerList = rawProviders.split(",").map((p) => p.trim().toLowerCase()).filter((p) => p.length > 0 && isProviderEnabled(p));
432
432
  const modelList = rawModels.split(",").map((m) => m.trim()).filter((m) => m.length > 0 && isModelAllowed(m));
433
433
  const chain = [];
434
434
  for (const provider of providerList) {
435
435
  let providerModels = [];
436
- if (provider === "nvidia") {
436
+ if (provider === "9router" || provider === "ninerouter") {
437
+ providerModels = modelList.filter((m) => ["fast-reasoning", "deep-reasoning", "mid-range", "free-tier"].includes(m));
438
+ if (providerModels.length === 0) {
439
+ providerModels = ["fast-reasoning", "mid-range", "free-tier"];
440
+ }
441
+ } else if (provider === "nvidia") {
437
442
  providerModels = modelList.filter((m) => m.startsWith("nvidia/") || m.startsWith("meta/") || m.startsWith("mistralai/"));
438
443
  if (providerModels.length === 0) {
439
444
  providerModels = ["nvidia/nemotron-3-ultra-550b-a55b:free", "nvidia/nemotron-3.5-lightning-30b-a3b"];
@@ -704,8 +709,51 @@ Guidelines:
704
709
  }))
705
710
  ];
706
711
  const providerErrors = {};
707
- const requestedModel = options.model || "@preset/coding-free";
712
+ const requestedModel = options.model || "fast-reasoning";
708
713
  const isNvidiaPreferred = requestedModel.startsWith("nvidia/") || Boolean(nvidiaKey && !openrouterKey) && isProviderEnabled("nvidia");
714
+ const ninerouterKey = resolveApiKey2("NINEROUTER_API_KEY") || resolveApiKey2("NINE_ROUTER_API_KEY");
715
+ if (ninerouterKey && isProviderEnabled("9router")) {
716
+ const rawUrl = resolveApiKey2("NINEROUTER_BASE_URL") || resolveApiKey2("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
717
+ const ninerouterBaseUrl = rawUrl.replace(/^["']|["']$/g, "").replace(/\/$/, "");
718
+ const candidateModels = [
719
+ options.model || "fast-reasoning",
720
+ "fast-reasoning",
721
+ "mid-range",
722
+ "free-tier"
723
+ ].filter((m) => isModelAllowed(m));
724
+ const unique9RouterModels = Array.from(new Set(candidateModels));
725
+ for (const model of unique9RouterModels) {
726
+ try {
727
+ const idle = createStreamAbortController({ idleMs: 45e3, totalMs: 3e5 });
728
+ const res = await fetch(`${ninerouterBaseUrl}/chat/completions`, {
729
+ method: "POST",
730
+ headers: {
731
+ "Authorization": `Bearer ${ninerouterKey}`,
732
+ "Content-Type": "application/json"
733
+ },
734
+ body: JSON.stringify({
735
+ model,
736
+ messages: formattedMessages,
737
+ max_tokens: maxTokens,
738
+ temperature,
739
+ stream: true,
740
+ stream_options: { include_usage: true }
741
+ }),
742
+ signal: idle.signal
743
+ });
744
+ if (res.ok) {
745
+ const text = await processOpenAISSEStream(res, onChunk, idle);
746
+ if (text && text.trim()) return text;
747
+ } else {
748
+ const errText = await res.text().catch(() => "");
749
+ providerErrors[`9router_${model}`] = `HTTP ${res.status}: ${errText.slice(0, 120)}`;
750
+ }
751
+ } catch (e) {
752
+ providerErrors[`9router_${model}`] = e?.message || "Network error";
753
+ console.warn(`[9Router Stream] Failover for ${model}:`, e?.message || e);
754
+ }
755
+ }
756
+ }
709
757
  if (nvidiaKey && isProviderEnabled("nvidia")) {
710
758
  const candidateNemotronModels = [
711
759
  requestedModel.startsWith("nvidia/") ? requestedModel : "nvidia/nemotron-3-ultra-550b-a55b:free",