@juspay/neurolink 9.64.0 → 9.65.1
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 +12 -0
- package/README.md +18 -17
- package/dist/adapters/providerImageAdapter.js +29 -1
- package/dist/adapters/replicate/auth.d.ts +19 -0
- package/dist/adapters/replicate/auth.js +32 -0
- package/dist/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/adapters/replicate/predictionLifecycle.js +283 -0
- package/dist/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/adapters/video/klingVideoHandler.js +305 -0
- package/dist/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/adapters/video/replicateVideoHandler.js +157 -0
- package/dist/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/adapters/video/runwayVideoHandler.js +316 -0
- package/dist/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/agent/directTools.js +11 -3
- package/dist/autoresearch/runner.js +8 -2
- package/dist/avatar/index.d.ts +13 -0
- package/dist/avatar/index.js +13 -0
- package/dist/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/avatar/providers/DIDAvatar.js +501 -0
- package/dist/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/avatar/providers/HeyGenAvatar.js +337 -0
- package/dist/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/avatar/providers/ReplicateAvatar.js +267 -0
- package/dist/browser/neurolink.min.js +624 -601
- package/dist/cli/commands/mcp.js +29 -0
- package/dist/cli/commands/proxy.js +24 -5
- package/dist/cli/factories/commandFactory.d.ts +11 -1
- package/dist/cli/factories/commandFactory.js +291 -38
- package/dist/constants/contextWindows.js +101 -0
- package/dist/constants/enums.d.ts +273 -2
- package/dist/constants/enums.js +290 -1
- package/dist/constants/videoErrors.d.ts +4 -0
- package/dist/constants/videoErrors.js +4 -0
- package/dist/core/baseProvider.d.ts +22 -2
- package/dist/core/baseProvider.js +217 -11
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.js +72 -1
- package/dist/evaluation/index.d.ts +2 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/factories/providerFactory.js +7 -1
- package/dist/factories/providerRegistry.js +202 -5
- package/dist/features/ppt/contentPlanner.js +42 -14
- package/dist/index.d.ts +9 -1
- package/dist/index.js +16 -1
- package/dist/lib/adapters/providerImageAdapter.js +29 -1
- package/dist/lib/adapters/replicate/auth.d.ts +19 -0
- package/dist/lib/adapters/replicate/auth.js +33 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +46 -0
- package/dist/lib/adapters/replicate/predictionLifecycle.js +284 -0
- package/dist/lib/adapters/video/klingVideoHandler.d.ts +37 -0
- package/dist/lib/adapters/video/klingVideoHandler.js +306 -0
- package/dist/lib/adapters/video/replicateVideoHandler.d.ts +29 -0
- package/dist/lib/adapters/video/replicateVideoHandler.js +158 -0
- package/dist/lib/adapters/video/runwayVideoHandler.d.ts +32 -0
- package/dist/lib/adapters/video/runwayVideoHandler.js +317 -0
- package/dist/lib/adapters/video/vertexVideoHandler.d.ts +19 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +33 -9
- package/dist/lib/agent/directTools.js +11 -3
- package/dist/lib/autoresearch/runner.js +8 -2
- package/dist/lib/avatar/index.d.ts +13 -0
- package/dist/lib/avatar/index.js +14 -0
- package/dist/lib/avatar/providers/DIDAvatar.d.ts +49 -0
- package/dist/lib/avatar/providers/DIDAvatar.js +502 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.d.ts +30 -0
- package/dist/lib/avatar/providers/HeyGenAvatar.js +338 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.d.ts +36 -0
- package/dist/lib/avatar/providers/ReplicateAvatar.js +268 -0
- package/dist/lib/constants/contextWindows.js +101 -0
- package/dist/lib/constants/enums.d.ts +273 -2
- package/dist/lib/constants/enums.js +290 -1
- package/dist/lib/constants/videoErrors.d.ts +4 -0
- package/dist/lib/constants/videoErrors.js +4 -0
- package/dist/lib/core/baseProvider.d.ts +22 -2
- package/dist/lib/core/baseProvider.js +217 -11
- package/dist/lib/core/constants.d.ts +12 -0
- package/dist/lib/core/constants.js +72 -1
- package/dist/lib/evaluation/index.d.ts +2 -0
- package/dist/lib/evaluation/index.js +4 -0
- package/dist/lib/factories/providerFactory.js +7 -1
- package/dist/lib/factories/providerRegistry.js +202 -5
- package/dist/lib/features/ppt/contentPlanner.js +42 -14
- package/dist/lib/index.d.ts +9 -1
- package/dist/lib/index.js +16 -1
- package/dist/lib/middleware/builtin/lifecycle.js +39 -9
- package/dist/lib/music/index.d.ts +13 -0
- package/dist/lib/music/index.js +14 -0
- package/dist/lib/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/lib/music/providers/BeatovenMusic.js +334 -0
- package/dist/lib/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/lib/music/providers/ElevenLabsMusic.js +169 -0
- package/dist/lib/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/lib/music/providers/LyriaMusic.js +173 -0
- package/dist/lib/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/lib/music/providers/ReplicateMusic.js +262 -0
- package/dist/lib/neurolink.d.ts +30 -0
- package/dist/lib/neurolink.js +323 -77
- package/dist/lib/providers/amazonBedrock.d.ts +10 -0
- package/dist/lib/providers/amazonBedrock.js +94 -39
- package/dist/lib/providers/anthropic.js +55 -7
- package/dist/lib/providers/anthropicBaseProvider.js +1 -1
- package/dist/lib/providers/azureOpenai.js +66 -17
- package/dist/lib/providers/cloudflare.d.ts +35 -0
- package/dist/lib/providers/cloudflare.js +174 -0
- package/dist/lib/providers/cohere.d.ts +52 -0
- package/dist/lib/providers/cohere.js +253 -0
- package/dist/lib/providers/deepseek.js +72 -17
- package/dist/lib/providers/fireworks.d.ts +33 -0
- package/dist/lib/providers/fireworks.js +164 -0
- package/dist/lib/providers/googleAiStudio.js +126 -10
- package/dist/lib/providers/googleNativeGemini3.d.ts +26 -6
- package/dist/lib/providers/googleNativeGemini3.js +276 -29
- package/dist/lib/providers/googleVertex.js +639 -181
- package/dist/lib/providers/groq.d.ts +33 -0
- package/dist/lib/providers/groq.js +181 -0
- package/dist/lib/providers/huggingFace.js +9 -8
- package/dist/lib/providers/ideogram.d.ts +34 -0
- package/dist/lib/providers/ideogram.js +184 -0
- package/dist/lib/providers/index.d.ts +13 -0
- package/dist/lib/providers/index.js +13 -0
- package/dist/lib/providers/jina.d.ts +59 -0
- package/dist/lib/providers/jina.js +218 -0
- package/dist/lib/providers/llamaCpp.js +14 -46
- package/dist/lib/providers/lmStudio.js +14 -47
- package/dist/lib/providers/mistral.js +7 -7
- package/dist/lib/providers/nvidiaNim.js +160 -19
- package/dist/lib/providers/ollama.js +7 -7
- package/dist/lib/providers/openAI.d.ts +22 -1
- package/dist/lib/providers/openAI.js +181 -0
- package/dist/lib/providers/openRouter.js +35 -23
- package/dist/lib/providers/openaiCompatible.js +9 -8
- package/dist/lib/providers/perplexity.d.ts +33 -0
- package/dist/lib/providers/perplexity.js +179 -0
- package/dist/lib/providers/recraft.d.ts +34 -0
- package/dist/lib/providers/recraft.js +197 -0
- package/dist/lib/providers/replicate.d.ts +75 -0
- package/dist/lib/providers/replicate.js +403 -0
- package/dist/lib/providers/stability.d.ts +37 -0
- package/dist/lib/providers/stability.js +191 -0
- package/dist/lib/providers/togetherAi.d.ts +33 -0
- package/dist/lib/providers/togetherAi.js +176 -0
- package/dist/lib/providers/voyage.d.ts +47 -0
- package/dist/lib/providers/voyage.js +177 -0
- package/dist/lib/providers/xai.d.ts +33 -0
- package/dist/lib/providers/xai.js +172 -0
- package/dist/lib/telemetry/index.d.ts +1 -1
- package/dist/lib/telemetry/index.js +1 -1
- package/dist/lib/telemetry/tracers.d.ts +19 -0
- package/dist/lib/telemetry/tracers.js +19 -0
- package/dist/lib/telemetry/withSpan.d.ts +35 -0
- package/dist/lib/telemetry/withSpan.js +103 -0
- package/dist/lib/types/avatar.d.ts +143 -0
- package/dist/lib/types/avatar.js +20 -0
- package/dist/lib/types/cli.d.ts +6 -0
- package/dist/lib/types/conversation.d.ts +16 -0
- package/dist/lib/types/generate.d.ts +62 -5
- package/dist/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/middleware.d.ts +27 -0
- package/dist/lib/types/multimodal.d.ts +35 -2
- package/dist/lib/types/music.d.ts +165 -0
- package/dist/lib/types/music.js +21 -0
- package/dist/lib/types/providers.d.ts +144 -1
- package/dist/lib/types/replicate.d.ts +67 -0
- package/dist/lib/types/replicate.js +10 -0
- package/dist/lib/types/safeFetch.d.ts +15 -0
- package/dist/lib/types/safeFetch.js +7 -0
- package/dist/lib/types/stream.d.ts +2 -1
- package/dist/lib/types/tools.d.ts +13 -0
- package/dist/lib/types/video.d.ts +89 -0
- package/dist/lib/types/video.js +15 -0
- package/dist/lib/utils/avatarProcessor.d.ts +68 -0
- package/dist/lib/utils/avatarProcessor.js +172 -0
- package/dist/lib/utils/cloneOptions.d.ts +36 -0
- package/dist/lib/utils/cloneOptions.js +62 -0
- package/dist/lib/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/lib/utils/lifecycleCallbacks.js +82 -26
- package/dist/lib/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/lib/utils/lifecycleTimeout.js +39 -0
- package/dist/lib/utils/logSanitize.d.ts +49 -0
- package/dist/lib/utils/logSanitize.js +170 -0
- package/dist/lib/utils/loggingFetch.d.ts +29 -0
- package/dist/lib/utils/loggingFetch.js +60 -0
- package/dist/lib/utils/messageBuilder.js +43 -25
- package/dist/lib/utils/modelChoices.js +236 -3
- package/dist/lib/utils/musicProcessor.d.ts +67 -0
- package/dist/lib/utils/musicProcessor.js +189 -0
- package/dist/lib/utils/optionsConversion.js +3 -2
- package/dist/lib/utils/parameterValidation.js +14 -4
- package/dist/lib/utils/pricing.js +193 -0
- package/dist/lib/utils/providerConfig.d.ts +55 -0
- package/dist/lib/utils/providerConfig.js +224 -0
- package/dist/lib/utils/safeFetch.d.ts +26 -0
- package/dist/lib/utils/safeFetch.js +83 -0
- package/dist/lib/utils/sizeGuard.d.ts +34 -0
- package/dist/lib/utils/sizeGuard.js +45 -0
- package/dist/lib/utils/ssrfGuard.d.ts +52 -0
- package/dist/lib/utils/ssrfGuard.js +411 -0
- package/dist/lib/utils/videoProcessor.d.ts +60 -0
- package/dist/lib/utils/videoProcessor.js +201 -0
- package/dist/lib/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/lib/voice/providers/FishAudioTTS.js +183 -0
- package/dist/lib/workflow/core/ensembleExecutor.js +26 -9
- package/dist/middleware/builtin/lifecycle.js +39 -9
- package/dist/music/index.d.ts +13 -0
- package/dist/music/index.js +13 -0
- package/dist/music/providers/BeatovenMusic.d.ts +31 -0
- package/dist/music/providers/BeatovenMusic.js +333 -0
- package/dist/music/providers/ElevenLabsMusic.d.ts +30 -0
- package/dist/music/providers/ElevenLabsMusic.js +168 -0
- package/dist/music/providers/LyriaMusic.d.ts +29 -0
- package/dist/music/providers/LyriaMusic.js +172 -0
- package/dist/music/providers/ReplicateMusic.d.ts +31 -0
- package/dist/music/providers/ReplicateMusic.js +261 -0
- package/dist/neurolink.d.ts +30 -0
- package/dist/neurolink.js +323 -77
- package/dist/providers/amazonBedrock.d.ts +10 -0
- package/dist/providers/amazonBedrock.js +94 -39
- package/dist/providers/anthropic.js +55 -7
- package/dist/providers/anthropicBaseProvider.js +1 -1
- package/dist/providers/azureOpenai.js +66 -17
- package/dist/providers/cloudflare.d.ts +35 -0
- package/dist/providers/cloudflare.js +173 -0
- package/dist/providers/cohere.d.ts +52 -0
- package/dist/providers/cohere.js +252 -0
- package/dist/providers/deepseek.js +72 -17
- package/dist/providers/fireworks.d.ts +33 -0
- package/dist/providers/fireworks.js +163 -0
- package/dist/providers/googleAiStudio.js +126 -10
- package/dist/providers/googleNativeGemini3.d.ts +26 -6
- package/dist/providers/googleNativeGemini3.js +276 -29
- package/dist/providers/googleVertex.js +639 -181
- package/dist/providers/groq.d.ts +33 -0
- package/dist/providers/groq.js +180 -0
- package/dist/providers/huggingFace.js +9 -8
- package/dist/providers/ideogram.d.ts +34 -0
- package/dist/providers/ideogram.js +183 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/jina.d.ts +59 -0
- package/dist/providers/jina.js +217 -0
- package/dist/providers/llamaCpp.js +14 -46
- package/dist/providers/lmStudio.js +14 -47
- package/dist/providers/mistral.js +7 -7
- package/dist/providers/nvidiaNim.js +160 -19
- package/dist/providers/ollama.js +7 -7
- package/dist/providers/openAI.d.ts +22 -1
- package/dist/providers/openAI.js +181 -0
- package/dist/providers/openRouter.js +35 -23
- package/dist/providers/openaiCompatible.js +9 -8
- package/dist/providers/perplexity.d.ts +33 -0
- package/dist/providers/perplexity.js +178 -0
- package/dist/providers/recraft.d.ts +34 -0
- package/dist/providers/recraft.js +196 -0
- package/dist/providers/replicate.d.ts +75 -0
- package/dist/providers/replicate.js +402 -0
- package/dist/providers/stability.d.ts +37 -0
- package/dist/providers/stability.js +190 -0
- package/dist/providers/togetherAi.d.ts +33 -0
- package/dist/providers/togetherAi.js +175 -0
- package/dist/providers/voyage.d.ts +47 -0
- package/dist/providers/voyage.js +176 -0
- package/dist/providers/xai.d.ts +33 -0
- package/dist/providers/xai.js +171 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/tracers.d.ts +19 -0
- package/dist/telemetry/tracers.js +19 -0
- package/dist/telemetry/withSpan.d.ts +35 -0
- package/dist/telemetry/withSpan.js +103 -0
- package/dist/types/avatar.d.ts +143 -0
- package/dist/types/avatar.js +19 -0
- package/dist/types/cli.d.ts +6 -0
- package/dist/types/conversation.d.ts +16 -0
- package/dist/types/generate.d.ts +62 -5
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +7 -0
- package/dist/types/middleware.d.ts +27 -0
- package/dist/types/multimodal.d.ts +35 -2
- package/dist/types/music.d.ts +165 -0
- package/dist/types/music.js +20 -0
- package/dist/types/providers.d.ts +144 -1
- package/dist/types/replicate.d.ts +67 -0
- package/dist/types/replicate.js +9 -0
- package/dist/types/safeFetch.d.ts +15 -0
- package/dist/types/safeFetch.js +6 -0
- package/dist/types/stream.d.ts +2 -1
- package/dist/types/tools.d.ts +13 -0
- package/dist/types/video.d.ts +89 -0
- package/dist/types/video.js +14 -0
- package/dist/utils/avatarProcessor.d.ts +68 -0
- package/dist/utils/avatarProcessor.js +171 -0
- package/dist/utils/cloneOptions.d.ts +36 -0
- package/dist/utils/cloneOptions.js +61 -0
- package/dist/utils/lifecycleCallbacks.d.ts +51 -8
- package/dist/utils/lifecycleCallbacks.js +82 -26
- package/dist/utils/lifecycleTimeout.d.ts +25 -0
- package/dist/utils/lifecycleTimeout.js +38 -0
- package/dist/utils/logSanitize.d.ts +49 -0
- package/dist/utils/logSanitize.js +169 -0
- package/dist/utils/loggingFetch.d.ts +29 -0
- package/dist/utils/loggingFetch.js +59 -0
- package/dist/utils/messageBuilder.js +43 -25
- package/dist/utils/modelChoices.js +236 -3
- package/dist/utils/musicProcessor.d.ts +67 -0
- package/dist/utils/musicProcessor.js +188 -0
- package/dist/utils/optionsConversion.js +3 -2
- package/dist/utils/parameterValidation.js +14 -4
- package/dist/utils/pricing.js +193 -0
- package/dist/utils/providerConfig.d.ts +55 -0
- package/dist/utils/providerConfig.js +224 -0
- package/dist/utils/safeFetch.d.ts +26 -0
- package/dist/utils/safeFetch.js +82 -0
- package/dist/utils/sizeGuard.d.ts +34 -0
- package/dist/utils/sizeGuard.js +44 -0
- package/dist/utils/ssrfGuard.d.ts +52 -0
- package/dist/utils/ssrfGuard.js +410 -0
- package/dist/utils/videoProcessor.d.ts +60 -0
- package/dist/utils/videoProcessor.js +200 -0
- package/dist/voice/providers/FishAudioTTS.d.ts +27 -0
- package/dist/voice/providers/FishAudioTTS.js +182 -0
- package/dist/workflow/core/ensembleExecutor.js +26 -9
- package/package.json +32 -5
|
@@ -5,7 +5,10 @@ import { IMAGE_GENERATION_MODELS } from "../core/constants.js";
|
|
|
5
5
|
import { MiddlewareFactory } from "../middleware/factory.js";
|
|
6
6
|
import { ATTR, tracers } from "../telemetry/index.js";
|
|
7
7
|
import { isAbortError } from "../utils/errorHandling.js";
|
|
8
|
+
import { hasLifecycleErrorFired, markLifecycleErrorFired, } from "../utils/lifecycleCallbacks.js";
|
|
9
|
+
import { resolveLifecycleTimeoutMs } from "../utils/lifecycleTimeout.js";
|
|
8
10
|
import { logger } from "../utils/logger.js";
|
|
11
|
+
import { withTimeoutFn } from "../utils/async/withTimeout.js";
|
|
9
12
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
10
13
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
11
14
|
import { getKeyCount, getKeysAsString } from "../utils/transformationUtils.js";
|
|
@@ -133,7 +136,14 @@ export class BaseProvider {
|
|
|
133
136
|
provider: this.providerName,
|
|
134
137
|
model: this.modelName,
|
|
135
138
|
});
|
|
136
|
-
|
|
139
|
+
// Note: executeFakeStreaming() owns its own catch that fires the
|
|
140
|
+
// consumer-supplied onError before re-throwing through
|
|
141
|
+
// handleProviderError(), so we do not need to wrap again here —
|
|
142
|
+
// doing so would route the error through handleProviderError()
|
|
143
|
+
// twice (and risk a double-fire onError without the shared
|
|
144
|
+
// lifecycle-fired WeakSet mark).
|
|
145
|
+
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
146
|
+
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
137
147
|
}
|
|
138
148
|
}
|
|
139
149
|
// CRITICAL: Image generation models don't support real streaming
|
|
@@ -151,8 +161,11 @@ export class BaseProvider {
|
|
|
151
161
|
model: this.modelName,
|
|
152
162
|
reason: "Image generation requires fake streaming to yield image output",
|
|
153
163
|
});
|
|
154
|
-
// Skip real streaming, go directly to fake streaming
|
|
155
|
-
|
|
164
|
+
// Skip real streaming, go directly to fake streaming.
|
|
165
|
+
// executeFakeStreaming() owns its own catch + lifecycle fire, so
|
|
166
|
+
// wrapping again here would double-route through handleProviderError().
|
|
167
|
+
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
168
|
+
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
156
169
|
}
|
|
157
170
|
// Central tool merge: Pre-merge base tools (MCP/built-in) with user-provided
|
|
158
171
|
// tools (e.g. RAG tools) into options.tools. This way, every provider's
|
|
@@ -177,8 +190,14 @@ export class BaseProvider {
|
|
|
177
190
|
provider: this.providerName,
|
|
178
191
|
timestamp: Date.now(),
|
|
179
192
|
});
|
|
180
|
-
//
|
|
181
|
-
|
|
193
|
+
// Wire lifecycle callbacks (onChunk/onFinish/onError) on the user-
|
|
194
|
+
// facing StreamResult.stream. The AI-SDK lifecycle middleware only
|
|
195
|
+
// sees AI-SDK-internal chunks via streamText/wrapLanguageModel, so
|
|
196
|
+
// providers with custom HTTP streaming (Ollama, llama.cpp's /api,
|
|
197
|
+
// anything that doesn't go through streamText) bypass it. Wrapping
|
|
198
|
+
// here makes the callbacks fire for every provider, regardless of
|
|
199
|
+
// streaming implementation.
|
|
200
|
+
return this.wrapStreamWithLifecycleCallbacks(realStreamResult, options);
|
|
182
201
|
}
|
|
183
202
|
catch (realStreamError) {
|
|
184
203
|
// Don't retry on terminal/abort errors — only fall back for
|
|
@@ -195,23 +214,178 @@ export class BaseProvider {
|
|
|
195
214
|
errMsg.includes("quota") ||
|
|
196
215
|
errMsg.includes("rate limit") ||
|
|
197
216
|
errMsg.includes("authentication")) {
|
|
217
|
+
await this.fireLifecycleErrorCallback(options, realStreamError);
|
|
198
218
|
throw this.handleProviderError(realStreamError);
|
|
199
219
|
}
|
|
200
220
|
logger.warn(`Real streaming failed for ${this.providerName}, falling back to fake streaming:`, {
|
|
201
221
|
error: errMsg,
|
|
202
222
|
timestamp: Date.now(),
|
|
203
223
|
});
|
|
204
|
-
// Fallback to fake streaming only if real streaming fails AND tools
|
|
224
|
+
// Fallback to fake streaming only if real streaming fails AND tools
|
|
225
|
+
// are enabled. executeFakeStreaming() owns its own catch + lifecycle
|
|
226
|
+
// fire, so a fake-streaming failure here surfaces through that path
|
|
227
|
+
// without needing an outer wrap (which would double-route through
|
|
228
|
+
// handleProviderError()).
|
|
205
229
|
if (!options.disableTools && this.supportsTools()) {
|
|
206
|
-
|
|
230
|
+
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
231
|
+
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
207
232
|
}
|
|
208
233
|
else {
|
|
234
|
+
// If real streaming failed and no tools are enabled, fire onError
|
|
235
|
+
// before re-throwing so consumer-supplied callbacks see the failure.
|
|
236
|
+
await this.fireLifecycleErrorCallback(options, realStreamError);
|
|
209
237
|
// If real streaming failed and no tools are enabled, re-throw the original error
|
|
210
238
|
logger.error(`Real streaming failed for ${this.providerName}:`, realStreamError);
|
|
211
239
|
throw this.handleProviderError(realStreamError);
|
|
212
240
|
}
|
|
213
241
|
}
|
|
214
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Wrap a StreamResult with consumer-facing lifecycle callbacks.
|
|
245
|
+
*
|
|
246
|
+
* `options.onChunk`, `options.onFinish`, `options.onError` are translated
|
|
247
|
+
* by NeuroLink.applyStreamLifecycleMiddleware() into
|
|
248
|
+
* `options.middleware.middlewareConfig.lifecycle.config`. The AI SDK's
|
|
249
|
+
* lifecycle middleware only sees these via the wrapped LanguageModel —
|
|
250
|
+
* which is bypassed by providers that stream via raw HTTP fetch (Ollama
|
|
251
|
+
* over /api/chat, custom OpenAI-compatible servers, etc). Wrapping the
|
|
252
|
+
* user-facing stream here ensures the callbacks fire regardless of the
|
|
253
|
+
* underlying transport.
|
|
254
|
+
*/
|
|
255
|
+
wrapStreamWithLifecycleCallbacks(result, options) {
|
|
256
|
+
const lifecycle = options
|
|
257
|
+
?.middleware?.middlewareConfig?.lifecycle?.config;
|
|
258
|
+
if (!lifecycle?.onChunk && !lifecycle?.onFinish && !lifecycle?.onError) {
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
const { onChunk, onFinish, onError } = lifecycle;
|
|
262
|
+
const startTime = Date.now();
|
|
263
|
+
const originalStream = result.stream;
|
|
264
|
+
// Lifecycle callbacks are awaited with a bounded deadline so callers
|
|
265
|
+
// observe ordering guarantees (onChunk/onFinish/onError have all
|
|
266
|
+
// settled by the time `for await` returns / throws). The previous
|
|
267
|
+
// fire-and-forget pattern left async work running past stream close,
|
|
268
|
+
// creating races during cleanup. The deadline is configurable via
|
|
269
|
+
// `lifecycle.timeoutMs` (per-call) or `NEUROLINK_LIFECYCLE_TIMEOUT_MS`
|
|
270
|
+
// (env / CLI surface) — see `resolveLifecycleTimeoutMs`.
|
|
271
|
+
const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
|
|
272
|
+
const safeFire = async (fn, label) => {
|
|
273
|
+
try {
|
|
274
|
+
await withTimeoutFn(async () => {
|
|
275
|
+
const ret = fn();
|
|
276
|
+
if (ret && typeof ret.then === "function") {
|
|
277
|
+
await ret;
|
|
278
|
+
}
|
|
279
|
+
}, timeoutMs, `[lifecycle] ${label} callback exceeded ${timeoutMs}ms`);
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
logger.warn(`[lifecycle] ${label} callback error:`, e);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const wrappedStream = (async function* () {
|
|
286
|
+
let accumulated = "";
|
|
287
|
+
let seq = 0;
|
|
288
|
+
try {
|
|
289
|
+
for await (const chunk of originalStream) {
|
|
290
|
+
const textPart = chunk &&
|
|
291
|
+
typeof chunk === "object" &&
|
|
292
|
+
"content" in chunk &&
|
|
293
|
+
typeof chunk.content === "string"
|
|
294
|
+
? chunk.content
|
|
295
|
+
: "";
|
|
296
|
+
// Only fire onChunk for actual text deltas. Non-text chunks
|
|
297
|
+
// (image, tts_audio) would otherwise produce empty text-delta
|
|
298
|
+
// events that consumers must filter out themselves.
|
|
299
|
+
if (onChunk && textPart) {
|
|
300
|
+
const currentSeq = seq++;
|
|
301
|
+
await safeFire(() => onChunk({
|
|
302
|
+
type: "text-delta",
|
|
303
|
+
textDelta: textPart,
|
|
304
|
+
sequenceNumber: currentSeq,
|
|
305
|
+
}), "onChunk");
|
|
306
|
+
}
|
|
307
|
+
if (textPart) {
|
|
308
|
+
accumulated += textPart;
|
|
309
|
+
}
|
|
310
|
+
yield chunk;
|
|
311
|
+
}
|
|
312
|
+
if (onFinish) {
|
|
313
|
+
await safeFire(() => onFinish({
|
|
314
|
+
text: accumulated,
|
|
315
|
+
duration: Date.now() - startTime,
|
|
316
|
+
}), "onFinish");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
321
|
+
if (onError && !hasLifecycleErrorFired(err)) {
|
|
322
|
+
// Mark before firing so a higher layer that also routes through
|
|
323
|
+
// fireLifecycleErrorCallback (or its own lifecycle wrapper) with
|
|
324
|
+
// the same error instance won't double-fire onError. Mirrors the
|
|
325
|
+
// pattern in fireLifecycleErrorCallback below.
|
|
326
|
+
markLifecycleErrorFired(err);
|
|
327
|
+
await safeFire(() => onError({
|
|
328
|
+
error: err,
|
|
329
|
+
duration: Date.now() - startTime,
|
|
330
|
+
recoverable: false,
|
|
331
|
+
}), "onError");
|
|
332
|
+
}
|
|
333
|
+
throw err;
|
|
334
|
+
}
|
|
335
|
+
})();
|
|
336
|
+
return { ...result, stream: wrappedStream };
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Fire the consumer-supplied onError callback before throwing. Used in
|
|
340
|
+
* error branches inside stream() that re-throw without emitting any
|
|
341
|
+
* stream chunks (which would otherwise hide the failure from a caller
|
|
342
|
+
* that supplied `onError`).
|
|
343
|
+
*/
|
|
344
|
+
async fireLifecycleErrorCallback(options, error) {
|
|
345
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
346
|
+
// The AI-SDK lifecycle middleware stamps errors it has already
|
|
347
|
+
// surfaced (Symbol.for("neurolink.onErrorFired"); see
|
|
348
|
+
// utils/lifecycleCallbacks.ts). Skip here so consumers don't receive
|
|
349
|
+
// duplicate onError events for the same failure.
|
|
350
|
+
if (hasLifecycleErrorFired(err)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const lifecycle = options
|
|
354
|
+
?.middleware?.middlewareConfig?.lifecycle?.config;
|
|
355
|
+
const onError = lifecycle?.onError;
|
|
356
|
+
if (!onError) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// Set the marker before invoking so a sync re-entry (or a concurrent
|
|
360
|
+
// dispatch path) can't double-fire onError for the same error object.
|
|
361
|
+
markLifecycleErrorFired(err);
|
|
362
|
+
// Fire the consumer's onError with a bounded deadline AND await its
|
|
363
|
+
// completion — callers can now `await fireLifecycleErrorCallback(...)`
|
|
364
|
+
// to guarantee the consumer's async onError settles before the
|
|
365
|
+
// surrounding stream() / executeFakeStreaming() rethrows. Deadline is
|
|
366
|
+
// configurable via `lifecycle.timeoutMs` or the
|
|
367
|
+
// `NEUROLINK_LIFECYCLE_TIMEOUT_MS` env var.
|
|
368
|
+
const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
|
|
369
|
+
try {
|
|
370
|
+
await withTimeoutFn(async () => {
|
|
371
|
+
// Capturing `onError` into a const above means TypeScript sees the
|
|
372
|
+
// narrowing past the early-return, so no non-null assertion needed
|
|
373
|
+
// here — and the callback identity is stable across the timeout
|
|
374
|
+
// boundary even if the caller mutates `lifecycle.onError` mid-call.
|
|
375
|
+
const ret = onError({
|
|
376
|
+
error: err,
|
|
377
|
+
duration: 0,
|
|
378
|
+
recoverable: false,
|
|
379
|
+
});
|
|
380
|
+
if (ret && typeof ret.then === "function") {
|
|
381
|
+
await ret;
|
|
382
|
+
}
|
|
383
|
+
}, timeoutMs, `[lifecycle] onError callback exceeded ${timeoutMs}ms`);
|
|
384
|
+
}
|
|
385
|
+
catch (e) {
|
|
386
|
+
logger.warn("[lifecycle] onError callback error:", e);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
215
389
|
/**
|
|
216
390
|
* Execute fake streaming - extracted method for reusability
|
|
217
391
|
*/
|
|
@@ -347,6 +521,14 @@ export class BaseProvider {
|
|
|
347
521
|
}
|
|
348
522
|
catch (error) {
|
|
349
523
|
logger.error(`Fake streaming fallback failed for ${this.providerName}:`, error);
|
|
524
|
+
// Fire the consumer-supplied onError BEFORE re-throwing through
|
|
525
|
+
// handleProviderError() so callers using onChunk/onFinish/onError
|
|
526
|
+
// get notified even when fake-streaming setup (message build, image
|
|
527
|
+
// adapter, etc.) fails synchronously. Awaited so the consumer's
|
|
528
|
+
// async onError fully settles before we rethrow. The shared
|
|
529
|
+
// lifecycle-fired WeakSet mark prevents double-fire if a wrapper
|
|
530
|
+
// layer also handles this.
|
|
531
|
+
await this.fireLifecycleErrorCallback(options, error);
|
|
350
532
|
throw this.handleProviderError(error);
|
|
351
533
|
}
|
|
352
534
|
}
|
|
@@ -694,7 +876,15 @@ export class BaseProvider {
|
|
|
694
876
|
}, options, startTime);
|
|
695
877
|
}
|
|
696
878
|
async executeStandardGenerateFlow(options, startTime, model, messages, tools) {
|
|
697
|
-
|
|
879
|
+
// Apply a defensive default timeout (3 min) when the caller didn't pass
|
|
880
|
+
// one. Without this guard, AI SDK's generateText() will wait forever on
|
|
881
|
+
// an upstream that accepts the connection but never produces a response
|
|
882
|
+
// (observed against the litellm gateway when a request triggers the
|
|
883
|
+
// team-access denial path — connection stays open, no response is sent,
|
|
884
|
+
// and the matrix test hangs the entire suite). Callers can still pass
|
|
885
|
+
// a larger value (e.g. video generation passes 10 min).
|
|
886
|
+
const effectiveTimeout = options.timeout ?? 180_000;
|
|
887
|
+
const timeoutController = createTimeoutController(effectiveTimeout, this.providerName, "generate");
|
|
698
888
|
const composedSignal = composeAbortSignals(options.abortSignal, timeoutController?.controller.signal);
|
|
699
889
|
const composedOptions = composedSignal
|
|
700
890
|
? { ...options, abortSignal: composedSignal }
|
|
@@ -802,6 +992,11 @@ export class BaseProvider {
|
|
|
802
992
|
analytics: result.analytics,
|
|
803
993
|
evaluation: result.evaluation,
|
|
804
994
|
audio: result.audio,
|
|
995
|
+
// Forward reasoning fields populated by GenerationHandler from AI-SDK
|
|
996
|
+
// reasoning parts (DeepSeek `reasoning_content`, Anthropic thinking,
|
|
997
|
+
// Gemini thought parts, OpenAI o1).
|
|
998
|
+
reasoning: result.reasoning,
|
|
999
|
+
reasoningTokens: result.reasoningTokens,
|
|
805
1000
|
};
|
|
806
1001
|
}
|
|
807
1002
|
/**
|
|
@@ -828,8 +1023,9 @@ export class BaseProvider {
|
|
|
828
1023
|
textLength: text.length,
|
|
829
1024
|
});
|
|
830
1025
|
throw new Error(`Embedding generation is not supported by the ${this.providerName} provider. ` +
|
|
831
|
-
`Supported providers: openai, vertex/google, bedrock. ` +
|
|
1026
|
+
`Supported providers: openai, vertex/google, bedrock, cohere, voyage, jina. ` +
|
|
832
1027
|
`Use an embedding model like text-embedding-3-small (OpenAI), text-embedding-004 (Vertex), ` +
|
|
1028
|
+
`embed-english-v3.0 (Cohere), voyage-3 (Voyage), jina-embeddings-v3 (Jina), ` +
|
|
833
1029
|
`or amazon.titan-embed-text-v2:0 (Bedrock).`);
|
|
834
1030
|
}
|
|
835
1031
|
/**
|
|
@@ -849,9 +1045,10 @@ export class BaseProvider {
|
|
|
849
1045
|
count: texts.length,
|
|
850
1046
|
});
|
|
851
1047
|
throw new Error(`Batch embedding generation is not supported by the ${this.providerName} provider. ` +
|
|
852
|
-
`Supported providers: openai, googleAiStudio, vertex/google, bedrock. ` +
|
|
1048
|
+
`Supported providers: openai, googleAiStudio, vertex/google, bedrock, cohere, voyage, jina. ` +
|
|
853
1049
|
`Use an embedding model like text-embedding-3-small (OpenAI), gemini-embedding-001 (Google AI), ` +
|
|
854
|
-
`text-embedding-004 (Vertex),
|
|
1050
|
+
`text-embedding-004 (Vertex), embed-english-v3.0 (Cohere), voyage-3 (Voyage), ` +
|
|
1051
|
+
`jina-embeddings-v3 (Jina), or amazon.titan-embed-text-v2:0 (Bedrock).`);
|
|
855
1052
|
}
|
|
856
1053
|
/**
|
|
857
1054
|
* Get the default embedding model for this provider
|
|
@@ -1005,6 +1202,15 @@ export class BaseProvider {
|
|
|
1005
1202
|
: new DOMException("The operation was aborted", "AbortError");
|
|
1006
1203
|
}
|
|
1007
1204
|
const formatted = this.formatProviderError(error);
|
|
1205
|
+
// Preserve the lifecycle-fired mark across formatting:
|
|
1206
|
+
// fireLifecycleErrorCallback() marks the ORIGINAL error in the shared
|
|
1207
|
+
// WeakSet, but formatProviderError() typically returns a new Error
|
|
1208
|
+
// instance. Re-mark the formatted error so a higher layer (e.g.
|
|
1209
|
+
// NeuroLink.stream()'s top-level catch + applyStreamLifecycleMiddleware)
|
|
1210
|
+
// doesn't fire onError a second time for the same failure.
|
|
1211
|
+
if (hasLifecycleErrorFired(error)) {
|
|
1212
|
+
markLifecycleErrorFired(formatted);
|
|
1213
|
+
}
|
|
1008
1214
|
// P3 fix: Classify error and set error.type on the active OTel span
|
|
1009
1215
|
try {
|
|
1010
1216
|
const activeSpan = trace.getSpan(context.active());
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
* Single source of truth for all default values
|
|
4
4
|
*/
|
|
5
5
|
export declare const IMAGE_GENERATION_MODELS: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Boundary-aware test for whether `modelName` represents an image-generation
|
|
8
|
+
* model.
|
|
9
|
+
*
|
|
10
|
+
* Matches when the model name **equals** an entry in
|
|
11
|
+
* {@link IMAGE_GENERATION_MODELS} or contains the entry as a prefix followed
|
|
12
|
+
* by a separator (`-`, `_`, `:`, `/`, `.`) or end-of-string. This avoids
|
|
13
|
+
* accidental matches such as a custom fine-tune named `"my-V_1"` matching
|
|
14
|
+
* `"V_1"` via plain substring inclusion.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isImageGenerationModel(modelName: string | undefined): boolean;
|
|
6
17
|
export declare const PDF_IMAGE_GENERATION_MODELS: string[];
|
|
7
18
|
export declare const GLOBAL_LOCATION_MODELS: string[];
|
|
8
19
|
export declare const DEFAULT_MAX_TOKENS: undefined;
|
|
@@ -10,6 +21,7 @@ export declare const DEFAULT_TEMPERATURE = 0.7;
|
|
|
10
21
|
export declare const DEFAULT_TIMEOUT = 60000;
|
|
11
22
|
export declare const DEFAULT_MAX_STEPS = 200;
|
|
12
23
|
export declare const DEFAULT_TOOL_MAX_RETRIES = 2;
|
|
24
|
+
export declare const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
13
25
|
export declare const STEP_LIMITS: {
|
|
14
26
|
min: number;
|
|
15
27
|
max: number;
|
package/dist/core/constants.js
CHANGED
|
@@ -3,12 +3,80 @@
|
|
|
3
3
|
* Single source of truth for all default values
|
|
4
4
|
*/
|
|
5
5
|
// Image Generation Model Identifiers
|
|
6
|
-
// Used to detect if a model is an image generation model (not text generation)
|
|
6
|
+
// Used to detect if a model is an image generation model (not text generation).
|
|
7
|
+
// `isImageGenerationModel(name)` (below) does boundary-aware matching:
|
|
8
|
+
// the modelName must equal an entry OR contain an entry followed by a
|
|
9
|
+
// non-alphanumeric character (`-`, `_`, `:`, `/`, `.`, end-of-string).
|
|
10
|
+
// This prevents short identifiers like `"V_1"` or `"gpt-image-1"` from
|
|
11
|
+
// accidentally matching unrelated model names that happen to embed them.
|
|
7
12
|
export const IMAGE_GENERATION_MODELS = [
|
|
13
|
+
// Gemini image models (Vertex AI, Google AI Studio)
|
|
8
14
|
"gemini-3-pro-image-preview",
|
|
9
15
|
"gemini-2.5-flash-image",
|
|
10
16
|
"gemini-3.1-flash-image-preview",
|
|
17
|
+
// Stability AI (direct provider — image-only)
|
|
18
|
+
"stable-image-ultra",
|
|
19
|
+
"stable-image-core",
|
|
20
|
+
"sd3.5-large",
|
|
21
|
+
"sd3.5-large-turbo",
|
|
22
|
+
"sd3.5-medium",
|
|
23
|
+
// Ideogram (direct provider — image-only). API uses model-version
|
|
24
|
+
// identifiers like "V_1", "V_1_TURBO", "V_2", "V_2_TURBO", "V_2A",
|
|
25
|
+
// "V_2A_TURBO", "V_3". Keep prefixes that won't collide with generic
|
|
26
|
+
// text-model names.
|
|
27
|
+
"V_1",
|
|
28
|
+
"V_1_TURBO",
|
|
29
|
+
"V_2",
|
|
30
|
+
"V_2_TURBO",
|
|
31
|
+
"V_2A",
|
|
32
|
+
"V_2A_TURBO",
|
|
33
|
+
"V_3",
|
|
34
|
+
// Recraft (direct provider — image-only)
|
|
35
|
+
"recraftv3",
|
|
36
|
+
"recraftv2",
|
|
37
|
+
// OpenAI image models (DALL-E + GPT-Image). Substring match keeps
|
|
38
|
+
// version variants like "dall-e-3" / "dall-e-2" routed correctly.
|
|
39
|
+
"gpt-image-1",
|
|
40
|
+
"dall-e-3",
|
|
41
|
+
"dall-e-2",
|
|
42
|
+
// Replicate-hosted image models (matched on model slug prefix).
|
|
43
|
+
// Replicate model slugs are passed through as-is via the LLM
|
|
44
|
+
// provider; image-gen models trigger the image-gen path.
|
|
45
|
+
"black-forest-labs/flux",
|
|
46
|
+
"stability-ai/sdxl",
|
|
47
|
+
"stability-ai/stable-diffusion",
|
|
11
48
|
];
|
|
49
|
+
/**
|
|
50
|
+
* Boundary-aware test for whether `modelName` represents an image-generation
|
|
51
|
+
* model.
|
|
52
|
+
*
|
|
53
|
+
* Matches when the model name **equals** an entry in
|
|
54
|
+
* {@link IMAGE_GENERATION_MODELS} or contains the entry as a prefix followed
|
|
55
|
+
* by a separator (`-`, `_`, `:`, `/`, `.`) or end-of-string. This avoids
|
|
56
|
+
* accidental matches such as a custom fine-tune named `"my-V_1"` matching
|
|
57
|
+
* `"V_1"` via plain substring inclusion.
|
|
58
|
+
*/
|
|
59
|
+
export function isImageGenerationModel(modelName) {
|
|
60
|
+
if (!modelName) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
for (const entry of IMAGE_GENERATION_MODELS) {
|
|
64
|
+
if (modelName === entry) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
const idx = modelName.indexOf(entry);
|
|
68
|
+
if (idx === -1) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const before = idx === 0 ? "" : modelName[idx - 1];
|
|
72
|
+
const after = modelName[idx + entry.length] ?? "";
|
|
73
|
+
const isBoundary = (ch) => ch === "" || /[-_:./@]/.test(ch);
|
|
74
|
+
if (isBoundary(before) && isBoundary(after)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
12
80
|
// PDF Image Generation Models
|
|
13
81
|
// Models that support generating images from PDFs
|
|
14
82
|
export const PDF_IMAGE_GENERATION_MODELS = [
|
|
@@ -39,6 +107,9 @@ export const DEFAULT_TEMPERATURE = 0.7;
|
|
|
39
107
|
export const DEFAULT_TIMEOUT = 60000;
|
|
40
108
|
export const DEFAULT_MAX_STEPS = 200;
|
|
41
109
|
export const DEFAULT_TOOL_MAX_RETRIES = 2; // Maximum retries per tool before permanently failing
|
|
110
|
+
// Fire-and-forget tool storage writes (Redis). 5s is generous for a single
|
|
111
|
+
// Redis write; if breached, the .catch logs a warning.
|
|
112
|
+
export const TOOL_STORAGE_TIMEOUT_MS = 5000;
|
|
42
113
|
// Step execution limits
|
|
43
114
|
export const STEP_LIMITS = {
|
|
44
115
|
min: 1,
|
|
@@ -12,6 +12,8 @@ export { BatchEvaluator } from "./BatchEvaluator.js";
|
|
|
12
12
|
export { EvaluationAggregator } from "./EvaluationAggregator.js";
|
|
13
13
|
export { EvaluatorFactory, getEvaluatorFactory } from "./EvaluatorFactory.js";
|
|
14
14
|
export { EvaluatorRegistry, getEvaluatorRegistry, } from "./EvaluatorRegistry.js";
|
|
15
|
+
export { RAGASEvaluator } from "./ragasEvaluator.js";
|
|
16
|
+
export { RetryManager } from "./retryManager.js";
|
|
15
17
|
/**
|
|
16
18
|
* A centralized class for performing response evaluations. It supports different
|
|
17
19
|
* evaluation strategies, with RAGAS-style model-based evaluation as the default.
|
package/dist/evaluation/index.js
CHANGED
|
@@ -19,6 +19,10 @@ export { BatchEvaluator } from "./BatchEvaluator.js";
|
|
|
19
19
|
export { EvaluationAggregator } from "./EvaluationAggregator.js";
|
|
20
20
|
export { EvaluatorFactory, getEvaluatorFactory } from "./EvaluatorFactory.js";
|
|
21
21
|
export { EvaluatorRegistry, getEvaluatorRegistry, } from "./EvaluatorRegistry.js";
|
|
22
|
+
// Re-export internal RAGAS classes so callers (and the evaluation test
|
|
23
|
+
// suite) can instantiate them directly from the public surface.
|
|
24
|
+
export { RAGASEvaluator } from "./ragasEvaluator.js";
|
|
25
|
+
export { RetryManager } from "./retryManager.js";
|
|
22
26
|
/**
|
|
23
27
|
* A centralized class for performing response evaluations. It supports different
|
|
24
28
|
* evaluation strategies, with RAGAS-style model-based evaluation as the default.
|
|
@@ -60,11 +60,17 @@ export class ProviderFactory {
|
|
|
60
60
|
}
|
|
61
61
|
// Map registered provider names to NeurolinkCredentials keys.
|
|
62
62
|
// Most names match (openai, anthropic, vertex, bedrock, etc.)
|
|
63
|
-
// but
|
|
63
|
+
// but every kebab-case provider whose canonical credentials key is
|
|
64
|
+
// camelCase MUST be mapped here — otherwise per-call credential
|
|
65
|
+
// overrides silently get dropped (the factory looks up
|
|
66
|
+
// credentials["lm-studio"] which is undefined while the user wrote
|
|
67
|
+
// credentials.lmStudio).
|
|
64
68
|
const credentialKeyMap = {
|
|
65
69
|
"google-ai": "googleAiStudio",
|
|
66
70
|
"openai-compatible": "openaiCompatible",
|
|
67
71
|
huggingface: "huggingFace",
|
|
72
|
+
"lm-studio": "lmStudio",
|
|
73
|
+
"nvidia-nim": "nvidiaNim",
|
|
68
74
|
};
|
|
69
75
|
const credKey = credentialKeyMap[normalizedName] ?? normalizedName;
|
|
70
76
|
// Extract provider-scoped credential slice (e.g. credentials.openai for OpenAI)
|