@firebase/ai 2.11.1 → 2.12.0-20260505164105
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/ai-public.d.ts +358 -9
- package/dist/ai.d.ts +386 -12
- package/dist/esm/index.esm.js +375 -223
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/methods/live-session.d.ts +40 -5
- package/dist/esm/src/models/live-generative-model.d.ts +6 -4
- package/dist/esm/src/models/template-generative-model.d.ts +7 -3
- package/dist/esm/src/types/enums.d.ts +80 -0
- package/dist/esm/src/types/live-responses.d.ts +3 -1
- package/dist/esm/src/types/requests.d.ts +148 -2
- package/dist/esm/src/types/responses.d.ts +69 -2
- package/dist/index.cjs.js +376 -222
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +376 -222
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +375 -223
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/methods/live-session.d.ts +40 -5
- package/dist/src/models/live-generative-model.d.ts +6 -4
- package/dist/src/models/template-generative-model.d.ts +7 -3
- package/dist/src/types/enums.d.ts +80 -0
- package/dist/src/types/live-responses.d.ts +3 -1
- package/dist/src/types/requests.d.ts +148 -2
- package/dist/src/types/responses.d.ts +69 -2
- package/package.json +9 -9
package/dist/ai.d.ts
CHANGED
|
@@ -594,6 +594,26 @@ export declare interface Content {
|
|
|
594
594
|
parts: Part[];
|
|
595
595
|
}
|
|
596
596
|
|
|
597
|
+
/**
|
|
598
|
+
* Enables context window compression to manage the model's context window.
|
|
599
|
+
*
|
|
600
|
+
* @remarks
|
|
601
|
+
* This mechanism prevents the context from exceeding a given length.
|
|
602
|
+
*
|
|
603
|
+
* @beta
|
|
604
|
+
*/
|
|
605
|
+
export declare interface ContextWindowCompressionConfig {
|
|
606
|
+
/**
|
|
607
|
+
* The number of tokens (before running a turn) that triggers the context
|
|
608
|
+
* window compression.
|
|
609
|
+
*/
|
|
610
|
+
triggerTokens?: number;
|
|
611
|
+
/**
|
|
612
|
+
* The sliding window compression mechanism.
|
|
613
|
+
*/
|
|
614
|
+
slidingWindow?: SlidingWindow;
|
|
615
|
+
}
|
|
616
|
+
|
|
597
617
|
/**
|
|
598
618
|
* Params for calling {@link GenerativeModel.countTokens}
|
|
599
619
|
* @public
|
|
@@ -833,6 +853,46 @@ export declare const FinishReason: {
|
|
|
833
853
|
* The function call generated by the model was invalid.
|
|
834
854
|
*/
|
|
835
855
|
readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
|
|
856
|
+
/**
|
|
857
|
+
* Token generation stopped because generated images contain safety violations.
|
|
858
|
+
*/
|
|
859
|
+
readonly IMAGE_SAFETY: "IMAGE_SAFETY";
|
|
860
|
+
/**
|
|
861
|
+
* Image generation stopped because generated images have other prohibited content.
|
|
862
|
+
*/
|
|
863
|
+
readonly IMAGE_PROHIBITED_CONTENT: "IMAGE_PROHIBITED_CONTENT";
|
|
864
|
+
/**
|
|
865
|
+
* Image generation stopped because of other miscellaneous issue.
|
|
866
|
+
*/
|
|
867
|
+
readonly IMAGE_OTHER: "IMAGE_OTHER";
|
|
868
|
+
/**
|
|
869
|
+
* The model was expected to generate an image, but none was generated.
|
|
870
|
+
*/
|
|
871
|
+
readonly NO_IMAGE: "NO_IMAGE";
|
|
872
|
+
/**
|
|
873
|
+
* Image generation stopped due to recitation.
|
|
874
|
+
*/
|
|
875
|
+
readonly IMAGE_RECITATION: "IMAGE_RECITATION";
|
|
876
|
+
/**
|
|
877
|
+
* The response candidate content was flagged for using an unsupported language.
|
|
878
|
+
*/
|
|
879
|
+
readonly LANGUAGE: "LANGUAGE";
|
|
880
|
+
/**
|
|
881
|
+
* Model generated a tool call but no tools were enabled in the request.
|
|
882
|
+
*/
|
|
883
|
+
readonly UNEXPECTED_TOOL_CALL: "UNEXPECTED_TOOL_CALL";
|
|
884
|
+
/**
|
|
885
|
+
* Model called too many tools consecutively, thus the system exited execution.
|
|
886
|
+
*/
|
|
887
|
+
readonly TOO_MANY_TOOL_CALLS: "TOO_MANY_TOOL_CALLS";
|
|
888
|
+
/**
|
|
889
|
+
* Request has at least one thought signature missing.
|
|
890
|
+
*/
|
|
891
|
+
readonly MISSING_THOUGHT_SIGNATURE: "MISSING_THOUGHT_SIGNATURE";
|
|
892
|
+
/**
|
|
893
|
+
* Finished due to malformed response.
|
|
894
|
+
*/
|
|
895
|
+
readonly MALFORMED_RESPONSE: "MALFORMED_RESPONSE";
|
|
836
896
|
};
|
|
837
897
|
|
|
838
898
|
/**
|
|
@@ -1124,6 +1184,11 @@ export declare interface GenerationConfig {
|
|
|
1124
1184
|
* Configuration for "thinking" behavior of compatible Gemini models.
|
|
1125
1185
|
*/
|
|
1126
1186
|
thinkingConfig?: ThinkingConfig;
|
|
1187
|
+
/**
|
|
1188
|
+
* Configuration options for generating images with Gemini models.
|
|
1189
|
+
* @public
|
|
1190
|
+
*/
|
|
1191
|
+
imageConfig?: ImageConfig;
|
|
1127
1192
|
}
|
|
1128
1193
|
|
|
1129
1194
|
/**
|
|
@@ -1338,6 +1403,66 @@ export declare interface GoogleAIGenerateContentResponse {
|
|
|
1338
1403
|
usageMetadata?: UsageMetadata;
|
|
1339
1404
|
}
|
|
1340
1405
|
|
|
1406
|
+
/**
|
|
1407
|
+
* Specifies the Google Maps configuration.
|
|
1408
|
+
*
|
|
1409
|
+
* @public
|
|
1410
|
+
*/
|
|
1411
|
+
export declare interface GoogleMaps {
|
|
1412
|
+
enableWidget?: boolean;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* A grounding chunk from Google Maps.
|
|
1417
|
+
*
|
|
1418
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
1419
|
+
* {@link https://cloud.google.com/terms/service-terms | Service Specific Terms} for "Grounding with Google Maps".
|
|
1420
|
+
*
|
|
1421
|
+
* @public
|
|
1422
|
+
*/
|
|
1423
|
+
export declare interface GoogleMapsGroundingChunk {
|
|
1424
|
+
/**
|
|
1425
|
+
* The URI of the place.
|
|
1426
|
+
*/
|
|
1427
|
+
uri?: string;
|
|
1428
|
+
/**
|
|
1429
|
+
* The title of the place.
|
|
1430
|
+
*/
|
|
1431
|
+
title?: string;
|
|
1432
|
+
/**
|
|
1433
|
+
* The text of the place answer.
|
|
1434
|
+
*/
|
|
1435
|
+
text?: string;
|
|
1436
|
+
/**
|
|
1437
|
+
* This Place's resource name, in `places/{place_id}` format. This can be used to look up the
|
|
1438
|
+
* place in the Google Maps API.
|
|
1439
|
+
*/
|
|
1440
|
+
placeId?: string;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* A tool that allows a Gemini model to connect to Google Maps to access and incorporate
|
|
1445
|
+
* location-based information into its responses.
|
|
1446
|
+
*
|
|
1447
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
1448
|
+
* "Grounding with Google Maps" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
1449
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
1450
|
+
* section within the Service Specific Terms).
|
|
1451
|
+
*
|
|
1452
|
+
* @public
|
|
1453
|
+
*/
|
|
1454
|
+
export declare interface GoogleMapsTool {
|
|
1455
|
+
/**
|
|
1456
|
+
* Specifies the Google Maps configuration.
|
|
1457
|
+
*
|
|
1458
|
+
* When using this feature, you are required to comply with the "Grounding with Google Maps"
|
|
1459
|
+
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
1460
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
1461
|
+
* section within the Service Specific Terms).
|
|
1462
|
+
*/
|
|
1463
|
+
googleMaps: GoogleMaps;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1341
1466
|
/**
|
|
1342
1467
|
* Specifies the Google Search configuration.
|
|
1343
1468
|
*
|
|
@@ -1383,18 +1508,28 @@ export declare interface GroundingChunk {
|
|
|
1383
1508
|
* Contains details if the grounding chunk is from a web source.
|
|
1384
1509
|
*/
|
|
1385
1510
|
web?: WebGroundingChunk;
|
|
1511
|
+
/**
|
|
1512
|
+
* Contains details if the grounding chunk is from a Google Maps source.
|
|
1513
|
+
*/
|
|
1514
|
+
maps?: GoogleMapsGroundingChunk;
|
|
1386
1515
|
}
|
|
1387
1516
|
|
|
1388
1517
|
/**
|
|
1389
1518
|
* Metadata returned when grounding is enabled.
|
|
1390
1519
|
*
|
|
1391
|
-
* Currently, only Grounding with Google Search
|
|
1520
|
+
* Currently, only Grounding with Google Search and Grounding with Google Maps are supported
|
|
1521
|
+
* (see {@link GoogleSearchTool} and {@link GoogleMapsTool}, respectively).
|
|
1392
1522
|
*
|
|
1393
1523
|
* Important: If using Grounding with Google Search, you are required to comply with the
|
|
1394
1524
|
* "Grounding with Google Search" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
1395
1525
|
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
1396
1526
|
* section within the Service Specific Terms).
|
|
1397
1527
|
*
|
|
1528
|
+
* Important: If using Grounding with Google Maps, you are required to comply with the
|
|
1529
|
+
* "Grounding with Google Maps" usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-maps | Gemini Developer API}
|
|
1530
|
+
* or Vertex AI Gemini API (see {@link https://cloud.google.com/terms/service-terms | Service Terms}
|
|
1531
|
+
* section within the Service Specific Terms).
|
|
1532
|
+
*
|
|
1398
1533
|
* @public
|
|
1399
1534
|
*/
|
|
1400
1535
|
export declare interface GroundingMetadata {
|
|
@@ -1423,6 +1558,12 @@ export declare interface GroundingMetadata {
|
|
|
1423
1558
|
* @deprecated Use {@link GroundingSupport} instead.
|
|
1424
1559
|
*/
|
|
1425
1560
|
retrievalQueries?: string[];
|
|
1561
|
+
/**
|
|
1562
|
+
* Resource name of the Google Maps widget context token that can be used with the
|
|
1563
|
+
* `PlacesContextElement` widget in order to render contextual data. Only populated in the case
|
|
1564
|
+
* that grounding with Google Maps is enabled.
|
|
1565
|
+
*/
|
|
1566
|
+
googleMapsWidgetContextToken?: string;
|
|
1426
1567
|
}
|
|
1427
1568
|
|
|
1428
1569
|
/**
|
|
@@ -1604,6 +1745,65 @@ export declare interface HybridParams {
|
|
|
1604
1745
|
inCloudParams?: ModelParams;
|
|
1605
1746
|
}
|
|
1606
1747
|
|
|
1748
|
+
/**
|
|
1749
|
+
* Configuration options for generating images with Gemini models.
|
|
1750
|
+
* @public
|
|
1751
|
+
*/
|
|
1752
|
+
export declare interface ImageConfig {
|
|
1753
|
+
/**
|
|
1754
|
+
* The aspect ratio of generated images.
|
|
1755
|
+
*/
|
|
1756
|
+
aspectRatio?: ImageConfigAspectRatio;
|
|
1757
|
+
/**
|
|
1758
|
+
* The size of the generated images.
|
|
1759
|
+
*/
|
|
1760
|
+
imageSize?: ImageConfigImageSize;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Aspect ratios for generated images.
|
|
1765
|
+
* @public
|
|
1766
|
+
*/
|
|
1767
|
+
export declare const ImageConfigAspectRatio: {
|
|
1768
|
+
readonly SQUARE_1x1: "1:1";
|
|
1769
|
+
readonly PORTRAIT_9x16: "9:16";
|
|
1770
|
+
readonly LANDSCAPE_16x9: "16:9";
|
|
1771
|
+
readonly PORTRAIT_3x4: "3:4";
|
|
1772
|
+
readonly LANDSCAPE_4x3: "4:3";
|
|
1773
|
+
readonly PORTRAIT_2x3: "2:3";
|
|
1774
|
+
readonly LANDSCAPE_3x2: "3:2";
|
|
1775
|
+
readonly PORTRAIT_4x5: "4:5";
|
|
1776
|
+
readonly LANDSCAPE_5x4: "5:4";
|
|
1777
|
+
readonly PORTRAIT_1x4: "1:4";
|
|
1778
|
+
readonly LANDSCAPE_4x1: "4:1";
|
|
1779
|
+
readonly PORTRAIT_1x8: "1:8";
|
|
1780
|
+
readonly LANDSCAPE_8x1: "8:1";
|
|
1781
|
+
readonly ULTRAWIDE_21x9: "21:9";
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Aspect ratios for generated images.
|
|
1786
|
+
* @public
|
|
1787
|
+
*/
|
|
1788
|
+
export declare type ImageConfigAspectRatio = (typeof ImageConfigAspectRatio)[keyof typeof ImageConfigAspectRatio];
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Sizes for generated images. For example, '1K' is 1024px, '2K' is 2048px, and '4K' is 4096px.
|
|
1792
|
+
* @public
|
|
1793
|
+
*/
|
|
1794
|
+
export declare const ImageConfigImageSize: {
|
|
1795
|
+
readonly SIZE_512: "512";
|
|
1796
|
+
readonly SIZE_1K: "1K";
|
|
1797
|
+
readonly SIZE_2K: "2K";
|
|
1798
|
+
readonly SIZE_4K: "4K";
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* Sizes for generated images.
|
|
1803
|
+
* @public
|
|
1804
|
+
*/
|
|
1805
|
+
export declare type ImageConfigImageSize = (typeof ImageConfigImageSize)[keyof typeof ImageConfigImageSize];
|
|
1806
|
+
|
|
1607
1807
|
/**
|
|
1608
1808
|
* Aspect ratios for Imagen images.
|
|
1609
1809
|
*
|
|
@@ -2316,6 +2516,40 @@ export declare interface LanguageModelPromptOptions {
|
|
|
2316
2516
|
responseConstraint?: object;
|
|
2317
2517
|
}
|
|
2318
2518
|
|
|
2519
|
+
/**
|
|
2520
|
+
* An object that represents a latitude/longitude pair.
|
|
2521
|
+
* @public
|
|
2522
|
+
*/
|
|
2523
|
+
export declare interface LatLng {
|
|
2524
|
+
/**
|
|
2525
|
+
* The latitude in degrees. It must be in the range `[-90.0, +90.0]`.
|
|
2526
|
+
*/
|
|
2527
|
+
latitude?: number;
|
|
2528
|
+
/**
|
|
2529
|
+
* The longitude in degrees. It must be in the range `[-180.0, +180.0]`.
|
|
2530
|
+
*/
|
|
2531
|
+
longitude?: number;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* The first message in a Live session, used to configure generation options.
|
|
2536
|
+
*
|
|
2537
|
+
* @internal
|
|
2538
|
+
*/
|
|
2539
|
+
declare interface _LiveClientSetup {
|
|
2540
|
+
setup: {
|
|
2541
|
+
model: string;
|
|
2542
|
+
generationConfig?: _LiveGenerationConfig;
|
|
2543
|
+
tools?: Tool[];
|
|
2544
|
+
toolConfig?: ToolConfig;
|
|
2545
|
+
systemInstruction?: string | Part | Content;
|
|
2546
|
+
inputAudioTranscription?: AudioTranscriptionConfig;
|
|
2547
|
+
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2548
|
+
sessionResumption?: SessionResumptionConfig;
|
|
2549
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2319
2553
|
/**
|
|
2320
2554
|
* Configuration parameters used by {@link LiveGenerativeModel} to control live content generation.
|
|
2321
2555
|
*
|
|
@@ -2383,8 +2617,22 @@ export declare interface LiveGenerationConfig {
|
|
|
2383
2617
|
* "How are you today?", the model may transcribe that output across three messages, broken up as "How a", "re yo", "u today?".
|
|
2384
2618
|
*/
|
|
2385
2619
|
outputAudioTranscription?: AudioTranscriptionConfig;
|
|
2620
|
+
/**
|
|
2621
|
+
* The context window compression configuration.
|
|
2622
|
+
*
|
|
2623
|
+
* @beta
|
|
2624
|
+
*/
|
|
2625
|
+
contextWindowCompression?: ContextWindowCompressionConfig;
|
|
2386
2626
|
}
|
|
2387
2627
|
|
|
2628
|
+
/**
|
|
2629
|
+
* The Live Generation Config.
|
|
2630
|
+
*
|
|
2631
|
+
* The public API ({@link LiveGenerationConfig}) has `inputAudioTranscription` and `outputAudioTranscription`,
|
|
2632
|
+
* but the server expects these fields to be in the top-level `setup` message. This was a conscious API decision.
|
|
2633
|
+
*/
|
|
2634
|
+
declare type _LiveGenerationConfig = Omit<LiveGenerationConfig, 'inputAudioTranscription' | 'outputAudioTranscription'>;
|
|
2635
|
+
|
|
2388
2636
|
/**
|
|
2389
2637
|
* Class for Live generative model APIs. The Live API enables low-latency, two-way multimodal
|
|
2390
2638
|
* interactions with Gemini.
|
|
@@ -2395,9 +2643,10 @@ export declare interface LiveGenerationConfig {
|
|
|
2395
2643
|
*/
|
|
2396
2644
|
export declare class LiveGenerativeModel extends AIModel {
|
|
2397
2645
|
/**
|
|
2646
|
+
* For testing injection
|
|
2398
2647
|
* @internal
|
|
2399
2648
|
*/
|
|
2400
|
-
private _webSocketHandler
|
|
2649
|
+
private _webSocketHandler?;
|
|
2401
2650
|
generationConfig: LiveGenerationConfig;
|
|
2402
2651
|
tools?: Tool[];
|
|
2403
2652
|
toolConfig?: ToolConfig;
|
|
@@ -2407,9 +2656,10 @@ export declare class LiveGenerativeModel extends AIModel {
|
|
|
2407
2656
|
*/
|
|
2408
2657
|
constructor(ai: AI, modelParams: LiveModelParams,
|
|
2409
2658
|
/**
|
|
2659
|
+
* For testing injection
|
|
2410
2660
|
* @internal
|
|
2411
2661
|
*/
|
|
2412
|
-
_webSocketHandler
|
|
2662
|
+
_webSocketHandler?: WebSocketHandler | undefined);
|
|
2413
2663
|
/**
|
|
2414
2664
|
* Starts a {@link LiveSession}.
|
|
2415
2665
|
*
|
|
@@ -2418,7 +2668,7 @@ export declare class LiveGenerativeModel extends AIModel {
|
|
|
2418
2668
|
*
|
|
2419
2669
|
* @beta
|
|
2420
2670
|
*/
|
|
2421
|
-
connect(): Promise<LiveSession>;
|
|
2671
|
+
connect(sessionResumption?: SessionResumptionConfig): Promise<LiveSession>;
|
|
2422
2672
|
}
|
|
2423
2673
|
|
|
2424
2674
|
/**
|
|
@@ -2443,6 +2693,7 @@ export declare const LiveResponseType: {
|
|
|
2443
2693
|
TOOL_CALL: string;
|
|
2444
2694
|
TOOL_CALL_CANCELLATION: string;
|
|
2445
2695
|
GOING_AWAY_NOTICE: string;
|
|
2696
|
+
SESSION_RESUMPTION_UPDATE: string;
|
|
2446
2697
|
};
|
|
2447
2698
|
|
|
2448
2699
|
/**
|
|
@@ -2532,8 +2783,9 @@ export declare interface LiveServerToolCallCancellation {
|
|
|
2532
2783
|
* @beta
|
|
2533
2784
|
*/
|
|
2534
2785
|
export declare class LiveSession {
|
|
2535
|
-
private
|
|
2536
|
-
private
|
|
2786
|
+
private _setupMessage;
|
|
2787
|
+
private _apiSettings;
|
|
2788
|
+
private _sessionResumption?;
|
|
2537
2789
|
/**
|
|
2538
2790
|
* Indicates whether this Live session is closed.
|
|
2539
2791
|
*
|
|
@@ -2547,9 +2799,41 @@ export declare class LiveSession {
|
|
|
2547
2799
|
*/
|
|
2548
2800
|
inConversation: boolean;
|
|
2549
2801
|
/**
|
|
2802
|
+
* Allows external code to await the opening of the WebSocket connection.
|
|
2803
|
+
*/
|
|
2804
|
+
connectionPromise: Promise<void>;
|
|
2805
|
+
/**
|
|
2806
|
+
* Generator yielding WebSocket messages from the server.
|
|
2807
|
+
*/
|
|
2808
|
+
private _serverMessages;
|
|
2809
|
+
/**
|
|
2810
|
+
* WebSocket handler. Injectable for testing.
|
|
2811
|
+
*/
|
|
2812
|
+
private _webSocketHandler;
|
|
2813
|
+
/**
|
|
2814
|
+
* @internal
|
|
2815
|
+
*/
|
|
2816
|
+
constructor(_setupMessage: _LiveClientSetup, _apiSettings: ApiSettings, _sessionResumption?: SessionResumptionConfig | undefined, webSocketHandler?: WebSocketHandler);
|
|
2817
|
+
/**
|
|
2818
|
+
* Initializes connection to the WebSocket. Should be called immediately
|
|
2819
|
+
* after instantiation.
|
|
2820
|
+
*
|
|
2550
2821
|
* @internal
|
|
2551
2822
|
*/
|
|
2552
|
-
|
|
2823
|
+
private _connectSession;
|
|
2824
|
+
/**
|
|
2825
|
+
* Resumes an existing live session with the server.
|
|
2826
|
+
*
|
|
2827
|
+
* This closes the current WebSocket connection and establishes a new one using
|
|
2828
|
+
* the same configuration (URI, headers, model, system instruction, tools, etc.)
|
|
2829
|
+
* as the original session.
|
|
2830
|
+
*
|
|
2831
|
+
* @param sessionResumption - The configuration for session resumption, such as the handle to the previous session state to restore.
|
|
2832
|
+
* @throws If the session resumption configuration is unsupported.
|
|
2833
|
+
*
|
|
2834
|
+
* @beta
|
|
2835
|
+
*/
|
|
2836
|
+
resumeSession(sessionResumption?: SessionResumptionConfig): Promise<void>;
|
|
2553
2837
|
/**
|
|
2554
2838
|
* Sends content to the server.
|
|
2555
2839
|
*
|
|
@@ -2629,7 +2913,7 @@ export declare class LiveSession {
|
|
|
2629
2913
|
*
|
|
2630
2914
|
* @beta
|
|
2631
2915
|
*/
|
|
2632
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
2916
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice | LiveSessionResumptionUpdate>;
|
|
2633
2917
|
/**
|
|
2634
2918
|
* Closes this session.
|
|
2635
2919
|
* All methods on this session will throw an error once this resolves.
|
|
@@ -2661,6 +2945,30 @@ export declare class LiveSession {
|
|
|
2661
2945
|
sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>;
|
|
2662
2946
|
}
|
|
2663
2947
|
|
|
2948
|
+
/**
|
|
2949
|
+
* An update of the session resumption state.
|
|
2950
|
+
*
|
|
2951
|
+
* This message is only sent if {@link SessionResumptionConfig} was set in the
|
|
2952
|
+
* session setup.
|
|
2953
|
+
*
|
|
2954
|
+
* @beta
|
|
2955
|
+
*/
|
|
2956
|
+
export declare interface LiveSessionResumptionUpdate {
|
|
2957
|
+
type: 'sessionResumptionUpdate';
|
|
2958
|
+
/**
|
|
2959
|
+
* The new handle that represents the state that can be resumed. Empty if `resumable` is false.
|
|
2960
|
+
*/
|
|
2961
|
+
newHandle?: string;
|
|
2962
|
+
/**
|
|
2963
|
+
* Indicates if the session can be resumed at this point.
|
|
2964
|
+
*/
|
|
2965
|
+
resumable?: boolean;
|
|
2966
|
+
/**
|
|
2967
|
+
* The index of the last client message that is included in the state represented by this update.
|
|
2968
|
+
*/
|
|
2969
|
+
lastConsumedClientMessageIndex?: number;
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2664
2972
|
/**
|
|
2665
2973
|
* Content part modality.
|
|
2666
2974
|
* @public
|
|
@@ -2894,6 +3202,21 @@ export declare const ResponseModality: {
|
|
|
2894
3202
|
*/
|
|
2895
3203
|
export declare type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];
|
|
2896
3204
|
|
|
3205
|
+
/**
|
|
3206
|
+
* Configuration options for data retrieval tools.
|
|
3207
|
+
* @public
|
|
3208
|
+
*/
|
|
3209
|
+
export declare interface RetrievalConfig {
|
|
3210
|
+
/**
|
|
3211
|
+
* The location of the user.
|
|
3212
|
+
*/
|
|
3213
|
+
latLng?: LatLng;
|
|
3214
|
+
/**
|
|
3215
|
+
* The language code of the user.
|
|
3216
|
+
*/
|
|
3217
|
+
languageCode?: string;
|
|
3218
|
+
}
|
|
3219
|
+
|
|
2897
3220
|
/**
|
|
2898
3221
|
* @public
|
|
2899
3222
|
*/
|
|
@@ -3193,7 +3516,7 @@ export declare interface Segment {
|
|
|
3193
3516
|
/**
|
|
3194
3517
|
* The zero-based start index of the segment within the specified `Part`,
|
|
3195
3518
|
* measured in UTF-8 bytes. This offset is inclusive, starting from 0 at the
|
|
3196
|
-
* beginning of the part's content (
|
|
3519
|
+
* beginning of the part's content (for example, `Part.text`).
|
|
3197
3520
|
*/
|
|
3198
3521
|
startIndex: number;
|
|
3199
3522
|
/**
|
|
@@ -3208,6 +3531,24 @@ export declare interface Segment {
|
|
|
3208
3531
|
text: string;
|
|
3209
3532
|
}
|
|
3210
3533
|
|
|
3534
|
+
/**
|
|
3535
|
+
* Configuration for the session resumption mechanism.
|
|
3536
|
+
*
|
|
3537
|
+
* @remarks
|
|
3538
|
+
* When included in the session setup, the server will send
|
|
3539
|
+
* {@link LiveSessionResumptionUpdate} messages in the response stream.
|
|
3540
|
+
*
|
|
3541
|
+
* @beta
|
|
3542
|
+
*/
|
|
3543
|
+
export declare interface SessionResumptionConfig {
|
|
3544
|
+
/**
|
|
3545
|
+
* The session resumption handle of the previous session to restore.
|
|
3546
|
+
*
|
|
3547
|
+
* If not present, a new session will be started.
|
|
3548
|
+
*/
|
|
3549
|
+
handle?: string;
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3211
3552
|
/**
|
|
3212
3553
|
* Options that can be provided per-request.
|
|
3213
3554
|
* Extends the base {@link RequestOptions} (like `timeout` and `baseUrl`)
|
|
@@ -3249,6 +3590,25 @@ export declare interface SingleRequestOptions extends RequestOptions {
|
|
|
3249
3590
|
signal?: AbortSignal;
|
|
3250
3591
|
}
|
|
3251
3592
|
|
|
3593
|
+
/**
|
|
3594
|
+
* Configures the sliding window context compression mechanism.
|
|
3595
|
+
*
|
|
3596
|
+
* @remarks
|
|
3597
|
+
* The sliding window discards content at the beginning of the
|
|
3598
|
+
* context window. The resulting context will always begin at
|
|
3599
|
+
* the start of a `user` role turn. System instructions
|
|
3600
|
+
* will always remain at the start of the result.
|
|
3601
|
+
*
|
|
3602
|
+
* @beta
|
|
3603
|
+
*/
|
|
3604
|
+
export declare interface SlidingWindow {
|
|
3605
|
+
/**
|
|
3606
|
+
* The session reduction target, for example, how many tokens the model
|
|
3607
|
+
* should keep.
|
|
3608
|
+
*/
|
|
3609
|
+
targetTokens?: number;
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3252
3612
|
/**
|
|
3253
3613
|
* Configures speech synthesis.
|
|
3254
3614
|
*
|
|
@@ -3495,10 +3855,12 @@ export declare class TemplateGenerativeModel {
|
|
|
3495
3855
|
* @param templateId - The ID of the server-side template to execute.
|
|
3496
3856
|
* @param templateVariables - A key-value map of variables to populate the
|
|
3497
3857
|
* template with.
|
|
3858
|
+
* @param singleRequestOptions - Optional. Options to use for this request.
|
|
3859
|
+
* @param templateToolConfig - Optional. Configuration for tools to use with this request.
|
|
3498
3860
|
*
|
|
3499
3861
|
* @beta
|
|
3500
3862
|
*/
|
|
3501
|
-
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
|
|
3863
|
+
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentResult>;
|
|
3502
3864
|
/**
|
|
3503
3865
|
* Makes a single streaming call to the model and returns an object
|
|
3504
3866
|
* containing an iterable stream that iterates over all chunks in the
|
|
@@ -3508,10 +3870,12 @@ export declare class TemplateGenerativeModel {
|
|
|
3508
3870
|
* @param templateId - The ID of the server-side template to execute.
|
|
3509
3871
|
* @param templateVariables - A key-value map of variables to populate the
|
|
3510
3872
|
* template with.
|
|
3873
|
+
* @param singleRequestOptions - Optional.Options to use for this request.
|
|
3874
|
+
* @param templateToolConfig - Optional. Configuration for tools to use with this request.
|
|
3511
3875
|
*
|
|
3512
3876
|
* @beta
|
|
3513
3877
|
*/
|
|
3514
|
-
generateContentStream(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
|
|
3878
|
+
generateContentStream(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions, templateToolConfig?: TemplateToolConfig): Promise<GenerateContentStreamResult>;
|
|
3515
3879
|
/**
|
|
3516
3880
|
* Starts a {@link TemplateChatSession} that will use this template to
|
|
3517
3881
|
* respond to messages.
|
|
@@ -3576,6 +3940,15 @@ export declare interface TemplateRequestInternal extends Omit<TemplateGenerateCo
|
|
|
3576
3940
|
*/
|
|
3577
3941
|
export declare type TemplateTool = TemplateFunctionDeclarationsTool;
|
|
3578
3942
|
|
|
3943
|
+
/**
|
|
3944
|
+
* Tool configuration for `TemplateGenerativeModel`s.
|
|
3945
|
+
* This config is shared for all tools provided in the server prompt template request.
|
|
3946
|
+
* @public
|
|
3947
|
+
*/
|
|
3948
|
+
export declare interface TemplateToolConfig {
|
|
3949
|
+
retrievalConfig?: RetrievalConfig;
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3579
3952
|
/**
|
|
3580
3953
|
* Content part interface if the part represents a text string.
|
|
3581
3954
|
* @public
|
|
@@ -3680,7 +4053,7 @@ export declare type ThinkingLevel = (typeof ThinkingLevel)[keyof typeof Thinking
|
|
|
3680
4053
|
* Defines a tool that model can call to access external knowledge.
|
|
3681
4054
|
* @public
|
|
3682
4055
|
*/
|
|
3683
|
-
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
4056
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleMapsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
3684
4057
|
|
|
3685
4058
|
/**
|
|
3686
4059
|
* Tool config. This config is shared for all tools provided in the request.
|
|
@@ -3688,6 +4061,7 @@ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExe
|
|
|
3688
4061
|
*/
|
|
3689
4062
|
export declare interface ToolConfig {
|
|
3690
4063
|
functionCallingConfig?: FunctionCallingConfig;
|
|
4064
|
+
retrievalConfig?: RetrievalConfig;
|
|
3691
4065
|
}
|
|
3692
4066
|
|
|
3693
4067
|
/**
|