@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.
@@ -963,7 +963,41 @@ Guidelines:
963
963
  );
964
964
  for (const target of fallbackChain) {
965
965
  const { provider, model } = target;
966
- if (provider === "nvidia" && nvidiaKey && isProviderEnabled("nvidia")) {
966
+ if ((provider === "9router" || provider === "ninerouter") && ninerouterKey && isProviderEnabled("9router")) {
967
+ try {
968
+ const rawUrl = resolveApiKey2("NINEROUTER_BASE_URL") || resolveApiKey2("NINE_ROUTER_BASE_URL") || "https://ai-router.orchable.app/v1";
969
+ const fbBaseUrl = rawUrl.replace(/["']/g, "").replace(/\/$/, "");
970
+ const idle = createStreamAbortController({ idleMs: 45e3, totalMs: 3e5 });
971
+ const res = await fetch(`${fbBaseUrl}/chat/completions`, {
972
+ method: "POST",
973
+ headers: {
974
+ "Authorization": `Bearer ${ninerouterKey}`,
975
+ "Content-Type": "application/json"
976
+ },
977
+ body: JSON.stringify({
978
+ model,
979
+ messages: formattedMessages,
980
+ max_tokens: maxTokens,
981
+ temperature,
982
+ stream: true,
983
+ stream_options: { include_usage: true }
984
+ }),
985
+ signal: idle.signal
986
+ });
987
+ if (res.ok) {
988
+ const text = await processOpenAISSEStream(res, onChunk, idle);
989
+ if (text && text.trim()) {
990
+ console.log(`[streamRunner] \u2705 Designated fallback 9Router (${model}) succeeded!`);
991
+ return text;
992
+ }
993
+ } else {
994
+ const errText = await res.text().catch(() => "");
995
+ providerErrors[`designated_fallback_9router_${model}`] = `HTTP ${res.status}: ${errText.slice(0, 120)}`;
996
+ }
997
+ } catch (e) {
998
+ providerErrors[`designated_fallback_9router_${model}`] = e?.message || "Network error";
999
+ }
1000
+ } else if (provider === "nvidia" && nvidiaKey && isProviderEnabled("nvidia")) {
967
1001
  try {
968
1002
  const nvdIdle = options.idleTimeoutMs ?? 18e4;
969
1003
  const nvdTotal = options.timeoutMs ?? 6e5;