@providerprotocol/ai 0.0.13 → 0.0.15
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/dist/anthropic/index.d.ts +427 -2
- package/dist/anthropic/index.js +142 -13
- package/dist/anthropic/index.js.map +1 -1
- package/dist/google/index.d.ts +480 -7
- package/dist/google/index.js +104 -26
- package/dist/google/index.js.map +1 -1
- package/dist/http/index.d.ts +2 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/ollama/index.d.ts +1 -1
- package/dist/ollama/index.js +14 -0
- package/dist/ollama/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/openai/index.js +48 -16
- package/dist/openai/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +1 -1
- package/dist/openrouter/index.js +48 -16
- package/dist/openrouter/index.js.map +1 -1
- package/dist/{provider-mKkz7Q9U.d.ts → provider-Bi0nyNhA.d.ts} +17 -0
- package/dist/{retry-Dh70lgr0.d.ts → retry-BatS2hjD.d.ts} +1 -1
- package/dist/xai/index.d.ts +368 -6
- package/dist/xai/index.js +121 -26
- package/dist/xai/index.js.map +1 -1
- package/package.json +4 -3
package/dist/google/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as Provider } from '../provider-
|
|
1
|
+
import { b as Provider } from '../provider-Bi0nyNhA.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Provider-specific parameters for Google Gemini API requests.
|
|
@@ -79,6 +79,50 @@ interface GoogleLLMParams {
|
|
|
79
79
|
* When set, the cached content is prepended to the request.
|
|
80
80
|
*/
|
|
81
81
|
cachedContent?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Built-in tools for server-side execution.
|
|
84
|
+
*
|
|
85
|
+
* Use the tool helper constructors from the `tools` namespace:
|
|
86
|
+
* - `tools.googleSearch()` - Google Search grounding
|
|
87
|
+
* - `tools.codeExecution()` - Python code execution
|
|
88
|
+
* - `tools.urlContext()` - URL fetching and analysis
|
|
89
|
+
* - `tools.googleMaps()` - Google Maps grounding
|
|
90
|
+
* - `tools.fileSearch()` - Document RAG search
|
|
91
|
+
*
|
|
92
|
+
* Note: File Search cannot be combined with other built-in tools.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* import { google, tools } from 'provider-protocol/google';
|
|
97
|
+
*
|
|
98
|
+
* const model = llm({
|
|
99
|
+
* model: google('gemini-2.5-flash'),
|
|
100
|
+
* params: {
|
|
101
|
+
* builtInTools: [
|
|
102
|
+
* tools.googleSearch(),
|
|
103
|
+
* tools.codeExecution(),
|
|
104
|
+
* ],
|
|
105
|
+
* },
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
builtInTools?: GoogleBuiltInTool[];
|
|
110
|
+
/**
|
|
111
|
+
* Tool configuration for retrieval (e.g., user location for Maps).
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const params: GoogleLLMParams = {
|
|
116
|
+
* builtInTools: [tools.googleMaps()],
|
|
117
|
+
* toolConfig: {
|
|
118
|
+
* retrievalConfig: {
|
|
119
|
+
* latLng: { latitude: 40.758896, longitude: -73.985130 },
|
|
120
|
+
* },
|
|
121
|
+
* },
|
|
122
|
+
* };
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
toolConfig?: GoogleToolConfig;
|
|
82
126
|
}
|
|
83
127
|
/**
|
|
84
128
|
* Configuration for extended thinking/reasoning in Gemini 3+ models.
|
|
@@ -106,9 +150,10 @@ interface GoogleContent {
|
|
|
106
150
|
* Union type for all possible content part types in Google messages.
|
|
107
151
|
*
|
|
108
152
|
* Parts can contain text, inline images, function calls (from model),
|
|
109
|
-
*
|
|
153
|
+
* function responses (from user providing tool results), or code execution
|
|
154
|
+
* results (from built-in code execution tool).
|
|
110
155
|
*/
|
|
111
|
-
type GooglePart = GoogleTextPart | GoogleImagePart | GoogleFunctionCallPart | GoogleFunctionResponsePart;
|
|
156
|
+
type GooglePart = GoogleTextPart | GoogleImagePart | GoogleFunctionCallPart | GoogleFunctionResponsePart | GoogleExecutableCodePart | GoogleCodeExecutionResultPart;
|
|
112
157
|
/**
|
|
113
158
|
* Text content part.
|
|
114
159
|
*/
|
|
@@ -160,6 +205,36 @@ interface GoogleFunctionResponsePart {
|
|
|
160
205
|
response: Record<string, unknown>;
|
|
161
206
|
};
|
|
162
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Executable code part generated by the model.
|
|
210
|
+
*
|
|
211
|
+
* Contains code that was written by the model for execution
|
|
212
|
+
* via the built-in code execution tool.
|
|
213
|
+
*/
|
|
214
|
+
interface GoogleExecutableCodePart {
|
|
215
|
+
/** Executable code details. */
|
|
216
|
+
executableCode: {
|
|
217
|
+
/** Programming language of the code. */
|
|
218
|
+
language: 'PYTHON' | 'LANGUAGE_UNSPECIFIED';
|
|
219
|
+
/** The code to execute. */
|
|
220
|
+
code: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Code execution result part from built-in code execution.
|
|
225
|
+
*
|
|
226
|
+
* Contains the output from executing code via the code execution tool.
|
|
227
|
+
* Always follows an ExecutableCode part.
|
|
228
|
+
*/
|
|
229
|
+
interface GoogleCodeExecutionResultPart {
|
|
230
|
+
/** Code execution result details. */
|
|
231
|
+
codeExecutionResult: {
|
|
232
|
+
/** Execution outcome. */
|
|
233
|
+
outcome: 'OUTCOME_UNSPECIFIED' | 'OUTCOME_OK' | 'OUTCOME_FAILED' | 'OUTCOME_DEADLINE_EXCEEDED';
|
|
234
|
+
/** Execution output (stdout on success, stderr on failure). */
|
|
235
|
+
output: string;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
163
238
|
/**
|
|
164
239
|
* Tool definition containing function declarations.
|
|
165
240
|
*
|
|
@@ -191,6 +266,39 @@ interface GoogleFunctionDeclaration {
|
|
|
191
266
|
required?: string[];
|
|
192
267
|
};
|
|
193
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Request body for creating a cached content entry.
|
|
271
|
+
*
|
|
272
|
+
* @see {@link https://ai.google.dev/api/caching Google Caching API docs}
|
|
273
|
+
*/
|
|
274
|
+
interface GoogleCacheCreateRequest {
|
|
275
|
+
/** Model to use with this cache (format: models/{model}) */
|
|
276
|
+
model: string;
|
|
277
|
+
/** Optional display name for the cache (max 128 chars) */
|
|
278
|
+
displayName?: string;
|
|
279
|
+
/** Content to cache (immutable after creation) */
|
|
280
|
+
contents?: GoogleContent[];
|
|
281
|
+
/** System instruction to cache (text-only, immutable after creation) */
|
|
282
|
+
systemInstruction?: {
|
|
283
|
+
role?: 'user';
|
|
284
|
+
parts: Array<{
|
|
285
|
+
text: string;
|
|
286
|
+
}>;
|
|
287
|
+
};
|
|
288
|
+
/** Tool declarations to cache (immutable after creation) */
|
|
289
|
+
tools?: GoogleTool[];
|
|
290
|
+
/** Tool configuration to cache (immutable after creation) */
|
|
291
|
+
toolConfig?: {
|
|
292
|
+
functionCallingConfig?: {
|
|
293
|
+
mode?: 'AUTO' | 'ANY' | 'NONE' | 'VALIDATED';
|
|
294
|
+
allowedFunctionNames?: string[];
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
/** Absolute expiration time (RFC 3339 format, mutually exclusive with ttl) */
|
|
298
|
+
expireTime?: string;
|
|
299
|
+
/** Time-to-live duration (e.g., "300s", "3600s", mutually exclusive with expireTime) */
|
|
300
|
+
ttl?: string;
|
|
301
|
+
}
|
|
194
302
|
/**
|
|
195
303
|
* Response from creating or retrieving a cached content entry.
|
|
196
304
|
*/
|
|
@@ -232,6 +340,319 @@ interface GoogleCacheListResponse {
|
|
|
232
340
|
/** Token for fetching the next page of results */
|
|
233
341
|
nextPageToken?: string;
|
|
234
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Google Gemini-specific HTTP headers for API requests.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* const headers: GoogleHeaders = {
|
|
349
|
+
* 'x-goog-api-client': 'myapp/1.0.0',
|
|
350
|
+
* };
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
interface GoogleHeaders {
|
|
354
|
+
/** Client identification header for partners and libraries. */
|
|
355
|
+
'x-goog-api-client'?: string;
|
|
356
|
+
/** Quota project ID for Vertex AI billing. */
|
|
357
|
+
'x-goog-user-project'?: string;
|
|
358
|
+
[key: string]: string | undefined;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Google Search grounding tool for real-time web information.
|
|
362
|
+
*
|
|
363
|
+
* Enables Gemini to search the web using Google Search for up-to-date information.
|
|
364
|
+
* Results are returned with grounding metadata including sources and citations.
|
|
365
|
+
*
|
|
366
|
+
* Pricing:
|
|
367
|
+
* - Gemini 2.x and earlier: $35 per 1,000 grounded prompts
|
|
368
|
+
* - Gemini 3.x: $14 per 1,000 search queries
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* const tool: GoogleSearchTool = {
|
|
373
|
+
* googleSearch: {},
|
|
374
|
+
* };
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
interface GoogleSearchTool {
|
|
378
|
+
/** Empty object to enable Google Search grounding */
|
|
379
|
+
googleSearch: Record<string, never>;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Code execution tool for running Python in a sandbox.
|
|
383
|
+
*
|
|
384
|
+
* Enables Gemini to write and execute Python code in a secure environment.
|
|
385
|
+
* Supports data analysis, calculations, and visualization.
|
|
386
|
+
*
|
|
387
|
+
* No additional cost - standard token pricing applies.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* const tool: GoogleCodeExecutionTool = {
|
|
392
|
+
* codeExecution: {},
|
|
393
|
+
* };
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
interface GoogleCodeExecutionTool {
|
|
397
|
+
/** Empty object to enable code execution */
|
|
398
|
+
codeExecution: Record<string, never>;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* URL context tool for fetching and processing URLs.
|
|
402
|
+
*
|
|
403
|
+
* Enables Gemini to fetch and analyze content from URLs.
|
|
404
|
+
* Supports text, images, and PDF documents.
|
|
405
|
+
*
|
|
406
|
+
* Limits:
|
|
407
|
+
* - Maximum 20 URLs per request
|
|
408
|
+
* - Maximum 34MB content per URL
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const tool: GoogleUrlContextTool = {
|
|
413
|
+
* urlContext: {},
|
|
414
|
+
* };
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
interface GoogleUrlContextTool {
|
|
418
|
+
/** Empty object to enable URL context */
|
|
419
|
+
urlContext: Record<string, never>;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Google Maps grounding tool for location-based queries.
|
|
423
|
+
*
|
|
424
|
+
* Enables Gemini to search for places, businesses, and locations
|
|
425
|
+
* using Google Maps data.
|
|
426
|
+
*
|
|
427
|
+
* Pricing: $25 per 1,000 grounded prompts.
|
|
428
|
+
*
|
|
429
|
+
* Note: Not supported in Gemini 3 models.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const tool: GoogleMapsTool = {
|
|
434
|
+
* googleMaps: {
|
|
435
|
+
* enableWidget: true,
|
|
436
|
+
* },
|
|
437
|
+
* };
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
interface GoogleMapsTool {
|
|
441
|
+
/** Google Maps configuration */
|
|
442
|
+
googleMaps: {
|
|
443
|
+
/** Return widget context token for Places widget */
|
|
444
|
+
enableWidget?: boolean;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* File search (RAG) tool for document retrieval.
|
|
449
|
+
*
|
|
450
|
+
* Enables Gemini to search through uploaded documents
|
|
451
|
+
* using semantic search on FileSearchStore.
|
|
452
|
+
*
|
|
453
|
+
* Pricing:
|
|
454
|
+
* - Embeddings at indexing: $0.15 per 1M tokens
|
|
455
|
+
* - Storage and query embeddings: Free
|
|
456
|
+
*
|
|
457
|
+
* Note: Cannot be combined with other built-in tools.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const tool: GoogleFileSearchTool = {
|
|
462
|
+
* fileSearch: {
|
|
463
|
+
* fileSearchStoreNames: ['fileSearchStores/abc123'],
|
|
464
|
+
* },
|
|
465
|
+
* };
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
interface GoogleFileSearchTool {
|
|
469
|
+
/** File search configuration */
|
|
470
|
+
fileSearch: {
|
|
471
|
+
/** FileSearchStore names to query */
|
|
472
|
+
fileSearchStoreNames: string[];
|
|
473
|
+
/** AIP-160 filter syntax for metadata filtering */
|
|
474
|
+
metadataFilter?: string;
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Union type for all Google built-in tools.
|
|
479
|
+
*
|
|
480
|
+
* Note: Google's built-in tools use a different structure than function tools.
|
|
481
|
+
* They are passed directly in the tools array alongside functionDeclarations.
|
|
482
|
+
*/
|
|
483
|
+
type GoogleBuiltInTool = GoogleSearchTool | GoogleCodeExecutionTool | GoogleUrlContextTool | GoogleMapsTool | GoogleFileSearchTool;
|
|
484
|
+
/**
|
|
485
|
+
* Tool configuration for retrieval (e.g., user location for Maps).
|
|
486
|
+
*/
|
|
487
|
+
interface GoogleToolConfig {
|
|
488
|
+
/** Retrieval configuration */
|
|
489
|
+
retrievalConfig?: {
|
|
490
|
+
/** User location for "near me" queries */
|
|
491
|
+
latLng?: {
|
|
492
|
+
/** User latitude */
|
|
493
|
+
latitude: number;
|
|
494
|
+
/** User longitude */
|
|
495
|
+
longitude: number;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Grounding metadata returned with search/maps results.
|
|
501
|
+
*/
|
|
502
|
+
interface GoogleGroundingMetadata {
|
|
503
|
+
/** Web search queries executed */
|
|
504
|
+
webSearchQueries?: string[];
|
|
505
|
+
/** Search entry point with rendered HTML */
|
|
506
|
+
searchEntryPoint?: {
|
|
507
|
+
renderedContent: string;
|
|
508
|
+
};
|
|
509
|
+
/** Grounding chunks (sources) */
|
|
510
|
+
groundingChunks?: Array<{
|
|
511
|
+
web?: {
|
|
512
|
+
uri: string;
|
|
513
|
+
title: string;
|
|
514
|
+
};
|
|
515
|
+
maps?: {
|
|
516
|
+
uri: string;
|
|
517
|
+
placeId: string;
|
|
518
|
+
title: string;
|
|
519
|
+
};
|
|
520
|
+
}>;
|
|
521
|
+
/** Grounding supports (citations) */
|
|
522
|
+
groundingSupports?: Array<{
|
|
523
|
+
segment: {
|
|
524
|
+
startIndex: number;
|
|
525
|
+
endIndex: number;
|
|
526
|
+
text: string;
|
|
527
|
+
};
|
|
528
|
+
groundingChunkIndices: number[];
|
|
529
|
+
confidenceScores: number[];
|
|
530
|
+
}>;
|
|
531
|
+
/** Google Maps widget context token */
|
|
532
|
+
googleMapsWidgetContextToken?: string;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Code execution result in response.
|
|
536
|
+
*/
|
|
537
|
+
interface GoogleCodeExecutionResult {
|
|
538
|
+
/** Execution outcome */
|
|
539
|
+
outcome: 'OUTCOME_OK' | 'OUTCOME_FAILED' | 'OUTCOME_DEADLINE_EXCEEDED';
|
|
540
|
+
/** Execution output (stdout) */
|
|
541
|
+
output: string;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Creates a Google Search grounding tool configuration.
|
|
545
|
+
*
|
|
546
|
+
* Enables Gemini to search the web using Google Search for up-to-date information.
|
|
547
|
+
*
|
|
548
|
+
* @returns A Google Search tool configuration object
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```typescript
|
|
552
|
+
* const search = googleSearchTool();
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
declare function googleSearchTool(): GoogleSearchTool;
|
|
556
|
+
/**
|
|
557
|
+
* Creates a code execution tool configuration.
|
|
558
|
+
*
|
|
559
|
+
* Enables Gemini to write and execute Python code in a sandbox.
|
|
560
|
+
*
|
|
561
|
+
* @returns A code execution tool configuration object
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* const codeExec = codeExecutionTool();
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
declare function codeExecutionTool(): GoogleCodeExecutionTool;
|
|
569
|
+
/**
|
|
570
|
+
* Creates a URL context tool configuration.
|
|
571
|
+
*
|
|
572
|
+
* Enables Gemini to fetch and analyze content from URLs.
|
|
573
|
+
*
|
|
574
|
+
* @returns A URL context tool configuration object
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```typescript
|
|
578
|
+
* const urlCtx = urlContextTool();
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
declare function urlContextTool(): GoogleUrlContextTool;
|
|
582
|
+
/**
|
|
583
|
+
* Creates a Google Maps grounding tool configuration.
|
|
584
|
+
*
|
|
585
|
+
* Enables Gemini to search for places using Google Maps data.
|
|
586
|
+
*
|
|
587
|
+
* Note: Not supported in Gemini 3 models.
|
|
588
|
+
*
|
|
589
|
+
* @param options - Optional configuration
|
|
590
|
+
* @returns A Google Maps tool configuration object
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* ```typescript
|
|
594
|
+
* const maps = googleMapsTool();
|
|
595
|
+
*
|
|
596
|
+
* // With widget enabled
|
|
597
|
+
* const mapsWithWidget = googleMapsTool({ enableWidget: true });
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
600
|
+
declare function googleMapsTool(options?: {
|
|
601
|
+
enableWidget?: boolean;
|
|
602
|
+
}): GoogleMapsTool;
|
|
603
|
+
/**
|
|
604
|
+
* Creates a file search (RAG) tool configuration.
|
|
605
|
+
*
|
|
606
|
+
* Enables Gemini to search through uploaded documents.
|
|
607
|
+
*
|
|
608
|
+
* Note: Cannot be combined with other built-in tools.
|
|
609
|
+
*
|
|
610
|
+
* @param options - File search configuration
|
|
611
|
+
* @returns A file search tool configuration object
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```typescript
|
|
615
|
+
* const fileSearch = fileSearchTool({
|
|
616
|
+
* fileSearchStoreNames: ['fileSearchStores/abc123'],
|
|
617
|
+
* });
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
declare function fileSearchTool(options: {
|
|
621
|
+
fileSearchStoreNames: string[];
|
|
622
|
+
metadataFilter?: string;
|
|
623
|
+
}): GoogleFileSearchTool;
|
|
624
|
+
/**
|
|
625
|
+
* Namespace object containing all Google tool helper constructors.
|
|
626
|
+
*
|
|
627
|
+
* Provides a convenient way to create built-in tool configurations.
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```typescript
|
|
631
|
+
* import { google, tools } from 'provider-protocol/google';
|
|
632
|
+
*
|
|
633
|
+
* const model = llm({
|
|
634
|
+
* model: google('gemini-2.5-flash'),
|
|
635
|
+
* params: {
|
|
636
|
+
* builtInTools: [
|
|
637
|
+
* tools.googleSearch(),
|
|
638
|
+
* tools.codeExecution(),
|
|
639
|
+
* ],
|
|
640
|
+
* },
|
|
641
|
+
* });
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
declare const tools: {
|
|
645
|
+
/** Creates a Google Search grounding tool configuration */
|
|
646
|
+
googleSearch: typeof googleSearchTool;
|
|
647
|
+
/** Creates a code execution tool configuration */
|
|
648
|
+
codeExecution: typeof codeExecutionTool;
|
|
649
|
+
/** Creates a URL context tool configuration */
|
|
650
|
+
urlContext: typeof urlContextTool;
|
|
651
|
+
/** Creates a Google Maps grounding tool configuration */
|
|
652
|
+
googleMaps: typeof googleMapsTool;
|
|
653
|
+
/** Creates a file search (RAG) tool configuration */
|
|
654
|
+
fileSearch: typeof fileSearchTool;
|
|
655
|
+
};
|
|
235
656
|
|
|
236
657
|
/**
|
|
237
658
|
* @fileoverview Google Gemini caching utilities.
|
|
@@ -250,7 +671,7 @@ interface GoogleCacheListResponse {
|
|
|
250
671
|
interface CacheCreateOptions {
|
|
251
672
|
/** API key for authentication */
|
|
252
673
|
apiKey: string;
|
|
253
|
-
/** Model to associate with this cache (e.g., "gemini-
|
|
674
|
+
/** Model to associate with this cache (e.g., "gemini-3-flash-preview") */
|
|
254
675
|
model: string;
|
|
255
676
|
/** Optional display name for the cache (max 128 chars) */
|
|
256
677
|
displayName?: string;
|
|
@@ -293,7 +714,7 @@ interface CacheListOptions {
|
|
|
293
714
|
* // Create a cache with system instruction and large context
|
|
294
715
|
* const cache = await google.cache.create({
|
|
295
716
|
* apiKey: process.env.GOOGLE_API_KEY,
|
|
296
|
-
* model: 'gemini-
|
|
717
|
+
* model: 'gemini-3-flash-preview',
|
|
297
718
|
* displayName: 'Code Review Context',
|
|
298
719
|
* systemInstruction: 'You are an expert code reviewer...',
|
|
299
720
|
* contents: [
|
|
@@ -365,6 +786,58 @@ declare function list(options: CacheListOptions): Promise<GoogleCacheListRespons
|
|
|
365
786
|
* ```
|
|
366
787
|
*/
|
|
367
788
|
declare function update(name: string, updateRequest: GoogleCacheUpdateRequest, apiKey: string): Promise<GoogleCacheResponse>;
|
|
789
|
+
/**
|
|
790
|
+
* Deletes a cached content entry.
|
|
791
|
+
*
|
|
792
|
+
* @param name - The cache name (format: "cachedContents/{id}")
|
|
793
|
+
* @param apiKey - API key for authentication
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* await google.cache.delete('cachedContents/abc123', apiKey);
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
declare function deleteCache(name: string, apiKey: string): Promise<void>;
|
|
801
|
+
/**
|
|
802
|
+
* Cache utilities namespace.
|
|
803
|
+
*
|
|
804
|
+
* Provides functions for creating and managing Google Gemini cached content
|
|
805
|
+
* entries. Use cached content to reduce costs and latency when repeatedly
|
|
806
|
+
* sending the same context (system instructions, large documents, etc.)
|
|
807
|
+
* across multiple requests.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* ```typescript
|
|
811
|
+
* import { google } from '@anthropic/provider-protocol';
|
|
812
|
+
*
|
|
813
|
+
* // Create a cache
|
|
814
|
+
* const cache = await google.cache.create({
|
|
815
|
+
* apiKey: process.env.GOOGLE_API_KEY,
|
|
816
|
+
* model: 'gemini-3-flash-preview',
|
|
817
|
+
* systemInstruction: 'You are an expert assistant...',
|
|
818
|
+
* contents: [{ role: 'user', parts: [{ text: largeDocument }] }],
|
|
819
|
+
* ttl: '3600s',
|
|
820
|
+
* });
|
|
821
|
+
*
|
|
822
|
+
* // Use cache.name in requests via params.cachedContent
|
|
823
|
+
* const response = await model.complete({
|
|
824
|
+
* messages: [userMessage('Summarize the document')],
|
|
825
|
+
* params: { cachedContent: cache.name },
|
|
826
|
+
* });
|
|
827
|
+
*
|
|
828
|
+
* // Manage caches
|
|
829
|
+
* const caches = await google.cache.list({ apiKey });
|
|
830
|
+
* await google.cache.update(cache.name, { ttl: '7200s' }, apiKey);
|
|
831
|
+
* await google.cache.delete(cache.name, apiKey);
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
declare const cache: {
|
|
835
|
+
create: typeof create;
|
|
836
|
+
get: typeof get;
|
|
837
|
+
list: typeof list;
|
|
838
|
+
update: typeof update;
|
|
839
|
+
delete: typeof deleteCache;
|
|
840
|
+
};
|
|
368
841
|
|
|
369
842
|
/**
|
|
370
843
|
* Google Gemini provider for the Unified Provider Protocol (UPP).
|
|
@@ -404,7 +877,7 @@ declare function update(name: string, updateRequest: GoogleCacheUpdateRequest, a
|
|
|
404
877
|
* // Create a cache for repeated context
|
|
405
878
|
* const cacheEntry = await google.cache.create({
|
|
406
879
|
* apiKey: process.env.GOOGLE_API_KEY,
|
|
407
|
-
* model: 'gemini-
|
|
880
|
+
* model: 'gemini-3-flash-preview',
|
|
408
881
|
* systemInstruction: 'You are an expert code reviewer...',
|
|
409
882
|
* contents: [{ role: 'user', parts: [{ text: largeCodebase }] }],
|
|
410
883
|
* ttl: '3600s',
|
|
@@ -435,4 +908,4 @@ declare const google: Provider<unknown> & {
|
|
|
435
908
|
};
|
|
436
909
|
};
|
|
437
910
|
|
|
438
|
-
export { type GoogleLLMParams, google };
|
|
911
|
+
export { type CacheCreateOptions, type CacheListOptions, type GoogleBuiltInTool, type GoogleCacheCreateRequest, type GoogleCacheListResponse, type GoogleCacheResponse, type GoogleCacheUpdateRequest, type GoogleCodeExecutionResult, type GoogleCodeExecutionTool, type GoogleFileSearchTool, type GoogleGroundingMetadata, type GoogleHeaders, type GoogleLLMParams, type GoogleMapsTool, type GoogleSearchTool, type GoogleToolConfig, type GoogleUrlContextTool, cache, google, tools };
|