@juspay/neurolink 10.12.9 → 11.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 +32 -0
- package/dist/browser/neurolink.min.js +504 -506
- package/dist/cli/commands/setup.d.ts +20 -1
- package/dist/cli/commands/setup.js +160 -36
- package/dist/cli/factories/commandFactory.d.ts +1157 -1
- package/dist/cli/factories/commandFactory.js +20 -53
- 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/providerDescriptors.d.ts +18 -0
- package/dist/factories/providerDescriptors.js +536 -0
- package/dist/factories/providerFactory.d.ts +28 -2
- package/dist/factories/providerFactory.js +53 -42
- package/dist/factories/providerRegistry.js +33 -32
- package/dist/index.d.ts +10 -1
- package/dist/index.js +13 -3
- 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/providerDescriptors.d.ts +18 -0
- package/dist/lib/factories/providerDescriptors.js +537 -0
- package/dist/lib/factories/providerFactory.d.ts +28 -2
- package/dist/lib/factories/providerFactory.js +53 -42
- package/dist/lib/factories/providerRegistry.js +33 -32
- package/dist/lib/index.d.ts +10 -1
- package/dist/lib/index.js +13 -3
- package/dist/lib/models/anthropicModels.d.ts +0 -7
- package/dist/lib/models/anthropicModels.js +0 -9
- package/dist/lib/neurolink.js +25 -37
- package/dist/lib/providers/amazonBedrock/client.js +34 -16
- package/dist/lib/providers/anthropic/client.js +39 -34
- 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/azureOpenai.js +17 -15
- package/dist/lib/providers/cloudflare.js +12 -21
- package/dist/lib/providers/cohere.js +31 -25
- package/dist/lib/providers/deepseek.js +23 -26
- package/dist/lib/providers/fireworks.js +12 -21
- package/dist/lib/providers/googleAiStudio/client.d.ts +2 -0
- package/dist/lib/providers/googleAiStudio/client.js +39 -17
- 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 +107 -777
- package/dist/lib/providers/groq.js +19 -22
- package/dist/lib/providers/huggingFace/client.d.ts +1 -1
- package/dist/lib/providers/huggingFace/client.js +27 -25
- 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/client.js +54 -39
- 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 +24 -18
- package/dist/lib/providers/lmStudio.js +25 -42
- package/dist/lib/providers/mistral.js +12 -24
- package/dist/lib/providers/nvidiaNim/client.js +37 -34
- 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 +51 -58
- package/dist/lib/providers/ollama/index.d.ts +0 -1
- package/dist/lib/providers/ollama/index.js +0 -1
- package/dist/lib/providers/openAI/client.js +37 -40
- package/dist/lib/providers/openAI/index.d.ts +0 -2
- package/dist/lib/providers/openAI/index.js +0 -2
- package/dist/lib/providers/openRouter/client.js +53 -47
- 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 +73 -16
- package/dist/lib/providers/openaiCompatible/client.js +36 -32
- package/dist/lib/providers/perplexity.d.ts +2 -1
- package/dist/lib/providers/perplexity.js +14 -22
- package/dist/lib/providers/replicate.d.ts +0 -1
- package/dist/lib/providers/replicate.js +22 -9
- package/dist/lib/providers/togetherAi.js +12 -21
- package/dist/lib/providers/voyage.d.ts +0 -1
- package/dist/lib/providers/voyage.js +0 -1
- package/dist/lib/providers/xai.js +17 -26
- package/dist/lib/server/errors.d.ts +1 -1
- package/dist/lib/server/errors.js +2 -2
- package/dist/lib/server/index.d.ts +2 -2
- package/dist/lib/server/index.js +5 -3
- package/dist/lib/server/middleware/rateLimit.d.ts +0 -4
- package/dist/lib/server/middleware/rateLimit.js +0 -4
- package/dist/lib/types/errors.d.ts +35 -0
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/providers.d.ts +66 -11
- package/dist/lib/utils/errorClassifier.d.ts +30 -0
- package/dist/lib/utils/errorClassifier.js +94 -0
- package/dist/lib/utils/fileDetector.js +6 -43
- package/dist/lib/utils/providerConfig.d.ts +0 -8
- package/dist/lib/utils/providerConfig.js +0 -37
- package/dist/lib/utils/providerHealth.d.ts +42 -7
- package/dist/lib/utils/providerHealth.js +115 -122
- package/dist/lib/utils/providerUtils.js +21 -87
- package/dist/models/anthropicModels.d.ts +0 -7
- package/dist/models/anthropicModels.js +0 -9
- package/dist/neurolink.js +25 -37
- package/dist/providers/amazonBedrock/client.js +34 -16
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/anthropic/client.js +39 -34
- 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/azureOpenai.js +17 -15
- package/dist/providers/cloudflare.js +12 -21
- package/dist/providers/cohere.js +31 -25
- package/dist/providers/deepseek.js +23 -26
- package/dist/providers/fireworks.js +12 -21
- package/dist/providers/googleAiStudio/client.d.ts +2 -0
- package/dist/providers/googleAiStudio/client.js +39 -17
- 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 +107 -777
- package/dist/providers/groq.js +19 -22
- package/dist/providers/huggingFace/client.d.ts +1 -1
- package/dist/providers/huggingFace/client.js +27 -25
- 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/client.js +54 -39
- 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 +24 -18
- package/dist/providers/lmStudio.js +25 -42
- package/dist/providers/mistral.js +12 -24
- package/dist/providers/nvidiaNim/client.js +37 -34
- package/dist/providers/nvidiaNim/index.d.ts +0 -1
- package/dist/providers/nvidiaNim/index.js +0 -1
- package/dist/providers/ollama/client.js +51 -58
- package/dist/providers/ollama/index.d.ts +0 -1
- package/dist/providers/ollama/index.js +0 -1
- package/dist/providers/openAI/client.js +37 -40
- package/dist/providers/openAI/index.d.ts +0 -2
- package/dist/providers/openAI/index.js +0 -2
- package/dist/providers/openRouter/client.js +53 -47
- 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 +73 -16
- package/dist/providers/openaiCompatible/client.js +36 -32
- package/dist/providers/perplexity.d.ts +2 -1
- package/dist/providers/perplexity.js +14 -22
- package/dist/providers/replicate.d.ts +0 -1
- package/dist/providers/replicate.js +22 -9
- package/dist/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/providers/togetherAi.js +12 -21
- package/dist/providers/voyage.d.ts +0 -1
- package/dist/providers/voyage.js +0 -1
- package/dist/providers/xai.js +17 -26
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/errors.js +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +5 -3
- package/dist/server/middleware/rateLimit.d.ts +0 -4
- package/dist/server/middleware/rateLimit.js +0 -4
- package/dist/types/errors.d.ts +35 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/providers.d.ts +66 -11
- package/dist/utils/errorClassifier.d.ts +30 -0
- package/dist/utils/errorClassifier.js +93 -0
- package/dist/utils/fileDetector.js +6 -43
- package/dist/utils/providerConfig.d.ts +0 -8
- package/dist/utils/providerConfig.js +0 -37
- package/dist/utils/providerHealth.d.ts +42 -7
- package/dist/utils/providerHealth.js +115 -122
- package/dist/utils/providerUtils.js +21 -87
- package/package.json +21 -75
- 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
|
@@ -6,6 +6,7 @@ import { ATTR, tracers, withClientSpan, withClientStreamSpan, withSpan, } from "
|
|
|
6
6
|
import { AuthenticationError, InvalidModelError, NetworkError, ProviderError, RateLimitError, } from "../../types/index.js";
|
|
7
7
|
import { ERROR_CODES, NeuroLinkError } from "../../utils/errorHandling.js";
|
|
8
8
|
import { logger } from "../../utils/logger.js";
|
|
9
|
+
import { isToolsSchemaExclusionInForce } from "../../core/modules/structuredOutputPolicy.js";
|
|
9
10
|
import { GEMINI_ELISION_NOTE, planGeminiLoopReclaim, previewGeminiToolResponseText, } from "../../context/geminiLoopGuard.js";
|
|
10
11
|
import { getAvailableInputTokens, getContextWindowSize, } from "../../constants/contextWindows.js";
|
|
11
12
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../../utils/timeout.js";
|
|
@@ -18,7 +19,7 @@ import { createProxyFetch } from "../../proxy/proxyFetch.js";
|
|
|
18
19
|
// Google AI Live API types now imported from ../types/providerSpecific.js
|
|
19
20
|
// Import proper types for multimodal message handling
|
|
20
21
|
// Create Google GenAI client
|
|
21
|
-
async function createGoogleGenAIClient(apiKey) {
|
|
22
|
+
async function createGoogleGenAIClient(apiKey, baseURL) {
|
|
22
23
|
const mod = await import("@google/genai");
|
|
23
24
|
const ctor = mod.GoogleGenAI;
|
|
24
25
|
if (!ctor) {
|
|
@@ -32,11 +33,17 @@ async function createGoogleGenAIClient(apiKey) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
const Ctor = ctor;
|
|
35
|
-
// Include httpOptions with proxy fetch for corporate network support
|
|
36
|
+
// Include httpOptions with proxy fetch for corporate network support.
|
|
37
|
+
// baseUrl is only included when resolved — verified against
|
|
38
|
+
// @google/genai's ApiClient (dist/node/index.cjs) that it falls back to
|
|
39
|
+
// its own default whenever httpOptions.baseUrl is undefined, so omitting
|
|
40
|
+
// the key and passing `baseUrl: undefined` behave identically; the key is
|
|
41
|
+
// still omitted outright for a cleaner outbound config object.
|
|
36
42
|
return new Ctor({
|
|
37
43
|
apiKey,
|
|
38
44
|
httpOptions: {
|
|
39
45
|
fetch: createProxyFetch(),
|
|
46
|
+
...(baseURL ? { baseUrl: baseURL } : {}),
|
|
40
47
|
},
|
|
41
48
|
});
|
|
42
49
|
}
|
|
@@ -256,7 +263,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
256
263
|
// Use the @google/genai client for image generation
|
|
257
264
|
let client;
|
|
258
265
|
try {
|
|
259
|
-
client = await createGoogleGenAIClient(apiKey);
|
|
266
|
+
client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
260
267
|
}
|
|
261
268
|
catch {
|
|
262
269
|
throw new AuthenticationError("Missing '@google/genai'. Install with: npm install @google/genai", this.providerName);
|
|
@@ -563,7 +570,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
563
570
|
// generate() does, or attached files are dropped on this path alone.
|
|
564
571
|
await this.preprocessNativeFileInput(options);
|
|
565
572
|
// Structured output (analysisSchema, JSON format, or schema) is incompatible with tools on Gemini.
|
|
566
|
-
const wantsStructuredOutput = analysisSchema || options.output?.format === "json" || options.schema;
|
|
573
|
+
const wantsStructuredOutput = Boolean(analysisSchema || options.output?.format === "json" || options.schema);
|
|
567
574
|
// Tool filter (a0269210): trust options.tools — caller (BaseProvider.stream)
|
|
568
575
|
// already merged MCP/built-in tools with user tools and applied any
|
|
569
576
|
// enabledToolNames filter. Re-attaching getAllTools() here would clobber
|
|
@@ -575,12 +582,10 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
575
582
|
...options,
|
|
576
583
|
tools: optionTools,
|
|
577
584
|
};
|
|
578
|
-
//
|
|
585
|
+
// Tools + JSON conflict (Gemini), via the shared predicate.
|
|
579
586
|
const wantsJsonOutput = options.output?.format === "json" || options.schema;
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
Object.keys(mergedOptions.tools).length > 0 &&
|
|
583
|
-
!mergedOptions.disableTools) {
|
|
587
|
+
const exclusionInForce = isToolsSchemaExclusionInForce(this.providerName, modelName, !mergedOptions.disableTools, Object.keys(mergedOptions.tools ?? {}).length);
|
|
588
|
+
if (wantsJsonOutput && exclusionInForce) {
|
|
584
589
|
logger.warn("[GoogleAIStudio] Gemini does not support tools and JSON schema output simultaneously. Disabling tools for this request.");
|
|
585
590
|
mergedOptions = { ...mergedOptions, disableTools: true, tools: {} };
|
|
586
591
|
}
|
|
@@ -618,7 +623,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
618
623
|
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
619
624
|
try {
|
|
620
625
|
const apiKey = this.getApiKey();
|
|
621
|
-
const client = await createGoogleGenAIClient(apiKey);
|
|
626
|
+
const client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
622
627
|
logger.debug("[GoogleAIStudio] Using native @google/genai for Gemini 3", {
|
|
623
628
|
model: modelName,
|
|
624
629
|
hasTools: !!options.tools && Object.keys(options.tools).length > 0,
|
|
@@ -956,7 +961,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
956
961
|
const timeoutController = createTimeoutController(timeout, this.providerName, "generate");
|
|
957
962
|
try {
|
|
958
963
|
const apiKey = this.getApiKey();
|
|
959
|
-
const client = await createGoogleGenAIClient(apiKey);
|
|
964
|
+
const client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
960
965
|
logger.debug("[GoogleAIStudio] Using native @google/genai for Gemini 3 generate", {
|
|
961
966
|
model: modelName,
|
|
962
967
|
hasTools: !!options.tools && Object.keys(options.tools).length > 0,
|
|
@@ -985,7 +990,16 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
985
990
|
let originalNameMap = new Map();
|
|
986
991
|
let declarationsResult;
|
|
987
992
|
const shouldUseTools = !options.disableTools;
|
|
988
|
-
|
|
993
|
+
// Structured output (JSON format or schema) is incompatible with
|
|
994
|
+
// tools on Gemini — routed through the shared predicate so this
|
|
995
|
+
// decision matches stream()'s orchestrator (previously this path
|
|
996
|
+
// had no proactive check and silently dropped the schema instead).
|
|
997
|
+
const wantsNativeJsonRequested = Boolean(options.output?.format === "json" || options.schema);
|
|
998
|
+
const exclusionInForce = isToolsSchemaExclusionInForce(this.providerName, modelName, shouldUseTools, Object.keys(options.tools || {}).length);
|
|
999
|
+
if (wantsNativeJsonRequested && exclusionInForce) {
|
|
1000
|
+
logger.warn("[GoogleAIStudio] Gemini does not support tools and JSON schema output simultaneously. Disabling tools for this request (generate()).");
|
|
1001
|
+
}
|
|
1002
|
+
if (shouldUseTools && !exclusionInForce) {
|
|
989
1003
|
const tools = options.tools || {};
|
|
990
1004
|
if (Object.keys(tools).length > 0) {
|
|
991
1005
|
const result = buildNativeToolDeclarations(tools);
|
|
@@ -1002,8 +1016,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
1002
1016
|
// Native JSON / schema enforcement (generate path). Mirrors the
|
|
1003
1017
|
// stream block above; only set when no tools are being sent
|
|
1004
1018
|
// because Gemini cannot combine function calling with JSON mime.
|
|
1005
|
-
const wantsNativeJson = !toolsConfig &&
|
|
1006
|
-
(options.output?.format === "json" || !!options.schema);
|
|
1019
|
+
const wantsNativeJson = !toolsConfig && wantsNativeJsonRequested;
|
|
1007
1020
|
const nativeResponseSchema = wantsNativeJson && options.schema
|
|
1008
1021
|
? buildGeminiResponseSchema(options.schema)
|
|
1009
1022
|
: undefined;
|
|
@@ -1332,7 +1345,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
1332
1345
|
// Dynamic import to avoid hard dependency unless audio streaming is used
|
|
1333
1346
|
let client;
|
|
1334
1347
|
try {
|
|
1335
|
-
client = await createGoogleGenAIClient(apiKey);
|
|
1348
|
+
client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
1336
1349
|
}
|
|
1337
1350
|
catch {
|
|
1338
1351
|
throw new AuthenticationError("Missing '@google/genai'. Install with: pnpm add @google/genai", this.providerName);
|
|
@@ -1522,7 +1535,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
1522
1535
|
});
|
|
1523
1536
|
try {
|
|
1524
1537
|
const apiKey = this.getApiKey();
|
|
1525
|
-
const client = await createGoogleGenAIClient(apiKey);
|
|
1538
|
+
const client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
1526
1539
|
const result = await client.models.embedContent({
|
|
1527
1540
|
model: embeddingModelName,
|
|
1528
1541
|
contents: [text],
|
|
@@ -1562,7 +1575,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
1562
1575
|
});
|
|
1563
1576
|
try {
|
|
1564
1577
|
const apiKey = this.getApiKey();
|
|
1565
|
-
const client = await createGoogleGenAIClient(apiKey);
|
|
1578
|
+
const client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
|
|
1566
1579
|
const result = await client.models.embedContent({
|
|
1567
1580
|
model: embeddingModelName,
|
|
1568
1581
|
contents: texts,
|
|
@@ -1594,6 +1607,15 @@ export class GoogleAIStudioProvider extends BaseProvider {
|
|
|
1594
1607
|
}
|
|
1595
1608
|
return apiKey;
|
|
1596
1609
|
}
|
|
1610
|
+
// Mirrors mistral.ts's baseURL precedence (credentials override, then env,
|
|
1611
|
+
// then unset — the SDK's own default applies when unset). Blank/whitespace
|
|
1612
|
+
// values are treated as unset so an empty override can't accidentally
|
|
1613
|
+
// clobber the default.
|
|
1614
|
+
getBaseURL() {
|
|
1615
|
+
const baseURL = this.credentials?.baseURL?.trim() ||
|
|
1616
|
+
process.env.GOOGLE_AI_BASE_URL?.trim();
|
|
1617
|
+
return baseURL && baseURL.length > 0 ? baseURL : undefined;
|
|
1618
|
+
}
|
|
1597
1619
|
}
|
|
1598
1620
|
export default GoogleAIStudioProvider;
|
|
1599
1621
|
//# sourceMappingURL=client.js.map
|
|
@@ -70,28 +70,6 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
70
70
|
* Creates fresh model instances for each request
|
|
71
71
|
*/
|
|
72
72
|
protected getAISDKModel(): Promise<LanguageModel>;
|
|
73
|
-
/**
|
|
74
|
-
* Initialize model creation tracking
|
|
75
|
-
*/
|
|
76
|
-
private initializeModelCreationLogging;
|
|
77
|
-
/**
|
|
78
|
-
* Check if model is Anthropic-based and attempt creation
|
|
79
|
-
*/
|
|
80
|
-
private attemptAnthropicModelCreation;
|
|
81
|
-
/**
|
|
82
|
-
* Create Google Vertex model with comprehensive logging and error handling
|
|
83
|
-
*/
|
|
84
|
-
private createGoogleVertexModel;
|
|
85
|
-
/**
|
|
86
|
-
* @deprecated This method is no longer used. All models now use native SDKs.
|
|
87
|
-
*/
|
|
88
|
-
private createVertexInstance;
|
|
89
|
-
/**
|
|
90
|
-
* Gets the appropriate model instance (Google or Anthropic)
|
|
91
|
-
* Uses dual provider architecture for proper model routing
|
|
92
|
-
* Creates fresh instances for each request to ensure proper authentication
|
|
93
|
-
*/
|
|
94
|
-
private getModel;
|
|
95
73
|
/**
|
|
96
74
|
* Validate stream options
|
|
97
75
|
*/
|
|
@@ -320,35 +298,6 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
320
298
|
* @returns Promise<boolean> indicating if Anthropic support is available
|
|
321
299
|
*/
|
|
322
300
|
hasAnthropicSupport(): Promise<boolean>;
|
|
323
|
-
/**
|
|
324
|
-
* @deprecated This method is no longer used. Claude models now use native @anthropic-ai/vertex-sdk
|
|
325
|
-
* via executeNativeAnthropicStream and executeNativeAnthropicGenerate.
|
|
326
|
-
*/
|
|
327
|
-
createAnthropicModel(_modelName: string): Promise<LanguageModel | null>;
|
|
328
|
-
/**
|
|
329
|
-
* Validate Vertex AI authentication configuration
|
|
330
|
-
*/
|
|
331
|
-
private validateVertexAuthentication;
|
|
332
|
-
/**
|
|
333
|
-
* Validate Vertex AI project configuration
|
|
334
|
-
*/
|
|
335
|
-
private validateVertexProjectConfiguration;
|
|
336
|
-
/**
|
|
337
|
-
* Check if the specified region supports Anthropic models
|
|
338
|
-
*/
|
|
339
|
-
private checkVertexRegionalSupport;
|
|
340
|
-
/**
|
|
341
|
-
* Validate Anthropic model name format and availability
|
|
342
|
-
*/
|
|
343
|
-
private validateAnthropicModelName;
|
|
344
|
-
/**
|
|
345
|
-
* Analyze Anthropic model creation errors for detailed troubleshooting
|
|
346
|
-
*/
|
|
347
|
-
private analyzeAnthropicCreationError;
|
|
348
|
-
/**
|
|
349
|
-
* Get detailed troubleshooting steps based on error analysis
|
|
350
|
-
*/
|
|
351
|
-
private getAnthropicTroubleshootingSteps;
|
|
352
301
|
/**
|
|
353
302
|
* Register a tool with the AI provider
|
|
354
303
|
* @param name The name of the tool
|