@firebase/ai 0.0.1

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.
Files changed (90) hide show
  1. package/README.md +5 -0
  2. package/dist/ai-public.d.ts +1972 -0
  3. package/dist/ai.d.ts +2073 -0
  4. package/dist/esm/index.esm2017.js +2624 -0
  5. package/dist/esm/index.esm2017.js.map +1 -0
  6. package/dist/esm/package.json +1 -0
  7. package/dist/esm/src/api.d.ts +120 -0
  8. package/dist/esm/src/backend.d.ts +74 -0
  9. package/dist/esm/src/constants.d.ts +23 -0
  10. package/dist/esm/src/errors.d.ts +35 -0
  11. package/dist/esm/src/googleai-mappers.d.ts +73 -0
  12. package/dist/esm/src/helpers.d.ts +30 -0
  13. package/dist/esm/src/index.d.ts +12 -0
  14. package/dist/esm/src/index.node.d.ts +7 -0
  15. package/dist/esm/src/logger.d.ts +18 -0
  16. package/dist/esm/src/methods/chat-session-helpers.d.ts +18 -0
  17. package/dist/esm/src/methods/chat-session.d.ts +50 -0
  18. package/dist/esm/src/methods/count-tokens.d.ts +19 -0
  19. package/dist/esm/src/methods/generate-content.d.ts +20 -0
  20. package/dist/esm/src/models/ai-model.d.ts +72 -0
  21. package/dist/esm/src/models/generative-model.d.ts +54 -0
  22. package/dist/esm/src/models/imagen-model.d.ts +102 -0
  23. package/dist/esm/src/models/index.d.ts +19 -0
  24. package/dist/esm/src/public-types.d.ts +106 -0
  25. package/dist/esm/src/requests/imagen-image-format.d.ts +61 -0
  26. package/dist/esm/src/requests/request-helpers.d.ts +28 -0
  27. package/dist/esm/src/requests/request.d.ts +43 -0
  28. package/dist/esm/src/requests/response-helpers.d.ts +53 -0
  29. package/dist/esm/src/requests/schema-builder.d.ts +145 -0
  30. package/dist/esm/src/requests/stream-reader.d.ts +38 -0
  31. package/dist/esm/src/service.d.ts +31 -0
  32. package/dist/esm/src/types/content.d.ts +144 -0
  33. package/dist/esm/src/types/enums.d.ts +263 -0
  34. package/dist/esm/src/types/error.d.ts +81 -0
  35. package/dist/esm/src/types/googleai.d.ts +56 -0
  36. package/dist/esm/src/types/imagen/index.d.ts +18 -0
  37. package/dist/esm/src/types/imagen/internal.d.ts +124 -0
  38. package/dist/esm/src/types/imagen/requests.d.ts +211 -0
  39. package/dist/esm/src/types/imagen/responses.d.ts +78 -0
  40. package/dist/esm/src/types/index.d.ts +24 -0
  41. package/dist/esm/src/types/internal.d.ts +33 -0
  42. package/dist/esm/src/types/requests.d.ts +213 -0
  43. package/dist/esm/src/types/responses.d.ts +257 -0
  44. package/dist/esm/src/types/schema.d.ts +102 -0
  45. package/dist/index.cjs.js +2652 -0
  46. package/dist/index.cjs.js.map +1 -0
  47. package/dist/index.node.cjs.js +2652 -0
  48. package/dist/index.node.cjs.js.map +1 -0
  49. package/dist/index.node.mjs +2624 -0
  50. package/dist/index.node.mjs.map +1 -0
  51. package/dist/src/api.d.ts +120 -0
  52. package/dist/src/backend.d.ts +74 -0
  53. package/dist/src/constants.d.ts +23 -0
  54. package/dist/src/errors.d.ts +35 -0
  55. package/dist/src/googleai-mappers.d.ts +73 -0
  56. package/dist/src/helpers.d.ts +30 -0
  57. package/dist/src/index.d.ts +12 -0
  58. package/dist/src/index.node.d.ts +7 -0
  59. package/dist/src/logger.d.ts +18 -0
  60. package/dist/src/methods/chat-session-helpers.d.ts +18 -0
  61. package/dist/src/methods/chat-session.d.ts +50 -0
  62. package/dist/src/methods/count-tokens.d.ts +19 -0
  63. package/dist/src/methods/generate-content.d.ts +20 -0
  64. package/dist/src/models/ai-model.d.ts +72 -0
  65. package/dist/src/models/generative-model.d.ts +54 -0
  66. package/dist/src/models/imagen-model.d.ts +102 -0
  67. package/dist/src/models/index.d.ts +19 -0
  68. package/dist/src/public-types.d.ts +106 -0
  69. package/dist/src/requests/imagen-image-format.d.ts +61 -0
  70. package/dist/src/requests/request-helpers.d.ts +28 -0
  71. package/dist/src/requests/request.d.ts +43 -0
  72. package/dist/src/requests/response-helpers.d.ts +53 -0
  73. package/dist/src/requests/schema-builder.d.ts +145 -0
  74. package/dist/src/requests/stream-reader.d.ts +38 -0
  75. package/dist/src/service.d.ts +31 -0
  76. package/dist/src/tsdoc-metadata.json +11 -0
  77. package/dist/src/types/content.d.ts +144 -0
  78. package/dist/src/types/enums.d.ts +263 -0
  79. package/dist/src/types/error.d.ts +81 -0
  80. package/dist/src/types/googleai.d.ts +56 -0
  81. package/dist/src/types/imagen/index.d.ts +18 -0
  82. package/dist/src/types/imagen/internal.d.ts +124 -0
  83. package/dist/src/types/imagen/requests.d.ts +211 -0
  84. package/dist/src/types/imagen/responses.d.ts +78 -0
  85. package/dist/src/types/index.d.ts +24 -0
  86. package/dist/src/types/internal.d.ts +33 -0
  87. package/dist/src/types/requests.d.ts +213 -0
  88. package/dist/src/types/responses.d.ts +257 -0
  89. package/dist/src/types/schema.d.ts +102 -0
  90. package/package.json +81 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ImagenImageFormat } from '../../requests/imagen-image-format';
