@juspay/neurolink 12.47.12 → 12.47.14

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.
@@ -278,7 +278,14 @@ export const MODEL_CONTEXT_WINDOWS = {
278
278
  "anthropic.claude-opus-4-5-20251101-v1:0": 200_000,
279
279
  "anthropic.claude-sonnet-4-5-20250929-v1:0": 200_000,
280
280
  "anthropic.claude-haiku-4-5-20251001-v1:0": 200_000,
281
- // Claude legacy
281
+ // Claude 4.1 / 4 — the AWS Bedrock model cards state 200K tokens
282
+ "anthropic.claude-opus-4-1-20250805-v1:0": 200_000,
283
+ "anthropic.claude-sonnet-4-20250514-v1:0": 200_000,
284
+ // Claude legacy. AWS lists no model card for 3.7 Sonnet; 200K is the window
285
+ // of the same model in the Anthropic manifest. The `us.` id is its
286
+ // cross-region inference profile, the form tokens.ts keys its output cap by.
287
+ "anthropic.claude-3-7-sonnet-20250219-v1:0": 200_000,
288
+ "us.anthropic.claude-3-7-sonnet-20250219-v1:0": 200_000,
282
289
  "anthropic.claude-3-5-sonnet-20241022-v1:0": 200_000,
283
290
  "anthropic.claude-3-5-haiku-20241022-v1:0": 200_000,
284
291
  "anthropic.claude-3-opus-20240229-v1:0": 200_000,
@@ -2393,7 +2393,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
2393
2393
  contents: [text],
2394
2394
  });
2395
2395
  const embedding = result.embeddings?.[0]?.values;
2396
- if (!embedding) {
2396
+ if (!embedding || embedding.length === 0) {
2397
2397
  throw new ProviderError("No embedding returned from Google AI", this.providerName);
2398
2398
  }
2399
2399
  logger.debug("Embedding generated successfully", {
@@ -2425,10 +2425,11 @@ export class GoogleAIStudioProvider extends BaseProvider {
2425
2425
  model: embeddingModelName,
2426
2426
  count: texts.length,
2427
2427
  });
2428
+ let rows;
2428
2429
  try {
2429
2430
  const apiKey = this.getApiKey();
2430
2431
  const client = await createGoogleGenAIClient(apiKey, this.getBaseURL());
2431
- const embeddings = [];
2432
+ rows = [];
2432
2433
  if (embeddingModelName.includes("gemini-embedding-2")) {
2433
2434
  // @google/genai 2.x reads an array of strings for these models as ONE
2434
2435
  // content with several parts, so a batch would come back as a single
@@ -2441,7 +2442,7 @@ export class GoogleAIStudioProvider extends BaseProvider {
2441
2442
  contents: [text],
2442
2443
  })));
2443
2444
  for (const result of results) {
2444
- embeddings.push(result.embeddings?.[0]?.values || []);
2445
+ rows.push(result.embeddings?.[0]?.values);
2445
2446
  }
2446
2447
  }
2447
2448
  }
@@ -2450,20 +2451,13 @@ export class GoogleAIStudioProvider extends BaseProvider {
2450
2451
  model: embeddingModelName,
2451
2452
  contents: texts,
2452
2453
  });
2453
- embeddings.push(...(result.embeddings || []).map((e) => e.values || []));
2454
+ rows.push(...(result.embeddings || []).map((e) => e.values));
2454
2455
  }
2455
2456
  // One vector per text, or fail: a silent mismatch would pair texts with
2456
2457
  // the wrong vectors downstream.
2457
- if (embeddings.length !== texts.length) {
2458
- throw new Error(`Embedding response held ${embeddings.length} vectors for ${texts.length} texts`);
2458
+ if (rows.length !== texts.length) {
2459
+ throw new Error(`Embedding response held ${rows.length} vectors for ${texts.length} texts`);
2459
2460
  }
2460
- logger.debug("Batch embeddings generated successfully", {
2461
- provider: this.providerName,
2462
- model: embeddingModelName,
2463
- count: embeddings.length,
2464
- embeddingDimension: embeddings[0]?.length,
2465
- });
2466
- return embeddings;
2467
2461
  }
2468
2462
  catch (error) {
2469
2463
  logger.error("Batch embedding generation failed", {
@@ -2473,6 +2467,26 @@ export class GoogleAIStudioProvider extends BaseProvider {
2473
2467
  });
2474
2468
  throw this.handleProviderError(error);
2475
2469
  }
2470
+ // Checked after the try on purpose: a thrown error is re-worded by
2471
+ // handleProviderError from keywords in its text, so an index such as 429
2472
+ // or 502 would turn this into a rate-limit or server error.
2473
+ const embeddings = rows.map((values, index) => {
2474
+ if (!values || values.length === 0) {
2475
+ logger.error("Batch embedding returned no values", {
2476
+ model: embeddingModelName,
2477
+ index,
2478
+ });
2479
+ throw new ProviderError(`Embedding for the text at index ${index} came back without values`, this.providerName);
2480
+ }
2481
+ return values;
2482
+ });
2483
+ logger.debug("Batch embeddings generated successfully", {
2484
+ provider: this.providerName,
2485
+ model: embeddingModelName,
2486
+ count: embeddings.length,
2487
+ embeddingDimension: embeddings[0]?.length,
2488
+ });
2489
+ return embeddings;
2476
2490
  }
2477
2491
  getApiKey() {
2478
2492
  const apiKey = this.credentials?.apiKey ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.47.12",
3
+ "version": "12.47.14",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
6
6
  "author": {