@juspay/neurolink 10.12.9 → 11.0.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 +26 -0
- package/dist/browser/neurolink.min.js +407 -409
- package/dist/cli/commands/setup.d.ts +16 -1
- package/dist/cli/commands/setup.js +141 -3
- package/dist/core/baseProvider.js +3 -3
- package/dist/core/dynamicModels.d.ts +1 -1
- package/dist/core/dynamicModels.js +1 -23
- package/dist/core/modelConfiguration.d.ts +1 -70
- package/dist/core/modelConfiguration.js +0 -303
- package/dist/core/modules/GenerationHandler.js +2 -2
- package/dist/core/modules/structuredOutputPolicy.d.ts +2 -2
- package/dist/core/modules/structuredOutputPolicy.js +2 -2
- package/dist/factories/providerFactory.d.ts +15 -0
- package/dist/factories/providerFactory.js +27 -39
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/lib/core/baseProvider.js +3 -3
- package/dist/lib/core/dynamicModels.d.ts +1 -1
- package/dist/lib/core/dynamicModels.js +1 -23
- package/dist/lib/core/modelConfiguration.d.ts +1 -70
- package/dist/lib/core/modelConfiguration.js +0 -303
- package/dist/lib/core/modules/GenerationHandler.js +2 -2
- package/dist/lib/core/modules/structuredOutputPolicy.d.ts +2 -2
- package/dist/lib/core/modules/structuredOutputPolicy.js +2 -2
- package/dist/lib/factories/providerFactory.d.ts +15 -0
- package/dist/lib/factories/providerFactory.js +27 -39
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/models/anthropicModels.d.ts +0 -7
- package/dist/lib/models/anthropicModels.js +0 -9
- package/dist/lib/providers/anthropic/constants.d.ts +0 -1
- package/dist/lib/providers/anthropic/constants.js +0 -2
- package/dist/lib/providers/anthropic/index.d.ts +0 -1
- package/dist/lib/providers/anthropic/index.js +0 -1
- package/dist/lib/providers/googleAiStudio/index.d.ts +0 -1
- package/dist/lib/providers/googleAiStudio/index.js +0 -1
- package/dist/lib/providers/googleNativeGemini3/index.d.ts +0 -1
- package/dist/lib/providers/googleNativeGemini3/index.js +0 -1
- package/dist/lib/providers/googleVertex/client.d.ts +0 -51
- package/dist/lib/providers/googleVertex/client.js +0 -678
- package/dist/lib/providers/huggingFace/client.d.ts +1 -1
- package/dist/lib/providers/huggingFace/client.js +1 -1
- package/dist/lib/providers/huggingFace/index.d.ts +0 -1
- package/dist/lib/providers/huggingFace/index.js +0 -1
- package/dist/lib/providers/jina.d.ts +0 -1
- package/dist/lib/providers/jina.js +0 -1
- package/dist/lib/providers/litellm/index.d.ts +0 -2
- package/dist/lib/providers/litellm/index.js +0 -2
- package/dist/lib/providers/llamaCpp.d.ts +1 -0
- package/dist/lib/providers/llamaCpp.js +3 -0
- package/dist/lib/providers/lmStudio.js +3 -23
- package/dist/lib/providers/nvidiaNim/index.d.ts +0 -1
- package/dist/lib/providers/nvidiaNim/index.js +0 -1
- package/dist/lib/providers/ollama/client.js +1 -23
- package/dist/lib/providers/ollama/index.d.ts +0 -1
- package/dist/lib/providers/ollama/index.js +0 -1
- package/dist/lib/providers/openAI/index.d.ts +0 -2
- package/dist/lib/providers/openAI/index.js +0 -2
- package/dist/lib/providers/openRouter/utils.d.ts +0 -2
- package/dist/lib/providers/openRouter/utils.js +0 -12
- package/dist/lib/providers/openaiChatCompletionsBase.d.ts +9 -0
- package/dist/lib/providers/openaiChatCompletionsBase.js +33 -0
- package/dist/lib/providers/perplexity.d.ts +2 -1
- package/dist/lib/providers/perplexity.js +2 -1
- package/dist/lib/providers/replicate.d.ts +0 -1
- package/dist/lib/providers/replicate.js +22 -9
- package/dist/lib/providers/voyage.d.ts +0 -1
- package/dist/lib/providers/voyage.js +0 -1
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/providers.d.ts +2 -11
- package/dist/lib/utils/providerConfig.d.ts +0 -8
- package/dist/lib/utils/providerConfig.js +0 -37
- package/dist/lib/utils/providerUtils.js +1 -25
- package/dist/models/anthropicModels.d.ts +0 -7
- package/dist/models/anthropicModels.js +0 -9
- package/dist/providers/anthropic/constants.d.ts +0 -1
- package/dist/providers/anthropic/constants.js +0 -2
- package/dist/providers/anthropic/index.d.ts +0 -1
- package/dist/providers/anthropic/index.js +0 -1
- package/dist/providers/googleAiStudio/index.d.ts +0 -1
- package/dist/providers/googleAiStudio/index.js +0 -1
- package/dist/providers/googleNativeGemini3/index.d.ts +0 -1
- package/dist/providers/googleNativeGemini3/index.js +0 -1
- package/dist/providers/googleVertex/client.d.ts +0 -51
- package/dist/providers/googleVertex/client.js +0 -678
- package/dist/providers/huggingFace/client.d.ts +1 -1
- package/dist/providers/huggingFace/client.js +1 -1
- package/dist/providers/huggingFace/index.d.ts +0 -1
- package/dist/providers/huggingFace/index.js +0 -1
- package/dist/providers/jina.d.ts +0 -1
- package/dist/providers/jina.js +0 -1
- package/dist/providers/litellm/index.d.ts +0 -2
- package/dist/providers/litellm/index.js +0 -2
- package/dist/providers/llamaCpp.d.ts +1 -0
- package/dist/providers/llamaCpp.js +3 -0
- package/dist/providers/lmStudio.js +3 -23
- package/dist/providers/nvidiaNim/index.d.ts +0 -1
- package/dist/providers/nvidiaNim/index.js +0 -1
- package/dist/providers/ollama/client.js +1 -23
- package/dist/providers/ollama/index.d.ts +0 -1
- package/dist/providers/ollama/index.js +0 -1
- package/dist/providers/openAI/index.d.ts +0 -2
- package/dist/providers/openAI/index.js +0 -2
- package/dist/providers/openRouter/utils.d.ts +0 -2
- package/dist/providers/openRouter/utils.js +0 -12
- package/dist/providers/openaiChatCompletionsBase.d.ts +9 -0
- package/dist/providers/openaiChatCompletionsBase.js +33 -0
- package/dist/providers/perplexity.d.ts +2 -1
- package/dist/providers/perplexity.js +2 -1
- package/dist/providers/replicate.d.ts +0 -1
- package/dist/providers/replicate.js +22 -9
- package/dist/providers/voyage.d.ts +0 -1
- package/dist/providers/voyage.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/providers.d.ts +2 -11
- package/dist/utils/providerConfig.d.ts +0 -8
- package/dist/utils/providerConfig.js +0 -37
- package/dist/utils/providerUtils.js +1 -25
- package/package.json +8 -7
- package/dist/lib/providers/anthropic/utils.d.ts +0 -7
- package/dist/lib/providers/anthropic/utils.js +0 -150
- package/dist/lib/providers/googleAiStudio/utils.d.ts +0 -2
- package/dist/lib/providers/googleAiStudio/utils.js +0 -19
- package/dist/lib/providers/googleNativeGemini3/constants.d.ts +0 -1
- package/dist/lib/providers/googleNativeGemini3/constants.js +0 -2
- package/dist/lib/providers/huggingFace/utils.d.ts +0 -2
- package/dist/lib/providers/huggingFace/utils.js +0 -8
- package/dist/lib/providers/index.d.ts +0 -33
- package/dist/lib/providers/index.js +0 -34
- package/dist/lib/providers/litellm/constants.d.ts +0 -1
- package/dist/lib/providers/litellm/constants.js +0 -3
- package/dist/lib/providers/litellm/utils.d.ts +0 -5
- package/dist/lib/providers/litellm/utils.js +0 -11
- package/dist/lib/providers/nvidiaNim/utils.d.ts +0 -9
- package/dist/lib/providers/nvidiaNim/utils.js +0 -101
- package/dist/lib/providers/ollama/utils.d.ts +0 -8
- package/dist/lib/providers/ollama/utils.js +0 -43
- package/dist/lib/providers/openAI/constants.d.ts +0 -1
- package/dist/lib/providers/openAI/constants.js +0 -3
- package/dist/lib/providers/openAI/utils.d.ts +0 -2
- package/dist/lib/providers/openAI/utils.js +0 -8
- package/dist/lib/types/universalProviderOptions.d.ts +0 -89
- package/dist/lib/types/universalProviderOptions.js +0 -55
- package/dist/providers/anthropic/utils.d.ts +0 -7
- package/dist/providers/anthropic/utils.js +0 -149
- package/dist/providers/googleAiStudio/utils.d.ts +0 -2
- package/dist/providers/googleAiStudio/utils.js +0 -18
- package/dist/providers/googleNativeGemini3/constants.d.ts +0 -1
- package/dist/providers/googleNativeGemini3/constants.js +0 -1
- package/dist/providers/huggingFace/utils.d.ts +0 -2
- package/dist/providers/huggingFace/utils.js +0 -7
- package/dist/providers/index.d.ts +0 -33
- package/dist/providers/index.js +0 -33
- package/dist/providers/litellm/constants.d.ts +0 -1
- package/dist/providers/litellm/constants.js +0 -2
- package/dist/providers/litellm/utils.d.ts +0 -5
- package/dist/providers/litellm/utils.js +0 -10
- package/dist/providers/nvidiaNim/utils.d.ts +0 -9
- package/dist/providers/nvidiaNim/utils.js +0 -100
- package/dist/providers/ollama/utils.d.ts +0 -8
- package/dist/providers/ollama/utils.js +0 -42
- package/dist/providers/openAI/constants.d.ts +0 -1
- package/dist/providers/openAI/constants.js +0 -2
- package/dist/providers/openAI/utils.d.ts +0 -2
- package/dist/providers/openAI/utils.js +0 -7
- package/dist/types/universalProviderOptions.d.ts +0 -89
- package/dist/types/universalProviderOptions.js +0 -54
|
@@ -14,7 +14,7 @@ import { OpenAIChatCompletionsProvider } from "../openaiChatCompletionsBase.js";
|
|
|
14
14
|
* @see https://huggingface.co/docs/api-inference/index
|
|
15
15
|
*/
|
|
16
16
|
export declare class HuggingFaceProvider extends OpenAIChatCompletionsProvider {
|
|
17
|
-
constructor(modelName?: string, sdk?: unknown, credentials?: NeurolinkCredentials["huggingFace"]);
|
|
17
|
+
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["huggingFace"]);
|
|
18
18
|
protected getProviderName(): AIProviderName;
|
|
19
19
|
protected getDefaultModel(): string;
|
|
20
20
|
protected getFallbackModelName(): string;
|
|
@@ -20,7 +20,7 @@ const getDefaultHuggingFaceModel = () => getProviderModel("HUGGINGFACE_MODEL", "
|
|
|
20
20
|
* @see https://huggingface.co/docs/api-inference/index
|
|
21
21
|
*/
|
|
22
22
|
export class HuggingFaceProvider extends OpenAIChatCompletionsProvider {
|
|
23
|
-
constructor(modelName, sdk, credentials) {
|
|
23
|
+
constructor(modelName, sdk, _region, credentials) {
|
|
24
24
|
const apiKey = credentials?.apiKey?.trim()
|
|
25
25
|
? credentials.apiKey.trim()
|
|
26
26
|
: getHuggingFaceApiKey();
|
|
@@ -15,6 +15,7 @@ import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class LlamaCppProvider extends OpenAIChatCompletionsProvider {
|
|
17
17
|
constructor(modelName?: string, sdk?: unknown, _region?: string, credentials?: NeurolinkCredentials["llamacpp"]);
|
|
18
|
+
validateConfiguration(): Promise<boolean>;
|
|
18
19
|
protected getProviderName(): AIProviderName;
|
|
19
20
|
protected getDefaultModel(): string;
|
|
20
21
|
protected getFallbackModelName(): string;
|
|
@@ -36,6 +36,9 @@ export class LlamaCppProvider extends OpenAIChatCompletionsProvider {
|
|
|
36
36
|
baseURL: redactUrlCredentials(this.config.baseURL),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
async validateConfiguration() {
|
|
40
|
+
return this.probeModelsEndpoint(this.getAuthHeaders());
|
|
41
|
+
}
|
|
39
42
|
getProviderName() {
|
|
40
43
|
return "llamacpp";
|
|
41
44
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
2
1
|
import { InvalidModelError, NetworkError, ProviderError, } from "../types/index.js";
|
|
3
2
|
import { logger } from "../utils/logger.js";
|
|
4
3
|
import { redactUrlCredentials } from "../utils/logSanitize.js";
|
|
@@ -70,28 +69,9 @@ export class LMStudioProvider extends OpenAIChatCompletionsProvider {
|
|
|
70
69
|
return new ProviderError(`LM Studio error: ${message}`, "lm-studio");
|
|
71
70
|
}
|
|
72
71
|
async validateConfiguration() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const r = await proxyFetch(url, {
|
|
77
|
-
headers: this.config.apiKey && this.config.apiKey !== LM_STUDIO_PLACEHOLDER_KEY
|
|
78
|
-
? { Authorization: `Bearer ${this.config.apiKey}` }
|
|
79
|
-
: undefined,
|
|
80
|
-
signal: AbortSignal.timeout(5000),
|
|
81
|
-
});
|
|
82
|
-
if (!r.ok) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
// A 200 with an empty data array means LM Studio is up but no model is
|
|
86
|
-
// loaded — `resolveModelName()` will fall back to FALLBACK_MODEL and the
|
|
87
|
-
// first real request will fail. Require at least one loaded model so
|
|
88
|
-
// health checks honestly reflect whether the provider is usable.
|
|
89
|
-
const data = (await r.json().catch(() => null));
|
|
90
|
-
return Boolean(data?.data?.some((m) => typeof m?.id === "string" && m.id.trim().length > 0));
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
72
|
+
return this.probeModelsEndpoint(this.config.apiKey && this.config.apiKey !== LM_STUDIO_PLACEHOLDER_KEY
|
|
73
|
+
? { Authorization: `Bearer ${this.config.apiKey}` }
|
|
74
|
+
: {});
|
|
95
75
|
}
|
|
96
76
|
getConfiguration() {
|
|
97
77
|
return {
|
|
@@ -181,29 +181,7 @@ export class OllamaProvider extends OpenAIChatCompletionsProvider {
|
|
|
181
181
|
* back to a model that the first real request can't serve, so report unusable.
|
|
182
182
|
*/
|
|
183
183
|
async validateConfiguration() {
|
|
184
|
-
|
|
185
|
-
const url = `${stripTrailingSlash(this.config.baseURL)}/models`;
|
|
186
|
-
const proxyFetch = createProxyFetch();
|
|
187
|
-
const r = await proxyFetch(url, {
|
|
188
|
-
headers: {
|
|
189
|
-
...this.getAuthHeaders(),
|
|
190
|
-
"Content-Type": "application/json",
|
|
191
|
-
},
|
|
192
|
-
signal: AbortSignal.timeout(5000),
|
|
193
|
-
});
|
|
194
|
-
if (!r.ok) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
const data = (await r.json().catch(() => null));
|
|
198
|
-
return Boolean(data?.data?.some((m) => typeof m?.id === "string" && m.id.trim().length > 0));
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
logger.debug("Ollama validateConfiguration probe failed", {
|
|
202
|
-
baseURL: redactUrlCredentials(this.config.baseURL),
|
|
203
|
-
error: error instanceof Error ? error.message : String(error),
|
|
204
|
-
});
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
184
|
+
return this.probeModelsEndpoint(this.getAuthHeaders());
|
|
207
185
|
}
|
|
208
186
|
getConfiguration() {
|
|
209
187
|
return {
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { OpenRouterModels } from "../../constants/enums.js";
|
|
2
2
|
import { getProviderModel } from "../../utils/providerConfig.js";
|
|
3
|
-
export const getOpenRouterConfig = () => {
|
|
4
|
-
const apiKey = process.env.OPENROUTER_API_KEY;
|
|
5
|
-
if (!apiKey) {
|
|
6
|
-
throw new Error("OPENROUTER_API_KEY environment variable is required. " +
|
|
7
|
-
"Get your API key at https://openrouter.ai/keys");
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
apiKey,
|
|
11
|
-
referer: process.env.OPENROUTER_REFERER,
|
|
12
|
-
appName: process.env.OPENROUTER_APP_NAME,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
3
|
export const getDefaultOpenRouterModel = () => {
|
|
16
4
|
return getProviderModel("OPENROUTER_MODEL", OpenRouterModels.CLAUDE_SONNET_4_5);
|
|
17
5
|
};
|
|
@@ -166,6 +166,15 @@ export declare abstract class OpenAIChatCompletionsProvider extends BaseProvider
|
|
|
166
166
|
* override this to probe the server's `/models` endpoint.
|
|
167
167
|
*/
|
|
168
168
|
validateConfiguration(): Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* Shared local-runtime reachability probe: GET `${baseURL}/models` with a
|
|
171
|
+
* short timeout, requiring at least one model entry with a non-empty id.
|
|
172
|
+
* Local providers (Ollama, LM Studio, llama.cpp) call this from their own
|
|
173
|
+
* validateConfiguration() override instead of relying on the base class's
|
|
174
|
+
* "apiKey is a non-empty string" default, which can't detect an
|
|
175
|
+
* unreachable local server.
|
|
176
|
+
*/
|
|
177
|
+
protected probeModelsEndpoint(headers?: Record<string, string>): Promise<boolean>;
|
|
169
178
|
/**
|
|
170
179
|
* Snapshot of the provider's resolved configuration — part of the documented
|
|
171
180
|
* public provider contract (`docs/provider-integration/00-architecture.md`).
|
|
@@ -26,6 +26,7 @@ import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
|
26
26
|
import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
|
|
27
27
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
28
28
|
import { logger } from "../utils/logger.js";
|
|
29
|
+
import { redactUrlCredentials } from "../utils/logSanitize.js";
|
|
29
30
|
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
30
31
|
import { buildNoOutputSentinel, stampNoOutputSpan, } from "../utils/noOutputSentinel.js";
|
|
31
32
|
import { composeAbortSignalsScoped, createTimeoutController, mergeAbortSignals, } from "../utils/timeout.js";
|
|
@@ -272,6 +273,38 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
272
273
|
return (typeof this.config.apiKey === "string" &&
|
|
273
274
|
this.config.apiKey.trim().length > 0);
|
|
274
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Shared local-runtime reachability probe: GET `${baseURL}/models` with a
|
|
278
|
+
* short timeout, requiring at least one model entry with a non-empty id.
|
|
279
|
+
* Local providers (Ollama, LM Studio, llama.cpp) call this from their own
|
|
280
|
+
* validateConfiguration() override instead of relying on the base class's
|
|
281
|
+
* "apiKey is a non-empty string" default, which can't detect an
|
|
282
|
+
* unreachable local server.
|
|
283
|
+
*/
|
|
284
|
+
async probeModelsEndpoint(headers = {}) {
|
|
285
|
+
try {
|
|
286
|
+
const url = `${stripTrailingSlash(this.config.baseURL)}/models`;
|
|
287
|
+
const proxyFetch = createProxyFetch();
|
|
288
|
+
const response = await proxyFetch(url, {
|
|
289
|
+
headers: { ...headers, "Content-Type": "application/json" },
|
|
290
|
+
signal: AbortSignal.timeout(5000),
|
|
291
|
+
});
|
|
292
|
+
if (!response.ok) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const data = (await response
|
|
296
|
+
.json()
|
|
297
|
+
.catch(() => null));
|
|
298
|
+
return Boolean(data?.data?.some((m) => typeof m?.id === "string" && m.id.trim().length > 0));
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
logger.debug(`[${this.constructor.name}] probeModelsEndpoint failed`, {
|
|
302
|
+
baseURL: redactUrlCredentials(this.config.baseURL),
|
|
303
|
+
error: error instanceof Error ? error.message : String(error),
|
|
304
|
+
});
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
275
308
|
/**
|
|
276
309
|
* Snapshot of the provider's resolved configuration — part of the documented
|
|
277
310
|
* public provider contract (`docs/provider-integration/00-architecture.md`).
|
|
@@ -6,7 +6,8 @@ import { OpenAIChatCompletionsProvider } from "./openaiChatCompletionsBase.js";
|
|
|
6
6
|
*
|
|
7
7
|
* Sonar models with built-in web grounding. OpenAI-compatible chat
|
|
8
8
|
* completions at api.perplexity.ai. Best for queries that need fresh
|
|
9
|
-
* web context (search-augmented answers
|
|
9
|
+
* web context (search-augmented answers). Citation data, if the API returns
|
|
10
|
+
* any, is not extracted or exposed by this provider.
|
|
10
11
|
*
|
|
11
12
|
* All request/stream/tool-loop orchestration lives in
|
|
12
13
|
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
@@ -13,7 +13,8 @@ const getDefaultPerplexityModel = () => getProviderModel("PERPLEXITY_MODEL", Per
|
|
|
13
13
|
*
|
|
14
14
|
* Sonar models with built-in web grounding. OpenAI-compatible chat
|
|
15
15
|
* completions at api.perplexity.ai. Best for queries that need fresh
|
|
16
|
-
* web context (search-augmented answers
|
|
16
|
+
* web context (search-augmented answers). Citation data, if the API returns
|
|
17
|
+
* any, is not extracted or exposed by this provider.
|
|
17
18
|
*
|
|
18
19
|
* All request/stream/tool-loop orchestration lives in
|
|
19
20
|
* `OpenAIChatCompletionsProvider`; this class only declares configuration
|
|
@@ -34,6 +34,18 @@ function flattenReplicateOutput(output) {
|
|
|
34
34
|
}
|
|
35
35
|
return "";
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve Replicate credentials, aliasing the standard `apiKey`/`baseURL`
|
|
39
|
+
* field names (shared with every other provider in `NeurolinkCredentials`)
|
|
40
|
+
* against the legacy `apiToken`/`baseUrl` names. The standard name wins
|
|
41
|
+
* when both are present; used identically for instance-level and per-call
|
|
42
|
+
* credentials so aliasing never drifts between the two.
|
|
43
|
+
*/
|
|
44
|
+
function resolveReplicateCredentials(credentials) {
|
|
45
|
+
const apiToken = credentials?.apiKey?.trim() || credentials?.apiToken?.trim();
|
|
46
|
+
const baseUrl = credentials?.baseURL || credentials?.baseUrl;
|
|
47
|
+
return { apiToken, baseUrl };
|
|
48
|
+
}
|
|
37
49
|
/**
|
|
38
50
|
* Replicate LLM Provider — predict-then-stream pattern.
|
|
39
51
|
*
|
|
@@ -63,12 +75,12 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
63
75
|
constructor(modelName, sdk, _region, credentials) {
|
|
64
76
|
const validatedNeurolink = isNeuroLink(sdk) ? sdk : undefined;
|
|
65
77
|
super(modelName, "replicate", validatedNeurolink);
|
|
66
|
-
const overrideToken = credentials
|
|
78
|
+
const { apiToken: overrideToken, baseUrl: overrideBaseUrl } = resolveReplicateCredentials(credentials);
|
|
67
79
|
this.apiToken =
|
|
68
80
|
overrideToken && overrideToken.length > 0
|
|
69
81
|
? overrideToken
|
|
70
82
|
: validateApiKey(createReplicateConfig());
|
|
71
|
-
this.baseURL =
|
|
83
|
+
this.baseURL = overrideBaseUrl;
|
|
72
84
|
logger.debug("Replicate Provider initialized", {
|
|
73
85
|
modelName: this.modelName,
|
|
74
86
|
baseURL: this.baseURL,
|
|
@@ -109,7 +121,7 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
109
121
|
const options = typeof optionsOrPrompt === "string"
|
|
110
122
|
? { prompt: optionsOrPrompt }
|
|
111
123
|
: optionsOrPrompt;
|
|
112
|
-
const {
|
|
124
|
+
const { isImageGenerationModel } = await import("../core/constants.js");
|
|
113
125
|
// Delegate special output modes to base class (which never calls getAISDKModel for these)
|
|
114
126
|
if (options.output?.mode === "video" ||
|
|
115
127
|
options.output?.mode === "avatar" ||
|
|
@@ -117,7 +129,7 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
117
129
|
return super.generate(options, _analysisSchema);
|
|
118
130
|
}
|
|
119
131
|
// Image-gen models: delegate to base which calls executeImageGeneration()
|
|
120
|
-
const isImageModel =
|
|
132
|
+
const isImageModel = isImageGenerationModel(this.modelName);
|
|
121
133
|
const requestsNonImageOutput = options.output?.format === "json" ||
|
|
122
134
|
options.output?.format === "structured" ||
|
|
123
135
|
options.output?.format === "text";
|
|
@@ -175,8 +187,9 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
175
187
|
const startTime = Date.now();
|
|
176
188
|
// Resolve per-call credentials first, then fall back to instance-level.
|
|
177
189
|
const perCallCreds = options.credentials?.replicate;
|
|
178
|
-
const
|
|
179
|
-
const
|
|
190
|
+
const resolvedPerCall = resolveReplicateCredentials(perCallCreds);
|
|
191
|
+
const effectiveToken = resolvedPerCall.apiToken || this.apiToken;
|
|
192
|
+
const effectiveBaseUrl = resolvedPerCall.baseUrl || this.baseURL;
|
|
180
193
|
const auth = getReplicateAuth({
|
|
181
194
|
apiToken: effectiveToken,
|
|
182
195
|
baseUrl: effectiveBaseUrl,
|
|
@@ -255,8 +268,9 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
255
268
|
const startTime = Date.now();
|
|
256
269
|
// Resolve per-call credentials first, then fall back to instance-level.
|
|
257
270
|
const perCallCreds = options.credentials?.replicate;
|
|
258
|
-
const
|
|
259
|
-
const
|
|
271
|
+
const resolvedPerCall = resolveReplicateCredentials(perCallCreds);
|
|
272
|
+
const effectiveToken = resolvedPerCall.apiToken || this.apiToken;
|
|
273
|
+
const effectiveBaseUrl = resolvedPerCall.baseUrl || this.baseURL;
|
|
260
274
|
const auth = getReplicateAuth({
|
|
261
275
|
apiToken: effectiveToken,
|
|
262
276
|
baseUrl: effectiveBaseUrl,
|
|
@@ -399,5 +413,4 @@ export class ReplicateProvider extends BaseProvider {
|
|
|
399
413
|
};
|
|
400
414
|
}
|
|
401
415
|
}
|
|
402
|
-
export default ReplicateProvider;
|
|
403
416
|
//# sourceMappingURL=replicate.js.map
|
|
@@ -60,7 +60,6 @@ export * from "./tools.js";
|
|
|
60
60
|
export * from "./vectorStoreChroma.js";
|
|
61
61
|
export * from "./vectorStorePinecone.js";
|
|
62
62
|
export * from "./voice.js";
|
|
63
|
-
export * from "./universalProviderOptions.js";
|
|
64
63
|
export * from "./utilities.js";
|
|
65
64
|
export * from "./workflow.js";
|
|
66
65
|
export * from "./ioProcessor.js";
|
package/dist/lib/types/index.js
CHANGED
|
@@ -61,7 +61,6 @@ export * from "./tools.js";
|
|
|
61
61
|
export * from "./vectorStoreChroma.js";
|
|
62
62
|
export * from "./vectorStorePinecone.js";
|
|
63
63
|
export * from "./voice.js";
|
|
64
|
-
export * from "./universalProviderOptions.js";
|
|
65
64
|
export * from "./utilities.js";
|
|
66
65
|
export * from "./workflow.js";
|
|
67
66
|
// Processor base types are re-exported via ./processor.js
|
|
@@ -200,6 +200,8 @@ export type NeurolinkCredentials = {
|
|
|
200
200
|
replicate?: {
|
|
201
201
|
apiToken?: string;
|
|
202
202
|
baseUrl?: string;
|
|
203
|
+
apiKey?: string;
|
|
204
|
+
baseURL?: string;
|
|
203
205
|
};
|
|
204
206
|
voyage?: {
|
|
205
207
|
apiKey?: string;
|
|
@@ -1531,17 +1533,6 @@ export declare namespace TelemetryTypes {
|
|
|
1531
1533
|
recordException(exception: unknown): void;
|
|
1532
1534
|
};
|
|
1533
1535
|
}
|
|
1534
|
-
/**
|
|
1535
|
-
* OpenRouter provider configuration
|
|
1536
|
-
*/
|
|
1537
|
-
export type OpenRouterConfig = {
|
|
1538
|
-
/** OpenRouter API key */
|
|
1539
|
-
apiKey: string;
|
|
1540
|
-
/** HTTP Referer header for attribution on openrouter.ai/activity */
|
|
1541
|
-
referer?: string;
|
|
1542
|
-
/** App name for X-Title header attribution */
|
|
1543
|
-
appName?: string;
|
|
1544
|
-
};
|
|
1545
1536
|
/**
|
|
1546
1537
|
* OpenRouter model information from /api/v1/models endpoint
|
|
1547
1538
|
*/
|
|
@@ -115,14 +115,6 @@ export declare function createDeepSeekConfig(): ProviderConfigOptions;
|
|
|
115
115
|
* Creates NVIDIA NIM provider configuration
|
|
116
116
|
*/
|
|
117
117
|
export declare function createNvidiaNimConfig(): ProviderConfigOptions;
|
|
118
|
-
/**
|
|
119
|
-
* Creates LM Studio provider configuration (local server)
|
|
120
|
-
*/
|
|
121
|
-
export declare function createLmStudioConfig(): ProviderConfigOptions;
|
|
122
|
-
/**
|
|
123
|
-
* Creates llama.cpp provider configuration (local server)
|
|
124
|
-
*/
|
|
125
|
-
export declare function createLlamaCppConfig(): ProviderConfigOptions;
|
|
126
118
|
/**
|
|
127
119
|
* Creates xAI Grok provider configuration.
|
|
128
120
|
*/
|
|
@@ -411,43 +411,6 @@ export function createNvidiaNimConfig() {
|
|
|
411
411
|
],
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
|
-
/**
|
|
415
|
-
* Creates LM Studio provider configuration (local server)
|
|
416
|
-
*/
|
|
417
|
-
export function createLmStudioConfig() {
|
|
418
|
-
return {
|
|
419
|
-
providerName: "LM Studio",
|
|
420
|
-
envVarName: "LM_STUDIO_BASE_URL",
|
|
421
|
-
setupUrl: "https://lmstudio.ai/",
|
|
422
|
-
description: "LM Studio server URL",
|
|
423
|
-
instructions: [
|
|
424
|
-
"1. Install LM Studio: https://lmstudio.ai/",
|
|
425
|
-
"2. Open LM Studio and download a model (e.g. Llama 3.2 3B Instruct)",
|
|
426
|
-
'3. Click "Local Server" → Start Server',
|
|
427
|
-
"4. Default URL is http://localhost:1234/v1 (override via LM_STUDIO_BASE_URL)",
|
|
428
|
-
],
|
|
429
|
-
// Base URL is optional — defaults to http://localhost:1234/v1 if unset.
|
|
430
|
-
optional: true,
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Creates llama.cpp provider configuration (local server)
|
|
435
|
-
*/
|
|
436
|
-
export function createLlamaCppConfig() {
|
|
437
|
-
return {
|
|
438
|
-
providerName: "llama.cpp",
|
|
439
|
-
envVarName: "LLAMACPP_BASE_URL",
|
|
440
|
-
setupUrl: "https://github.com/ggerganov/llama.cpp",
|
|
441
|
-
description: "llama.cpp server URL",
|
|
442
|
-
instructions: [
|
|
443
|
-
"1. Build llama.cpp: https://github.com/ggerganov/llama.cpp#build",
|
|
444
|
-
"2. Run: ./llama-server -m model.gguf --port 8080",
|
|
445
|
-
"3. Default URL is http://localhost:8080/v1 (override via LLAMACPP_BASE_URL)",
|
|
446
|
-
],
|
|
447
|
-
// Base URL is optional — defaults to http://localhost:8080/v1 if unset.
|
|
448
|
-
optional: true,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
414
|
/**
|
|
452
415
|
* Creates xAI Grok provider configuration.
|
|
453
416
|
*/
|
|
@@ -20,19 +20,6 @@ export async function getBestProvider(requestedProvider) {
|
|
|
20
20
|
// For explicit provider requests, ALWAYS honor the request
|
|
21
21
|
// Never override explicit provider selection with health-based fallbacks
|
|
22
22
|
logger.debug(`[getBestProvider] Using explicitly requested provider: ${requestedProvider}`);
|
|
23
|
-
// Optional health check for logging purposes only
|
|
24
|
-
try {
|
|
25
|
-
const health = await ProviderHealthChecker.checkProviderHealth(requestedProvider, { includeConnectivityTest: false, cacheResults: true });
|
|
26
|
-
if (health.isHealthy) {
|
|
27
|
-
logger.debug(`[getBestProvider] Explicitly requested provider ${requestedProvider} is healthy`);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
logger.warn(`[getBestProvider] Explicitly requested provider ${requestedProvider} may have issues, but using anyway`, { error: health.error });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
logger.warn(`[getBestProvider] Health check failed for explicitly requested provider ${requestedProvider}, using anyway`, { error: error instanceof Error ? error.message : String(error) });
|
|
35
|
-
}
|
|
36
23
|
// ALWAYS return the explicitly requested provider
|
|
37
24
|
return requestedProvider;
|
|
38
25
|
}
|
|
@@ -402,18 +389,7 @@ export function hasProviderEnvVars(provider) {
|
|
|
402
389
|
* @returns Array of available provider names
|
|
403
390
|
*/
|
|
404
391
|
export function getAvailableProviders() {
|
|
405
|
-
return
|
|
406
|
-
"bedrock",
|
|
407
|
-
"vertex",
|
|
408
|
-
"openai",
|
|
409
|
-
"anthropic",
|
|
410
|
-
"azure",
|
|
411
|
-
"google-ai",
|
|
412
|
-
"litellm",
|
|
413
|
-
"huggingface",
|
|
414
|
-
"ollama",
|
|
415
|
-
"mistral",
|
|
416
|
-
];
|
|
392
|
+
return Object.values(AIProviderName).filter((name) => name !== AIProviderName.AUTO);
|
|
417
393
|
}
|
|
418
394
|
/**
|
|
419
395
|
* Validate provider name
|
|
@@ -242,13 +242,6 @@ export declare function getContextWindow(model: string): number;
|
|
|
242
242
|
* @returns The max output tokens, or 0 if model not found
|
|
243
243
|
*/
|
|
244
244
|
export declare function getMaxOutputTokens(model: string): number;
|
|
245
|
-
/**
|
|
246
|
-
* Check if a model supports vision/image input
|
|
247
|
-
*
|
|
248
|
-
* @param model - The model ID
|
|
249
|
-
* @returns true if the model supports vision
|
|
250
|
-
*/
|
|
251
|
-
export declare function supportsVision(model: string): boolean;
|
|
252
245
|
/**
|
|
253
246
|
* Check if a model supports extended thinking
|
|
254
247
|
*
|
|
@@ -531,15 +531,6 @@ export function getContextWindow(model) {
|
|
|
531
531
|
export function getMaxOutputTokens(model) {
|
|
532
532
|
return MODEL_METADATA[model]?.maxOutputTokens ?? 0;
|
|
533
533
|
}
|
|
534
|
-
/**
|
|
535
|
-
* Check if a model supports vision/image input
|
|
536
|
-
*
|
|
537
|
-
* @param model - The model ID
|
|
538
|
-
* @returns true if the model supports vision
|
|
539
|
-
*/
|
|
540
|
-
export function supportsVision(model) {
|
|
541
|
-
return MODEL_METADATA[model]?.supportsVision ?? false;
|
|
542
|
-
}
|
|
543
534
|
/**
|
|
544
535
|
* Check if a model supports extended thinking
|
|
545
536
|
*
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { trace } from "@opentelemetry/api";
|
|
2
1
|
export const ANTHROPIC_BETA_HEADERS = {
|
|
3
2
|
"anthropic-beta": [
|
|
4
3
|
"claude-code-20250219",
|
|
5
4
|
"fine-grained-tool-streaming-2025-05-14",
|
|
6
5
|
].join(","),
|
|
7
6
|
};
|
|
8
|
-
export const streamTracer = trace.getTracer("neurolink.provider.anthropic");
|