18
+ /**
19
+ * Parameters for configuring an {@link ImagenModel}.
20
+ *
21
+ * @beta
22
+ */
23
+ export interface ImagenModelParams {
24
+ /**
25
+ * The Imagen model to use for generating images.
26
+ * For example: `imagen-3.0-generate-002`.
27
+ *
28
+ * Only Imagen 3 models (named `imagen-3.0-*`) are supported.
29
+ *
30
+ * See {@link https://firebase.google.com/docs/vertex-ai/models | model versions}
31
+ * for a full list of supported Imagen 3 models.
32
+ */
33
+ model: string;
34
+ /**
35
+ * Configuration options for generating images with Imagen.
36
+ */
37
+ generationConfig?: ImagenGenerationConfig;
38
+ /**
39
+ * Safety settings for filtering potentially inappropriate content.
40
+ */
41
+ safetySettings?: ImagenSafetySettings;
42
+ }
43
+ /**
44
+ * Configuration options for generating images with Imagen.
45
+ *
46
+ * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images-imagen | documentation} for
47
+ * more details.
48
+ *
49
+ * @beta
50
+ */
51
+ export interface ImagenGenerationConfig {
52
+ /**
53
+ * A description of what should be omitted from the generated images.
54
+ *
55
+ * Support for negative prompts depends on the Imagen model.
56
+ *
57
+ * See the {@link http://firebase.google.com/docs/vertex-ai/model-parameters#imagen | documentation} for more details.
58
+ *
59
+ * This is no longer supported in the Gemini Developer API ({@link GoogleAIBackend}) in versions
60
+ * greater than `imagen-3.0-generate-002`.
61
+ */
62
+ negativePrompt?: string;
63
+ /**
64
+ * The number of images to generate. The default value is 1.
65
+ *
66
+ * The number of sample images that may be generated in each request depends on the model
67
+ * (typically up to 4); see the <a href="http://firebase.google.com/docs/vertex-ai/model-parameters#imagen">sampleCount</a>
68
+ * documentation for more details.
69
+ */
70
+ numberOfImages?: number;
71
+ /**
72
+ * The aspect ratio of the generated images. The default value is square 1:1.
73
+ * Supported aspect ratios depend on the Imagen model, see {@link ImagenAspectRatio}
74
+ * for more details.
75
+ */
76
+ aspectRatio?: ImagenAspectRatio;
77
+ /**
78
+ * The image format of the generated images. The default is PNG.
79
+ *
80
+ * See {@link ImagenImageFormat} for more details.
81
+ */
82
+ imageFormat?: ImagenImageFormat;
83
+ /**
84
+ * Whether to add an invisible watermark to generated images.
85
+ *
86
+ * If set to `true`, an invisible SynthID watermark is embedded in generated images to indicate
87
+ * that they are AI generated. If set to `false`, watermarking will be disabled.
88
+ *
89
+ * For Imagen 3 models, the default value is `true`; see the <a href="http://firebase.google.com/docs/vertex-ai/model-parameters#imagen">addWatermark</a>
90
+ * documentation for more details.
91
+ *
92
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), this will default to true,
93
+ * and cannot be turned off.
94
+ */
95
+ addWatermark?: boolean;
96
+ }
97
+ /**
98
+ * A filter level controlling how aggressively to filter sensitive content.
99
+ *
100
+ * Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI
101
+ * are assessed against a list of safety filters, which include 'harmful categories' (for example,
102
+ * `violence`, `sexual`, `derogatory`, and `toxic`). This filter level controls how aggressively to
103
+ * filter out potentially harmful content from responses. See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
104
+ * and the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters | Responsible AI and usage guidelines}
105
+ * for more details.
106
+ *
107
+ * @beta
108
+ */
109
+ export declare enum ImagenSafetyFilterLevel {
110
+ /**
111
+ * The most aggressive filtering level; most strict blocking.
112
+ */
113
+ BLOCK_LOW_AND_ABOVE = "block_low_and_above",
114
+ /**
115
+ * Blocks some sensitive prompts and responses.
116
+ */
117
+ BLOCK_MEDIUM_AND_ABOVE = "block_medium_and_above",
118
+ /**
119
+ * Blocks few sensitive prompts and responses.
120
+ */
121
+ BLOCK_ONLY_HIGH = "block_only_high",
122
+ /**
123
+ * The least aggressive filtering level; blocks very few sensitive prompts and responses.
124
+ *
125
+ * Access to this feature is restricted and may require your case to be reviewed and approved by
126
+ * Cloud support.
127
+ */
128
+ BLOCK_NONE = "block_none"
129
+ }
130
+ /**
131
+ * A filter level controlling whether generation of images containing people or faces is allowed.
132
+ *
133
+ * See the <a href="http://firebase.google.com/docs/vertex-ai/generate-images">personGeneration</a>
134
+ * documentation for more details.
135
+ *
136
+ * @beta
137
+ */
138
+ export declare enum ImagenPersonFilterLevel {
139
+ /**
140
+ * Disallow generation of images containing people or faces; images of people are filtered out.
141
+ */
142
+ BLOCK_ALL = "dont_allow",
143
+ /**
144
+ * Allow generation of images containing adults only; images of children are filtered out.
145
+ *
146
+ * Generation of images containing people or faces may require your use case to be
147
+ * reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
148
+ * for more details.
149
+ */
150
+ ALLOW_ADULT = "allow_adult",
151
+ /**
152
+ * Allow generation of images containing adults only; images of children are filtered out.
153
+ *
154
+ * Generation of images containing people or faces may require your use case to be
155
+ * reviewed and approved by Cloud support; see the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#person-face-gen | Responsible AI and usage guidelines}
156
+ * for more details.
157
+ */
158
+ ALLOW_ALL = "allow_all"
159
+ }
160
+ /**
161
+ * Settings for controlling the aggressiveness of filtering out sensitive content.
162
+ *
163
+ * See the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
164
+ * for more details.
165
+ *
166
+ * @beta
167
+ */
168
+ export interface ImagenSafetySettings {
169
+ /**
170
+ * A filter level controlling how aggressive to filter out sensitive content from generated
171
+ * images.
172
+ */
173
+ safetyFilterLevel?: ImagenSafetyFilterLevel;
174
+ /**
175
+ * A filter level controlling whether generation of images containing people or faces is allowed.
176
+ */
177
+ personFilterLevel?: ImagenPersonFilterLevel;
178
+ }
179
+ /**
180
+ * Aspect ratios for Imagen images.
181
+ *
182
+ * To specify an aspect ratio for generated images, set the `aspectRatio` property in your
183
+ * {@link ImagenGenerationConfig}.
184
+ *
185
+ * See the the {@link http://firebase.google.com/docs/vertex-ai/generate-images | documentation }
186
+ * for more details and examples of the supported aspect ratios.
187
+ *
188
+ * @beta
189
+ */
190
+ export declare enum ImagenAspectRatio {
191
+ /**
192
+ * Square (1:1) aspect ratio.
193
+ */
194
+ SQUARE = "1:1",
195
+ /**
196
+ * Landscape (3:4) aspect ratio.
197
+ */
198
+ LANDSCAPE_3x4 = "3:4",
199
+ /**
200
+ * Portrait (4:3) aspect ratio.
201
+ */
202
+ PORTRAIT_4x3 = "4:3",
203
+ /**
204
+ * Landscape (16:9) aspect ratio.
205
+ */
206
+ LANDSCAPE_16x9 = "16:9",
207
+ /**
208
+ * Portrait (9:16) aspect ratio.
209
+ */
210
+ PORTRAIT_9x16 = "9:16"
211
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * An image generated by Imagen, represented as inline data.
19
+ *
20
+ * @beta
21
+ */
22
+ export interface ImagenInlineImage {
23
+ /**
24
+ * The MIME type of the image; either `"image/png"` or `"image/jpeg"`.
25
+ *
26
+ * To request a different format, set the `imageFormat` property in your {@link ImagenGenerationConfig}.
27
+ */
28
+ mimeType: string;
29
+ /**
30
+ * The base64-encoded image data.
31
+ */
32
+ bytesBase64Encoded: string;
33
+ }
34
+ /**
35
+ * An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
36
+ *
37
+ * This feature is not available yet.
38
+ */
39
+ export interface ImagenGCSImage {
40
+ /**
41
+ * The MIME type of the image; either `"image/png"` or `"image/jpeg"`.
42
+ *
43
+ * To request a different format, set the `imageFormat` property in your {@link ImagenGenerationConfig}.
44
+ */
45
+ mimeType: string;
46
+ /**
47
+ * The URI of the file stored in a Cloud Storage for Firebase bucket.
48
+ *
49
+ * @example `"gs://bucket-name/path/sample_0.jpg"`.
50
+ */
51
+ gcsURI: string;
52
+ }
53
+ /**
54
+ * The response from a request to generate images with Imagen.
55
+ *
56
+ * @beta
57
+ */
58
+ export interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGCSImage> {
59
+ /**
60
+ * The images generated by Imagen.
61
+ *
62
+ * The number of images generated may be fewer than the number requested if one or more were
63
+ * filtered out; see `filteredReason`.
64
+ */
65
+ images: T[];
66
+ /**
67
+ * The reason that images were filtered out. This property will only be defined if one
68
+ * or more images were filtered.
69
+ *
70
+ * Images may be filtered out due to the {@link ImagenSafetyFilterLevel},
71
+ * {@link ImagenPersonFilterLevel}, or filtering included in the model.
72
+ * The filter levels may be adjusted in your {@link ImagenSafetySettings}.
73
+ *
74
+ * See the {@link https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen | Responsible AI and usage guidelines for Imagen}
75
+ * for more details.
76
+ */
77
+ filteredReason?: string;
78
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './content';
18
+ export * from './enums';
19
+ export * from './requests';
20
+ export * from './responses';
21
+ export * from './error';
22
+ export * from './schema';
23
+ export * from './imagen';
24
+ export * from './googleai';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
18
+ import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
19
+ import { Backend } from '../backend';
20
+ export * from './imagen/internal';
21
+ export interface ApiSettings {
22
+ apiKey: string;
23
+ project: string;
24
+ appId: string;
25
+ automaticDataCollectionEnabled?: boolean;
26
+ /**
27
+ * @deprecated Use `backend.location` instead.
28
+ */
29
+ location: string;
30
+ backend: Backend;
31
+ getAuthToken?: () => Promise<FirebaseAuthTokenData | null>;
32
+ getAppCheckToken?: () => Promise<AppCheckTokenResult>;
33
+ }
@@ -0,0 +1,213 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { TypedSchema } from '../requests/schema-builder';
18
+ import { Content, Part } from './content';
19
+ import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory, ResponseModality } from './enums';
20
+ import { ObjectSchemaInterface, SchemaRequest } from './schema';
21
+ /**
22
+ * Base parameters for a number of methods.
23
+ * @public
24
+ */
25
+ export interface BaseParams {
26
+ safetySettings?: SafetySetting[];
27
+ generationConfig?: GenerationConfig;
28
+ }
29
+ /**
30
+ * Params passed to {@link getGenerativeModel}.
31
+ * @public
32
+ */
33
+ export interface ModelParams extends BaseParams {
34
+ model: string;
35
+ tools?: Tool[];
36
+ toolConfig?: ToolConfig;
37
+ systemInstruction?: string | Part | Content;
38
+ }
39
+ /**
40
+ * Request sent through {@link GenerativeModel.generateContent}
41
+ * @public
42
+ */
43
+ export interface GenerateContentRequest extends BaseParams {
44
+ contents: Content[];
45
+ tools?: Tool[];
46
+ toolConfig?: ToolConfig;
47
+ systemInstruction?: string | Part | Content;
48
+ }
49
+ /**
50
+ * Safety setting that can be sent as part of request parameters.
51
+ * @public
52
+ */
53
+ export interface SafetySetting {
54
+ category: HarmCategory;
55
+ threshold: HarmBlockThreshold;
56
+ /**
57
+ * The harm block method.
58
+ *
59
+ * This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
60
+ * When using the Gemini Developer API ({@link GoogleAIBackend}), an {@link AIError} will be
61
+ * thrown if this property is defined.
62
+ */
63
+ method?: HarmBlockMethod;
64
+ }
65
+ /**
66
+ * Config options for content-related requests
67
+ * @public
68
+ */
69
+ export interface GenerationConfig {
70
+ candidateCount?: number;
71
+ stopSequences?: string[];
72
+ maxOutputTokens?: number;
73
+ temperature?: number;
74
+ topP?: number;
75
+ topK?: number;
76
+ presencePenalty?: number;
77
+ frequencyPenalty?: number;
78
+ /**
79
+ * Output response MIME type of the generated candidate text.
80
+ * Supported MIME types are `text/plain` (default, text output),
81
+ * `application/json` (JSON response in the candidates), and
82
+ * `text/x.enum`.
83
+ */
84
+ responseMimeType?: string;
85
+ /**
86
+ * Output response schema of the generated candidate text. This
87
+ * value can be a class generated with a {@link Schema} static method
88
+ * like `Schema.string()` or `Schema.object()` or it can be a plain
89
+ * JS object matching the {@link SchemaRequest} interface.
90
+ * <br/>Note: This only applies when the specified `responseMIMEType` supports a schema; currently
91
+ * this is limited to `application/json` and `text/x.enum`.
92
+ */
93
+ responseSchema?: TypedSchema | SchemaRequest;
94
+ /**
95
+ * Generation modalities to be returned in generation responses.
96
+ *
97
+ * @remarks
98
+ * - Multimodal response generation is only supported by some Gemini models and versions; see {@link https://firebase.google.com/docs/vertex-ai/models | model versions}.
99
+ * - Only image generation (`ResponseModality.IMAGE`) is supported.
100
+ *
101
+ * @beta
102
+ */
103
+ responseModalities?: ResponseModality[];
104
+ }
105
+ /**
106
+ * Params for {@link GenerativeModel.startChat}.
107
+ * @public
108
+ */
109
+ export interface StartChatParams extends BaseParams {
110
+ history?: Content[];
111
+ tools?: Tool[];
112
+ toolConfig?: ToolConfig;
113
+ systemInstruction?: string | Part | Content;
114
+ }
115
+ /**
116
+ * Params for calling {@link GenerativeModel.countTokens}
117
+ * @public
118
+ */
119
+ export interface CountTokensRequest {
120
+ contents: Content[];
121
+ /**
122
+ * Instructions that direct the model to behave a certain way.
123
+ */
124
+ systemInstruction?: string | Part | Content;
125
+ /**
126
+ * {@link Tool} configuration.
127
+ */
128
+ tools?: Tool[];
129
+ /**
130
+ * Configuration options that control how the model generates a response.
131
+ */
132
+ generationConfig?: GenerationConfig;
133
+ }
134
+ /**
135
+ * Params passed to {@link getGenerativeModel}.
136
+ * @public
137
+ */
138
+ export interface RequestOptions {
139
+ /**
140
+ * Request timeout in milliseconds. Defaults to 180 seconds (180000ms).
141
+ */
142
+ timeout?: number;
143
+ /**
144
+ * Base url for endpoint. Defaults to https://firebasevertexai.googleapis.com
145
+ */
146
+ baseUrl?: string;
147
+ }
148
+ /**
149
+ * Defines a tool that model can call to access external knowledge.
150
+ * @public
151
+ */
152
+ export declare type Tool = FunctionDeclarationsTool;
153
+ /**
154
+ * Structured representation of a function declaration as defined by the
155
+ * {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
156
+ * Included
157
+ * in this declaration are the function name and parameters. This
158
+ * `FunctionDeclaration` is a representation of a block of code that can be used
159
+ * as a Tool by the model and executed by the client.
160
+ * @public
161
+ */
162
+ export declare interface FunctionDeclaration {
163
+ /**
164
+ * The name of the function to call. Must start with a letter or an
165
+ * underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with
166
+ * a max length of 64.
167
+ */
168
+ name: string;
169
+ /**
170
+ * Description and purpose of the function. Model uses it to decide
171
+ * how and whether to call the function.
172
+ */
173
+ description: string;
174
+ /**
175
+ * Optional. Describes the parameters to this function in JSON Schema Object
176
+ * format. Reflects the Open API 3.03 Parameter Object. Parameter names are
177
+ * case-sensitive. For a function with no parameters, this can be left unset.
178
+ */
179
+ parameters?: ObjectSchemaInterface;
180
+ }
181
+ /**
182
+ * A `FunctionDeclarationsTool` is a piece of code that enables the system to
183
+ * interact with external systems to perform an action, or set of actions,
184
+ * outside of knowledge and scope of the model.
185
+ * @public
186
+ */
187
+ export declare interface FunctionDeclarationsTool {
188
+ /**
189
+ * Optional. One or more function declarations
190
+ * to be passed to the model along with the current user query. Model may
191
+ * decide to call a subset of these functions by populating
192
+ * {@link FunctionCall} in the response. User should
193
+ * provide a {@link FunctionResponse} for each
194
+ * function call in the next turn. Based on the function responses, the model will
195
+ * generate the final response back to the user. Maximum 64 function
196
+ * declarations can be provided.
197
+ */
198
+ functionDeclarations?: FunctionDeclaration[];
199
+ }
200
+ /**
201
+ * Tool config. This config is shared for all tools provided in the request.
202
+ * @public
203
+ */
204
+ export interface ToolConfig {
205
+ functionCallingConfig?: FunctionCallingConfig;
206
+ }
207
+ /**
208
+ * @public
209
+ */
210
+ export interface FunctionCallingConfig {
211
+ mode?: FunctionCallingMode;
212
+ allowedFunctionNames?: string[];
213
+ }