@thanh01.pmt/curriculum-kit 1.4.27 → 1.4.28

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/dist/ai/index.cjs CHANGED
@@ -726,7 +726,41 @@ Guidelines:
726
726
  );
727
727
  for (const target of fallbackChain) {
728
728
  const { provider, model } = target;
729
- if (provider === "nvidia" && nvidiaKey && isProviderEnabled("nvidia")) {
729
+ if ((provider === "9router" || provider === "ninerouter") && ninerouterKey && isProviderEnabled("9router")) {
730
+ try {
731
+ const rawUrl = resolveApiKey("NINEROUTER_BASE_URL") || resolveApiKey("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
732
+ const fbBaseUrl = rawUrl.replace(/["']/g, "").replace(/\/$/, "");
733
+ const idle = createStreamAbortController({ idleMs: 45e3, totalMs: 3e5 });
734
+ const res = await fetch(`${fbBaseUrl}/chat/completions`, {
735
+ method: "POST",
736
+ headers: {
737
+ "Authorization": `Bearer ${ninerouterKey}`,
738
+ "Content-Type": "application/json"
739
+ },
740
+ body: JSON.stringify({
741
+ model,
742
+ messages: formattedMessages,
743
+ max_tokens: maxTokens,
744
+ temperature,
745
+ stream: true,
746
+ stream_options: { include_usage: true }
747
+ }),
748
+ signal: idle.signal
749
+ });
750
+ if (res.ok) {
751
+ const text = await processOpenAISSEStream(res, onChunk, idle);
752
+ if (text && text.trim()) {
753
+ console.log(`[streamRunner] \u2705 Designated fallback 9Router (${model}) succeeded!`);
754
+ return text;
755
+ }
756
+ } else {
757
+ const errText = await res.text().catch(() => "");
758
+ providerErrors[`designated_fallback_9router_${model}`] = `HTTP ${res.status}: ${errText.slice(0, 120)}`;
759
+ }
760
+ } catch (e) {
761
+ providerErrors[`designated_fallback_9router_${model}`] = e?.message || "Network error";
762
+ }
763
+ } else if (provider === "nvidia" && nvidiaKey && isProviderEnabled("nvidia")) {
730
764
  try {
731
765
  const nvdIdle = options.idleTimeoutMs ?? 18e4;
732
766
  const nvdTotal = options.timeoutMs ?? 6e5;