@firebase/ai 2.7.0-canary.691a506ec → 2.7.0-canary.8123231a1
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 +15 -1
- package/dist/ai.d.ts +15 -1
- package/dist/esm/index.esm.js +22 -2
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/methods/live-session.d.ts +2 -2
- package/dist/esm/src/types/responses.d.ts +13 -0
- package/dist/index.cjs.js +22 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +22 -2
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +22 -2
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/methods/live-session.d.ts +2 -2
- package/dist/src/types/responses.d.ts +13 -0
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -2125,6 +2125,7 @@ export declare const LiveResponseType: {
|
|
|
2125
2125
|
SERVER_CONTENT: string;
|
|
2126
2126
|
TOOL_CALL: string;
|
|
2127
2127
|
TOOL_CALL_CANCELLATION: string;
|
|
2128
|
+
GOING_AWAY_NOTICE: string;
|
|
2128
2129
|
};
|
|
2129
2130
|
|
|
2130
2131
|
/**
|
|
@@ -2167,6 +2168,19 @@ export declare interface LiveServerContent {
|
|
|
2167
2168
|
outputTranscription?: Transcription;
|
|
2168
2169
|
}
|
|
2169
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
|
+
|
|
2170
2184
|
/**
|
|
2171
2185
|
* A request from the model for the client to execute one or more functions.
|
|
2172
2186
|
*
|
|
@@ -2295,7 +2309,7 @@ export declare class LiveSession {
|
|
|
2295
2309
|
*
|
|
2296
2310
|
* @beta
|
|
2297
2311
|
*/
|
|
2298
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
|
|
2312
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
2299
2313
|
/**
|
|
2300
2314
|
* Closes this session.
|
|
2301
2315
|
* All methods on this session will throw an error once this resolves.
|
package/dist/ai.d.ts
CHANGED
|
@@ -2265,6 +2265,7 @@ export declare const LiveResponseType: {
|
|
|
2265
2265
|
SERVER_CONTENT: string;
|
|
2266
2266
|
TOOL_CALL: string;
|
|
2267
2267
|
TOOL_CALL_CANCELLATION: string;
|
|
2268
|
+
GOING_AWAY_NOTICE: string;
|
|
2268
2269
|
};
|
|
2269
2270
|
|
|
2270
2271
|
/**
|
|
@@ -2307,6 +2308,19 @@ export declare interface LiveServerContent {
|
|
|
2307
2308
|
outputTranscription?: Transcription;
|
|
2308
2309
|
}
|
|
2309
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
|
+
|
|
2310
2324
|
/**
|
|
2311
2325
|
* A request from the model for the client to execute one or more functions.
|
|
2312
2326
|
*
|
|
@@ -2438,7 +2452,7 @@ export declare class LiveSession {
|
|
|
2438
2452
|
*
|
|
2439
2453
|
* @beta
|
|
2440
2454
|
*/
|
|
2441
|
-
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>;
|
|
2455
|
+
receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation | LiveServerGoingAwayNotice>;
|
|
2442
2456
|
/**
|
|
2443
2457
|
* Closes this session.
|
|
2444
2458
|
* All methods on this session will throw an error once this resolves.
|
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.8123231a1";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -486,7 +486,8 @@ const URLRetrievalStatus = {
|
|
|
486
486
|
const LiveResponseType = {
|
|
487
487
|
SERVER_CONTENT: 'serverContent',
|
|
488
488
|
TOOL_CALL: 'toolCall',
|
|
489
|
-
TOOL_CALL_CANCELLATION: 'toolCallCancellation'
|
|
489
|
+
TOOL_CALL_CANCELLATION: 'toolCallCancellation',
|
|
490
|
+
GOING_AWAY_NOTICE: 'goingAwayNotice'
|
|
490
491
|
};
|
|
491
492
|
|
|
492
493
|
/**
|
|
@@ -3148,6 +3149,13 @@ class LiveSession {
|
|
|
3148
3149
|
...message.toolCallCancellation
|
|
3149
3150
|
};
|
|
3150
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
|
+
}
|
|
3151
3159
|
else {
|
|
3152
3160
|
logger.warn(`Received an unknown message type from the server: ${JSON.stringify(message)}`);
|
|
3153
3161
|
}
|
|
@@ -3226,6 +3234,18 @@ class LiveSession {
|
|
|
3226
3234
|
}
|
|
3227
3235
|
}
|
|
3228
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
|
+
}
|
|
3229
3249
|
|
|
3230
3250
|
/**
|
|
3231
3251
|
* @license
|