@juspay/neurolink 9.63.0 → 9.64.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 +12 -0
- package/dist/adapters/video/vertexVideoHandler.js +9 -2
- package/dist/browser/neurolink.min.js +1015 -1019
- package/dist/cli/factories/commandFactory.d.ts +14 -0
- package/dist/cli/factories/commandFactory.js +50 -25
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/loop/optionsSchema.js +12 -0
- package/dist/core/baseProvider.d.ts +1 -1
- package/dist/core/modules/MessageBuilder.js +20 -0
- package/dist/core/redisConversationMemoryManager.js +0 -3
- package/dist/factories/providerRegistry.js +5 -1
- package/dist/lib/adapters/video/vertexVideoHandler.js +9 -2
- package/dist/lib/core/baseProvider.d.ts +1 -1
- package/dist/lib/core/modules/MessageBuilder.js +20 -0
- package/dist/lib/core/redisConversationMemoryManager.js +0 -3
- package/dist/lib/factories/providerRegistry.js +5 -1
- package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/lib/memory/hippocampusInitializer.js +32 -2
- package/dist/lib/middleware/builtin/lifecycle.js +19 -48
- package/dist/lib/neurolink.js +49 -2
- package/dist/lib/providers/googleAiStudio.d.ts +11 -3
- package/dist/lib/providers/googleAiStudio.js +292 -339
- package/dist/lib/providers/googleNativeGemini3.d.ts +83 -1
- package/dist/lib/providers/googleNativeGemini3.js +208 -4
- package/dist/lib/providers/googleVertex.d.ts +116 -129
- package/dist/lib/providers/googleVertex.js +2826 -1968
- package/dist/lib/providers/openRouter.js +7 -3
- package/dist/lib/types/aliases.d.ts +14 -0
- package/dist/lib/types/common.d.ts +0 -3
- package/dist/lib/types/conversation.d.ts +10 -3
- package/dist/lib/types/generate.d.ts +14 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/memory.d.ts +96 -0
- package/dist/lib/types/memory.js +23 -0
- package/dist/lib/types/providers.d.ts +140 -2
- package/dist/lib/types/stream.d.ts +6 -0
- package/dist/lib/utils/lifecycleCallbacks.d.ts +13 -0
- package/dist/lib/utils/lifecycleCallbacks.js +44 -0
- package/dist/lib/utils/messageBuilder.d.ts +10 -0
- package/dist/lib/utils/messageBuilder.js +40 -5
- package/dist/lib/utils/modelDetection.d.ts +11 -0
- package/dist/lib/utils/modelDetection.js +27 -0
- package/dist/lib/utils/providerHealth.js +7 -7
- package/dist/lib/utils/schemaConversion.d.ts +1 -1
- package/dist/lib/utils/schemaConversion.js +59 -4
- package/dist/lib/utils/tokenLimits.js +23 -32
- package/dist/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/memory/hippocampusInitializer.js +32 -2
- package/dist/middleware/builtin/lifecycle.js +19 -48
- package/dist/neurolink.js +49 -2
- package/dist/providers/googleAiStudio.d.ts +11 -3
- package/dist/providers/googleAiStudio.js +291 -339
- package/dist/providers/googleNativeGemini3.d.ts +83 -1
- package/dist/providers/googleNativeGemini3.js +208 -4
- package/dist/providers/googleVertex.d.ts +116 -129
- package/dist/providers/googleVertex.js +2824 -1967
- package/dist/providers/openRouter.js +7 -3
- package/dist/types/aliases.d.ts +14 -0
- package/dist/types/common.d.ts +0 -3
- package/dist/types/conversation.d.ts +10 -3
- package/dist/types/generate.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/memory.d.ts +96 -0
- package/dist/types/memory.js +22 -0
- package/dist/types/providers.d.ts +140 -2
- package/dist/types/stream.d.ts +6 -0
- package/dist/utils/lifecycleCallbacks.d.ts +13 -0
- package/dist/utils/lifecycleCallbacks.js +43 -0
- package/dist/utils/messageBuilder.d.ts +10 -0
- package/dist/utils/messageBuilder.js +40 -5
- package/dist/utils/modelDetection.d.ts +11 -0
- package/dist/utils/modelDetection.js +27 -0
- package/dist/utils/providerHealth.js +7 -7
- package/dist/utils/schemaConversion.d.ts +1 -1
- package/dist/utils/schemaConversion.js +59 -4
- package/dist/utils/tokenLimits.js +23 -32
- package/package.json +11 -4
|
@@ -1,37 +1,28 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
|
-
import { type
|
|
2
|
+
import { type Schema, type LanguageModel } from "ai";
|
|
3
|
+
import { AIProviderName } from "../constants/enums.js";
|
|
4
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
|
-
import type { EnhancedGenerateResult, TextGenerationOptions,
|
|
5
|
+
import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
|
-
* Resolve the
|
|
7
|
+
* Resolve the effective Vertex region for a given model.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* (`
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Policy (matches the bugfixes-suite contract):
|
|
10
|
+
* - Every Gemini model (`gemini-*`) is force-routed to the `global` endpoint
|
|
11
|
+
* regardless of any caller-supplied region. Regional endpoints 404 for
|
|
12
|
+
* Gemini 3.x previews and the regional/global behaviour for 2.x is
|
|
13
|
+
* consistent enough that pinning all Gemini traffic to global is the
|
|
14
|
+
* right safe default. The legacy `GLOBAL_LOCATION_MODELS` allowlist is
|
|
15
|
+
* kept as a defence-in-depth fallback so any non-`gemini-` identifiers
|
|
16
|
+
* that still need global (e.g. image-gen aliases) keep working.
|
|
17
|
+
* - Non-Gemini models (Claude on Vertex, embeddings, custom models) keep
|
|
18
|
+
* the caller-supplied region or fall back to env-derived defaults.
|
|
13
19
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* @param modelName - The target model identifier.
|
|
21
|
+
* @param configuredLocation - Caller-provided region (e.g. options.region).
|
|
22
|
+
* Used as the fallback for non-Gemini models; ignored for Gemini.
|
|
23
|
+
* @returns The region string to pass to the @google/genai client.
|
|
18
24
|
*/
|
|
19
|
-
export declare const resolveVertexLocation: (modelName: string | undefined, configuredLocation
|
|
20
|
-
/**
|
|
21
|
-
* Vertex Model Aliases
|
|
22
|
-
*
|
|
23
|
-
* Maps shorthand model names to their full versioned IDs required by the
|
|
24
|
-
* Vertex AI API. This allows users to pass convenient names like
|
|
25
|
-
* "claude-sonnet-4-5" instead of "claude-sonnet-4-5@20250929".
|
|
26
|
-
*
|
|
27
|
-
* Alias resolution runs at the very start of getModel() so that all
|
|
28
|
-
* downstream code (isAnthropicModel, validateAnthropicModelName, etc.)
|
|
29
|
-
* sees the canonical versioned name.
|
|
30
|
-
*
|
|
31
|
-
* To add a new model: simply add an entry mapping the shorthand to the
|
|
32
|
-
* full versioned string. No other changes are needed.
|
|
33
|
-
*/
|
|
34
|
-
export declare const VERTEX_MODEL_ALIASES: Record<string, string>;
|
|
25
|
+
export declare const resolveVertexLocation: (modelName: string | undefined, configuredLocation?: string) => string;
|
|
35
26
|
/**
|
|
36
27
|
* Google Vertex AI Provider v2 - BaseProvider Implementation
|
|
37
28
|
*
|
|
@@ -43,39 +34,38 @@ export declare const VERTEX_MODEL_ALIASES: Record<string, string>;
|
|
|
43
34
|
* - Enhanced error handling with setup guidance
|
|
44
35
|
* - Tool registration and context management
|
|
45
36
|
*
|
|
46
|
-
* @important
|
|
47
|
-
*
|
|
48
|
-
* structured output (JSON schema).
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* "Function calling with a response mime type: 'application/json' is unsupported"
|
|
37
|
+
* @important Tools + Schema Support (Fixed)
|
|
38
|
+
* Gemini models on Vertex AI now support combining function calling (tools) with
|
|
39
|
+
* structured output (JSON schema) simultaneously. The fix works by NOT setting
|
|
40
|
+
* `responseMimeType: "application/json"` when tools are present, which was
|
|
41
|
+
* causing the Google API error.
|
|
52
42
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
43
|
+
* The `responseSchema` is still set to guide the output structure, allowing
|
|
44
|
+
* tools to execute AND the final output to follow the schema format.
|
|
55
45
|
*
|
|
56
|
-
* @example Gemini models with schemas
|
|
46
|
+
* @example Gemini models with tools + schemas
|
|
57
47
|
* ```typescript
|
|
58
48
|
* const provider = new GoogleVertexProvider("gemini-2.5-flash");
|
|
59
49
|
* const result = await provider.generate({
|
|
60
|
-
* input: { text: "Analyze data" },
|
|
50
|
+
* input: { text: "Analyze data using tools" },
|
|
61
51
|
* schema: MySchema,
|
|
62
52
|
* output: { format: "json" },
|
|
63
|
-
*
|
|
53
|
+
* // No need for disableTools: true anymore!
|
|
64
54
|
* });
|
|
65
55
|
* ```
|
|
66
56
|
*
|
|
67
|
-
* @example Claude models (
|
|
57
|
+
* @example Claude models (always supported both)
|
|
68
58
|
* ```typescript
|
|
69
59
|
* const provider = new GoogleVertexProvider("claude-3-5-sonnet-20241022");
|
|
70
60
|
* const result = await provider.generate({
|
|
71
61
|
* input: { text: "Analyze data" },
|
|
72
62
|
* schema: MySchema,
|
|
73
63
|
* output: { format: "json" }
|
|
74
|
-
* // No disableTools needed - Claude supports both
|
|
75
64
|
* });
|
|
76
65
|
* ```
|
|
77
66
|
*
|
|
78
|
-
* @note
|
|
67
|
+
* @note "Too many states for serving" errors can still occur with very complex schemas + tools.
|
|
68
|
+
* Solution: Simplify schema or reduce number of tools if this occurs.
|
|
79
69
|
* @see https://cloud.google.com/vertex-ai/docs/generative-ai/learn/models
|
|
80
70
|
*/
|
|
81
71
|
export declare class GoogleVertexProvider extends BaseProvider {
|
|
@@ -83,31 +73,20 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
83
73
|
private location;
|
|
84
74
|
private registeredTools;
|
|
85
75
|
private toolContext;
|
|
86
|
-
private credentials;
|
|
87
76
|
private static modelConfigCache;
|
|
88
77
|
private static modelConfigCacheTime;
|
|
89
78
|
private static readonly CACHE_DURATION;
|
|
90
79
|
private static readonly MAX_CACHE_SIZE;
|
|
91
80
|
private static maxTokensCache;
|
|
92
81
|
private static maxTokensCacheTime;
|
|
93
|
-
constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string, credentials?:
|
|
82
|
+
constructor(modelName?: string, _providerName?: string, sdk?: unknown, region?: string, credentials?: Record<string, unknown>);
|
|
94
83
|
protected getProviderName(): AIProviderName;
|
|
95
84
|
protected getDefaultModel(): string;
|
|
96
|
-
/**
|
|
97
|
-
* Get the default embedding model for Google Vertex
|
|
98
|
-
* @returns The default Vertex AI embedding model name
|
|
99
|
-
*/
|
|
100
|
-
protected getDefaultEmbeddingModel(): string;
|
|
101
85
|
/**
|
|
102
86
|
* Returns the Vercel AI SDK model instance for Google Vertex
|
|
103
87
|
* Creates fresh model instances for each request
|
|
104
88
|
*/
|
|
105
89
|
protected getAISDKModel(): Promise<LanguageModel>;
|
|
106
|
-
/**
|
|
107
|
-
* Resolve a raw model name through the alias map.
|
|
108
|
-
* Used internally to normalize model names before any API calls.
|
|
109
|
-
*/
|
|
110
|
-
private resolveAlias;
|
|
111
90
|
/**
|
|
112
91
|
* Initialize model creation tracking
|
|
113
92
|
*/
|
|
@@ -121,7 +100,7 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
121
100
|
*/
|
|
122
101
|
private createGoogleVertexModel;
|
|
123
102
|
/**
|
|
124
|
-
*
|
|
103
|
+
* @deprecated This method is no longer used. All models now use native SDKs.
|
|
125
104
|
*/
|
|
126
105
|
private createVertexInstance;
|
|
127
106
|
/**
|
|
@@ -134,43 +113,40 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
134
113
|
* Validate stream options
|
|
135
114
|
*/
|
|
136
115
|
private validateStreamOptionsOnly;
|
|
137
|
-
protected executeStream(options: StreamOptions,
|
|
138
|
-
private maybeExecuteNativeGemini3ToolStream;
|
|
139
|
-
private executeAISDKStream;
|
|
140
|
-
private resolveAISDKStreamTools;
|
|
141
|
-
private buildAISDKStreamOptions;
|
|
142
|
-
private captureAISDKStreamToolStep;
|
|
143
|
-
private startObservedAISDKStream;
|
|
144
|
-
private attachAISDKStreamObservers;
|
|
145
|
-
private observeAISDKStreamResult;
|
|
116
|
+
protected executeStream(options: StreamOptions, _analysisSchema?: ZodType<unknown> | Schema<unknown>): Promise<StreamResult>;
|
|
146
117
|
/**
|
|
147
|
-
*
|
|
118
|
+
* Emit `stream:end` so the Pipeline B observability listener creates a
|
|
119
|
+
* `model.generation` span for native Vertex stream traffic. Mirrors
|
|
120
|
+
* `emitGenerationEnd` (used by `generate()`).
|
|
148
121
|
*/
|
|
149
|
-
private
|
|
122
|
+
private emitStreamEnd;
|
|
150
123
|
/**
|
|
151
|
-
*
|
|
152
|
-
* Shared by both stream and generate native Gemini 3 paths.
|
|
153
|
-
*/
|
|
154
|
-
private buildNativeContentParts;
|
|
155
|
-
/**
|
|
156
|
-
* Convert conversationMessages from NeuroLink's ChatMessage format into
|
|
157
|
-
* the @google/genai contents format and prepend them before the current
|
|
158
|
-
* user message. This gives the native Gemini 3 path multi-turn context
|
|
159
|
-
* that was previously dropped (only the current prompt was sent).
|
|
124
|
+
* Create @google/genai client configured for Vertex AI
|
|
160
125
|
*/
|
|
161
|
-
private
|
|
126
|
+
private createVertexGenAIClient;
|
|
162
127
|
/**
|
|
163
128
|
* Execute stream using native @google/genai SDK for Gemini 3 models on Vertex AI
|
|
164
129
|
* This bypasses @ai-sdk/google-vertex to properly handle thought_signature
|
|
165
130
|
*/
|
|
166
131
|
private executeNativeGemini3Stream;
|
|
167
|
-
private executeNativeGemini3StreamWithSpan;
|
|
168
|
-
private runNativeGemini3StreamLoop;
|
|
169
132
|
/**
|
|
170
133
|
* Execute generate using native @google/genai SDK for Gemini 3 models on Vertex AI
|
|
171
134
|
* This bypasses @ai-sdk/google-vertex to properly handle thought_signature
|
|
172
135
|
*/
|
|
173
136
|
private executeNativeGemini3Generate;
|
|
137
|
+
/**
|
|
138
|
+
* Create native AnthropicVertex client for Claude models
|
|
139
|
+
*/
|
|
140
|
+
private createAnthropicVertexClient;
|
|
141
|
+
/**
|
|
142
|
+
* Execute stream using native @anthropic-ai/vertex-sdk for Claude models on Vertex AI
|
|
143
|
+
* This bypasses @ai-sdk/google-vertex completely and uses Anthropic's native SDK
|
|
144
|
+
*/
|
|
145
|
+
private executeNativeAnthropicStream;
|
|
146
|
+
/**
|
|
147
|
+
* Execute generate using native @anthropic-ai/vertex-sdk for Claude models on Vertex AI
|
|
148
|
+
*/
|
|
149
|
+
private executeNativeAnthropicGenerate;
|
|
174
150
|
/**
|
|
175
151
|
* Process CSV files and append content to options.input.text
|
|
176
152
|
* This ensures CSV data is available in the prompt for native Gemini 3 SDK calls
|
|
@@ -178,9 +154,52 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
178
154
|
*/
|
|
179
155
|
private processCSVFilesForNativeSDK;
|
|
180
156
|
/**
|
|
181
|
-
* Override
|
|
157
|
+
* Override stream to handle image generation models
|
|
158
|
+
* Image models don't support streaming, so we fall back to generate
|
|
159
|
+
*/
|
|
160
|
+
stream(optionsOrPrompt: StreamOptions | string): Promise<StreamResult>;
|
|
161
|
+
/**
|
|
162
|
+
* Override generate to route ALL models to native SDKs
|
|
163
|
+
* No more @ai-sdk/google-vertex dependency
|
|
182
164
|
*/
|
|
183
165
|
generate(optionsOrPrompt: TextGenerationOptions | string): Promise<EnhancedGenerateResult | null>;
|
|
166
|
+
/**
|
|
167
|
+
* Invoke `options.onFinish` with the lifecycle payload shape consumers
|
|
168
|
+
* (and `test:middleware`) expect. Pulled out so generate / image-gen /
|
|
169
|
+
* Anthropic / Gemini code paths share one implementation. Errors thrown
|
|
170
|
+
* by the user's callback are swallowed so they cannot poison the
|
|
171
|
+
* primary generate path — same contract as the AI SDK middleware
|
|
172
|
+
* wrapGenerate uses.
|
|
173
|
+
*/
|
|
174
|
+
private fireGenerateOnFinish;
|
|
175
|
+
/**
|
|
176
|
+
* Invoke `options.onError` with the lifecycle payload shape consumers
|
|
177
|
+
* (and `test:middleware`) expect. Mirrors {@link fireGenerateOnFinish}.
|
|
178
|
+
*/
|
|
179
|
+
private fireGenerateOnError;
|
|
180
|
+
/**
|
|
181
|
+
* Wrap a {@link StreamResult} so each text chunk drives `options.onChunk`
|
|
182
|
+
* and the final yield drives `options.onFinish`. Pipeline A providers get
|
|
183
|
+
* this for free via the AI SDK `wrapStream` middleware; native @google/genai
|
|
184
|
+
* bypasses that wrapper, so native consumers need their lifecycle
|
|
185
|
+
* callbacks invoked from here.
|
|
186
|
+
*/
|
|
187
|
+
private wrapStreamResultWithLifecycle;
|
|
188
|
+
/**
|
|
189
|
+
* Attach `gen_ai.usage.*` and `neurolink.cost` attributes to a span.
|
|
190
|
+
* Pulled out so the generate / stream / image-gen paths share one
|
|
191
|
+
* implementation, and so observability/tracing tests find consistent
|
|
192
|
+
* attributes regardless of which native sub-route fulfilled the request.
|
|
193
|
+
*/
|
|
194
|
+
private attachUsageAndCostAttributes;
|
|
195
|
+
/**
|
|
196
|
+
* Emit `generation:end` so the Pipeline B observability listener creates
|
|
197
|
+
* the corresponding `model.generation` span. Vertex bypasses the AI SDK
|
|
198
|
+
* (and therefore the experimental_telemetry plumbing), so this hand-off
|
|
199
|
+
* is the only way native Vertex calls show up in Langfuse / Pipeline B
|
|
200
|
+
* exporters. Mirrors the Bedrock + Ollama pattern.
|
|
201
|
+
*/
|
|
202
|
+
private emitGenerationEnd;
|
|
184
203
|
protected formatProviderError(error: unknown): Error;
|
|
185
204
|
/**
|
|
186
205
|
* Memory-safe cache management for model configurations
|
|
@@ -208,27 +227,10 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
208
227
|
*/
|
|
209
228
|
hasAnthropicSupport(): Promise<boolean>;
|
|
210
229
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* @param modelName - A model name, possibly a shorthand alias
|
|
215
|
-
* @returns The resolved full versioned model name
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* ```typescript
|
|
219
|
-
* provider.resolveModelAlias("claude-sonnet-4-5"); // "claude-sonnet-4-5@20250929"
|
|
220
|
-
* provider.resolveModelAlias("gemini-3-pro"); // "gemini-3.1-pro-preview"
|
|
221
|
-
* provider.resolveModelAlias("gemini-2.5-flash"); // "gemini-2.5-flash" (unchanged)
|
|
222
|
-
* ```
|
|
230
|
+
* @deprecated This method is no longer used. Claude models now use native @anthropic-ai/vertex-sdk
|
|
231
|
+
* via executeNativeAnthropicStream and executeNativeAnthropicGenerate.
|
|
223
232
|
*/
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Create an Anthropic model instance using vertexAnthropic provider
|
|
227
|
-
* Uses fresh vertex settings for each request with comprehensive validation
|
|
228
|
-
* @param modelName Anthropic model name (e.g., 'claude-3-sonnet@20240229')
|
|
229
|
-
* @returns LanguageModel instance or null if not available
|
|
230
|
-
*/
|
|
231
|
-
createAnthropicModel(modelName: string): Promise<LanguageModel | null>;
|
|
233
|
+
createAnthropicModel(_modelName: string): Promise<LanguageModel | null>;
|
|
232
234
|
/**
|
|
233
235
|
* Validate Vertex AI authentication configuration
|
|
234
236
|
*/
|
|
@@ -299,28 +301,12 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
299
301
|
*/
|
|
300
302
|
private detectImageType;
|
|
301
303
|
/**
|
|
302
|
-
* Estimate token count from text
|
|
304
|
+
* Estimate token count from text (simple character-based estimation)
|
|
303
305
|
*/
|
|
304
306
|
private estimateTokenCount;
|
|
305
307
|
/**
|
|
306
|
-
*
|
|
308
|
+
* Build image parts for multimodal content
|
|
307
309
|
*/
|
|
308
|
-
private getImageGenerationAccessToken;
|
|
309
|
-
/**
|
|
310
|
-
* Build request parts for image generation from prompt, PDFs, and images.
|
|
311
|
-
*/
|
|
312
|
-
private buildImageGenerationParts;
|
|
313
|
-
/**
|
|
314
|
-
* Parse the Vertex AI image generation REST API response.
|
|
315
|
-
*
|
|
316
|
-
* Dual-mode image models (gemini-3.1-flash-image-preview, gemini-2.5-flash-image,
|
|
317
|
-
* gemini-3-pro-image-preview) decide per-request whether to emit an image or text.
|
|
318
|
-
* When the response contains text parts but no image part, surface the text via
|
|
319
|
-
* `textFallback` so the caller can return a normal text result instead of throwing
|
|
320
|
-
* "model returned text instead of image data" and burning retries on a query that
|
|
321
|
-
* the model has already answered.
|
|
322
|
-
*/
|
|
323
|
-
private parseImageGenerationResponse;
|
|
324
310
|
/**
|
|
325
311
|
* Overrides the BaseProvider's image generation method to implement it for Vertex AI.
|
|
326
312
|
* Uses REST API approach with google-auth-library for authentication.
|
|
@@ -330,23 +316,24 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
330
316
|
*/
|
|
331
317
|
protected executeImageGeneration(options: TextGenerationOptions): Promise<EnhancedGenerateResult>;
|
|
332
318
|
/**
|
|
333
|
-
*
|
|
334
|
-
* @param text - The text to embed
|
|
335
|
-
* @param modelName - The embedding model to use (default: text-embedding-004)
|
|
336
|
-
* @returns Promise resolving to the embedding vector
|
|
319
|
+
* Get model suggestions when a model is not found
|
|
337
320
|
*/
|
|
338
|
-
|
|
321
|
+
private getModelSuggestions;
|
|
339
322
|
/**
|
|
340
|
-
* Generate
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
323
|
+
* Generate an embedding for `text` using Vertex via @google/genai.
|
|
324
|
+
*
|
|
325
|
+
* Replaces the previous `@ai-sdk/google-vertex` text embedding model
|
|
326
|
+
* path. Without this, RAG indexing falls through to BaseProvider.embed()
|
|
327
|
+
* which throws "Embedding generation is not supported by the vertex
|
|
328
|
+
* provider", and `neurolink rag index --provider=vertex` fails even
|
|
329
|
+
* though the SDK conceptually supports it.
|
|
344
330
|
*/
|
|
345
|
-
|
|
331
|
+
embed(text: string, modelName?: string): Promise<number[]>;
|
|
346
332
|
/**
|
|
347
|
-
*
|
|
333
|
+
* Batch-embed an array of strings via Vertex @google/genai.
|
|
334
|
+
* Mirrors {@link embed} but returns one vector per input string.
|
|
348
335
|
*/
|
|
349
|
-
|
|
336
|
+
embedMany(texts: string[], modelName?: string): Promise<number[][]>;
|
|
350
337
|
}
|
|
351
338
|
export default GoogleVertexProvider;
|
|
352
339
|
export { GoogleVertexProvider as GoogleVertexAI };
|