@juspay/neurolink 12.47.13 → 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.
- package/CHANGELOG.md +2 -2
- package/dist/browser/neurolink.min.js +14 -14
- package/dist/providers/googleAiStudio/client.js +27 -13
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
2458
|
-
throw new Error(`Embedding response held ${
|
|
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.
|
|
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": {
|