@juspay/neurolink 7.44.0 → 7.45.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 +6 -0
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/core/factory.d.ts +3 -1
- package/dist/core/factory.js +5 -3
- package/dist/factories/providerFactory.d.ts +3 -3
- package/dist/factories/providerFactory.js +3 -3
- package/dist/factories/providerRegistry.js +6 -6
- package/dist/lib/core/factory.d.ts +3 -1
- package/dist/lib/core/factory.js +5 -3
- package/dist/lib/factories/providerFactory.d.ts +3 -3
- package/dist/lib/factories/providerFactory.js +3 -3
- package/dist/lib/factories/providerRegistry.js +6 -6
- package/dist/lib/neurolink.js +7 -3
- package/dist/lib/providers/amazonBedrock.d.ts +2 -1
- package/dist/lib/providers/amazonBedrock.js +6 -4
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/amazonSagemaker.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +9 -10
- package/dist/lib/providers/sagemaker/config.d.ts +7 -5
- package/dist/lib/providers/sagemaker/config.js +11 -6
- package/dist/lib/types/generateTypes.d.ts +2 -0
- package/dist/lib/types/streamTypes.d.ts +1 -0
- package/dist/neurolink.js +7 -3
- package/dist/providers/amazonBedrock.d.ts +2 -1
- package/dist/providers/amazonBedrock.js +6 -4
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/amazonSagemaker.js +2 -2
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/googleVertex.js +9 -10
- package/dist/providers/sagemaker/config.d.ts +7 -5
- package/dist/providers/sagemaker/config.js +11 -6
- package/dist/types/generateTypes.d.ts +2 -0
- package/dist/types/streamTypes.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [7.45.0](https://github.com/juspay/neurolink/compare/v7.44.0...v7.45.0) (2025-09-24)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **(provider):** Add support to provide region while streaming or generating for few providers ([a0a5bed](https://github.com/juspay/neurolink/commit/a0a5bed2bba4118dde149713708e36d4d29e1aae))
|
|
6
|
+
|
|
1
7
|
## [7.44.0](https://github.com/juspay/neurolink/compare/v7.43.0...v7.44.0) (2025-09-24)
|
|
2
8
|
|
|
3
9
|
### Features
|
|
@@ -12,4 +12,4 @@ export interface OptionSchema {
|
|
|
12
12
|
* This object provides metadata for validation and help text in the CLI loop.
|
|
13
13
|
* It is derived from the main TextGenerationOptions interface to ensure consistency.
|
|
14
14
|
*/
|
|
15
|
-
export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria">, OptionSchema>;
|
|
15
|
+
export declare const textGenerationOptionsSchema: Record<keyof Omit<TextGenerationOptions, "prompt" | "input" | "schema" | "tools" | "context" | "conversationHistory" | "conversationMessages" | "conversationMemoryConfig" | "originalPrompt" | "middleware" | "expectedOutcome" | "evaluationCriteria" | "region">, OptionSchema>;
|
package/dist/core/factory.d.ts
CHANGED
|
@@ -19,9 +19,11 @@ export declare class AIProviderFactory {
|
|
|
19
19
|
* @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
|
|
20
20
|
* @param modelName - Optional model name override
|
|
21
21
|
* @param enableMCP - Optional flag to enable MCP integration (default: true)
|
|
22
|
+
* @param sdk - SDK instance
|
|
23
|
+
* @param region - Optional region override for cloud providers
|
|
22
24
|
* @returns AIProvider instance
|
|
23
25
|
*/
|
|
24
|
-
static createProvider(providerName: string, modelName?: string | null, enableMCP?: boolean, sdk?: UnknownRecord): Promise<AIProvider>;
|
|
26
|
+
static createProvider(providerName: string, modelName?: string | null, enableMCP?: boolean, sdk?: UnknownRecord, region?: string): Promise<AIProvider>;
|
|
25
27
|
/**
|
|
26
28
|
* Create a provider instance with specific provider enum and model
|
|
27
29
|
* @param provider - Provider enum value
|
package/dist/core/factory.js
CHANGED
|
@@ -52,9 +52,11 @@ export class AIProviderFactory {
|
|
|
52
52
|
* @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
|
|
53
53
|
* @param modelName - Optional model name override
|
|
54
54
|
* @param enableMCP - Optional flag to enable MCP integration (default: true)
|
|
55
|
+
* @param sdk - SDK instance
|
|
56
|
+
* @param region - Optional region override for cloud providers
|
|
55
57
|
* @returns AIProvider instance
|
|
56
58
|
*/
|
|
57
|
-
static async createProvider(providerName, modelName, enableMCP = true, sdk) {
|
|
59
|
+
static async createProvider(providerName, modelName, enableMCP = true, sdk, region) {
|
|
58
60
|
const functionTag = "AIProviderFactory.createProvider";
|
|
59
61
|
// Providers are registered via ProviderFactory.initialize() on first use
|
|
60
62
|
logger.debug(`[${functionTag}] Provider creation started`, {
|
|
@@ -198,8 +200,8 @@ export class AIProviderFactory {
|
|
|
198
200
|
resolvedModelName: resolvedModelName || "not resolved",
|
|
199
201
|
finalModelName: finalModelName || "using provider default",
|
|
200
202
|
});
|
|
201
|
-
// Create provider with enhanced SDK
|
|
202
|
-
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk);
|
|
203
|
+
// Create provider with enhanced SDK and region support
|
|
204
|
+
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk, region);
|
|
203
205
|
// Summary logging in format expected by debugging tools
|
|
204
206
|
logger.debug(`[AIProviderFactory] Provider creation completed { providerName: '${normalizedName}', modelName: '${finalModelName}' }`);
|
|
205
207
|
logger.debug(`[AIProviderFactory] Resolved model: ${finalModelName}`);
|
|
@@ -4,8 +4,8 @@ import type { UnknownRecord } from "../types/common.js";
|
|
|
4
4
|
* Provider constructor interface - supports both sync constructors and async factory functions
|
|
5
5
|
*/
|
|
6
6
|
type ProviderConstructor = {
|
|
7
|
-
new (modelName?: string, providerName?: string, sdk?: UnknownRecord): AIProvider;
|
|
8
|
-
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord) => Promise<AIProvider>);
|
|
7
|
+
new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string): AIProvider;
|
|
8
|
+
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string) => Promise<AIProvider>);
|
|
9
9
|
/**
|
|
10
10
|
* Provider registration entry
|
|
11
11
|
*/
|
|
@@ -30,7 +30,7 @@ export declare class ProviderFactory {
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a provider instance
|
|
32
32
|
*/
|
|
33
|
-
static createProvider(providerName: AIProviderName | string, modelName?: string, sdk?: UnknownRecord): Promise<AIProvider>;
|
|
33
|
+
static createProvider(providerName: AIProviderName | string, modelName?: string, sdk?: UnknownRecord, region?: string): Promise<AIProvider>;
|
|
34
34
|
/**
|
|
35
35
|
* Check if a provider is registered
|
|
36
36
|
*/
|
|
@@ -28,7 +28,7 @@ export class ProviderFactory {
|
|
|
28
28
|
/**
|
|
29
29
|
* Create a provider instance
|
|
30
30
|
*/
|
|
31
|
-
static async createProvider(providerName, modelName, sdk) {
|
|
31
|
+
static async createProvider(providerName, modelName, sdk, region) {
|
|
32
32
|
// Note: Providers are registered explicitly by ProviderRegistry to avoid circular dependencies
|
|
33
33
|
const normalizedName = providerName.toLowerCase();
|
|
34
34
|
const registration = this.providers.get(normalizedName);
|
|
@@ -54,7 +54,7 @@ export class ProviderFactory {
|
|
|
54
54
|
}
|
|
55
55
|
let result;
|
|
56
56
|
try {
|
|
57
|
-
const factoryResult = registration.constructor(model, providerName, sdk);
|
|
57
|
+
const factoryResult = registration.constructor(model, providerName, sdk, region);
|
|
58
58
|
// Handle both sync and async results
|
|
59
59
|
result =
|
|
60
60
|
factoryResult instanceof Promise
|
|
@@ -66,7 +66,7 @@ export class ProviderFactory {
|
|
|
66
66
|
registration.constructor.prototype.constructor ===
|
|
67
67
|
registration.constructor) {
|
|
68
68
|
try {
|
|
69
|
-
result = new registration.constructor(model, providerName, sdk);
|
|
69
|
+
result = new registration.constructor(model, providerName, sdk, region);
|
|
70
70
|
}
|
|
71
71
|
catch (constructorError) {
|
|
72
72
|
throw new Error(`Both factory function and constructor failed. Factory error: ${factoryError}. Constructor error: ${constructorError}`);
|
|
@@ -39,9 +39,9 @@ export class ProviderRegistry {
|
|
|
39
39
|
return new AnthropicProvider(modelName, sdk);
|
|
40
40
|
}, "claude-3-5-sonnet-20241022", ["claude", "anthropic"]);
|
|
41
41
|
// Register Amazon Bedrock provider
|
|
42
|
-
ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk) => {
|
|
42
|
+
ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk, region) => {
|
|
43
43
|
const { AmazonBedrockProvider } = await import("../providers/amazonBedrock.js");
|
|
44
|
-
return new AmazonBedrockProvider(modelName, sdk);
|
|
44
|
+
return new AmazonBedrockProvider(modelName, sdk, region);
|
|
45
45
|
}, undefined, // Let provider read BEDROCK_MODEL from .env
|
|
46
46
|
["bedrock", "aws"]);
|
|
47
47
|
// Register Azure OpenAI provider
|
|
@@ -54,9 +54,9 @@ export class ProviderRegistry {
|
|
|
54
54
|
process.env.AZURE_OPENAI_DEPLOYMENT_ID ||
|
|
55
55
|
"gpt-4o-mini", ["azure", "azureOpenai"]);
|
|
56
56
|
// Register Google Vertex AI provider
|
|
57
|
-
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName, providerName, sdk) => {
|
|
57
|
+
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName, providerName, sdk, region) => {
|
|
58
58
|
const { GoogleVertexProvider } = await import("../providers/googleVertex.js");
|
|
59
|
-
return new GoogleVertexProvider(modelName, providerName, sdk);
|
|
59
|
+
return new GoogleVertexProvider(modelName, providerName, sdk, region);
|
|
60
60
|
}, "claude-sonnet-4@20250514", ["vertex", "googleVertex"]);
|
|
61
61
|
// Register Hugging Face provider (Unified Router implementation)
|
|
62
62
|
ProviderFactory.registerProvider(AIProviderName.HUGGINGFACE, async (modelName) => {
|
|
@@ -85,9 +85,9 @@ export class ProviderRegistry {
|
|
|
85
85
|
}, process.env.OPENAI_COMPATIBLE_MODEL || undefined, // Enable auto-discovery when no model specified
|
|
86
86
|
["openai-compatible", "openrouter", "vllm", "compatible"]);
|
|
87
87
|
// Register Amazon SageMaker provider
|
|
88
|
-
ProviderFactory.registerProvider(AIProviderName.SAGEMAKER, async (modelName, _providerName, _sdk) => {
|
|
88
|
+
ProviderFactory.registerProvider(AIProviderName.SAGEMAKER, async (modelName, _providerName, _sdk, region) => {
|
|
89
89
|
const { AmazonSageMakerProvider } = await import("../providers/amazonSagemaker.js");
|
|
90
|
-
return new AmazonSageMakerProvider(modelName);
|
|
90
|
+
return new AmazonSageMakerProvider(modelName, region);
|
|
91
91
|
}, process.env.SAGEMAKER_MODEL || "sagemaker-model", ["sagemaker", "aws-sagemaker"]);
|
|
92
92
|
logger.debug("All providers registered successfully");
|
|
93
93
|
this.registered = true;
|
|
@@ -19,9 +19,11 @@ export declare class AIProviderFactory {
|
|
|
19
19
|
* @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
|
|
20
20
|
* @param modelName - Optional model name override
|
|
21
21
|
* @param enableMCP - Optional flag to enable MCP integration (default: true)
|
|
22
|
+
* @param sdk - SDK instance
|
|
23
|
+
* @param region - Optional region override for cloud providers
|
|
22
24
|
* @returns AIProvider instance
|
|
23
25
|
*/
|
|
24
|
-
static createProvider(providerName: string, modelName?: string | null, enableMCP?: boolean, sdk?: UnknownRecord): Promise<AIProvider>;
|
|
26
|
+
static createProvider(providerName: string, modelName?: string | null, enableMCP?: boolean, sdk?: UnknownRecord, region?: string): Promise<AIProvider>;
|
|
25
27
|
/**
|
|
26
28
|
* Create a provider instance with specific provider enum and model
|
|
27
29
|
* @param provider - Provider enum value
|
package/dist/lib/core/factory.js
CHANGED
|
@@ -52,9 +52,11 @@ export class AIProviderFactory {
|
|
|
52
52
|
* @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
|
|
53
53
|
* @param modelName - Optional model name override
|
|
54
54
|
* @param enableMCP - Optional flag to enable MCP integration (default: true)
|
|
55
|
+
* @param sdk - SDK instance
|
|
56
|
+
* @param region - Optional region override for cloud providers
|
|
55
57
|
* @returns AIProvider instance
|
|
56
58
|
*/
|
|
57
|
-
static async createProvider(providerName, modelName, enableMCP = true, sdk) {
|
|
59
|
+
static async createProvider(providerName, modelName, enableMCP = true, sdk, region) {
|
|
58
60
|
const functionTag = "AIProviderFactory.createProvider";
|
|
59
61
|
// Providers are registered via ProviderFactory.initialize() on first use
|
|
60
62
|
logger.debug(`[${functionTag}] Provider creation started`, {
|
|
@@ -198,8 +200,8 @@ export class AIProviderFactory {
|
|
|
198
200
|
resolvedModelName: resolvedModelName || "not resolved",
|
|
199
201
|
finalModelName: finalModelName || "using provider default",
|
|
200
202
|
});
|
|
201
|
-
// Create provider with enhanced SDK
|
|
202
|
-
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk);
|
|
203
|
+
// Create provider with enhanced SDK and region support
|
|
204
|
+
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk, region);
|
|
203
205
|
// Summary logging in format expected by debugging tools
|
|
204
206
|
logger.debug(`[AIProviderFactory] Provider creation completed { providerName: '${normalizedName}', modelName: '${finalModelName}' }`);
|
|
205
207
|
logger.debug(`[AIProviderFactory] Resolved model: ${finalModelName}`);
|
|
@@ -4,8 +4,8 @@ import type { UnknownRecord } from "../types/common.js";
|
|
|
4
4
|
* Provider constructor interface - supports both sync constructors and async factory functions
|
|
5
5
|
*/
|
|
6
6
|
type ProviderConstructor = {
|
|
7
|
-
new (modelName?: string, providerName?: string, sdk?: UnknownRecord): AIProvider;
|
|
8
|
-
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord) => Promise<AIProvider>);
|
|
7
|
+
new (modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string): AIProvider;
|
|
8
|
+
} | ((modelName?: string, providerName?: string, sdk?: UnknownRecord, region?: string) => Promise<AIProvider>);
|
|
9
9
|
/**
|
|
10
10
|
* Provider registration entry
|
|
11
11
|
*/
|
|
@@ -30,7 +30,7 @@ export declare class ProviderFactory {
|
|
|
30
30
|
/**
|
|
31
31
|
* Create a provider instance
|
|
32
32
|
*/
|
|
33
|
-
static createProvider(providerName: AIProviderName | string, modelName?: string, sdk?: UnknownRecord): Promise<AIProvider>;
|
|
33
|
+
static createProvider(providerName: AIProviderName | string, modelName?: string, sdk?: UnknownRecord, region?: string): Promise<AIProvider>;
|
|
34
34
|
/**
|
|
35
35
|
* Check if a provider is registered
|
|
36
36
|
*/
|
|
@@ -28,7 +28,7 @@ export class ProviderFactory {
|
|
|
28
28
|
/**
|
|
29
29
|
* Create a provider instance
|
|
30
30
|
*/
|
|
31
|
-
static async createProvider(providerName, modelName, sdk) {
|
|
31
|
+
static async createProvider(providerName, modelName, sdk, region) {
|
|
32
32
|
// Note: Providers are registered explicitly by ProviderRegistry to avoid circular dependencies
|
|
33
33
|
const normalizedName = providerName.toLowerCase();
|
|
34
34
|
const registration = this.providers.get(normalizedName);
|
|
@@ -54,7 +54,7 @@ export class ProviderFactory {
|
|
|
54
54
|
}
|
|
55
55
|
let result;
|
|
56
56
|
try {
|
|
57
|
-
const factoryResult = registration.constructor(model, providerName, sdk);
|
|
57
|
+
const factoryResult = registration.constructor(model, providerName, sdk, region);
|
|
58
58
|
// Handle both sync and async results
|
|
59
59
|
result =
|
|
60
60
|
factoryResult instanceof Promise
|
|
@@ -66,7 +66,7 @@ export class ProviderFactory {
|
|
|
66
66
|
registration.constructor.prototype.constructor ===
|
|
67
67
|
registration.constructor) {
|
|
68
68
|
try {
|
|
69
|
-
result = new registration.constructor(model, providerName, sdk);
|
|
69
|
+
result = new registration.constructor(model, providerName, sdk, region);
|
|
70
70
|
}
|
|
71
71
|
catch (constructorError) {
|
|
72
72
|
throw new Error(`Both factory function and constructor failed. Factory error: ${factoryError}. Constructor error: ${constructorError}`);
|
|
@@ -39,9 +39,9 @@ export class ProviderRegistry {
|
|
|
39
39
|
return new AnthropicProvider(modelName, sdk);
|
|
40
40
|
}, "claude-3-5-sonnet-20241022", ["claude", "anthropic"]);
|
|
41
41
|
// Register Amazon Bedrock provider
|
|
42
|
-
ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk) => {
|
|
42
|
+
ProviderFactory.registerProvider(AIProviderName.BEDROCK, async (modelName, _providerName, sdk, region) => {
|
|
43
43
|
const { AmazonBedrockProvider } = await import("../providers/amazonBedrock.js");
|
|
44
|
-
return new AmazonBedrockProvider(modelName, sdk);
|
|
44
|
+
return new AmazonBedrockProvider(modelName, sdk, region);
|
|
45
45
|
}, undefined, // Let provider read BEDROCK_MODEL from .env
|
|
46
46
|
["bedrock", "aws"]);
|
|
47
47
|
// Register Azure OpenAI provider
|
|
@@ -54,9 +54,9 @@ export class ProviderRegistry {
|
|
|
54
54
|
process.env.AZURE_OPENAI_DEPLOYMENT_ID ||
|
|
55
55
|
"gpt-4o-mini", ["azure", "azureOpenai"]);
|
|
56
56
|
// Register Google Vertex AI provider
|
|
57
|
-
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName, providerName, sdk) => {
|
|
57
|
+
ProviderFactory.registerProvider(AIProviderName.VERTEX, async (modelName, providerName, sdk, region) => {
|
|
58
58
|
const { GoogleVertexProvider } = await import("../providers/googleVertex.js");
|
|
59
|
-
return new GoogleVertexProvider(modelName, providerName, sdk);
|
|
59
|
+
return new GoogleVertexProvider(modelName, providerName, sdk, region);
|
|
60
60
|
}, "claude-sonnet-4@20250514", ["vertex", "googleVertex"]);
|
|
61
61
|
// Register Hugging Face provider (Unified Router implementation)
|
|
62
62
|
ProviderFactory.registerProvider(AIProviderName.HUGGINGFACE, async (modelName) => {
|
|
@@ -85,9 +85,9 @@ export class ProviderRegistry {
|
|
|
85
85
|
}, process.env.OPENAI_COMPATIBLE_MODEL || undefined, // Enable auto-discovery when no model specified
|
|
86
86
|
["openai-compatible", "openrouter", "vllm", "compatible"]);
|
|
87
87
|
// Register Amazon SageMaker provider
|
|
88
|
-
ProviderFactory.registerProvider(AIProviderName.SAGEMAKER, async (modelName, _providerName, _sdk) => {
|
|
88
|
+
ProviderFactory.registerProvider(AIProviderName.SAGEMAKER, async (modelName, _providerName, _sdk, region) => {
|
|
89
89
|
const { AmazonSageMakerProvider } = await import("../providers/amazonSagemaker.js");
|
|
90
|
-
return new AmazonSageMakerProvider(modelName);
|
|
90
|
+
return new AmazonSageMakerProvider(modelName, region);
|
|
91
91
|
}, process.env.SAGEMAKER_MODEL || "sagemaker-model", ["sagemaker", "aws-sagemaker"]);
|
|
92
92
|
logger.debug("All providers registered successfully");
|
|
93
93
|
this.registered = true;
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -1082,6 +1082,7 @@ export class NeuroLink {
|
|
|
1082
1082
|
evaluationDomain: options.evaluationDomain,
|
|
1083
1083
|
toolUsageContext: options.toolUsageContext,
|
|
1084
1084
|
input: options.input, // This includes text, images, and content arrays
|
|
1085
|
+
region: options.region,
|
|
1085
1086
|
};
|
|
1086
1087
|
// Apply factory enhancement using centralized utilities
|
|
1087
1088
|
const textOptions = enhanceTextGenerationOptions(baseOptions, factoryResult);
|
|
@@ -1410,7 +1411,8 @@ export class NeuroLink {
|
|
|
1410
1411
|
const conversationMessages = await getConversationMessages(this.conversationMemory, options);
|
|
1411
1412
|
// Create provider and generate
|
|
1412
1413
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1413
|
-
this
|
|
1414
|
+
this, // Pass SDK instance
|
|
1415
|
+
options.region);
|
|
1414
1416
|
// ADD: Emit connection events for all providers (Bedrock-compatible)
|
|
1415
1417
|
this.emitter.emit("connected");
|
|
1416
1418
|
this.emitter.emit("message", `${providerName} provider initialized successfully`);
|
|
@@ -1520,7 +1522,8 @@ export class NeuroLink {
|
|
|
1520
1522
|
// Get conversation messages for context
|
|
1521
1523
|
const conversationMessages = await getConversationMessages(this.conversationMemory, options);
|
|
1522
1524
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1523
|
-
this
|
|
1525
|
+
this, // Pass SDK instance
|
|
1526
|
+
options.region);
|
|
1524
1527
|
// ADD: Emit connection events for successful provider creation (Bedrock-compatible)
|
|
1525
1528
|
this.emitter.emit("connected");
|
|
1526
1529
|
this.emitter.emit("message", `${providerName} provider initialized successfully`);
|
|
@@ -1897,7 +1900,8 @@ export class NeuroLink {
|
|
|
1897
1900
|
// Simplified placeholder - in the actual implementation this would contain the complex MCP stream logic
|
|
1898
1901
|
const providerName = await getBestProvider(options.provider);
|
|
1899
1902
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1900
|
-
this
|
|
1903
|
+
this, // Pass SDK instance
|
|
1904
|
+
options.region);
|
|
1901
1905
|
// Enable tool execution for the provider using BaseProvider method
|
|
1902
1906
|
provider.setupToolExecutor({
|
|
1903
1907
|
customTools: this.getCustomTools(),
|
|
@@ -6,7 +6,8 @@ import type { NeuroLink } from "../neurolink.js";
|
|
|
6
6
|
export declare class AmazonBedrockProvider extends BaseProvider {
|
|
7
7
|
private bedrockClient;
|
|
8
8
|
private conversationHistory;
|
|
9
|
-
|
|
9
|
+
private region;
|
|
10
|
+
constructor(modelName?: string, neurolink?: NeuroLink, region?: string);
|
|
10
11
|
/**
|
|
11
12
|
* Perform initial health check to catch credential/connectivity issues early
|
|
12
13
|
* This prevents the health check failure we saw in production logs
|
|
@@ -7,8 +7,10 @@ import { convertZodToJsonSchema } from "../utils/schemaConversion.js";
|
|
|
7
7
|
export class AmazonBedrockProvider extends BaseProvider {
|
|
8
8
|
bedrockClient;
|
|
9
9
|
conversationHistory = [];
|
|
10
|
-
|
|
10
|
+
region;
|
|
11
|
+
constructor(modelName, neurolink, region) {
|
|
11
12
|
super(modelName, "bedrock", neurolink);
|
|
13
|
+
this.region = region || process.env.AWS_REGION || "us-east-1";
|
|
12
14
|
logger.debug("[AmazonBedrockProvider] Starting constructor with extensive logging for debugging");
|
|
13
15
|
// Log environment variables for debugging
|
|
14
16
|
logger.debug(`[AmazonBedrockProvider] Environment check: AWS_REGION=${process.env.AWS_REGION || "undefined"}, AWS_ACCESS_KEY_ID=${process.env.AWS_ACCESS_KEY_ID ? "SET" : "undefined"}, AWS_SECRET_ACCESS_KEY=${process.env.AWS_SECRET_ACCESS_KEY ? "SET" : "undefined"}`);
|
|
@@ -17,14 +19,14 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
17
19
|
// Absolutely no proxy interference - let AWS SDK handle everything natively
|
|
18
20
|
logger.debug("[AmazonBedrockProvider] Creating BedrockRuntimeClient with clean configuration");
|
|
19
21
|
this.bedrockClient = new BedrockRuntimeClient({
|
|
20
|
-
region:
|
|
22
|
+
region: this.region,
|
|
21
23
|
// Clean configuration - AWS SDK will handle credentials via:
|
|
22
24
|
// 1. IAM roles (preferred in production)
|
|
23
25
|
// 2. Environment variables
|
|
24
26
|
// 3. AWS config files
|
|
25
27
|
// 4. Instance metadata
|
|
26
28
|
});
|
|
27
|
-
logger.debug(`[AmazonBedrockProvider] Successfully created BedrockRuntimeClient with model: ${this.modelName}, region: ${
|
|
29
|
+
logger.debug(`[AmazonBedrockProvider] Successfully created BedrockRuntimeClient with model: ${this.modelName}, region: ${this.region}`);
|
|
28
30
|
// Immediate health check to catch credential issues early
|
|
29
31
|
this.performInitialHealthCheck();
|
|
30
32
|
}
|
|
@@ -39,7 +41,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
39
41
|
*/
|
|
40
42
|
async performInitialHealthCheck() {
|
|
41
43
|
const bedrockClient = new BedrockClient({
|
|
42
|
-
region:
|
|
44
|
+
region: this.region,
|
|
43
45
|
});
|
|
44
46
|
try {
|
|
45
47
|
logger.debug("[AmazonBedrockProvider] Starting initial health check to validate credentials and connectivity");
|
|
@@ -16,7 +16,7 @@ export declare class AmazonSageMakerProvider extends BaseProvider {
|
|
|
16
16
|
private sagemakerModel;
|
|
17
17
|
private sagemakerConfig;
|
|
18
18
|
private modelConfig;
|
|
19
|
-
constructor(modelName?: string, endpointName?: string);
|
|
19
|
+
constructor(modelName?: string, endpointName?: string, region?: string);
|
|
20
20
|
protected getProviderName(): AIProviderName;
|
|
21
21
|
protected getDefaultModel(): string;
|
|
22
22
|
protected getAISDKModel(): LanguageModelV1;
|
|
@@ -17,11 +17,11 @@ export class AmazonSageMakerProvider extends BaseProvider {
|
|
|
17
17
|
sagemakerModel;
|
|
18
18
|
sagemakerConfig;
|
|
19
19
|
modelConfig;
|
|
20
|
-
constructor(modelName, endpointName) {
|
|
20
|
+
constructor(modelName, endpointName, region) {
|
|
21
21
|
super(modelName, "sagemaker");
|
|
22
22
|
try {
|
|
23
23
|
// Load and validate configuration
|
|
24
|
-
this.sagemakerConfig = getSageMakerConfig();
|
|
24
|
+
this.sagemakerConfig = getSageMakerConfig(region);
|
|
25
25
|
this.modelConfig = getSageMakerModelConfig(endpointName || getDefaultSageMakerEndpoint());
|
|
26
26
|
// Create the proper LanguageModel (v2) implementation
|
|
27
27
|
this.sagemakerModel = new SageMakerLanguageModel(this.modelName, this.sagemakerConfig, this.modelConfig);
|
|
@@ -25,7 +25,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
25
25
|
private static readonly MAX_CACHE_SIZE;
|
|
26
26
|
private static maxTokensCache;
|
|
27
27
|
private static maxTokensCacheTime;
|
|
28
|
-
constructor(modelName?: string, _providerName?: string, sdk?: unknown);
|
|
28
|
+
constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string);
|
|
29
29
|
protected getProviderName(): AIProviderName;
|
|
30
30
|
protected getDefaultModel(): string;
|
|
31
31
|
/**
|
|
@@ -46,10 +46,10 @@ const hasGoogleCredentials = () => {
|
|
|
46
46
|
process.env.GOOGLE_AUTH_PRIVATE_KEY));
|
|
47
47
|
};
|
|
48
48
|
// Enhanced Vertex settings creation with authentication fallback and proxy support
|
|
49
|
-
const createVertexSettings = async () => {
|
|
49
|
+
const createVertexSettings = async (region) => {
|
|
50
50
|
const baseSettings = {
|
|
51
51
|
project: getVertexProjectId(),
|
|
52
|
-
location: getVertexLocation(),
|
|
52
|
+
location: region || getVertexLocation(),
|
|
53
53
|
fetch: createProxyFetch(),
|
|
54
54
|
};
|
|
55
55
|
// 🎯 OPTION 2: Create credentials file from environment variables at runtime
|
|
@@ -157,8 +157,7 @@ const createVertexSettings = async () => {
|
|
|
157
157
|
private_key: requiredEnvVars.private_key.replace(/\\n/g, "\n"),
|
|
158
158
|
client_email: requiredEnvVars.client_email,
|
|
159
159
|
client_id: requiredEnvVars.client_id || "",
|
|
160
|
-
auth_uri: requiredEnvVars.auth_uri ||
|
|
161
|
-
"https://accounts.google.com/o/oauth2/auth",
|
|
160
|
+
auth_uri: requiredEnvVars.auth_uri || "https://accounts.google.com/o/oauth2/auth",
|
|
162
161
|
token_uri: requiredEnvVars.token_uri || "https://oauth2.googleapis.com/token",
|
|
163
162
|
auth_provider_x509_cert_url: requiredEnvVars.auth_provider_x509_cert_url ||
|
|
164
163
|
"https://www.googleapis.com/oauth2/v1/certs",
|
|
@@ -199,8 +198,8 @@ const createVertexSettings = async () => {
|
|
|
199
198
|
return baseSettings;
|
|
200
199
|
};
|
|
201
200
|
// Create Anthropic-specific Vertex settings with the same authentication and proxy support
|
|
202
|
-
const createVertexAnthropicSettings = async () => {
|
|
203
|
-
const baseVertexSettings = await createVertexSettings();
|
|
201
|
+
const createVertexAnthropicSettings = async (region) => {
|
|
202
|
+
const baseVertexSettings = await createVertexSettings(region);
|
|
204
203
|
// GoogleVertexAnthropicProviderSettings extends GoogleVertexProviderSettings
|
|
205
204
|
// so we can use the same settings with proper typing
|
|
206
205
|
return {
|
|
@@ -241,7 +240,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
241
240
|
// Memory-managed cache for maxTokens handling decisions to optimize streaming performance
|
|
242
241
|
static maxTokensCache = new Map();
|
|
243
242
|
static maxTokensCacheTime = 0;
|
|
244
|
-
constructor(modelName, _providerName, sdk) {
|
|
243
|
+
constructor(modelName, _providerName, sdk, region) {
|
|
245
244
|
super(modelName, "vertex", sdk);
|
|
246
245
|
// Validate Google Cloud credentials - now using consolidated utility
|
|
247
246
|
if (!hasGoogleCredentials()) {
|
|
@@ -249,7 +248,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
249
248
|
}
|
|
250
249
|
// Initialize Google Cloud configuration
|
|
251
250
|
this.projectId = getVertexProjectId();
|
|
252
|
-
this.location = getVertexLocation();
|
|
251
|
+
this.location = region || getVertexLocation();
|
|
253
252
|
logger.debug("Google Vertex AI BaseProvider v2 initialized", {
|
|
254
253
|
modelName: this.modelName,
|
|
255
254
|
projectId: this.projectId,
|
|
@@ -360,7 +359,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
360
359
|
message: "Starting Vertex settings creation with network configuration analysis",
|
|
361
360
|
});
|
|
362
361
|
try {
|
|
363
|
-
const vertexSettings = await createVertexSettings();
|
|
362
|
+
const vertexSettings = await createVertexSettings(this.location);
|
|
364
363
|
const vertexSettingsEndTime = process.hrtime.bigint();
|
|
365
364
|
const vertexSettingsDurationNs = vertexSettingsEndTime - vertexSettingsStartTime;
|
|
366
365
|
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V009_VERTEX_SETTINGS_SUCCESS`, {
|
|
@@ -920,7 +919,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
920
919
|
projectId: projectValidation.projectId,
|
|
921
920
|
region: projectValidation.region,
|
|
922
921
|
});
|
|
923
|
-
const vertexAnthropicSettings = await createVertexAnthropicSettings();
|
|
922
|
+
const vertexAnthropicSettings = await createVertexAnthropicSettings(this.location);
|
|
924
923
|
// 7. Settings Validation
|
|
925
924
|
if (!vertexAnthropicSettings.project ||
|
|
926
925
|
!vertexAnthropicSettings.location) {
|
|
@@ -8,15 +8,17 @@ import type { SageMakerConfig, SageMakerModelConfig } from "./types.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Load and validate SageMaker configuration from environment variables
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* 1.
|
|
13
|
-
* 2.
|
|
14
|
-
* 3.
|
|
11
|
+
* Region priority:
|
|
12
|
+
* 1. region parameter (highest priority)
|
|
13
|
+
* 2. SAGEMAKER_REGION environment variable
|
|
14
|
+
* 3. AWS_REGION environment variable
|
|
15
|
+
* 4. Default value "us-east-1" (lowest priority)
|
|
15
16
|
*
|
|
17
|
+
* @param region - Optional region parameter override
|
|
16
18
|
* @returns Validated SageMaker configuration
|
|
17
19
|
* @throws {Error} When required configuration is missing or invalid
|
|
18
20
|
*/
|
|
19
|
-
export declare function getSageMakerConfig(): SageMakerConfig;
|
|
21
|
+
export declare function getSageMakerConfig(region?: string): SageMakerConfig;
|
|
20
22
|
/**
|
|
21
23
|
* Load and validate SageMaker model configuration
|
|
22
24
|
*
|
|
@@ -45,21 +45,26 @@ const modelConfigCache = new Map();
|
|
|
45
45
|
/**
|
|
46
46
|
* Load and validate SageMaker configuration from environment variables
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* 1.
|
|
50
|
-
* 2.
|
|
51
|
-
* 3.
|
|
48
|
+
* Region priority:
|
|
49
|
+
* 1. region parameter (highest priority)
|
|
50
|
+
* 2. SAGEMAKER_REGION environment variable
|
|
51
|
+
* 3. AWS_REGION environment variable
|
|
52
|
+
* 4. Default value "us-east-1" (lowest priority)
|
|
52
53
|
*
|
|
54
|
+
* @param region - Optional region parameter override
|
|
53
55
|
* @returns Validated SageMaker configuration
|
|
54
56
|
* @throws {Error} When required configuration is missing or invalid
|
|
55
57
|
*/
|
|
56
|
-
export function getSageMakerConfig() {
|
|
58
|
+
export function getSageMakerConfig(region) {
|
|
57
59
|
// Return cached config if available
|
|
58
60
|
if (configCache) {
|
|
59
61
|
return configCache;
|
|
60
62
|
}
|
|
61
63
|
const config = {
|
|
62
|
-
region:
|
|
64
|
+
region: region ||
|
|
65
|
+
process.env.SAGEMAKER_REGION ||
|
|
66
|
+
process.env.AWS_REGION ||
|
|
67
|
+
"us-east-1",
|
|
63
68
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
|
|
64
69
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
|
|
65
70
|
sessionToken: process.env.AWS_SESSION_TOKEN,
|
|
@@ -22,6 +22,7 @@ export type GenerateOptions = {
|
|
|
22
22
|
};
|
|
23
23
|
provider?: AIProviderName | string;
|
|
24
24
|
model?: string;
|
|
25
|
+
region?: string;
|
|
25
26
|
temperature?: number;
|
|
26
27
|
maxTokens?: number;
|
|
27
28
|
systemPrompt?: string;
|
|
@@ -143,6 +144,7 @@ export type TextGenerationOptions = {
|
|
|
143
144
|
};
|
|
144
145
|
provider?: AIProviderName;
|
|
145
146
|
model?: string;
|
|
147
|
+
region?: string;
|
|
146
148
|
temperature?: number;
|
|
147
149
|
maxTokens?: number;
|
|
148
150
|
systemPrompt?: string;
|
package/dist/neurolink.js
CHANGED
|
@@ -1082,6 +1082,7 @@ export class NeuroLink {
|
|
|
1082
1082
|
evaluationDomain: options.evaluationDomain,
|
|
1083
1083
|
toolUsageContext: options.toolUsageContext,
|
|
1084
1084
|
input: options.input, // This includes text, images, and content arrays
|
|
1085
|
+
region: options.region,
|
|
1085
1086
|
};
|
|
1086
1087
|
// Apply factory enhancement using centralized utilities
|
|
1087
1088
|
const textOptions = enhanceTextGenerationOptions(baseOptions, factoryResult);
|
|
@@ -1410,7 +1411,8 @@ export class NeuroLink {
|
|
|
1410
1411
|
const conversationMessages = await getConversationMessages(this.conversationMemory, options);
|
|
1411
1412
|
// Create provider and generate
|
|
1412
1413
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1413
|
-
this
|
|
1414
|
+
this, // Pass SDK instance
|
|
1415
|
+
options.region);
|
|
1414
1416
|
// ADD: Emit connection events for all providers (Bedrock-compatible)
|
|
1415
1417
|
this.emitter.emit("connected");
|
|
1416
1418
|
this.emitter.emit("message", `${providerName} provider initialized successfully`);
|
|
@@ -1520,7 +1522,8 @@ export class NeuroLink {
|
|
|
1520
1522
|
// Get conversation messages for context
|
|
1521
1523
|
const conversationMessages = await getConversationMessages(this.conversationMemory, options);
|
|
1522
1524
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1523
|
-
this
|
|
1525
|
+
this, // Pass SDK instance
|
|
1526
|
+
options.region);
|
|
1524
1527
|
// ADD: Emit connection events for successful provider creation (Bedrock-compatible)
|
|
1525
1528
|
this.emitter.emit("connected");
|
|
1526
1529
|
this.emitter.emit("message", `${providerName} provider initialized successfully`);
|
|
@@ -1897,7 +1900,8 @@ export class NeuroLink {
|
|
|
1897
1900
|
// Simplified placeholder - in the actual implementation this would contain the complex MCP stream logic
|
|
1898
1901
|
const providerName = await getBestProvider(options.provider);
|
|
1899
1902
|
const provider = await AIProviderFactory.createProvider(providerName, options.model, !options.disableTools, // Pass disableTools as inverse of enableMCP
|
|
1900
|
-
this
|
|
1903
|
+
this, // Pass SDK instance
|
|
1904
|
+
options.region);
|
|
1901
1905
|
// Enable tool execution for the provider using BaseProvider method
|
|
1902
1906
|
provider.setupToolExecutor({
|
|
1903
1907
|
customTools: this.getCustomTools(),
|
|
@@ -6,7 +6,8 @@ import type { NeuroLink } from "../neurolink.js";
|
|
|
6
6
|
export declare class AmazonBedrockProvider extends BaseProvider {
|
|
7
7
|
private bedrockClient;
|
|
8
8
|
private conversationHistory;
|
|
9
|
-
|
|
9
|
+
private region;
|
|
10
|
+
constructor(modelName?: string, neurolink?: NeuroLink, region?: string);
|
|
10
11
|
/**
|
|
11
12
|
* Perform initial health check to catch credential/connectivity issues early
|
|
12
13
|
* This prevents the health check failure we saw in production logs
|
|
@@ -7,8 +7,10 @@ import { convertZodToJsonSchema } from "../utils/schemaConversion.js";
|
|
|
7
7
|
export class AmazonBedrockProvider extends BaseProvider {
|
|
8
8
|
bedrockClient;
|
|
9
9
|
conversationHistory = [];
|
|
10
|
-
|
|
10
|
+
region;
|
|
11
|
+
constructor(modelName, neurolink, region) {
|
|
11
12
|
super(modelName, "bedrock", neurolink);
|
|
13
|
+
this.region = region || process.env.AWS_REGION || "us-east-1";
|
|
12
14
|
logger.debug("[AmazonBedrockProvider] Starting constructor with extensive logging for debugging");
|
|
13
15
|
// Log environment variables for debugging
|
|
14
16
|
logger.debug(`[AmazonBedrockProvider] Environment check: AWS_REGION=${process.env.AWS_REGION || "undefined"}, AWS_ACCESS_KEY_ID=${process.env.AWS_ACCESS_KEY_ID ? "SET" : "undefined"}, AWS_SECRET_ACCESS_KEY=${process.env.AWS_SECRET_ACCESS_KEY ? "SET" : "undefined"}`);
|
|
@@ -17,14 +19,14 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
17
19
|
// Absolutely no proxy interference - let AWS SDK handle everything natively
|
|
18
20
|
logger.debug("[AmazonBedrockProvider] Creating BedrockRuntimeClient with clean configuration");
|
|
19
21
|
this.bedrockClient = new BedrockRuntimeClient({
|
|
20
|
-
region:
|
|
22
|
+
region: this.region,
|
|
21
23
|
// Clean configuration - AWS SDK will handle credentials via:
|
|
22
24
|
// 1. IAM roles (preferred in production)
|
|
23
25
|
// 2. Environment variables
|
|
24
26
|
// 3. AWS config files
|
|
25
27
|
// 4. Instance metadata
|
|
26
28
|
});
|
|
27
|
-
logger.debug(`[AmazonBedrockProvider] Successfully created BedrockRuntimeClient with model: ${this.modelName}, region: ${
|
|
29
|
+
logger.debug(`[AmazonBedrockProvider] Successfully created BedrockRuntimeClient with model: ${this.modelName}, region: ${this.region}`);
|
|
28
30
|
// Immediate health check to catch credential issues early
|
|
29
31
|
this.performInitialHealthCheck();
|
|
30
32
|
}
|
|
@@ -39,7 +41,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
39
41
|
*/
|
|
40
42
|
async performInitialHealthCheck() {
|
|
41
43
|
const bedrockClient = new BedrockClient({
|
|
42
|
-
region:
|
|
44
|
+
region: this.region,
|
|
43
45
|
});
|
|
44
46
|
try {
|
|
45
47
|
logger.debug("[AmazonBedrockProvider] Starting initial health check to validate credentials and connectivity");
|
|
@@ -16,7 +16,7 @@ export declare class AmazonSageMakerProvider extends BaseProvider {
|
|
|
16
16
|
private sagemakerModel;
|
|
17
17
|
private sagemakerConfig;
|
|
18
18
|
private modelConfig;
|
|
19
|
-
constructor(modelName?: string, endpointName?: string);
|
|
19
|
+
constructor(modelName?: string, endpointName?: string, region?: string);
|
|
20
20
|
protected getProviderName(): AIProviderName;
|
|
21
21
|
protected getDefaultModel(): string;
|
|
22
22
|
protected getAISDKModel(): LanguageModelV1;
|
|
@@ -17,11 +17,11 @@ export class AmazonSageMakerProvider extends BaseProvider {
|
|
|
17
17
|
sagemakerModel;
|
|
18
18
|
sagemakerConfig;
|
|
19
19
|
modelConfig;
|
|
20
|
-
constructor(modelName, endpointName) {
|
|
20
|
+
constructor(modelName, endpointName, region) {
|
|
21
21
|
super(modelName, "sagemaker");
|
|
22
22
|
try {
|
|
23
23
|
// Load and validate configuration
|
|
24
|
-
this.sagemakerConfig = getSageMakerConfig();
|
|
24
|
+
this.sagemakerConfig = getSageMakerConfig(region);
|
|
25
25
|
this.modelConfig = getSageMakerModelConfig(endpointName || getDefaultSageMakerEndpoint());
|
|
26
26
|
// Create the proper LanguageModel (v2) implementation
|
|
27
27
|
this.sagemakerModel = new SageMakerLanguageModel(this.modelName, this.sagemakerConfig, this.modelConfig);
|
|
@@ -25,7 +25,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
25
25
|
private static readonly MAX_CACHE_SIZE;
|
|
26
26
|
private static maxTokensCache;
|
|
27
27
|
private static maxTokensCacheTime;
|
|
28
|
-
constructor(modelName?: string, _providerName?: string, sdk?: unknown);
|
|
28
|
+
constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string);
|
|
29
29
|
protected getProviderName(): AIProviderName;
|
|
30
30
|
protected getDefaultModel(): string;
|
|
31
31
|
/**
|
|
@@ -46,10 +46,10 @@ const hasGoogleCredentials = () => {
|
|
|
46
46
|
process.env.GOOGLE_AUTH_PRIVATE_KEY));
|
|
47
47
|
};
|
|
48
48
|
// Enhanced Vertex settings creation with authentication fallback and proxy support
|
|
49
|
-
const createVertexSettings = async () => {
|
|
49
|
+
const createVertexSettings = async (region) => {
|
|
50
50
|
const baseSettings = {
|
|
51
51
|
project: getVertexProjectId(),
|
|
52
|
-
location: getVertexLocation(),
|
|
52
|
+
location: region || getVertexLocation(),
|
|
53
53
|
fetch: createProxyFetch(),
|
|
54
54
|
};
|
|
55
55
|
// 🎯 OPTION 2: Create credentials file from environment variables at runtime
|
|
@@ -157,8 +157,7 @@ const createVertexSettings = async () => {
|
|
|
157
157
|
private_key: requiredEnvVars.private_key.replace(/\\n/g, "\n"),
|
|
158
158
|
client_email: requiredEnvVars.client_email,
|
|
159
159
|
client_id: requiredEnvVars.client_id || "",
|
|
160
|
-
auth_uri: requiredEnvVars.auth_uri ||
|
|
161
|
-
"https://accounts.google.com/o/oauth2/auth",
|
|
160
|
+
auth_uri: requiredEnvVars.auth_uri || "https://accounts.google.com/o/oauth2/auth",
|
|
162
161
|
token_uri: requiredEnvVars.token_uri || "https://oauth2.googleapis.com/token",
|
|
163
162
|
auth_provider_x509_cert_url: requiredEnvVars.auth_provider_x509_cert_url ||
|
|
164
163
|
"https://www.googleapis.com/oauth2/v1/certs",
|
|
@@ -199,8 +198,8 @@ const createVertexSettings = async () => {
|
|
|
199
198
|
return baseSettings;
|
|
200
199
|
};
|
|
201
200
|
// Create Anthropic-specific Vertex settings with the same authentication and proxy support
|
|
202
|
-
const createVertexAnthropicSettings = async () => {
|
|
203
|
-
const baseVertexSettings = await createVertexSettings();
|
|
201
|
+
const createVertexAnthropicSettings = async (region) => {
|
|
202
|
+
const baseVertexSettings = await createVertexSettings(region);
|
|
204
203
|
// GoogleVertexAnthropicProviderSettings extends GoogleVertexProviderSettings
|
|
205
204
|
// so we can use the same settings with proper typing
|
|
206
205
|
return {
|
|
@@ -241,7 +240,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
241
240
|
// Memory-managed cache for maxTokens handling decisions to optimize streaming performance
|
|
242
241
|
static maxTokensCache = new Map();
|
|
243
242
|
static maxTokensCacheTime = 0;
|
|
244
|
-
constructor(modelName, _providerName, sdk) {
|
|
243
|
+
constructor(modelName, _providerName, sdk, region) {
|
|
245
244
|
super(modelName, "vertex", sdk);
|
|
246
245
|
// Validate Google Cloud credentials - now using consolidated utility
|
|
247
246
|
if (!hasGoogleCredentials()) {
|
|
@@ -249,7 +248,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
249
248
|
}
|
|
250
249
|
// Initialize Google Cloud configuration
|
|
251
250
|
this.projectId = getVertexProjectId();
|
|
252
|
-
this.location = getVertexLocation();
|
|
251
|
+
this.location = region || getVertexLocation();
|
|
253
252
|
logger.debug("Google Vertex AI BaseProvider v2 initialized", {
|
|
254
253
|
modelName: this.modelName,
|
|
255
254
|
projectId: this.projectId,
|
|
@@ -360,7 +359,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
360
359
|
message: "Starting Vertex settings creation with network configuration analysis",
|
|
361
360
|
});
|
|
362
361
|
try {
|
|
363
|
-
const vertexSettings = await createVertexSettings();
|
|
362
|
+
const vertexSettings = await createVertexSettings(this.location);
|
|
364
363
|
const vertexSettingsEndTime = process.hrtime.bigint();
|
|
365
364
|
const vertexSettingsDurationNs = vertexSettingsEndTime - vertexSettingsStartTime;
|
|
366
365
|
logger.debug(`[GoogleVertexProvider] ✅ LOG_POINT_V009_VERTEX_SETTINGS_SUCCESS`, {
|
|
@@ -920,7 +919,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
920
919
|
projectId: projectValidation.projectId,
|
|
921
920
|
region: projectValidation.region,
|
|
922
921
|
});
|
|
923
|
-
const vertexAnthropicSettings = await createVertexAnthropicSettings();
|
|
922
|
+
const vertexAnthropicSettings = await createVertexAnthropicSettings(this.location);
|
|
924
923
|
// 7. Settings Validation
|
|
925
924
|
if (!vertexAnthropicSettings.project ||
|
|
926
925
|
!vertexAnthropicSettings.location) {
|
|
@@ -8,15 +8,17 @@ import type { SageMakerConfig, SageMakerModelConfig } from "./types.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Load and validate SageMaker configuration from environment variables
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* 1.
|
|
13
|
-
* 2.
|
|
14
|
-
* 3.
|
|
11
|
+
* Region priority:
|
|
12
|
+
* 1. region parameter (highest priority)
|
|
13
|
+
* 2. SAGEMAKER_REGION environment variable
|
|
14
|
+
* 3. AWS_REGION environment variable
|
|
15
|
+
* 4. Default value "us-east-1" (lowest priority)
|
|
15
16
|
*
|
|
17
|
+
* @param region - Optional region parameter override
|
|
16
18
|
* @returns Validated SageMaker configuration
|
|
17
19
|
* @throws {Error} When required configuration is missing or invalid
|
|
18
20
|
*/
|
|
19
|
-
export declare function getSageMakerConfig(): SageMakerConfig;
|
|
21
|
+
export declare function getSageMakerConfig(region?: string): SageMakerConfig;
|
|
20
22
|
/**
|
|
21
23
|
* Load and validate SageMaker model configuration
|
|
22
24
|
*
|
|
@@ -45,21 +45,26 @@ const modelConfigCache = new Map();
|
|
|
45
45
|
/**
|
|
46
46
|
* Load and validate SageMaker configuration from environment variables
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* 1.
|
|
50
|
-
* 2.
|
|
51
|
-
* 3.
|
|
48
|
+
* Region priority:
|
|
49
|
+
* 1. region parameter (highest priority)
|
|
50
|
+
* 2. SAGEMAKER_REGION environment variable
|
|
51
|
+
* 3. AWS_REGION environment variable
|
|
52
|
+
* 4. Default value "us-east-1" (lowest priority)
|
|
52
53
|
*
|
|
54
|
+
* @param region - Optional region parameter override
|
|
53
55
|
* @returns Validated SageMaker configuration
|
|
54
56
|
* @throws {Error} When required configuration is missing or invalid
|
|
55
57
|
*/
|
|
56
|
-
export function getSageMakerConfig() {
|
|
58
|
+
export function getSageMakerConfig(region) {
|
|
57
59
|
// Return cached config if available
|
|
58
60
|
if (configCache) {
|
|
59
61
|
return configCache;
|
|
60
62
|
}
|
|
61
63
|
const config = {
|
|
62
|
-
region:
|
|
64
|
+
region: region ||
|
|
65
|
+
process.env.SAGEMAKER_REGION ||
|
|
66
|
+
process.env.AWS_REGION ||
|
|
67
|
+
"us-east-1",
|
|
63
68
|
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
|
|
64
69
|
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "",
|
|
65
70
|
sessionToken: process.env.AWS_SESSION_TOKEN,
|
|
@@ -22,6 +22,7 @@ export type GenerateOptions = {
|
|
|
22
22
|
};
|
|
23
23
|
provider?: AIProviderName | string;
|
|
24
24
|
model?: string;
|
|
25
|
+
region?: string;
|
|
25
26
|
temperature?: number;
|
|
26
27
|
maxTokens?: number;
|
|
27
28
|
systemPrompt?: string;
|
|
@@ -143,6 +144,7 @@ export type TextGenerationOptions = {
|
|
|
143
144
|
};
|
|
144
145
|
provider?: AIProviderName;
|
|
145
146
|
model?: string;
|
|
147
|
+
region?: string;
|
|
146
148
|
temperature?: number;
|
|
147
149
|
maxTokens?: number;
|
|
148
150
|
systemPrompt?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.45.0",
|
|
4
4
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juspay Technologies",
|