@juspay/neurolink 12.0.4 → 12.1.0
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/CHANGELOG.md +3 -3
- package/dist/browser/neurolink.min.js +338 -334
- package/dist/cli/commands/setup.js +2 -1
- package/dist/constants/enums.d.ts +19 -0
- package/dist/constants/enums.js +20 -0
- package/dist/factories/providerDescriptors.js +16 -1
- package/dist/models/manifestRegistry.js +2 -0
- package/dist/models/manifests/cerebras.d.ts +9 -0
- package/dist/models/manifests/cerebras.js +19 -0
- package/dist/neurolink.js +109 -23
- package/dist/providers/openaiCompatCatalog.d.ts +1 -1
- package/dist/providers/openaiCompatCatalog.js +34 -3
- package/dist/types/providers.d.ts +4 -0
- package/dist/utils/modelChoices.js +17 -1
- package/dist/utils/providerConfig.d.ts +4 -0
- package/dist/utils/providerConfig.js +17 -0
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ import { handleGCPSetup } from "./setup-gcp.js";
|
|
|
20
20
|
import { handleHuggingFaceSetup } from "./setup-huggingface.js";
|
|
21
21
|
import { handleMistralSetup } from "./setup-mistral.js";
|
|
22
22
|
import { PROVIDER_DESCRIPTORS_BY_NAME } from "../../factories/providerDescriptors.js";
|
|
23
|
-
import { createCloudflareConfig, createCohereConfig, createDeepSeekConfig, createFireworksConfig, createGroqConfig, createIdeogramConfig, createJinaConfig, createNvidiaNimConfig, createOpenAICompatibleConfig, createPerplexityConfig, createRecraftConfig, createReplicateConfig, createStabilityConfig, createTogetherAIConfig, createVoyageConfig, createXaiConfig, satisfiesFallbacks, } from "../../utils/providerConfig.js";
|
|
23
|
+
import { createCloudflareConfig, createCohereConfig, createDeepSeekConfig, createFireworksConfig, createCerebrasConfig, createGroqConfig, createIdeogramConfig, createJinaConfig, createNvidiaNimConfig, createOpenAICompatibleConfig, createPerplexityConfig, createRecraftConfig, createReplicateConfig, createStabilityConfig, createTogetherAIConfig, createVoyageConfig, createXaiConfig, satisfiesFallbacks, } from "../../utils/providerConfig.js";
|
|
24
24
|
// Provider information database
|
|
25
25
|
const PROVIDERS = [
|
|
26
26
|
{
|
|
@@ -157,6 +157,7 @@ export const EXTRA_PROVIDER_CONFIGS = {
|
|
|
157
157
|
"nvidia-nim": createNvidiaNimConfig(),
|
|
158
158
|
xai: createXaiConfig(),
|
|
159
159
|
groq: createGroqConfig(),
|
|
160
|
+
cerebras: createCerebrasConfig(),
|
|
160
161
|
cohere: createCohereConfig(),
|
|
161
162
|
replicate: createReplicateConfig(),
|
|
162
163
|
"together-ai": createTogetherAIConfig(),
|
|
@@ -21,6 +21,7 @@ export declare enum AIProviderName {
|
|
|
21
21
|
LLAMACPP = "llamacpp",
|
|
22
22
|
XAI = "xai",
|
|
23
23
|
GROQ = "groq",
|
|
24
|
+
CEREBRAS = "cerebras",
|
|
24
25
|
COHERE = "cohere",
|
|
25
26
|
TOGETHER_AI = "together-ai",
|
|
26
27
|
FIREWORKS = "fireworks",
|
|
@@ -751,6 +752,24 @@ export declare enum GroqModels {
|
|
|
751
752
|
/** Llama 3.2 11B Vision Preview — smaller multimodal */
|
|
752
753
|
LLAMA_3_2_11B_VISION_PREVIEW = "llama-3.2-11b-vision-preview"
|
|
753
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Cerebras inference models (wafer-scale, OpenAI-compatible API).
|
|
757
|
+
* @see https://inference-docs.cerebras.ai/introduction
|
|
758
|
+
*
|
|
759
|
+
* Note the vendor's inconsistent id scheme: `llama3.1-8b` has no dash
|
|
760
|
+
* after "llama", while `llama-3.3-70b` does — both are the DOCUMENTED
|
|
761
|
+
* ids, not typos.
|
|
762
|
+
*/
|
|
763
|
+
export declare enum CerebrasModels {
|
|
764
|
+
/** Llama 3.3 70B — production default */
|
|
765
|
+
LLAMA_3_3_70B = "llama-3.3-70b",
|
|
766
|
+
/** Llama 3.1 8B — low-latency tier (vendor id has no dash after "llama") */
|
|
767
|
+
LLAMA_3_1_8B = "llama3.1-8b",
|
|
768
|
+
/** Qwen 3 32B */
|
|
769
|
+
QWEN_3_32B = "qwen-3-32b",
|
|
770
|
+
/** OpenAI GPT-OSS 120B (open-weight) */
|
|
771
|
+
GPT_OSS_120B = "gpt-oss-120b"
|
|
772
|
+
}
|
|
754
773
|
/**
|
|
755
774
|
* Cohere Command + Embed models.
|
|
756
775
|
* @see https://docs.cohere.com/docs/models
|
package/dist/constants/enums.js
CHANGED
|
@@ -25,6 +25,7 @@ export var AIProviderName;
|
|
|
25
25
|
AIProviderName["LLAMACPP"] = "llamacpp";
|
|
26
26
|
AIProviderName["XAI"] = "xai";
|
|
27
27
|
AIProviderName["GROQ"] = "groq";
|
|
28
|
+
AIProviderName["CEREBRAS"] = "cerebras";
|
|
28
29
|
AIProviderName["COHERE"] = "cohere";
|
|
29
30
|
AIProviderName["TOGETHER_AI"] = "together-ai";
|
|
30
31
|
AIProviderName["FIREWORKS"] = "fireworks";
|
|
@@ -1004,6 +1005,25 @@ export var GroqModels;
|
|
|
1004
1005
|
/** Llama 3.2 11B Vision Preview — smaller multimodal */
|
|
1005
1006
|
GroqModels["LLAMA_3_2_11B_VISION_PREVIEW"] = "llama-3.2-11b-vision-preview";
|
|
1006
1007
|
})(GroqModels || (GroqModels = {}));
|
|
1008
|
+
/**
|
|
1009
|
+
* Cerebras inference models (wafer-scale, OpenAI-compatible API).
|
|
1010
|
+
* @see https://inference-docs.cerebras.ai/introduction
|
|
1011
|
+
*
|
|
1012
|
+
* Note the vendor's inconsistent id scheme: `llama3.1-8b` has no dash
|
|
1013
|
+
* after "llama", while `llama-3.3-70b` does — both are the DOCUMENTED
|
|
1014
|
+
* ids, not typos.
|
|
1015
|
+
*/
|
|
1016
|
+
export var CerebrasModels;
|
|
1017
|
+
(function (CerebrasModels) {
|
|
1018
|
+
/** Llama 3.3 70B — production default */
|
|
1019
|
+
CerebrasModels["LLAMA_3_3_70B"] = "llama-3.3-70b";
|
|
1020
|
+
/** Llama 3.1 8B — low-latency tier (vendor id has no dash after "llama") */
|
|
1021
|
+
CerebrasModels["LLAMA_3_1_8B"] = "llama3.1-8b";
|
|
1022
|
+
/** Qwen 3 32B */
|
|
1023
|
+
CerebrasModels["QWEN_3_32B"] = "qwen-3-32b";
|
|
1024
|
+
/** OpenAI GPT-OSS 120B (open-weight) */
|
|
1025
|
+
CerebrasModels["GPT_OSS_120B"] = "gpt-oss-120b";
|
|
1026
|
+
})(CerebrasModels || (CerebrasModels = {}));
|
|
1007
1027
|
/**
|
|
1008
1028
|
* Cohere Command + Embed models.
|
|
1009
1029
|
* @see https://docs.cohere.com/docs/models
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import { GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, MistralModels, OllamaModels, LiteLLMModels, HuggingFaceModels, DeepSeekModels, NvidiaNimModels, OpenRouterModels, XaiModels, GroqModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
2
|
+
import { GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, MistralModels, OllamaModels, LiteLLMModels, HuggingFaceModels, DeepSeekModels, NvidiaNimModels, OpenRouterModels, XaiModels, GroqModels, CerebrasModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
3
3
|
import { API_KEY_FORMATS } from "../utils/providerConfig.js";
|
|
4
4
|
/**
|
|
5
5
|
* Single source of truth for provider identity, credentials, defaults, and
|
|
@@ -368,6 +368,21 @@ export const PROVIDER_DESCRIPTORS = [
|
|
|
368
368
|
healthCheck: "env-only",
|
|
369
369
|
setupUrl: "https://console.x.ai/",
|
|
370
370
|
},
|
|
371
|
+
{
|
|
372
|
+
name: AIProviderName.CEREBRAS,
|
|
373
|
+
aliases: [],
|
|
374
|
+
credentialsKey: "cerebras",
|
|
375
|
+
envVars: {
|
|
376
|
+
apiKey: "CEREBRAS_API_KEY",
|
|
377
|
+
baseURL: "CEREBRAS_BASE_URL",
|
|
378
|
+
model: "CEREBRAS_MODEL",
|
|
379
|
+
},
|
|
380
|
+
defaultModel: CerebrasModels.LLAMA_3_3_70B,
|
|
381
|
+
toolSupport: "native",
|
|
382
|
+
localRuntime: false,
|
|
383
|
+
healthCheck: "env-only",
|
|
384
|
+
setupUrl: "https://cloud.cerebras.ai",
|
|
385
|
+
},
|
|
371
386
|
{
|
|
372
387
|
name: AIProviderName.GROQ,
|
|
373
388
|
aliases: [],
|
|
@@ -18,6 +18,7 @@ import { lmStudioManifest } from "./manifests/lm-studio.js";
|
|
|
18
18
|
import { llamacppManifest } from "./manifests/llamacpp.js";
|
|
19
19
|
import { xaiManifest } from "./manifests/xai.js";
|
|
20
20
|
import { groqManifest } from "./manifests/groq.js";
|
|
21
|
+
import { cerebrasManifest } from "./manifests/cerebras.js";
|
|
21
22
|
import { cohereManifest } from "./manifests/cohere.js";
|
|
22
23
|
import { togetherAiManifest } from "./manifests/together-ai.js";
|
|
23
24
|
import { fireworksManifest } from "./manifests/fireworks.js";
|
|
@@ -56,6 +57,7 @@ export const MANIFEST_REGISTRY = {
|
|
|
56
57
|
llamacpp: llamacppManifest,
|
|
57
58
|
xai: xaiManifest,
|
|
58
59
|
groq: groqManifest,
|
|
60
|
+
cerebras: cerebrasManifest,
|
|
59
61
|
cohere: cohereManifest,
|
|
60
62
|
"together-ai": togetherAiManifest,
|
|
61
63
|
fireworks: fireworksManifest,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProviderModelManifest } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal manifest: conservative floor values pending live verification —
|
|
4
|
+
* Cerebras serves large-context models, but the free tier caps effective
|
|
5
|
+
* context/output well below the architectural maximums, so these defaults
|
|
6
|
+
* stay deliberately modest. Named models can be added incrementally
|
|
7
|
+
* without touching any consumer — same pattern as groq.ts.
|
|
8
|
+
*/
|
|
9
|
+
export declare const cerebrasManifest: ProviderModelManifest;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal manifest: conservative floor values pending live verification —
|
|
3
|
+
* Cerebras serves large-context models, but the free tier caps effective
|
|
4
|
+
* context/output well below the architectural maximums, so these defaults
|
|
5
|
+
* stay deliberately modest. Named models can be added incrementally
|
|
6
|
+
* without touching any consumer — same pattern as groq.ts.
|
|
7
|
+
*/
|
|
8
|
+
export const cerebrasManifest = {
|
|
9
|
+
defaultContextWindow: 65536,
|
|
10
|
+
models: {
|
|
11
|
+
_default: {
|
|
12
|
+
aliases: [],
|
|
13
|
+
contextWindow: 65536,
|
|
14
|
+
maxOutputTokens: 8192,
|
|
15
|
+
vision: false,
|
|
16
|
+
functionCalling: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
package/dist/neurolink.js
CHANGED
|
@@ -6070,32 +6070,118 @@ Current user's request: ${currentInput}`;
|
|
|
6070
6070
|
// oversized case. When the budget check shows the request is
|
|
6071
6071
|
// over budget but there's nothing to compact (no memory + no
|
|
6072
6072
|
// inline messages — e.g. a huge prompt or huge tool definitions
|
|
6073
|
-
// alone),
|
|
6073
|
+
// alone), recover by WINDOWING the prompt when the prompt is what
|
|
6074
|
+
// blew the budget: keep its head and tail around an elision marker
|
|
6075
|
+
// and dispatch. Agentic callers (Yama's session loop) carry their
|
|
6076
|
+
// whole tool transcript in the prompt; the previous
|
|
6077
|
+
// unconditional throw dead-ended every such turn — observed live
|
|
6078
|
+
// as an unbounded retry loop (93K→299K tokens, no verdict, ever).
|
|
6079
|
+
// The throw remains for the truly unrecoverable case: system
|
|
6080
|
+
// prompt + tool definitions alone exceed the budget.
|
|
6081
|
+
let promptWindowRecovered = false;
|
|
6074
6082
|
if (!budgetCheck.withinBudget && !dpgHasCompactableMessages) {
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6083
|
+
const fixedOverhead = (budgetCheck.breakdown?.systemPrompt ?? 0) +
|
|
6084
|
+
(budgetCheck.breakdown?.toolDefinitions ?? 0) +
|
|
6085
|
+
(budgetCheck.breakdown?.fileAttachments ?? 0);
|
|
6086
|
+
// 3% margin against estimator drift; 1024-token floor — below
|
|
6087
|
+
// that, a windowed prompt carries too little to answer from.
|
|
6088
|
+
const promptBudget = Math.floor((budgetCheck.availableInputTokens - fixedOverhead) * 0.97);
|
|
6089
|
+
const promptText = typeof options.prompt === "string" ? options.prompt : undefined;
|
|
6090
|
+
if (promptText &&
|
|
6091
|
+
promptBudget >= 1024 &&
|
|
6092
|
+
(budgetCheck.breakdown?.currentPrompt ?? 0) > promptBudget) {
|
|
6093
|
+
const marker = "\n\n[... middle of this prompt elided by NeuroLink to fit the model's context window ...]\n\n";
|
|
6094
|
+
// Proportional char budget from the observed chars-per-token of
|
|
6095
|
+
// THIS text, re-checked and shrunk until the estimator agrees.
|
|
6096
|
+
let charBudget = Math.floor(promptText.length *
|
|
6097
|
+
(promptBudget /
|
|
6098
|
+
Math.max(budgetCheck.breakdown?.currentPrompt ?? 1, 1)));
|
|
6099
|
+
let windowed = promptText;
|
|
6100
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
6101
|
+
const headChars = Math.floor(charBudget * 0.6);
|
|
6102
|
+
const tailChars = Math.max(charBudget - headChars - marker.length, 0);
|
|
6103
|
+
windowed =
|
|
6104
|
+
promptText.slice(0, headChars) +
|
|
6105
|
+
marker +
|
|
6106
|
+
(tailChars > 0 ? promptText.slice(-tailChars) : "");
|
|
6107
|
+
const recheck = checkContextBudget({
|
|
6108
|
+
provider: providerName,
|
|
6109
|
+
model: options.model,
|
|
6110
|
+
maxTokens: options.maxTokens,
|
|
6111
|
+
systemPrompt: options.systemPrompt,
|
|
6112
|
+
conversationMessages: [],
|
|
6113
|
+
currentPrompt: windowed,
|
|
6114
|
+
toolDefinitions: options.tools
|
|
6115
|
+
? Object.values(options.tools)
|
|
6116
|
+
: undefined,
|
|
6117
|
+
});
|
|
6118
|
+
if (recheck.withinBudget) {
|
|
6119
|
+
break;
|
|
6120
|
+
}
|
|
6121
|
+
charBudget = Math.floor(charBudget * 0.8);
|
|
6122
|
+
if (attempt === 3) {
|
|
6123
|
+
windowed = promptText; // give up — fall through to the throw
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
if (windowed !== promptText) {
|
|
6127
|
+
logger.warn("[NeuroLink] Prompt exceeded the model's context budget with nothing to compact — " +
|
|
6128
|
+
"windowed the prompt (head+tail kept, middle elided) to fit.", {
|
|
6129
|
+
provider: providerName,
|
|
6130
|
+
model: options.model,
|
|
6131
|
+
estimatedTokens: budgetCheck.estimatedInputTokens,
|
|
6132
|
+
budget: budgetCheck.availableInputTokens,
|
|
6133
|
+
originalPromptChars: promptText.length,
|
|
6134
|
+
windowedPromptChars: windowed.length,
|
|
6135
|
+
});
|
|
6136
|
+
try {
|
|
6137
|
+
this.emitter.emit("compaction.applied", {
|
|
6138
|
+
stagesAttempted: ["pre-dispatch prompt window"],
|
|
6139
|
+
finalTokens: budgetCheck.availableInputTokens,
|
|
6140
|
+
budget: budgetCheck.availableInputTokens,
|
|
6141
|
+
provider: providerName,
|
|
6142
|
+
model: options.model,
|
|
6143
|
+
phase: "pre-dispatch-prompt-window",
|
|
6144
|
+
timestamp: Date.now(),
|
|
6145
|
+
});
|
|
6146
|
+
}
|
|
6147
|
+
catch {
|
|
6148
|
+
/* listener errors are non-fatal */
|
|
6149
|
+
}
|
|
6150
|
+
options.prompt = windowed;
|
|
6151
|
+
const inputHolder = options
|
|
6152
|
+
.input;
|
|
6153
|
+
if (inputHolder && typeof inputHolder.text === "string") {
|
|
6154
|
+
inputHolder.text = windowed;
|
|
6155
|
+
}
|
|
6156
|
+
promptWindowRecovered = true;
|
|
6157
|
+
}
|
|
6085
6158
|
}
|
|
6086
|
-
|
|
6087
|
-
|
|
6159
|
+
if (!promptWindowRecovered) {
|
|
6160
|
+
try {
|
|
6161
|
+
this.emitter.emit("compaction.insufficient", {
|
|
6162
|
+
stagesAttempted: ["pre-dispatch hard cap"],
|
|
6163
|
+
finalTokens: budgetCheck.estimatedInputTokens,
|
|
6164
|
+
budget: budgetCheck.availableInputTokens,
|
|
6165
|
+
provider: providerName,
|
|
6166
|
+
model: options.model,
|
|
6167
|
+
phase: "pre-dispatch-no-recovery",
|
|
6168
|
+
timestamp: Date.now(),
|
|
6169
|
+
});
|
|
6170
|
+
}
|
|
6171
|
+
catch {
|
|
6172
|
+
/* listener errors are non-fatal */
|
|
6173
|
+
}
|
|
6174
|
+
throw new ContextBudgetExceededError(`Context exceeds model budget and no compaction is possible ` +
|
|
6175
|
+
`(no conversationMemory, no inline conversationMessages — only ` +
|
|
6176
|
+
`prompt + tools). Estimated: ${budgetCheck.estimatedInputTokens} ` +
|
|
6177
|
+
`tokens, budget: ${budgetCheck.availableInputTokens} tokens. ` +
|
|
6178
|
+
`Reduce prompt or tool-definition size, or trim the request.`, {
|
|
6179
|
+
estimatedTokens: budgetCheck.estimatedInputTokens,
|
|
6180
|
+
availableTokens: budgetCheck.availableInputTokens,
|
|
6181
|
+
stagesUsed: [],
|
|
6182
|
+
breakdown: budgetCheck.breakdown,
|
|
6183
|
+
});
|
|
6088
6184
|
}
|
|
6089
|
-
throw new ContextBudgetExceededError(`Context exceeds model budget and no compaction is possible ` +
|
|
6090
|
-
`(no conversationMemory, no inline conversationMessages — only ` +
|
|
6091
|
-
`prompt + tools). Estimated: ${budgetCheck.estimatedInputTokens} ` +
|
|
6092
|
-
`tokens, budget: ${budgetCheck.availableInputTokens} tokens. ` +
|
|
6093
|
-
`Reduce prompt or tool-definition size, or trim the request.`, {
|
|
6094
|
-
estimatedTokens: budgetCheck.estimatedInputTokens,
|
|
6095
|
-
availableTokens: budgetCheck.availableInputTokens,
|
|
6096
|
-
stagesUsed: [],
|
|
6097
|
-
breakdown: budgetCheck.breakdown,
|
|
6098
|
-
});
|
|
6099
6185
|
}
|
|
6100
6186
|
if (budgetCheck.shouldCompact &&
|
|
6101
6187
|
(this.conversationMemory || dpgHasInlineMessages) &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenAICompatCatalogEntry } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Config-driven catalog of the
|
|
3
|
+
* Config-driven catalog of the 8 zero-quirk OpenAI-compatible providers.
|
|
4
4
|
* Each entry fully replaces what used to be a hand-written
|
|
5
5
|
* OpenAIChatCompletionsProvider subclass — see ConfiguredOpenAICompatProvider
|
|
6
6
|
* for the class that reads these entries, and providerRegistry.ts for the
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import { CloudflareModels, FireworksModels, GroqModels, MistralModels, PerplexityModels, TogetherAIModels, XaiModels, } from "../constants/enums.js";
|
|
2
|
+
import { CerebrasModels, CloudflareModels, FireworksModels, GroqModels, MistralModels, PerplexityModels, TogetherAIModels, XaiModels, } from "../constants/enums.js";
|
|
3
3
|
import { AuthenticationError, InvalidModelError, ProviderError, } from "../types/index.js";
|
|
4
4
|
import { DEFAULT_ERROR_RULES } from "../utils/errorClassifier.js";
|
|
5
|
-
import { createCloudflareConfig, createFireworksConfig, createGroqConfig, createMistralConfig, createPerplexityConfig, createTogetherAIConfig, createXaiConfig, } from "../utils/providerConfig.js";
|
|
5
|
+
import { createCerebrasConfig, createCloudflareConfig, createFireworksConfig, createGroqConfig, createMistralConfig, createPerplexityConfig, createTogetherAIConfig, createXaiConfig, } from "../utils/providerConfig.js";
|
|
6
6
|
function buildCloudflareBaseURL(accountId) {
|
|
7
7
|
return `https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1`;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Config-driven catalog of the
|
|
10
|
+
* Config-driven catalog of the 8 zero-quirk OpenAI-compatible providers.
|
|
11
11
|
* Each entry fully replaces what used to be a hand-written
|
|
12
12
|
* OpenAIChatCompletionsProvider subclass — see ConfiguredOpenAICompatProvider
|
|
13
13
|
* for the class that reads these entries, and providerRegistry.ts for the
|
|
@@ -29,6 +29,37 @@ function buildCloudflareBaseURL(accountId) {
|
|
|
29
29
|
* Task 14's docs task for the deciding criteria).
|
|
30
30
|
*/
|
|
31
31
|
export const OPENAI_COMPAT_CATALOG = [
|
|
32
|
+
{
|
|
33
|
+
providerName: AIProviderName.CEREBRAS,
|
|
34
|
+
aliases: ["cerebras"],
|
|
35
|
+
apiKeyEnvVar: "CEREBRAS_API_KEY",
|
|
36
|
+
baseURLEnvVar: "CEREBRAS_BASE_URL",
|
|
37
|
+
defaultBaseURL: "https://api.cerebras.ai/v1",
|
|
38
|
+
configOptions: createCerebrasConfig(),
|
|
39
|
+
modelEnvVar: "CEREBRAS_MODEL",
|
|
40
|
+
defaultModel: CerebrasModels.LLAMA_3_3_70B,
|
|
41
|
+
registryDefaultModel: CerebrasModels.LLAMA_3_3_70B,
|
|
42
|
+
registryDefaultModelChecksEnvVar: true,
|
|
43
|
+
fallbackModelName: CerebrasModels.LLAMA_3_1_8B,
|
|
44
|
+
fallbackModels: [
|
|
45
|
+
CerebrasModels.LLAMA_3_3_70B,
|
|
46
|
+
CerebrasModels.LLAMA_3_1_8B,
|
|
47
|
+
CerebrasModels.QWEN_3_32B,
|
|
48
|
+
CerebrasModels.GPT_OSS_120B,
|
|
49
|
+
],
|
|
50
|
+
errorRules: [
|
|
51
|
+
{
|
|
52
|
+
// Probed live 2026-08-26: a bad key gets HTTP 401 with body
|
|
53
|
+
// {"message":"Wrong API Key","type":"invalid_request_error",
|
|
54
|
+
// "param":"api_key","code":"wrong_api_key"}.
|
|
55
|
+
match: (ctx) => ctx.statusCode === 401 ||
|
|
56
|
+
/wrong_api_key|Wrong API Key|invalid_api_key/i.test(ctx.message),
|
|
57
|
+
errorClass: AuthenticationError,
|
|
58
|
+
message: "Invalid Cerebras API key. Check CEREBRAS_API_KEY. Get one at https://cloud.cerebras.ai",
|
|
59
|
+
},
|
|
60
|
+
...DEFAULT_ERROR_RULES,
|
|
61
|
+
],
|
|
62
|
+
},
|
|
32
63
|
{
|
|
33
64
|
providerName: AIProviderName.GROQ,
|
|
34
65
|
aliases: ["groq"],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Centralized model choices for CLI commands
|
|
3
3
|
* Derives choices from model enums to ensure consistency
|
|
4
4
|
*/
|
|
5
|
-
import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, MistralModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, XaiModels, GroqModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
5
|
+
import { AIProviderName, OpenAIModels, AnthropicModels, GoogleAIModels, BedrockModels, VertexModels, MistralModels, OllamaModels, AzureOpenAIModels, LiteLLMModels, HuggingFaceModels, SageMakerModels, OpenRouterModels, DeepSeekModels, NvidiaNimModels, XaiModels, GroqModels, CerebrasModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
6
6
|
/**
|
|
7
7
|
* Top models per provider with descriptions for CLI prompts
|
|
8
8
|
* These are curated lists of the most commonly used/recommended models
|
|
@@ -302,6 +302,21 @@ const TOP_MODELS_CONFIG = {
|
|
|
302
302
|
description: "Mistral 8x7B MoE, 32K context",
|
|
303
303
|
},
|
|
304
304
|
],
|
|
305
|
+
[AIProviderName.CEREBRAS]: [
|
|
306
|
+
{
|
|
307
|
+
model: CerebrasModels.LLAMA_3_3_70B,
|
|
308
|
+
description: "Recommended - Production default; wafer-scale speed",
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
model: CerebrasModels.LLAMA_3_1_8B,
|
|
312
|
+
description: "Lowest latency tier",
|
|
313
|
+
},
|
|
314
|
+
{ model: CerebrasModels.QWEN_3_32B, description: "Qwen 3 32B" },
|
|
315
|
+
{
|
|
316
|
+
model: CerebrasModels.GPT_OSS_120B,
|
|
317
|
+
description: "OpenAI GPT-OSS 120B (open-weight)",
|
|
318
|
+
},
|
|
319
|
+
],
|
|
305
320
|
[AIProviderName.COHERE]: [
|
|
306
321
|
{
|
|
307
322
|
model: CohereModels.COMMAND_R_PLUS,
|
|
@@ -539,6 +554,7 @@ const MODEL_ENUMS = {
|
|
|
539
554
|
[AIProviderName.LLAMACPP]: null,
|
|
540
555
|
[AIProviderName.XAI]: XaiModels,
|
|
541
556
|
[AIProviderName.GROQ]: GroqModels,
|
|
557
|
+
[AIProviderName.CEREBRAS]: CerebrasModels,
|
|
542
558
|
[AIProviderName.COHERE]: CohereModels,
|
|
543
559
|
[AIProviderName.TOGETHER_AI]: TogetherAIModels,
|
|
544
560
|
[AIProviderName.FIREWORKS]: FireworksModels,
|
|
@@ -135,6 +135,10 @@ export declare function createNvidiaNimConfig(): ProviderConfigOptions;
|
|
|
135
135
|
* Creates xAI Grok provider configuration.
|
|
136
136
|
*/
|
|
137
137
|
export declare function createXaiConfig(): ProviderConfigOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Creates Cerebras provider configuration.
|
|
140
|
+
*/
|
|
141
|
+
export declare function createCerebrasConfig(): ProviderConfigOptions;
|
|
138
142
|
/**
|
|
139
143
|
* Creates Groq provider configuration.
|
|
140
144
|
*/
|
|
@@ -451,6 +451,23 @@ export function createXaiConfig() {
|
|
|
451
451
|
],
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Creates Cerebras provider configuration.
|
|
456
|
+
*/
|
|
457
|
+
export function createCerebrasConfig() {
|
|
458
|
+
return {
|
|
459
|
+
providerName: "Cerebras",
|
|
460
|
+
envVarName: "CEREBRAS_API_KEY",
|
|
461
|
+
setupUrl: "https://cloud.cerebras.ai",
|
|
462
|
+
description: "API key",
|
|
463
|
+
instructions: [
|
|
464
|
+
"1. Visit: https://cloud.cerebras.ai",
|
|
465
|
+
"2. Sign in or create a free Cerebras account",
|
|
466
|
+
"3. Create an API key under API Keys",
|
|
467
|
+
"4. Set CEREBRAS_API_KEY in your .env file",
|
|
468
|
+
],
|
|
469
|
+
};
|
|
470
|
+
}
|
|
454
471
|
/**
|
|
455
472
|
* Creates Groq provider configuration.
|
|
456
473
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
|
|
6
6
|
"author": {
|