@firebase/ai 2.7.0-canary.c4a3a5643 → 2.7.0-canary.f9254b6d2
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 +40 -13
- package/dist/ai.d.ts +40 -13
- package/dist/esm/index.esm.js +40 -8
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/constants.d.ts +1 -0
- package/dist/esm/src/methods/live-session.d.ts +2 -2
- package/dist/esm/src/types/content.d.ts +4 -4
- package/dist/esm/src/types/enums.d.ts +4 -4
- package/dist/esm/src/types/internal.d.ts +2 -0
- package/dist/esm/src/types/responses.d.ts +29 -4
- package/dist/index.cjs.js +40 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +40 -8
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +40 -8
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/methods/live-session.d.ts +2 -2
- package/dist/src/types/content.d.ts +4 -4
- package/dist/src/types/enums.d.ts +4 -4
- package/dist/src/types/internal.d.ts +2 -0
- package/dist/src/types/responses.d.ts +29 -4
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ declare interface ApiSettings {
|
|
|
165
165
|
backend: Backend;
|
|
166
166
|
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
167
167
|
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
168
|
+
inferenceMode?: InferenceMode;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
/**
|
|
@@ -409,7 +410,7 @@ export declare interface CitationMetadata {
|
|
|
409
410
|
/**
|
|
410
411
|
* The results of code execution run by the model.
|
|
411
412
|
*
|
|
412
|
-
* @
|
|
413
|
+
* @public
|
|
413
414
|
*/
|
|
414
415
|
export declare interface CodeExecutionResult {
|
|
415
416
|
/**
|
|
@@ -426,7 +427,7 @@ export declare interface CodeExecutionResult {
|
|
|
426
427
|
/**
|
|
427
428
|
* Represents the code execution result from the model.
|
|
428
429
|
*
|
|
429
|
-
* @
|
|
430
|
+
* @public
|
|
430
431
|
*/
|
|
431
432
|
export declare interface CodeExecutionResultPart {
|
|
432
433
|
text?: never;
|
|
@@ -599,7 +600,7 @@ export declare interface ErrorDetails {
|
|
|
599
600
|
/**
|
|
600
601
|
* An interface for executable code returned by the model.
|
|
601
602
|
*
|
|
602
|
-
* @
|
|
603
|
+
* @public
|
|
603
604
|
*/
|
|
604
605
|
export declare interface ExecutableCode {
|
|
605
606
|
/**
|
|
@@ -615,7 +616,7 @@ export declare interface ExecutableCode {
|
|
|
615
616
|
/**
|
|
616
617
|
* Represents the code that is executed by the model.
|
|
617
618
|
*
|
|
618
|
-
* @
|
|
619
|
+
* @public
|
|
619
620
|
*/
|
|
620
621
|
export declare interface ExecutableCodePart {
|
|
621
622
|
text?: never;
|
|
@@ -1923,7 +1924,7 @@ export declare class IntegerSchema extends Schema {
|
|
|
1923
1924
|
/**
|
|
1924
1925
|
* The programming language of the code.
|
|
1925
1926
|
*
|
|
1926
|
-
* @
|
|
1927
|
+
* @public
|
|
1927
1928
|
*/
|
|
1928
1929
|
export declare const Language: {
|
|
1929
1930
|
UNSPECIFIED: string;
|
|
@@ -1933,7 +1934,7 @@ export declare const Language: {
|
|
|
1933
1934
|
/**
|
|
1934
1935
|
* The programming language of the code.
|
|
1935
1936
|
*
|
|
1936
|
-
* @
|
|
1937
|
+
* @public
|
|
1937
1938
|
*/
|
|
1938
1939
|
export declare type Language = (typeof Language)[keyof typeof Language];
|
|
1939
1940
|
|
|
@@ -2124,6 +2125,7 @@ export declare const LiveResponseType: {
|
|
|
2124
2125
|
SERVER_CONTENT: string;
|
|
2125
2126
|
TOOL_CALL: string;
|
|
2126
2127
|
TOOL_CALL_CANCELLATION: string;
|
|
2128
|
+
GOING_AWAY_NOTICE: string;
|
|
2127
2129
|
};
|
|
2128
2130
|
|
|
2129
2131
|
/**
|
|
@@ -2166,6 +2168,19 @@ export declare interface LiveServerContent {
|
|
|
2166
2168
|
outputTranscription?: Transcription;
|
|
2167
2169
|
}
|
|
2168
2170
|
|
|
2171
|
+
/**
|
|
2172
|
+
* Notification that the server will not be able to service the client soon.
|
|
2173
|
+
*
|
|
2174
|
+
* @beta
|
|
2175
|
+
*/
|
|
2176
|
+
export declare interface LiveServerGoingAwayNotice {
|
|
2177
|
+
type: 'goingAwayNotice';
|
|
2178
|
+
/**
|
|
2179
|
+
* The remaining time (in seconds) before the connection will be terminated.
|
|
2180
|
+
*/
|
|
2181
|
+
timeLeft: number;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2169
2184
|
/**
|
|
2170
2185
|
* A request from the model for the client to execute one or more functions.
|
|
2171
2186
|
*
|
|
@@ -2294,7 +2309,7 @@ export declare class LiveSession {
|
|
|
2294
2309
|
*
|
|
2295
2310
|
* @beta
|
|
2296
2311
|
*/
|
|
2297
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
|
|
2312
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
2298
2313
|
/**
|
|
2299
2314
|
* Closes this session.
|
|
2300
2315
|
* All methods on this session will throw an error once this resolves.
|
|
@@ -2440,7 +2455,7 @@ export declare interface OnDeviceParams {
|
|
|
2440
2455
|
/**
|
|
2441
2456
|
* Represents the result of the code execution.
|
|
2442
2457
|
*
|
|
2443
|
-
* @
|
|
2458
|
+
* @public
|
|
2444
2459
|
*/
|
|
2445
2460
|
export declare const Outcome: {
|
|
2446
2461
|
UNSPECIFIED: string;
|
|
@@ -2452,7 +2467,7 @@ export declare const Outcome: {
|
|
|
2452
2467
|
/**
|
|
2453
2468
|
* Represents the result of the code execution.
|
|
2454
2469
|
*
|
|
2455
|
-
* @
|
|
2470
|
+
* @public
|
|
2456
2471
|
*/
|
|
2457
2472
|
export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
2458
2473
|
|
|
@@ -3208,7 +3223,7 @@ export declare interface URLContext {
|
|
|
3208
3223
|
/**
|
|
3209
3224
|
* Metadata related to {@link URLContextTool}.
|
|
3210
3225
|
*
|
|
3211
|
-
* @
|
|
3226
|
+
* @public
|
|
3212
3227
|
*/
|
|
3213
3228
|
export declare interface URLContextMetadata {
|
|
3214
3229
|
/**
|
|
@@ -3234,7 +3249,7 @@ export declare interface URLContextTool {
|
|
|
3234
3249
|
/**
|
|
3235
3250
|
* Metadata for a single URL retrieved by the {@link URLContextTool} tool.
|
|
3236
3251
|
*
|
|
3237
|
-
* @
|
|
3252
|
+
* @public
|
|
3238
3253
|
*/
|
|
3239
3254
|
export declare interface URLMetadata {
|
|
3240
3255
|
/**
|
|
@@ -3262,7 +3277,7 @@ export declare interface URLMetadata {
|
|
|
3262
3277
|
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
3263
3278
|
* <br/>
|
|
3264
3279
|
*
|
|
3265
|
-
* @
|
|
3280
|
+
* @public
|
|
3266
3281
|
*/
|
|
3267
3282
|
export declare const URLRetrievalStatus: {
|
|
3268
3283
|
/**
|
|
@@ -3302,7 +3317,7 @@ export declare const URLRetrievalStatus: {
|
|
|
3302
3317
|
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
3303
3318
|
* <br/>
|
|
3304
3319
|
*
|
|
3305
|
-
* @
|
|
3320
|
+
* @public
|
|
3306
3321
|
*/
|
|
3307
3322
|
export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
|
|
3308
3323
|
|
|
@@ -3329,6 +3344,18 @@ export declare interface UsageMetadata {
|
|
|
3329
3344
|
* A list of tokens used by tools, broken down by modality.
|
|
3330
3345
|
*/
|
|
3331
3346
|
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
3347
|
+
/**
|
|
3348
|
+
* The number of tokens in the prompt that were served from the cache.
|
|
3349
|
+
* If implicit caching is not active or no content was cached,
|
|
3350
|
+
* this will be 0.
|
|
3351
|
+
*/
|
|
3352
|
+
cachedContentTokenCount?: number;
|
|
3353
|
+
/**
|
|
3354
|
+
* Detailed breakdown of the cached tokens by modality (for example, text or
|
|
3355
|
+
* image). This list provides granular insight into which parts of
|
|
3356
|
+
* the content were cached.
|
|
3357
|
+
*/
|
|
3358
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
3332
3359
|
}
|
|
3333
3360
|
|
|
3334
3361
|
/**
|
package/dist/ai.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ declare interface ApiSettings {
|
|
|
202
202
|
backend: Backend;
|
|
203
203
|
getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
|
|
204
204
|
getAppCheckToken?: () => Promise<AppCheckTokenResult>;
|
|
205
|
+
inferenceMode?: InferenceMode;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
/**
|
|
@@ -461,7 +462,7 @@ export declare interface CitationMetadata {
|
|
|
461
462
|
/**
|
|
462
463
|
* The results of code execution run by the model.
|
|
463
464
|
*
|
|
464
|
-
* @
|
|
465
|
+
* @public
|
|
465
466
|
*/
|
|
466
467
|
export declare interface CodeExecutionResult {
|
|
467
468
|
/**
|
|
@@ -478,7 +479,7 @@ export declare interface CodeExecutionResult {
|
|
|
478
479
|
/**
|
|
479
480
|
* Represents the code execution result from the model.
|
|
480
481
|
*
|
|
481
|
-
* @
|
|
482
|
+
* @public
|
|
482
483
|
*/
|
|
483
484
|
export declare interface CodeExecutionResultPart {
|
|
484
485
|
text?: never;
|
|
@@ -654,7 +655,7 @@ export declare interface ErrorDetails {
|
|
|
654
655
|
/**
|
|
655
656
|
* An interface for executable code returned by the model.
|
|
656
657
|
*
|
|
657
|
-
* @
|
|
658
|
+
* @public
|
|
658
659
|
*/
|
|
659
660
|
export declare interface ExecutableCode {
|
|
660
661
|
/**
|
|
@@ -670,7 +671,7 @@ export declare interface ExecutableCode {
|
|
|
670
671
|
/**
|
|
671
672
|
* Represents the code that is executed by the model.
|
|
672
673
|
*
|
|
673
|
-
* @
|
|
674
|
+
* @public
|
|
674
675
|
*/
|
|
675
676
|
export declare interface ExecutableCodePart {
|
|
676
677
|
text?: never;
|
|
@@ -2053,7 +2054,7 @@ export declare class IntegerSchema extends Schema {
|
|
|
2053
2054
|
/**
|
|
2054
2055
|
* The programming language of the code.
|
|
2055
2056
|
*
|
|
2056
|
-
* @
|
|
2057
|
+
* @public
|
|
2057
2058
|
*/
|
|
2058
2059
|
export declare const Language: {
|
|
2059
2060
|
UNSPECIFIED: string;
|
|
@@ -2063,7 +2064,7 @@ export declare const Language: {
|
|
|
2063
2064
|
/**
|
|
2064
2065
|
* The programming language of the code.
|
|
2065
2066
|
*
|
|
2066
|
-
* @
|
|
2067
|
+
* @public
|
|
2067
2068
|
*/
|
|
2068
2069
|
export declare type Language = (typeof Language)[keyof typeof Language];
|
|
2069
2070
|
|
|
@@ -2264,6 +2265,7 @@ export declare const LiveResponseType: {
|
|
|
2264
2265
|
SERVER_CONTENT: string;
|
|
2265
2266
|
TOOL_CALL: string;
|
|
2266
2267
|
TOOL_CALL_CANCELLATION: string;
|
|
2268
|
+
GOING_AWAY_NOTICE: string;
|
|
2267
2269
|
};
|
|
2268
2270
|
|
|
2269
2271
|
/**
|
|
@@ -2306,6 +2308,19 @@ export declare interface LiveServerContent {
|
|
|
2306
2308
|
outputTranscription?: Transcription;
|
|
2307
2309
|
}
|
|
2308
2310
|
|
|
2311
|
+
/**
|
|
2312
|
+
* Notification that the server will not be able to service the client soon.
|
|
2313
|
+
*
|
|
2314
|
+
* @beta
|
|
2315
|
+
*/
|
|
2316
|
+
export declare interface LiveServerGoingAwayNotice {
|
|
2317
|
+
type: 'goingAwayNotice';
|
|
2318
|
+
/**
|
|
2319
|
+
* The remaining time (in seconds) before the connection will be terminated.
|
|
2320
|
+
*/
|
|
2321
|
+
timeLeft: number;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2309
2324
|
/**
|
|
2310
2325
|
* A request from the model for the client to execute one or more functions.
|
|
2311
2326
|
*
|
|
@@ -2437,7 +2452,7 @@ export declare class LiveSession {
|
|
|
2437
2452
|
*
|
|
2438
2453
|
* @beta
|
|
2439
2454
|
*/
|
|
2440
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
|
|
2455
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
2441
2456
|
/**
|
|
2442
2457
|
* Closes this session.
|
|
2443
2458
|
* All methods on this session will throw an error once this resolves.
|
|
@@ -2586,7 +2601,7 @@ export declare interface OnDeviceParams {
|
|
|
2586
2601
|
/**
|
|
2587
2602
|
* Represents the result of the code execution.
|
|
2588
2603
|
*
|
|
2589
|
-
* @
|
|
2604
|
+
* @public
|
|
2590
2605
|
*/
|
|
2591
2606
|
export declare const Outcome: {
|
|
2592
2607
|
UNSPECIFIED: string;
|
|
@@ -2598,7 +2613,7 @@ export declare const Outcome: {
|
|
|
2598
2613
|
/**
|
|
2599
2614
|
* Represents the result of the code execution.
|
|
2600
2615
|
*
|
|
2601
|
-
* @
|
|
2616
|
+
* @public
|
|
2602
2617
|
*/
|
|
2603
2618
|
export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
2604
2619
|
|
|
@@ -3371,7 +3386,7 @@ export declare interface URLContext {
|
|
|
3371
3386
|
/**
|
|
3372
3387
|
* Metadata related to {@link URLContextTool}.
|
|
3373
3388
|
*
|
|
3374
|
-
* @
|
|
3389
|
+
* @public
|
|
3375
3390
|
*/
|
|
3376
3391
|
export declare interface URLContextMetadata {
|
|
3377
3392
|
/**
|
|
@@ -3397,7 +3412,7 @@ export declare interface URLContextTool {
|
|
|
3397
3412
|
/**
|
|
3398
3413
|
* Metadata for a single URL retrieved by the {@link URLContextTool} tool.
|
|
3399
3414
|
*
|
|
3400
|
-
* @
|
|
3415
|
+
* @public
|
|
3401
3416
|
*/
|
|
3402
3417
|
export declare interface URLMetadata {
|
|
3403
3418
|
/**
|
|
@@ -3425,7 +3440,7 @@ export declare interface URLMetadata {
|
|
|
3425
3440
|
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
3426
3441
|
* <br/>
|
|
3427
3442
|
*
|
|
3428
|
-
* @
|
|
3443
|
+
* @public
|
|
3429
3444
|
*/
|
|
3430
3445
|
export declare const URLRetrievalStatus: {
|
|
3431
3446
|
/**
|
|
@@ -3465,7 +3480,7 @@ export declare const URLRetrievalStatus: {
|
|
|
3465
3480
|
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
3466
3481
|
* <br/>
|
|
3467
3482
|
*
|
|
3468
|
-
* @
|
|
3483
|
+
* @public
|
|
3469
3484
|
*/
|
|
3470
3485
|
export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
|
|
3471
3486
|
|
|
@@ -3492,6 +3507,18 @@ export declare interface UsageMetadata {
|
|
|
3492
3507
|
* A list of tokens used by tools, broken down by modality.
|
|
3493
3508
|
*/
|
|
3494
3509
|
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
3510
|
+
/**
|
|
3511
|
+
* The number of tokens in the prompt that were served from the cache.
|
|
3512
|
+
* If implicit caching is not active or no content was cached,
|
|
3513
|
+
* this will be 0.
|
|
3514
|
+
*/
|
|
3515
|
+
cachedContentTokenCount?: number;
|
|
3516
|
+
/**
|
|
3517
|
+
* Detailed breakdown of the cached tokens by modality (for example, text or
|
|
3518
|
+
* image). This list provides granular insight into which parts of
|
|
3519
|
+
* the content were cached.
|
|
3520
|
+
*/
|
|
3521
|
+
cacheTokensDetails?: ModalityTokenCount[];
|
|
3495
3522
|
}
|
|
3496
3523
|
|
|
3497
3524
|
/**
|
package/dist/esm/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
|
|
|
4
4
|
import { Logger } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
var name = "@firebase/ai";
|
|
7
|
-
var version = "2.7.0-canary.
|
|
7
|
+
var version = "2.7.0-canary.f9254b6d2";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -28,6 +28,7 @@ const DEFAULT_DOMAIN = 'firebasevertexai.googleapis.com';
|
|
|
28
28
|
const DEFAULT_API_VERSION = 'v1beta';
|
|
29
29
|
const PACKAGE_VERSION = version;
|
|
30
30
|
const LANGUAGE_TAG = 'gl-js';
|
|
31
|
+
const HYBRID_TAG = 'hybrid';
|
|
31
32
|
const DEFAULT_FETCH_TIMEOUT_MS = 180 * 1000;
|
|
32
33
|
/**
|
|
33
34
|
* Defines the name of the default in-cloud model to use for hybrid inference.
|
|
@@ -391,7 +392,7 @@ const InferenceSource = {
|
|
|
391
392
|
/**
|
|
392
393
|
* Represents the result of the code execution.
|
|
393
394
|
*
|
|
394
|
-
* @
|
|
395
|
+
* @public
|
|
395
396
|
*/
|
|
396
397
|
const Outcome = {
|
|
397
398
|
UNSPECIFIED: 'OUTCOME_UNSPECIFIED',
|
|
@@ -402,7 +403,7 @@ const Outcome = {
|
|
|
402
403
|
/**
|
|
403
404
|
* The programming language of the code.
|
|
404
405
|
*
|
|
405
|
-
* @
|
|
406
|
+
* @public
|
|
406
407
|
*/
|
|
407
408
|
const Language = {
|
|
408
409
|
UNSPECIFIED: 'LANGUAGE_UNSPECIFIED',
|
|
@@ -453,7 +454,7 @@ const ThinkingLevel = {
|
|
|
453
454
|
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
454
455
|
* <br/>
|
|
455
456
|
*
|
|
456
|
-
* @
|
|
457
|
+
* @public
|
|
457
458
|
*/
|
|
458
459
|
const URLRetrievalStatus = {
|
|
459
460
|
/**
|
|
@@ -485,7 +486,8 @@ const URLRetrievalStatus = {
|
|
|
485
486
|
const LiveResponseType = {
|
|
486
487
|
SERVER_CONTENT: 'serverContent',
|
|
487
488
|
TOOL_CALL: 'toolCall',
|
|
488
|
-
TOOL_CALL_CANCELLATION: 'toolCallCancellation'
|
|
489
|
+
TOOL_CALL_CANCELLATION: 'toolCallCancellation',
|
|
490
|
+
GOING_AWAY_NOTICE: 'goingAwayNotice'
|
|
489
491
|
};
|
|
490
492
|
|
|
491
493
|
/**
|
|
@@ -1512,16 +1514,25 @@ class WebSocketUrl {
|
|
|
1512
1514
|
/**
|
|
1513
1515
|
* Log language and "fire/version" to x-goog-api-client
|
|
1514
1516
|
*/
|
|
1515
|
-
function getClientHeaders() {
|
|
1517
|
+
function getClientHeaders(url) {
|
|
1516
1518
|
const loggingTags = [];
|
|
1517
1519
|
loggingTags.push(`${LANGUAGE_TAG}/${PACKAGE_VERSION}`);
|
|
1518
1520
|
loggingTags.push(`fire/${PACKAGE_VERSION}`);
|
|
1521
|
+
/**
|
|
1522
|
+
* No call would be made if ONLY_ON_DEVICE.
|
|
1523
|
+
* ONLY_IN_CLOUD does not indicate an intention to use hybrid.
|
|
1524
|
+
*/
|
|
1525
|
+
if (url.params.apiSettings.inferenceMode === InferenceMode.PREFER_ON_DEVICE ||
|
|
1526
|
+
url.params.apiSettings.inferenceMode === InferenceMode.PREFER_IN_CLOUD) {
|
|
1527
|
+
// No version
|
|
1528
|
+
loggingTags.push(HYBRID_TAG);
|
|
1529
|
+
}
|
|
1519
1530
|
return loggingTags.join(' ');
|
|
1520
1531
|
}
|
|
1521
1532
|
async function getHeaders(url) {
|
|
1522
1533
|
const headers = new Headers();
|
|
1523
1534
|
headers.append('Content-Type', 'application/json');
|
|
1524
|
-
headers.append('x-goog-api-client', getClientHeaders());
|
|
1535
|
+
headers.append('x-goog-api-client', getClientHeaders(url));
|
|
1525
1536
|
headers.append('x-goog-api-key', url.params.apiSettings.apiKey);
|
|
1526
1537
|
if (url.params.apiSettings.automaticDataCollectionEnabled) {
|
|
1527
1538
|
headers.append('X-Firebase-Appid', url.params.apiSettings.appId);
|
|
@@ -3138,6 +3149,13 @@ class LiveSession {
|
|
|
3138
3149
|
...message.toolCallCancellation
|
|
3139
3150
|
};
|
|
3140
3151
|
}
|
|
3152
|
+
else if ('goAway' in message) {
|
|
3153
|
+
const notice = message.goAway;
|
|
3154
|
+
yield {
|
|
3155
|
+
type: LiveResponseType.GOING_AWAY_NOTICE,
|
|
3156
|
+
timeLeft: parseDuration(notice.timeLeft)
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3141
3159
|
else {
|
|
3142
3160
|
logger.warn(`Received an unknown message type from the server: ${JSON.stringify(message)}`);
|
|
3143
3161
|
}
|
|
@@ -3216,6 +3234,18 @@ class LiveSession {
|
|
|
3216
3234
|
}
|
|
3217
3235
|
}
|
|
3218
3236
|
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Parses a duration string (e.g. "3.000000001s") into a number of seconds.
|
|
3239
|
+
*
|
|
3240
|
+
* @param duration - The duration string to parse.
|
|
3241
|
+
* @returns The duration in seconds.
|
|
3242
|
+
*/
|
|
3243
|
+
function parseDuration(duration) {
|
|
3244
|
+
if (!duration || !duration.endsWith('s')) {
|
|
3245
|
+
return 0;
|
|
3246
|
+
}
|
|
3247
|
+
return Number(duration.slice(0, -1)); // slice removes the trailing 's'.
|
|
3248
|
+
}
|
|
3219
3249
|
|
|
3220
3250
|
/**
|
|
3221
3251
|
* @license
|
|
@@ -4463,7 +4493,9 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4463
4493
|
* chromeAdapterFactory() method.
|
|
4464
4494
|
*/
|
|
4465
4495
|
const chromeAdapter = ai.chromeAdapterFactory?.(hybridParams.mode, typeof window === 'undefined' ? undefined : window, hybridParams.onDeviceParams);
|
|
4466
|
-
|
|
4496
|
+
const generativeModel = new GenerativeModel(ai, inCloudParams, requestOptions, chromeAdapter);
|
|
4497
|
+
generativeModel._apiSettings.inferenceMode = hybridParams.mode;
|
|
4498
|
+
return generativeModel;
|
|
4467
4499
|
}
|
|
4468
4500
|
/**
|
|
4469
4501
|
* Returns an {@link ImagenModel} class with methods for using Imagen.
|