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