@firebase/ai 2.0.0 → 2.1.0
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 +178 -8
- package/dist/ai.d.ts +181 -8
- package/dist/esm/index.esm.js +359 -19
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/api.d.ts +2 -2
- package/dist/esm/src/constants.d.ts +4 -0
- package/dist/esm/src/methods/chat-session.d.ts +3 -1
- package/dist/esm/src/methods/chrome-adapter.d.ts +118 -0
- package/dist/esm/src/methods/count-tokens.d.ts +3 -1
- package/dist/esm/src/methods/generate-content.d.ts +3 -2
- package/dist/esm/src/models/generative-model.d.ts +3 -1
- package/dist/esm/src/types/chrome-adapter.d.ts +54 -0
- package/dist/esm/src/types/enums.d.ts +20 -1
- package/dist/esm/src/types/imagen/requests.d.ts +2 -2
- package/dist/esm/src/types/imagen/responses.d.ts +1 -0
- package/dist/esm/src/types/index.d.ts +2 -0
- package/dist/esm/src/types/language-model.d.ts +117 -0
- package/dist/esm/src/types/requests.d.ts +31 -1
- package/dist/esm/src/types/responses.d.ts +1 -1
- package/dist/esm/src/types/schema.d.ts +1 -1
- package/dist/index.cjs.js +359 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +359 -18
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +359 -19
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/api.d.ts +2 -2
- package/dist/src/constants.d.ts +4 -0
- package/dist/src/methods/chat-session.d.ts +3 -1
- package/dist/src/methods/chrome-adapter.d.ts +118 -0
- package/dist/src/methods/count-tokens.d.ts +3 -1
- package/dist/src/methods/generate-content.d.ts +3 -2
- package/dist/src/models/generative-model.d.ts +3 -1
- package/dist/src/types/chrome-adapter.d.ts +54 -0
- package/dist/src/types/enums.d.ts +20 -1
- package/dist/src/types/imagen/requests.d.ts +2 -2
- package/dist/src/types/imagen/responses.d.ts +1 -0
- package/dist/src/types/index.d.ts +2 -0
- package/dist/src/types/language-model.d.ts +117 -0
- package/dist/src/types/requests.d.ts +31 -1
- package/dist/src/types/responses.d.ts +1 -1
- package/dist/src/types/schema.d.ts +1 -1
- package/package.json +2 -2
package/dist/ai-public.d.ts
CHANGED
|
@@ -275,12 +275,13 @@ export declare class BooleanSchema extends Schema {
|
|
|
275
275
|
*/
|
|
276
276
|
export declare class ChatSession {
|
|
277
277
|
model: string;
|
|
278
|
+
private chromeAdapter?;
|
|
278
279
|
params?: StartChatParams | undefined;
|
|
279
280
|
requestOptions?: RequestOptions | undefined;
|
|
280
281
|
private _apiSettings;
|
|
281
282
|
private _history;
|
|
282
283
|
private _sendPromise;
|
|
283
|
-
constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
|
|
284
|
+
constructor(apiSettings: ApiSettings, model: string, chromeAdapter?: ChromeAdapter | undefined, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
|
|
284
285
|
/**
|
|
285
286
|
* Gets the chat history so far. Blocked prompts are not added to history.
|
|
286
287
|
* Neither blocked candidates nor the prompts that generated them are added
|
|
@@ -300,6 +301,41 @@ export declare class ChatSession {
|
|
|
300
301
|
sendMessageStream(request: string | Array<string | Part>): Promise<GenerateContentStreamResult>;
|
|
301
302
|
}
|
|
302
303
|
|
|
304
|
+
/**
|
|
305
|
+
* <b>(EXPERIMENTAL)</b> Defines an inference "backend" that uses Chrome's on-device model,
|
|
306
|
+
* and encapsulates logic for detecting when on-device inference is
|
|
307
|
+
* possible.
|
|
308
|
+
*
|
|
309
|
+
* These methods should not be called directly by the user.
|
|
310
|
+
*
|
|
311
|
+
* @public
|
|
312
|
+
*/
|
|
313
|
+
export declare interface ChromeAdapter {
|
|
314
|
+
/**
|
|
315
|
+
* Checks if the on-device model is capable of handling a given
|
|
316
|
+
* request.
|
|
317
|
+
* @param request - A potential request to be passed to the model.
|
|
318
|
+
*/
|
|
319
|
+
isAvailable(request: GenerateContentRequest): Promise<boolean>;
|
|
320
|
+
/**
|
|
321
|
+
* Generates content using on-device inference.
|
|
322
|
+
*
|
|
323
|
+
* <p>This is comparable to {@link GenerativeModel.generateContent} for generating
|
|
324
|
+
* content using in-cloud inference.</p>
|
|
325
|
+
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
326
|
+
*/
|
|
327
|
+
generateContent(request: GenerateContentRequest): Promise<Response>;
|
|
328
|
+
/**
|
|
329
|
+
* Generates a content stream using on-device inference.
|
|
330
|
+
*
|
|
331
|
+
* <p>This is comparable to {@link GenerativeModel.generateContentStream} for generating
|
|
332
|
+
* a content stream using in-cloud inference.</p>
|
|
333
|
+
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
334
|
+
*/
|
|
335
|
+
generateContentStream(request: GenerateContentRequest): Promise<Response>;
|
|
336
|
+
/* Excluded from this release type: countTokens */
|
|
337
|
+
}
|
|
338
|
+
|
|
303
339
|
/**
|
|
304
340
|
* A single citation.
|
|
305
341
|
* @public
|
|
@@ -561,6 +597,9 @@ export declare const FunctionCallingMode: {
|
|
|
561
597
|
readonly NONE: "NONE";
|
|
562
598
|
};
|
|
563
599
|
|
|
600
|
+
/**
|
|
601
|
+
* @public
|
|
602
|
+
*/
|
|
564
603
|
export declare type FunctionCallingMode = (typeof FunctionCallingMode)[keyof typeof FunctionCallingMode];
|
|
565
604
|
|
|
566
605
|
/**
|
|
@@ -770,13 +809,14 @@ export declare interface GenerativeContentBlob {
|
|
|
770
809
|
* @public
|
|
771
810
|
*/
|
|
772
811
|
export declare class GenerativeModel extends AIModel {
|
|
812
|
+
private chromeAdapter?;
|
|
773
813
|
generationConfig: GenerationConfig;
|
|
774
814
|
safetySettings: SafetySetting[];
|
|
775
815
|
requestOptions?: RequestOptions;
|
|
776
816
|
tools?: Tool[];
|
|
777
817
|
toolConfig?: ToolConfig;
|
|
778
818
|
systemInstruction?: Content;
|
|
779
|
-
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);
|
|
819
|
+
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions, chromeAdapter?: ChromeAdapter | undefined);
|
|
780
820
|
/**
|
|
781
821
|
* Makes a single non-streaming call to the model
|
|
782
822
|
* and returns an object containing a single {@link GenerateContentResponse}.
|
|
@@ -836,7 +876,7 @@ export declare function getAI(app?: FirebaseApp, options?: AIOptions): AI;
|
|
|
836
876
|
*
|
|
837
877
|
* @public
|
|
838
878
|
*/
|
|
839
|
-
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
|
|
879
|
+
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | HybridParams, requestOptions?: RequestOptions): GenerativeModel;
|
|
840
880
|
|
|
841
881
|
/**
|
|
842
882
|
* Returns an {@link ImagenModel} class with methods for using Imagen.
|
|
@@ -942,7 +982,7 @@ export declare interface GroundingMetadata {
|
|
|
942
982
|
/**
|
|
943
983
|
* Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
|
|
944
984
|
* embedded in an app to display a Google Search entry point for follow-up web searches related to
|
|
945
|
-
* a model's
|
|
985
|
+
* a model's "Grounded Response".
|
|
946
986
|
*/
|
|
947
987
|
searchEntryPoint?: SearchEntrypoint;
|
|
948
988
|
/**
|
|
@@ -1033,7 +1073,7 @@ export declare const HarmBlockThreshold: {
|
|
|
1033
1073
|
readonly BLOCK_NONE: "BLOCK_NONE";
|
|
1034
1074
|
/**
|
|
1035
1075
|
* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
|
|
1036
|
-
* to the {@link HarmCategory} will not be present in the response.
|
|
1076
|
+
* to the {@link (HarmCategory:type)} will not be present in the response.
|
|
1037
1077
|
*/
|
|
1038
1078
|
readonly OFF: "OFF";
|
|
1039
1079
|
};
|
|
@@ -1126,13 +1166,33 @@ export declare const HarmSeverity: {
|
|
|
1126
1166
|
*/
|
|
1127
1167
|
export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
|
|
1128
1168
|
|
|
1169
|
+
/**
|
|
1170
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1171
|
+
* Configures hybrid inference.
|
|
1172
|
+
* @public
|
|
1173
|
+
*/
|
|
1174
|
+
export declare interface HybridParams {
|
|
1175
|
+
/**
|
|
1176
|
+
* Specifies on-device or in-cloud inference. Defaults to prefer on-device.
|
|
1177
|
+
*/
|
|
1178
|
+
mode: InferenceMode;
|
|
1179
|
+
/**
|
|
1180
|
+
* Optional. Specifies advanced params for on-device inference.
|
|
1181
|
+
*/
|
|
1182
|
+
onDeviceParams?: OnDeviceParams;
|
|
1183
|
+
/**
|
|
1184
|
+
* Optional. Specifies advanced params for in-cloud inference.
|
|
1185
|
+
*/
|
|
1186
|
+
inCloudParams?: ModelParams;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1129
1189
|
/**
|
|
1130
1190
|
* Aspect ratios for Imagen images.
|
|
1131
1191
|
*
|
|
1132
1192
|
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
1133
1193
|
* {@link ImagenGenerationConfig}.
|
|
1134
1194
|
*
|
|
1135
|
-
* See the
|
|
1195
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1136
1196
|
* for more details and examples of the supported aspect ratios.
|
|
1137
1197
|
*
|
|
1138
1198
|
* @beta
|
|
@@ -1166,7 +1226,7 @@ export declare const ImagenAspectRatio: {
|
|
|
1166
1226
|
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
1167
1227
|
* {@link ImagenGenerationConfig}.
|
|
1168
1228
|
*
|
|
1169
|
-
* See the
|
|
1229
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1170
1230
|
* for more details and examples of the supported aspect ratios.
|
|
1171
1231
|
*
|
|
1172
1232
|
* @beta
|
|
@@ -1177,6 +1237,7 @@ export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof
|
|
|
1177
1237
|
* An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
|
|
1178
1238
|
*
|
|
1179
1239
|
* This feature is not available yet.
|
|
1240
|
+
* @beta
|
|
1180
1241
|
*/
|
|
1181
1242
|
export declare interface ImagenGCSImage {
|
|
1182
1243
|
/**
|
|
@@ -1571,6 +1632,24 @@ export declare interface ImagenSafetySettings {
|
|
|
1571
1632
|
personFilterLevel?: ImagenPersonFilterLevel;
|
|
1572
1633
|
}
|
|
1573
1634
|
|
|
1635
|
+
/**
|
|
1636
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1637
|
+
* Determines whether inference happens on-device or in-cloud.
|
|
1638
|
+
* @public
|
|
1639
|
+
*/
|
|
1640
|
+
export declare const InferenceMode: {
|
|
1641
|
+
readonly PREFER_ON_DEVICE: "prefer_on_device";
|
|
1642
|
+
readonly ONLY_ON_DEVICE: "only_on_device";
|
|
1643
|
+
readonly ONLY_IN_CLOUD: "only_in_cloud";
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1648
|
+
* Determines whether inference happens on-device or in-cloud.
|
|
1649
|
+
* @public
|
|
1650
|
+
*/
|
|
1651
|
+
export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
1652
|
+
|
|
1574
1653
|
/**
|
|
1575
1654
|
* Content part interface if the part represents an image.
|
|
1576
1655
|
* @public
|
|
@@ -1594,6 +1673,86 @@ export declare class IntegerSchema extends Schema {
|
|
|
1594
1673
|
constructor(schemaParams?: SchemaParams);
|
|
1595
1674
|
}
|
|
1596
1675
|
|
|
1676
|
+
/**
|
|
1677
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1678
|
+
* Configures the creation of an on-device language model session.
|
|
1679
|
+
* @public
|
|
1680
|
+
*/
|
|
1681
|
+
export declare interface LanguageModelCreateCoreOptions {
|
|
1682
|
+
topK?: number;
|
|
1683
|
+
temperature?: number;
|
|
1684
|
+
expectedInputs?: LanguageModelExpected[];
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1689
|
+
* Configures the creation of an on-device language model session.
|
|
1690
|
+
* @public
|
|
1691
|
+
*/
|
|
1692
|
+
export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
|
|
1693
|
+
signal?: AbortSignal;
|
|
1694
|
+
initialPrompts?: LanguageModelMessage[];
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
/**
|
|
1698
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1699
|
+
* Options for the expected inputs for an on-device language model.
|
|
1700
|
+
* @public
|
|
1701
|
+
*/ export declare interface LanguageModelExpected {
|
|
1702
|
+
type: LanguageModelMessageType;
|
|
1703
|
+
languages?: string[];
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1708
|
+
* An on-device language model message.
|
|
1709
|
+
* @public
|
|
1710
|
+
*/
|
|
1711
|
+
export declare interface LanguageModelMessage {
|
|
1712
|
+
role: LanguageModelMessageRole;
|
|
1713
|
+
content: LanguageModelMessageContent[];
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1718
|
+
* An on-device language model content object.
|
|
1719
|
+
* @public
|
|
1720
|
+
*/
|
|
1721
|
+
export declare interface LanguageModelMessageContent {
|
|
1722
|
+
type: LanguageModelMessageType;
|
|
1723
|
+
value: LanguageModelMessageContentValue;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/**
|
|
1727
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1728
|
+
* Content formats that can be provided as on-device message content.
|
|
1729
|
+
* @public
|
|
1730
|
+
*/
|
|
1731
|
+
export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
|
|
1732
|
+
|
|
1733
|
+
/**
|
|
1734
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1735
|
+
* Allowable roles for on-device language model usage.
|
|
1736
|
+
* @public
|
|
1737
|
+
*/
|
|
1738
|
+
export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1742
|
+
* Allowable types for on-device language model messages.
|
|
1743
|
+
* @public
|
|
1744
|
+
*/
|
|
1745
|
+
export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1749
|
+
* Options for an on-device language model prompt.
|
|
1750
|
+
* @public
|
|
1751
|
+
*/
|
|
1752
|
+
export declare interface LanguageModelPromptOptions {
|
|
1753
|
+
responseConstraint?: object;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1597
1756
|
/**
|
|
1598
1757
|
* Content part modality.
|
|
1599
1758
|
* @public
|
|
@@ -1679,7 +1838,7 @@ export declare class ObjectSchema extends Schema {
|
|
|
1679
1838
|
}
|
|
1680
1839
|
|
|
1681
1840
|
/**
|
|
1682
|
-
* Interface for JSON parameters in a schema of {@link SchemaType}
|
|
1841
|
+
* Interface for JSON parameters in a schema of {@link (SchemaType:type)}
|
|
1683
1842
|
* "object" when not using the `Schema.object()` helper.
|
|
1684
1843
|
* @public
|
|
1685
1844
|
*/
|
|
@@ -1695,6 +1854,17 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
|
|
|
1695
1854
|
optionalProperties?: never;
|
|
1696
1855
|
}
|
|
1697
1856
|
|
|
1857
|
+
/**
|
|
1858
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1859
|
+
* Encapsulates configuration for on-device inference.
|
|
1860
|
+
*
|
|
1861
|
+
* @public
|
|
1862
|
+
*/
|
|
1863
|
+
export declare interface OnDeviceParams {
|
|
1864
|
+
createOptions?: LanguageModelCreateOptions;
|
|
1865
|
+
promptOptions?: LanguageModelPromptOptions;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1698
1868
|
/**
|
|
1699
1869
|
* Content part - includes text, image/video, or function call/response
|
|
1700
1870
|
* part types.
|
package/dist/ai.d.ts
CHANGED
|
@@ -315,12 +315,13 @@ export declare class BooleanSchema extends Schema {
|
|
|
315
315
|
*/
|
|
316
316
|
export declare class ChatSession {
|
|
317
317
|
model: string;
|
|
318
|
+
private chromeAdapter?;
|
|
318
319
|
params?: StartChatParams | undefined;
|
|
319
320
|
requestOptions?: RequestOptions | undefined;
|
|
320
321
|
private _apiSettings;
|
|
321
322
|
private _history;
|
|
322
323
|
private _sendPromise;
|
|
323
|
-
constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
|
|
324
|
+
constructor(apiSettings: ApiSettings, model: string, chromeAdapter?: ChromeAdapter | undefined, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
|
|
324
325
|
/**
|
|
325
326
|
* Gets the chat history so far. Blocked prompts are not added to history.
|
|
326
327
|
* Neither blocked candidates nor the prompts that generated them are added
|
|
@@ -340,6 +341,44 @@ export declare class ChatSession {
|
|
|
340
341
|
sendMessageStream(request: string | Array<string | Part>): Promise<GenerateContentStreamResult>;
|
|
341
342
|
}
|
|
342
343
|
|
|
344
|
+
/**
|
|
345
|
+
* <b>(EXPERIMENTAL)</b> Defines an inference "backend" that uses Chrome's on-device model,
|
|
346
|
+
* and encapsulates logic for detecting when on-device inference is
|
|
347
|
+
* possible.
|
|
348
|
+
*
|
|
349
|
+
* These methods should not be called directly by the user.
|
|
350
|
+
*
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
export declare interface ChromeAdapter {
|
|
354
|
+
/**
|
|
355
|
+
* Checks if the on-device model is capable of handling a given
|
|
356
|
+
* request.
|
|
357
|
+
* @param request - A potential request to be passed to the model.
|
|
358
|
+
*/
|
|
359
|
+
isAvailable(request: GenerateContentRequest): Promise<boolean>;
|
|
360
|
+
/**
|
|
361
|
+
* Generates content using on-device inference.
|
|
362
|
+
*
|
|
363
|
+
* <p>This is comparable to {@link GenerativeModel.generateContent} for generating
|
|
364
|
+
* content using in-cloud inference.</p>
|
|
365
|
+
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
366
|
+
*/
|
|
367
|
+
generateContent(request: GenerateContentRequest): Promise<Response>;
|
|
368
|
+
/**
|
|
369
|
+
* Generates a content stream using on-device inference.
|
|
370
|
+
*
|
|
371
|
+
* <p>This is comparable to {@link GenerativeModel.generateContentStream} for generating
|
|
372
|
+
* a content stream using in-cloud inference.</p>
|
|
373
|
+
* @param request - a standard Firebase AI {@link GenerateContentRequest}
|
|
374
|
+
*/
|
|
375
|
+
generateContentStream(request: GenerateContentRequest): Promise<Response>;
|
|
376
|
+
/**
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
countTokens(request: CountTokensRequest): Promise<Response>;
|
|
380
|
+
}
|
|
381
|
+
|
|
343
382
|
/**
|
|
344
383
|
* A single citation.
|
|
345
384
|
* @public
|
|
@@ -601,6 +640,9 @@ export declare const FunctionCallingMode: {
|
|
|
601
640
|
readonly NONE: "NONE";
|
|
602
641
|
};
|
|
603
642
|
|
|
643
|
+
/**
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
604
646
|
export declare type FunctionCallingMode = (typeof FunctionCallingMode)[keyof typeof FunctionCallingMode];
|
|
605
647
|
|
|
606
648
|
/**
|
|
@@ -810,13 +852,14 @@ export declare interface GenerativeContentBlob {
|
|
|
810
852
|
* @public
|
|
811
853
|
*/
|
|
812
854
|
export declare class GenerativeModel extends AIModel {
|
|
855
|
+
private chromeAdapter?;
|
|
813
856
|
generationConfig: GenerationConfig;
|
|
814
857
|
safetySettings: SafetySetting[];
|
|
815
858
|
requestOptions?: RequestOptions;
|
|
816
859
|
tools?: Tool[];
|
|
817
860
|
toolConfig?: ToolConfig;
|
|
818
861
|
systemInstruction?: Content;
|
|
819
|
-
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);
|
|
862
|
+
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions, chromeAdapter?: ChromeAdapter | undefined);
|
|
820
863
|
/**
|
|
821
864
|
* Makes a single non-streaming call to the model
|
|
822
865
|
* and returns an object containing a single {@link GenerateContentResponse}.
|
|
@@ -876,7 +919,7 @@ export declare function getAI(app?: FirebaseApp, options?: AIOptions): AI;
|
|
|
876
919
|
*
|
|
877
920
|
* @public
|
|
878
921
|
*/
|
|
879
|
-
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
|
|
922
|
+
export declare function getGenerativeModel(ai: AI, modelParams: ModelParams | HybridParams, requestOptions?: RequestOptions): GenerativeModel;
|
|
880
923
|
|
|
881
924
|
/**
|
|
882
925
|
* Returns an {@link ImagenModel} class with methods for using Imagen.
|
|
@@ -1016,7 +1059,7 @@ export declare interface GroundingMetadata {
|
|
|
1016
1059
|
/**
|
|
1017
1060
|
* Google Search entry point for web searches. This contains an HTML/CSS snippet that must be
|
|
1018
1061
|
* embedded in an app to display a Google Search entry point for follow-up web searches related to
|
|
1019
|
-
* a model's
|
|
1062
|
+
* a model's "Grounded Response".
|
|
1020
1063
|
*/
|
|
1021
1064
|
searchEntryPoint?: SearchEntrypoint;
|
|
1022
1065
|
/**
|
|
@@ -1107,7 +1150,7 @@ export declare const HarmBlockThreshold: {
|
|
|
1107
1150
|
readonly BLOCK_NONE: "BLOCK_NONE";
|
|
1108
1151
|
/**
|
|
1109
1152
|
* All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
|
|
1110
|
-
* to the {@link HarmCategory} will not be present in the response.
|
|
1153
|
+
* to the {@link (HarmCategory:type)} will not be present in the response.
|
|
1111
1154
|
*/
|
|
1112
1155
|
readonly OFF: "OFF";
|
|
1113
1156
|
};
|
|
@@ -1200,13 +1243,33 @@ export declare const HarmSeverity: {
|
|
|
1200
1243
|
*/
|
|
1201
1244
|
export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
|
|
1202
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1248
|
+
* Configures hybrid inference.
|
|
1249
|
+
* @public
|
|
1250
|
+
*/
|
|
1251
|
+
export declare interface HybridParams {
|
|
1252
|
+
/**
|
|
1253
|
+
* Specifies on-device or in-cloud inference. Defaults to prefer on-device.
|
|
1254
|
+
*/
|
|
1255
|
+
mode: InferenceMode;
|
|
1256
|
+
/**
|
|
1257
|
+
* Optional. Specifies advanced params for on-device inference.
|
|
1258
|
+
*/
|
|
1259
|
+
onDeviceParams?: OnDeviceParams;
|
|
1260
|
+
/**
|
|
1261
|
+
* Optional. Specifies advanced params for in-cloud inference.
|
|
1262
|
+
*/
|
|
1263
|
+
inCloudParams?: ModelParams;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1203
1266
|
/**
|
|
1204
1267
|
* Aspect ratios for Imagen images.
|
|
1205
1268
|
*
|
|
1206
1269
|
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
1207
1270
|
* {@link ImagenGenerationConfig}.
|
|
1208
1271
|
*
|
|
1209
|
-
* See the
|
|
1272
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1210
1273
|
* for more details and examples of the supported aspect ratios.
|
|
1211
1274
|
*
|
|
1212
1275
|
* @beta
|
|
@@ -1240,7 +1303,7 @@ export declare const ImagenAspectRatio: {
|
|
|
1240
1303
|
* To specify an aspect ratio for generated images, set the `aspectRatio` property in your
|
|
1241
1304
|
* {@link ImagenGenerationConfig}.
|
|
1242
1305
|
*
|
|
1243
|
-
* See the
|
|
1306
|
+
* See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
|
|
1244
1307
|
* for more details and examples of the supported aspect ratios.
|
|
1245
1308
|
*
|
|
1246
1309
|
* @beta
|
|
@@ -1251,6 +1314,7 @@ export declare type ImagenAspectRatio = (typeof ImagenAspectRatio)[keyof typeof
|
|
|
1251
1314
|
* An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
|
|
1252
1315
|
*
|
|
1253
1316
|
* This feature is not available yet.
|
|
1317
|
+
* @beta
|
|
1254
1318
|
*/
|
|
1255
1319
|
export declare interface ImagenGCSImage {
|
|
1256
1320
|
/**
|
|
@@ -1664,6 +1728,24 @@ export declare interface ImagenSafetySettings {
|
|
|
1664
1728
|
personFilterLevel?: ImagenPersonFilterLevel;
|
|
1665
1729
|
}
|
|
1666
1730
|
|
|
1731
|
+
/**
|
|
1732
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1733
|
+
* Determines whether inference happens on-device or in-cloud.
|
|
1734
|
+
* @public
|
|
1735
|
+
*/
|
|
1736
|
+
export declare const InferenceMode: {
|
|
1737
|
+
readonly PREFER_ON_DEVICE: "prefer_on_device";
|
|
1738
|
+
readonly ONLY_ON_DEVICE: "only_on_device";
|
|
1739
|
+
readonly ONLY_IN_CLOUD: "only_in_cloud";
|
|
1740
|
+
};
|
|
1741
|
+
|
|
1742
|
+
/**
|
|
1743
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1744
|
+
* Determines whether inference happens on-device or in-cloud.
|
|
1745
|
+
* @public
|
|
1746
|
+
*/
|
|
1747
|
+
export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
1748
|
+
|
|
1667
1749
|
/**
|
|
1668
1750
|
* Content part interface if the part represents an image.
|
|
1669
1751
|
* @public
|
|
@@ -1687,6 +1769,86 @@ export declare class IntegerSchema extends Schema {
|
|
|
1687
1769
|
constructor(schemaParams?: SchemaParams);
|
|
1688
1770
|
}
|
|
1689
1771
|
|
|
1772
|
+
/**
|
|
1773
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1774
|
+
* Configures the creation of an on-device language model session.
|
|
1775
|
+
* @public
|
|
1776
|
+
*/
|
|
1777
|
+
export declare interface LanguageModelCreateCoreOptions {
|
|
1778
|
+
topK?: number;
|
|
1779
|
+
temperature?: number;
|
|
1780
|
+
expectedInputs?: LanguageModelExpected[];
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/**
|
|
1784
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1785
|
+
* Configures the creation of an on-device language model session.
|
|
1786
|
+
* @public
|
|
1787
|
+
*/
|
|
1788
|
+
export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
|
|
1789
|
+
signal?: AbortSignal;
|
|
1790
|
+
initialPrompts?: LanguageModelMessage[];
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1795
|
+
* Options for the expected inputs for an on-device language model.
|
|
1796
|
+
* @public
|
|
1797
|
+
*/ export declare interface LanguageModelExpected {
|
|
1798
|
+
type: LanguageModelMessageType;
|
|
1799
|
+
languages?: string[];
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1804
|
+
* An on-device language model message.
|
|
1805
|
+
* @public
|
|
1806
|
+
*/
|
|
1807
|
+
export declare interface LanguageModelMessage {
|
|
1808
|
+
role: LanguageModelMessageRole;
|
|
1809
|
+
content: LanguageModelMessageContent[];
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1814
|
+
* An on-device language model content object.
|
|
1815
|
+
* @public
|
|
1816
|
+
*/
|
|
1817
|
+
export declare interface LanguageModelMessageContent {
|
|
1818
|
+
type: LanguageModelMessageType;
|
|
1819
|
+
value: LanguageModelMessageContentValue;
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/**
|
|
1823
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1824
|
+
* Content formats that can be provided as on-device message content.
|
|
1825
|
+
* @public
|
|
1826
|
+
*/
|
|
1827
|
+
export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
|
|
1828
|
+
|
|
1829
|
+
/**
|
|
1830
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1831
|
+
* Allowable roles for on-device language model usage.
|
|
1832
|
+
* @public
|
|
1833
|
+
*/
|
|
1834
|
+
export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1838
|
+
* Allowable types for on-device language model messages.
|
|
1839
|
+
* @public
|
|
1840
|
+
*/
|
|
1841
|
+
export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1845
|
+
* Options for an on-device language model prompt.
|
|
1846
|
+
* @public
|
|
1847
|
+
*/
|
|
1848
|
+
export declare interface LanguageModelPromptOptions {
|
|
1849
|
+
responseConstraint?: object;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1690
1852
|
/**
|
|
1691
1853
|
* Content part modality.
|
|
1692
1854
|
* @public
|
|
@@ -1775,7 +1937,7 @@ export declare class ObjectSchema extends Schema {
|
|
|
1775
1937
|
}
|
|
1776
1938
|
|
|
1777
1939
|
/**
|
|
1778
|
-
* Interface for JSON parameters in a schema of {@link SchemaType}
|
|
1940
|
+
* Interface for JSON parameters in a schema of {@link (SchemaType:type)}
|
|
1779
1941
|
* "object" when not using the `Schema.object()` helper.
|
|
1780
1942
|
* @public
|
|
1781
1943
|
*/
|
|
@@ -1791,6 +1953,17 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
|
|
|
1791
1953
|
optionalProperties?: never;
|
|
1792
1954
|
}
|
|
1793
1955
|
|
|
1956
|
+
/**
|
|
1957
|
+
* <b>(EXPERIMENTAL)</b>
|
|
1958
|
+
* Encapsulates configuration for on-device inference.
|
|
1959
|
+
*
|
|
1960
|
+
* @public
|
|
1961
|
+
*/
|
|
1962
|
+
export declare interface OnDeviceParams {
|
|
1963
|
+
createOptions?: LanguageModelCreateOptions;
|
|
1964
|
+
promptOptions?: LanguageModelPromptOptions;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1794
1967
|
/**
|
|
1795
1968
|
* Content part - includes text, image/video, or function call/response
|
|
1796
1969
|
* part types.
|