@firebase/ai 2.4.0-20251007135320 → 2.4.0-canary.22e0a1adb
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 +87 -9
- package/dist/ai.d.ts +87 -9
- package/dist/esm/index.esm.js +195 -66
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/methods/chrome-adapter.d.ts +1 -1
- package/dist/esm/src/methods/live-session.d.ts +64 -9
- package/dist/esm/src/requests/hybrid-helpers.d.ts +7 -2
- package/dist/esm/src/requests/response-helpers.d.ts +2 -2
- package/dist/esm/src/requests/stream-reader.d.ts +2 -1
- package/dist/esm/src/types/enums.d.ts +15 -0
- package/dist/esm/src/types/live-responses.d.ts +7 -1
- package/dist/esm/src/types/responses.d.ts +7 -1
- package/dist/index.cjs.js +195 -65
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +175 -58
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +175 -59
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/methods/chrome-adapter.d.ts +1 -1
- package/dist/src/methods/live-session.d.ts +64 -9
- package/dist/src/requests/hybrid-helpers.d.ts +7 -2
- package/dist/src/requests/response-helpers.d.ts +2 -2
- package/dist/src/requests/stream-reader.d.ts +2 -1
- package/dist/src/types/enums.d.ts +15 -0
- package/dist/src/types/live-responses.d.ts +7 -1
- package/dist/src/types/responses.d.ts +7 -1
- package/package.json +8 -8
package/dist/ai-public.d.ts
CHANGED
|
@@ -558,6 +558,12 @@ export declare interface EnhancedGenerateContentResponse extends GenerateContent
|
|
|
558
558
|
* set to `true`.
|
|
559
559
|
*/
|
|
560
560
|
thoughtSummary: () => string | undefined;
|
|
561
|
+
/**
|
|
562
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
563
|
+
*
|
|
564
|
+
* @beta
|
|
565
|
+
*/
|
|
566
|
+
inferenceSource?: InferenceSource;
|
|
561
567
|
}
|
|
562
568
|
|
|
563
569
|
/**
|
|
@@ -1833,6 +1839,23 @@ export declare const InferenceMode: {
|
|
|
1833
1839
|
*/
|
|
1834
1840
|
export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
1835
1841
|
|
|
1842
|
+
/**
|
|
1843
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
1844
|
+
*
|
|
1845
|
+
* @beta
|
|
1846
|
+
*/
|
|
1847
|
+
export declare const InferenceSource: {
|
|
1848
|
+
readonly ON_DEVICE: "on_device";
|
|
1849
|
+
readonly IN_CLOUD: "in_cloud";
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
1854
|
+
*
|
|
1855
|
+
* @beta
|
|
1856
|
+
*/
|
|
1857
|
+
export declare type InferenceSource = (typeof InferenceSource)[keyof typeof InferenceSource];
|
|
1858
|
+
|
|
1836
1859
|
/**
|
|
1837
1860
|
* Content part interface if the part represents an image.
|
|
1838
1861
|
* @public
|
|
@@ -2140,32 +2163,65 @@ export declare class LiveSession {
|
|
|
2140
2163
|
*/
|
|
2141
2164
|
send(request: string | Array<string | Part>, turnComplete?: boolean): Promise<void>;
|
|
2142
2165
|
/**
|
|
2143
|
-
* Sends
|
|
2166
|
+
* Sends text to the server in realtime.
|
|
2144
2167
|
*
|
|
2145
|
-
* @
|
|
2168
|
+
* @example
|
|
2169
|
+
* ```javascript
|
|
2170
|
+
* liveSession.sendTextRealtime("Hello, how are you?");
|
|
2171
|
+
* ```
|
|
2172
|
+
*
|
|
2173
|
+
* @param text - The text data to send.
|
|
2146
2174
|
* @throws If this session has been closed.
|
|
2147
2175
|
*
|
|
2148
2176
|
* @beta
|
|
2149
2177
|
*/
|
|
2150
|
-
|
|
2178
|
+
sendTextRealtime(text: string): Promise<void>;
|
|
2151
2179
|
/**
|
|
2152
|
-
* Sends
|
|
2180
|
+
* Sends audio data to the server in realtime.
|
|
2153
2181
|
*
|
|
2154
|
-
* @
|
|
2182
|
+
* @remarks The server requires that the audio data is base64-encoded 16-bit PCM at 16kHz
|
|
2183
|
+
* little-endian.
|
|
2184
|
+
*
|
|
2185
|
+
* @example
|
|
2186
|
+
* ```javascript
|
|
2187
|
+
* // const pcmData = ... base64-encoded 16-bit PCM at 16kHz little-endian.
|
|
2188
|
+
* const blob = { mimeType: "audio/pcm", data: pcmData };
|
|
2189
|
+
* liveSession.sendAudioRealtime(blob);
|
|
2190
|
+
* ```
|
|
2191
|
+
*
|
|
2192
|
+
* @param blob - The base64-encoded PCM data to send to the server in realtime.
|
|
2155
2193
|
* @throws If this session has been closed.
|
|
2156
2194
|
*
|
|
2157
2195
|
* @beta
|
|
2158
2196
|
*/
|
|
2159
|
-
|
|
2197
|
+
sendAudioRealtime(blob: GenerativeContentBlob): Promise<void>;
|
|
2160
2198
|
/**
|
|
2161
|
-
* Sends
|
|
2199
|
+
* Sends video data to the server in realtime.
|
|
2162
2200
|
*
|
|
2163
|
-
* @
|
|
2201
|
+
* @remarks The server requires that the video is sent as individual video frames at 1 FPS. It
|
|
2202
|
+
* is recommended to set `mimeType` to `image/jpeg`.
|
|
2203
|
+
*
|
|
2204
|
+
* @example
|
|
2205
|
+
* ```javascript
|
|
2206
|
+
* // const videoFrame = ... base64-encoded JPEG data
|
|
2207
|
+
* const blob = { mimeType: "image/jpeg", data: videoFrame };
|
|
2208
|
+
* liveSession.sendVideoRealtime(blob);
|
|
2209
|
+
* ```
|
|
2210
|
+
* @param blob - The base64-encoded video data to send to the server in realtime.
|
|
2164
2211
|
* @throws If this session has been closed.
|
|
2165
2212
|
*
|
|
2166
2213
|
* @beta
|
|
2167
2214
|
*/
|
|
2168
|
-
|
|
2215
|
+
sendVideoRealtime(blob: GenerativeContentBlob): Promise<void>;
|
|
2216
|
+
/**
|
|
2217
|
+
* Sends function responses to the server.
|
|
2218
|
+
*
|
|
2219
|
+
* @param functionResponses - The function responses to send.
|
|
2220
|
+
* @throws If this session has been closed.
|
|
2221
|
+
*
|
|
2222
|
+
* @beta
|
|
2223
|
+
*/
|
|
2224
|
+
sendFunctionResponses(functionResponses: FunctionResponse[]): Promise<void>;
|
|
2169
2225
|
/**
|
|
2170
2226
|
* Yields messages received from the server.
|
|
2171
2227
|
* This can only be used by one consumer at a time.
|
|
@@ -2183,6 +2239,28 @@ export declare class LiveSession {
|
|
|
2183
2239
|
* @beta
|
|
2184
2240
|
*/
|
|
2185
2241
|
close(): Promise<void>;
|
|
2242
|
+
/**
|
|
2243
|
+
* Sends realtime input to the server.
|
|
2244
|
+
*
|
|
2245
|
+
* @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead.
|
|
2246
|
+
*
|
|
2247
|
+
* @param mediaChunks - The media chunks to send.
|
|
2248
|
+
* @throws If this session has been closed.
|
|
2249
|
+
*
|
|
2250
|
+
* @beta
|
|
2251
|
+
*/
|
|
2252
|
+
sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
|
|
2253
|
+
/**
|
|
2254
|
+
* @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead.
|
|
2255
|
+
*
|
|
2256
|
+
* Sends a stream of {@link GenerativeContentBlob}.
|
|
2257
|
+
*
|
|
2258
|
+
* @param mediaChunkStream - The stream of {@link GenerativeContentBlob} to send.
|
|
2259
|
+
* @throws If this session has been closed.
|
|
2260
|
+
*
|
|
2261
|
+
* @beta
|
|
2262
|
+
*/
|
|
2263
|
+
sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>;
|
|
2186
2264
|
}
|
|
2187
2265
|
|
|
2188
2266
|
/**
|
package/dist/ai.d.ts
CHANGED
|
@@ -604,6 +604,12 @@ export declare interface EnhancedGenerateContentResponse extends GenerateContent
|
|
|
604
604
|
* set to `true`.
|
|
605
605
|
*/
|
|
606
606
|
thoughtSummary: () => string | undefined;
|
|
607
|
+
/**
|
|
608
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
609
|
+
*
|
|
610
|
+
* @beta
|
|
611
|
+
*/
|
|
612
|
+
inferenceSource?: InferenceSource;
|
|
607
613
|
}
|
|
608
614
|
|
|
609
615
|
/**
|
|
@@ -1945,6 +1951,23 @@ export declare const InferenceMode: {
|
|
|
1945
1951
|
*/
|
|
1946
1952
|
export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
1947
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
1956
|
+
*
|
|
1957
|
+
* @beta
|
|
1958
|
+
*/
|
|
1959
|
+
export declare const InferenceSource: {
|
|
1960
|
+
readonly ON_DEVICE: "on_device";
|
|
1961
|
+
readonly IN_CLOUD: "in_cloud";
|
|
1962
|
+
};
|
|
1963
|
+
|
|
1964
|
+
/**
|
|
1965
|
+
* Indicates whether inference happened on-device or in-cloud.
|
|
1966
|
+
*
|
|
1967
|
+
* @beta
|
|
1968
|
+
*/
|
|
1969
|
+
export declare type InferenceSource = (typeof InferenceSource)[keyof typeof InferenceSource];
|
|
1970
|
+
|
|
1948
1971
|
/**
|
|
1949
1972
|
* Content part interface if the part represents an image.
|
|
1950
1973
|
* @public
|
|
@@ -2268,32 +2291,65 @@ export declare class LiveSession {
|
|
|
2268
2291
|
*/
|
|
2269
2292
|
send(request: string | Array<string | Part>, turnComplete?: boolean): Promise<void>;
|
|
2270
2293
|
/**
|
|
2271
|
-
* Sends
|
|
2294
|
+
* Sends text to the server in realtime.
|
|
2272
2295
|
*
|
|
2273
|
-
* @
|
|
2296
|
+
* @example
|
|
2297
|
+
* ```javascript
|
|
2298
|
+
* liveSession.sendTextRealtime("Hello, how are you?");
|
|
2299
|
+
* ```
|
|
2300
|
+
*
|
|
2301
|
+
* @param text - The text data to send.
|
|
2274
2302
|
* @throws If this session has been closed.
|
|
2275
2303
|
*
|
|
2276
2304
|
* @beta
|
|
2277
2305
|
*/
|
|
2278
|
-
|
|
2306
|
+
sendTextRealtime(text: string): Promise<void>;
|
|
2279
2307
|
/**
|
|
2280
|
-
* Sends
|
|
2308
|
+
* Sends audio data to the server in realtime.
|
|
2281
2309
|
*
|
|
2282
|
-
* @
|
|
2310
|
+
* @remarks The server requires that the audio data is base64-encoded 16-bit PCM at 16kHz
|
|
2311
|
+
* little-endian.
|
|
2312
|
+
*
|
|
2313
|
+
* @example
|
|
2314
|
+
* ```javascript
|
|
2315
|
+
* // const pcmData = ... base64-encoded 16-bit PCM at 16kHz little-endian.
|
|
2316
|
+
* const blob = { mimeType: "audio/pcm", data: pcmData };
|
|
2317
|
+
* liveSession.sendAudioRealtime(blob);
|
|
2318
|
+
* ```
|
|
2319
|
+
*
|
|
2320
|
+
* @param blob - The base64-encoded PCM data to send to the server in realtime.
|
|
2283
2321
|
* @throws If this session has been closed.
|
|
2284
2322
|
*
|
|
2285
2323
|
* @beta
|
|
2286
2324
|
*/
|
|
2287
|
-
|
|
2325
|
+
sendAudioRealtime(blob: GenerativeContentBlob): Promise<void>;
|
|
2288
2326
|
/**
|
|
2289
|
-
* Sends
|
|
2327
|
+
* Sends video data to the server in realtime.
|
|
2290
2328
|
*
|
|
2291
|
-
* @
|
|
2329
|
+
* @remarks The server requires that the video is sent as individual video frames at 1 FPS. It
|
|
2330
|
+
* is recommended to set `mimeType` to `image/jpeg`.
|
|
2331
|
+
*
|
|
2332
|
+
* @example
|
|
2333
|
+
* ```javascript
|
|
2334
|
+
* // const videoFrame = ... base64-encoded JPEG data
|
|
2335
|
+
* const blob = { mimeType: "image/jpeg", data: videoFrame };
|
|
2336
|
+
* liveSession.sendVideoRealtime(blob);
|
|
2337
|
+
* ```
|
|
2338
|
+
* @param blob - The base64-encoded video data to send to the server in realtime.
|
|
2292
2339
|
* @throws If this session has been closed.
|
|
2293
2340
|
*
|
|
2294
2341
|
* @beta
|
|
2295
2342
|
*/
|
|
2296
|
-
|
|
2343
|
+
sendVideoRealtime(blob: GenerativeContentBlob): Promise<void>;
|
|
2344
|
+
/**
|
|
2345
|
+
* Sends function responses to the server.
|
|
2346
|
+
*
|
|
2347
|
+
* @param functionResponses - The function responses to send.
|
|
2348
|
+
* @throws If this session has been closed.
|
|
2349
|
+
*
|
|
2350
|
+
* @beta
|
|
2351
|
+
*/
|
|
2352
|
+
sendFunctionResponses(functionResponses: FunctionResponse[]): Promise<void>;
|
|
2297
2353
|
/**
|
|
2298
2354
|
* Yields messages received from the server.
|
|
2299
2355
|
* This can only be used by one consumer at a time.
|
|
@@ -2311,6 +2367,28 @@ export declare class LiveSession {
|
|
|
2311
2367
|
* @beta
|
|
2312
2368
|
*/
|
|
2313
2369
|
close(): Promise<void>;
|
|
2370
|
+
/**
|
|
2371
|
+
* Sends realtime input to the server.
|
|
2372
|
+
*
|
|
2373
|
+
* @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead.
|
|
2374
|
+
*
|
|
2375
|
+
* @param mediaChunks - The media chunks to send.
|
|
2376
|
+
* @throws If this session has been closed.
|
|
2377
|
+
*
|
|
2378
|
+
* @beta
|
|
2379
|
+
*/
|
|
2380
|
+
sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>;
|
|
2381
|
+
/**
|
|
2382
|
+
* @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead.
|
|
2383
|
+
*
|
|
2384
|
+
* Sends a stream of {@link GenerativeContentBlob}.
|
|
2385
|
+
*
|
|
2386
|
+
* @param mediaChunkStream - The stream of {@link GenerativeContentBlob} to send.
|
|
2387
|
+
* @throws If this session has been closed.
|
|
2388
|
+
*
|
|
2389
|
+
* @beta
|
|
2390
|
+
*/
|
|
2391
|
+
sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>;
|
|
2314
2392
|
}
|
|
2315
2393
|
|
|
2316
2394
|
/**
|