@depup/firebase__ai 2.9.0-depup.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.
Files changed (119) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/ai-public.d.ts +3472 -0
  4. package/dist/ai.d.ts +3712 -0
  5. package/dist/esm/index.esm.js +4765 -0
  6. package/dist/esm/index.esm.js.map +1 -0
  7. package/dist/esm/package.json +1 -0
  8. package/dist/esm/src/api.d.ts +121 -0
  9. package/dist/esm/src/backend.d.ts +98 -0
  10. package/dist/esm/src/constants.d.ts +29 -0
  11. package/dist/esm/src/errors.d.ts +35 -0
  12. package/dist/esm/src/factory-browser.d.ts +19 -0
  13. package/dist/esm/src/factory-node.d.ts +19 -0
  14. package/dist/esm/src/googleai-mappers.d.ts +73 -0
  15. package/dist/esm/src/helpers.d.ts +30 -0
  16. package/dist/esm/src/index.d.ts +13 -0
  17. package/dist/esm/src/index.node.d.ts +7 -0
  18. package/dist/esm/src/logger.d.ts +18 -0
  19. package/dist/esm/src/methods/chat-session-helpers.d.ts +18 -0
  20. package/dist/esm/src/methods/chat-session.d.ts +77 -0
  21. package/dist/esm/src/methods/chrome-adapter.d.ts +124 -0
  22. package/dist/esm/src/methods/count-tokens.d.ts +21 -0
  23. package/dist/esm/src/methods/generate-content.d.ts +25 -0
  24. package/dist/esm/src/methods/live-session-helpers.d.ts +154 -0
  25. package/dist/esm/src/methods/live-session.d.ts +154 -0
  26. package/dist/esm/src/models/ai-model.d.ts +72 -0
  27. package/dist/esm/src/models/generative-model.d.ts +56 -0
  28. package/dist/esm/src/models/imagen-model.d.ts +102 -0
  29. package/dist/esm/src/models/index.d.ts +20 -0
  30. package/dist/esm/src/models/live-generative-model.d.ts +55 -0
  31. package/dist/esm/src/models/template-generative-model.d.ts +64 -0
  32. package/dist/esm/src/models/template-imagen-model.d.ts +51 -0
  33. package/dist/esm/src/models/utils.d.ts +26 -0
  34. package/dist/esm/src/public-types.d.ts +97 -0
  35. package/dist/esm/src/requests/hybrid-helpers.d.ts +33 -0
  36. package/dist/esm/src/requests/imagen-image-format.d.ts +61 -0
  37. package/dist/esm/src/requests/request-helpers.d.ts +28 -0
  38. package/dist/esm/src/requests/request.d.ts +69 -0
  39. package/dist/esm/src/requests/response-helpers.d.ts +57 -0
  40. package/dist/esm/src/requests/schema-builder.d.ts +170 -0
  41. package/dist/esm/src/requests/stream-reader.d.ts +39 -0
  42. package/dist/esm/src/service.d.ts +35 -0
  43. package/dist/esm/src/types/chrome-adapter.d.ts +61 -0
  44. package/dist/esm/src/types/content.d.ts +266 -0
  45. package/dist/esm/src/types/enums.d.ts +419 -0
  46. package/dist/esm/src/types/error.d.ts +89 -0
  47. package/dist/esm/src/types/googleai.d.ts +57 -0
  48. package/dist/esm/src/types/imagen/index.d.ts +18 -0
  49. package/dist/esm/src/types/imagen/internal.d.ts +134 -0
  50. package/dist/esm/src/types/imagen/requests.d.ts +245 -0
  51. package/dist/esm/src/types/imagen/responses.d.ts +79 -0
  52. package/dist/esm/src/types/index.d.ts +26 -0
  53. package/dist/esm/src/types/internal.d.ts +35 -0
  54. package/dist/esm/src/types/language-model.d.ts +107 -0
  55. package/dist/esm/src/types/live-responses.d.ts +79 -0
  56. package/dist/esm/src/types/requests.d.ts +543 -0
  57. package/dist/esm/src/types/responses.d.ts +607 -0
  58. package/dist/esm/src/types/schema.d.ts +139 -0
  59. package/dist/esm/src/websocket.d.ts +67 -0
  60. package/dist/index.cjs.js +4820 -0
  61. package/dist/index.cjs.js.map +1 -0
  62. package/dist/index.node.cjs.js +4512 -0
  63. package/dist/index.node.cjs.js.map +1 -0
  64. package/dist/index.node.mjs +4457 -0
  65. package/dist/index.node.mjs.map +1 -0
  66. package/dist/src/api.d.ts +121 -0
  67. package/dist/src/backend.d.ts +98 -0
  68. package/dist/src/constants.d.ts +29 -0
  69. package/dist/src/errors.d.ts +35 -0
  70. package/dist/src/factory-browser.d.ts +19 -0
  71. package/dist/src/factory-node.d.ts +19 -0
  72. package/dist/src/googleai-mappers.d.ts +73 -0
  73. package/dist/src/helpers.d.ts +30 -0
  74. package/dist/src/index.d.ts +13 -0
  75. package/dist/src/index.node.d.ts +7 -0
  76. package/dist/src/logger.d.ts +18 -0
  77. package/dist/src/methods/chat-session-helpers.d.ts +18 -0
  78. package/dist/src/methods/chat-session.d.ts +77 -0
  79. package/dist/src/methods/chrome-adapter.d.ts +124 -0
  80. package/dist/src/methods/count-tokens.d.ts +21 -0
  81. package/dist/src/methods/generate-content.d.ts +25 -0
  82. package/dist/src/methods/live-session-helpers.d.ts +154 -0
  83. package/dist/src/methods/live-session.d.ts +154 -0
  84. package/dist/src/models/ai-model.d.ts +72 -0
  85. package/dist/src/models/generative-model.d.ts +56 -0
  86. package/dist/src/models/imagen-model.d.ts +102 -0
  87. package/dist/src/models/index.d.ts +20 -0
  88. package/dist/src/models/live-generative-model.d.ts +55 -0
  89. package/dist/src/models/template-generative-model.d.ts +64 -0
  90. package/dist/src/models/template-imagen-model.d.ts +51 -0
  91. package/dist/src/models/utils.d.ts +26 -0
  92. package/dist/src/public-types.d.ts +97 -0
  93. package/dist/src/requests/hybrid-helpers.d.ts +33 -0
  94. package/dist/src/requests/imagen-image-format.d.ts +61 -0
  95. package/dist/src/requests/request-helpers.d.ts +28 -0
  96. package/dist/src/requests/request.d.ts +69 -0
  97. package/dist/src/requests/response-helpers.d.ts +57 -0
  98. package/dist/src/requests/schema-builder.d.ts +170 -0
  99. package/dist/src/requests/stream-reader.d.ts +39 -0
  100. package/dist/src/service.d.ts +35 -0
  101. package/dist/src/tsdoc-metadata.json +11 -0
  102. package/dist/src/types/chrome-adapter.d.ts +61 -0
  103. package/dist/src/types/content.d.ts +266 -0
  104. package/dist/src/types/enums.d.ts +419 -0
  105. package/dist/src/types/error.d.ts +89 -0
  106. package/dist/src/types/googleai.d.ts +57 -0
  107. package/dist/src/types/imagen/index.d.ts +18 -0
  108. package/dist/src/types/imagen/internal.d.ts +134 -0
  109. package/dist/src/types/imagen/requests.d.ts +245 -0
  110. package/dist/src/types/imagen/responses.d.ts +79 -0
  111. package/dist/src/types/index.d.ts +26 -0
  112. package/dist/src/types/internal.d.ts +35 -0
  113. package/dist/src/types/language-model.d.ts +107 -0
  114. package/dist/src/types/live-responses.d.ts +79 -0
  115. package/dist/src/types/requests.d.ts +543 -0
  116. package/dist/src/types/responses.d.ts +607 -0
  117. package/dist/src/types/schema.d.ts +139 -0
  118. package/dist/src/websocket.d.ts +67 -0
  119. package/package.json +106 -0
@@ -0,0 +1,419 @@
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
+ /**
18
+ * Role is the producer of the content.
19
+ * @public
20
+ */
21
+ export type Role = (typeof POSSIBLE_ROLES)[number];
22
+ /**
23
+ * Possible roles.
24
+ * @public
25
+ */
26
+ export declare const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
27
+ /**
28
+ * Harm categories that would cause prompts or candidates to be blocked.
29
+ * @public
30
+ */
31
+ export declare const HarmCategory: {
32
+ readonly HARM_CATEGORY_HATE_SPEECH: "HARM_CATEGORY_HATE_SPEECH";
33
+ readonly HARM_CATEGORY_SEXUALLY_EXPLICIT: "HARM_CATEGORY_SEXUALLY_EXPLICIT";
34
+ readonly HARM_CATEGORY_HARASSMENT: "HARM_CATEGORY_HARASSMENT";
35
+ readonly HARM_CATEGORY_DANGEROUS_CONTENT: "HARM_CATEGORY_DANGEROUS_CONTENT";
36
+ };
37
+ /**
38
+ * Harm categories that would cause prompts or candidates to be blocked.
39
+ * @public
40
+ */
41
+ export type HarmCategory = (typeof HarmCategory)[keyof typeof HarmCategory];
42
+ /**
43
+ * Threshold above which a prompt or candidate will be blocked.
44
+ * @public
45
+ */
46
+ export declare const HarmBlockThreshold: {
47
+ /**
48
+ * Content with `NEGLIGIBLE` will be allowed.
49
+ */
50
+ readonly BLOCK_LOW_AND_ABOVE: "BLOCK_LOW_AND_ABOVE";
51
+ /**
52
+ * Content with `NEGLIGIBLE` and `LOW` will be allowed.
53
+ */
54
+ readonly BLOCK_MEDIUM_AND_ABOVE: "BLOCK_MEDIUM_AND_ABOVE";
55
+ /**
56
+ * Content with `NEGLIGIBLE`, `LOW`, and `MEDIUM` will be allowed.
57
+ */
58
+ readonly BLOCK_ONLY_HIGH: "BLOCK_ONLY_HIGH";
59
+ /**
60
+ * All content will be allowed.
61
+ */
62
+ readonly BLOCK_NONE: "BLOCK_NONE";
63
+ /**
64
+ * All content will be allowed. This is the same as `BLOCK_NONE`, but the metadata corresponding
65
+ * to the {@link (HarmCategory:type)} will not be present in the response.
66
+ */
67
+ readonly OFF: "OFF";
68
+ };
69
+ /**
70
+ * Threshold above which a prompt or candidate will be blocked.
71
+ * @public
72
+ */
73
+ export type HarmBlockThreshold = (typeof HarmBlockThreshold)[keyof typeof HarmBlockThreshold];
74
+ /**
75
+ * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
76
+ *
77
+ * @public
78
+ */
79
+ export declare const HarmBlockMethod: {
80
+ /**
81
+ * The harm block method uses both probability and severity scores.
82
+ */
83
+ readonly SEVERITY: "SEVERITY";
84
+ /**
85
+ * The harm block method uses the probability score.
86
+ */
87
+ readonly PROBABILITY: "PROBABILITY";
88
+ };
89
+ /**
90
+ * This property is not supported in the Gemini Developer API ({@link GoogleAIBackend}).
91
+ *
92
+ * @public
93
+ */
94
+ export type HarmBlockMethod = (typeof HarmBlockMethod)[keyof typeof HarmBlockMethod];
95
+ /**
96
+ * Probability that a prompt or candidate matches a harm category.
97
+ * @public
98
+ */
99
+ export declare const HarmProbability: {
100
+ /**
101
+ * Content has a negligible chance of being unsafe.
102
+ */
103
+ readonly NEGLIGIBLE: "NEGLIGIBLE";
104
+ /**
105
+ * Content has a low chance of being unsafe.
106
+ */
107
+ readonly LOW: "LOW";
108
+ /**
109
+ * Content has a medium chance of being unsafe.
110
+ */
111
+ readonly MEDIUM: "MEDIUM";
112
+ /**
113
+ * Content has a high chance of being unsafe.
114
+ */
115
+ readonly HIGH: "HIGH";
116
+ };
117
+ /**
118
+ * Probability that a prompt or candidate matches a harm category.
119
+ * @public
120
+ */
121
+ export type HarmProbability = (typeof HarmProbability)[keyof typeof HarmProbability];
122
+ /**
123
+ * Harm severity levels.
124
+ * @public
125
+ */
126
+ export declare const HarmSeverity: {
127
+ /**
128
+ * Negligible level of harm severity.
129
+ */
130
+ readonly HARM_SEVERITY_NEGLIGIBLE: "HARM_SEVERITY_NEGLIGIBLE";
131
+ /**
132
+ * Low level of harm severity.
133
+ */
134
+ readonly HARM_SEVERITY_LOW: "HARM_SEVERITY_LOW";
135
+ /**
136
+ * Medium level of harm severity.
137
+ */
138
+ readonly HARM_SEVERITY_MEDIUM: "HARM_SEVERITY_MEDIUM";
139
+ /**
140
+ * High level of harm severity.
141
+ */
142
+ readonly HARM_SEVERITY_HIGH: "HARM_SEVERITY_HIGH";
143
+ /**
144
+ * Harm severity is not supported.
145
+ *
146
+ * @remarks
147
+ * The GoogleAI backend does not support `HarmSeverity`, so this value is used as a fallback.
148
+ */
149
+ readonly HARM_SEVERITY_UNSUPPORTED: "HARM_SEVERITY_UNSUPPORTED";
150
+ };
151
+ /**
152
+ * Harm severity levels.
153
+ * @public
154
+ */
155
+ export type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
156
+ /**
157
+ * Reason that a prompt was blocked.
158
+ * @public
159
+ */
160
+ export declare const BlockReason: {
161
+ /**
162
+ * Content was blocked by safety settings.
163
+ */
164
+ readonly SAFETY: "SAFETY";
165
+ /**
166
+ * Content was blocked, but the reason is uncategorized.
167
+ */
168
+ readonly OTHER: "OTHER";
169
+ /**
170
+ * Content was blocked because it contained terms from the terminology blocklist.
171
+ */
172
+ readonly BLOCKLIST: "BLOCKLIST";
173
+ /**
174
+ * Content was blocked due to prohibited content.
175
+ */
176
+ readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
177
+ };
178
+ /**
179
+ * Reason that a prompt was blocked.
180
+ * @public
181
+ */
182
+ export type BlockReason = (typeof BlockReason)[keyof typeof BlockReason];
183
+ /**
184
+ * Reason that a candidate finished.
185
+ * @public
186
+ */
187
+ export declare const FinishReason: {
188
+ /**
189
+ * Natural stop point of the model or provided stop sequence.
190
+ */
191
+ readonly STOP: "STOP";
192
+ /**
193
+ * The maximum number of tokens as specified in the request was reached.
194
+ */
195
+ readonly MAX_TOKENS: "MAX_TOKENS";
196
+ /**
197
+ * The candidate content was flagged for safety reasons.
198
+ */
199
+ readonly SAFETY: "SAFETY";
200
+ /**
201
+ * The candidate content was flagged for recitation reasons.
202
+ */
203
+ readonly RECITATION: "RECITATION";
204
+ /**
205
+ * Unknown reason.
206
+ */
207
+ readonly OTHER: "OTHER";
208
+ /**
209
+ * The candidate content contained forbidden terms.
210
+ */
211
+ readonly BLOCKLIST: "BLOCKLIST";
212
+ /**
213
+ * The candidate content potentially contained prohibited content.
214
+ */
215
+ readonly PROHIBITED_CONTENT: "PROHIBITED_CONTENT";
216
+ /**
217
+ * The candidate content potentially contained Sensitive Personally Identifiable Information (SPII).
218
+ */
219
+ readonly SPII: "SPII";
220
+ /**
221
+ * The function call generated by the model was invalid.
222
+ */
223
+ readonly MALFORMED_FUNCTION_CALL: "MALFORMED_FUNCTION_CALL";
224
+ };
225
+ /**
226
+ * Reason that a candidate finished.
227
+ * @public
228
+ */
229
+ export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
230
+ /**
231
+ * @public
232
+ */
233
+ export declare const FunctionCallingMode: {
234
+ /**
235
+ * Default model behavior; model decides to predict either a function call
236
+ * or a natural language response.
237
+ */
238
+ readonly AUTO: "AUTO";
239
+ /**
240
+ * Model is constrained to always predicting a function call only.
241
+ * If `allowed_function_names` is set, the predicted function call will be
242
+ * limited to any one of `allowed_function_names`, else the predicted
243
+ * function call will be any one of the provided `function_declarations`.
244
+ */
245
+ readonly ANY: "ANY";
246
+ /**
247
+ * Model will not predict any function call. Model behavior is same as when
248
+ * not passing any function declarations.
249
+ */
250
+ readonly NONE: "NONE";
251
+ };
252
+ /**
253
+ * @public
254
+ */
255
+ export type FunctionCallingMode = (typeof FunctionCallingMode)[keyof typeof FunctionCallingMode];
256
+ /**
257
+ * Content part modality.
258
+ * @public
259
+ */
260
+ export declare const Modality: {
261
+ /**
262
+ * Unspecified modality.
263
+ */
264
+ readonly MODALITY_UNSPECIFIED: "MODALITY_UNSPECIFIED";
265
+ /**
266
+ * Plain text.
267
+ */
268
+ readonly TEXT: "TEXT";
269
+ /**
270
+ * Image.
271
+ */
272
+ readonly IMAGE: "IMAGE";
273
+ /**
274
+ * Video.
275
+ */
276
+ readonly VIDEO: "VIDEO";
277
+ /**
278
+ * Audio.
279
+ */
280
+ readonly AUDIO: "AUDIO";
281
+ /**
282
+ * Document (for example, PDF).
283
+ */
284
+ readonly DOCUMENT: "DOCUMENT";
285
+ };
286
+ /**
287
+ * Content part modality.
288
+ * @public
289
+ */
290
+ export type Modality = (typeof Modality)[keyof typeof Modality];
291
+ /**
292
+ * Generation modalities to be returned in generation responses.
293
+ *
294
+ * @beta
295
+ */
296
+ export declare const ResponseModality: {
297
+ /**
298
+ * Text.
299
+ * @beta
300
+ */
301
+ readonly TEXT: "TEXT";
302
+ /**
303
+ * Image.
304
+ * @beta
305
+ */
306
+ readonly IMAGE: "IMAGE";
307
+ /**
308
+ * Audio.
309
+ * @beta
310
+ */
311
+ readonly AUDIO: "AUDIO";
312
+ };
313
+ /**
314
+ * Generation modalities to be returned in generation responses.
315
+ *
316
+ * @beta
317
+ */
318
+ export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];
319
+ /**
320
+ * Determines whether inference happens on-device or in-cloud.
321
+ *
322
+ * @remarks
323
+ * <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
324
+ * on-device model. If on-device inference is not available, the SDK
325
+ * will fall back to using a cloud-hosted model.
326
+ * <br/>
327
+ * <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
328
+ * on-device model. The SDK will not fall back to a cloud-hosted model.
329
+ * If on-device inference is not available, inference methods will throw.
330
+ * <br/>
331
+ * <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
332
+ * cloud-hosted model. The SDK will not fall back to an on-device model.
333
+ * <br/>
334
+ * <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
335
+ * cloud-hosted model. If not available, the SDK will fall back to an
336
+ * on-device model.
337
+ *
338
+ * @beta
339
+ */
340
+ export declare const InferenceMode: {
341
+ readonly PREFER_ON_DEVICE: "prefer_on_device";
342
+ readonly ONLY_ON_DEVICE: "only_on_device";
343
+ readonly ONLY_IN_CLOUD: "only_in_cloud";
344
+ readonly PREFER_IN_CLOUD: "prefer_in_cloud";
345
+ };
346
+ /**
347
+ * Determines whether inference happens on-device or in-cloud.
348
+ *
349
+ * @beta
350
+ */
351
+ export type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
352
+ /**
353
+ * Indicates whether inference happened on-device or in-cloud.
354
+ *
355
+ * @beta
356
+ */
357
+ export declare const InferenceSource: {
358
+ readonly ON_DEVICE: "on_device";
359
+ readonly IN_CLOUD: "in_cloud";
360
+ };
361
+ /**
362
+ * Indicates whether inference happened on-device or in-cloud.
363
+ *
364
+ * @beta
365
+ */
366
+ export type InferenceSource = (typeof InferenceSource)[keyof typeof InferenceSource];
367
+ /**
368
+ * Represents the result of the code execution.
369
+ *
370
+ * @public
371
+ */
372
+ export declare const Outcome: {
373
+ UNSPECIFIED: string;
374
+ OK: string;
375
+ FAILED: string;
376
+ DEADLINE_EXCEEDED: string;
377
+ };
378
+ /**
379
+ * Represents the result of the code execution.
380
+ *
381
+ * @public
382
+ */
383
+ export type Outcome = (typeof Outcome)[keyof typeof Outcome];
384
+ /**
385
+ * The programming language of the code.
386
+ *
387
+ * @public
388
+ */
389
+ export declare const Language: {
390
+ UNSPECIFIED: string;
391
+ PYTHON: string;
392
+ };
393
+ /**
394
+ * The programming language of the code.
395
+ *
396
+ * @public
397
+ */
398
+ export type Language = (typeof Language)[keyof typeof Language];
399
+ /**
400
+ * A preset that controls the model's "thinking" process. Use
401
+ * `ThinkingLevel.LOW` for faster responses on less complex tasks, and
402
+ * `ThinkingLevel.HIGH` for better reasoning on more complex tasks.
403
+ *
404
+ * @public
405
+ */
406
+ export declare const ThinkingLevel: {
407
+ MINIMAL: string;
408
+ LOW: string;
409
+ MEDIUM: string;
410
+ HIGH: string;
411
+ };
412
+ /**
413
+ * A preset that controls the model's "thinking" process. Use
414
+ * `ThinkingLevel.LOW` for faster responses on less complex tasks, and
415
+ * `ThinkingLevel.HIGH` for better reasoning on more complex tasks.
416
+ *
417
+ * @public
418
+ */
419
+ export type ThinkingLevel = (typeof ThinkingLevel)[keyof typeof ThinkingLevel];
@@ -0,0 +1,89 @@
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 { GenerateContentResponse } from './responses';
18
+ /**
19
+ * Details object that may be included in an error response.
20
+ *
21
+ * @public
22
+ */
23
+ export interface ErrorDetails {
24
+ '@type'?: string;
25
+ /** The reason for the error. */
26
+ reason?: string;
27
+ /** The domain where the error occurred. */
28
+ domain?: string;
29
+ /** Additional metadata about the error. */
30
+ metadata?: Record<string, unknown>;
31
+ /** Any other relevant information about the error. */
32
+ [key: string]: unknown;
33
+ }
34
+ /**
35
+ * Details object that contains data originating from a bad HTTP response.
36
+ *
37
+ * @public
38
+ */
39
+ export interface CustomErrorData {
40
+ /** HTTP status code of the error response. */
41
+ status?: number;
42
+ /** HTTP status text of the error response. */
43
+ statusText?: string;
44
+ /** Response from a {@link GenerateContentRequest} */
45
+ response?: GenerateContentResponse;
46
+ /** Optional additional details about the error. */
47
+ errorDetails?: ErrorDetails[];
48
+ }
49
+ /**
50
+ * Standardized error codes that {@link AIError} can have.
51
+ *
52
+ * @public
53
+ */
54
+ export declare const AIErrorCode: {
55
+ /** A generic error occurred. */
56
+ readonly ERROR: "error";
57
+ /** An error occurred in a request. */
58
+ readonly REQUEST_ERROR: "request-error";
59
+ /** An error occurred in a response. */
60
+ readonly RESPONSE_ERROR: "response-error";
61
+ /** An error occurred while performing a fetch. */
62
+ readonly FETCH_ERROR: "fetch-error";
63
+ /** An error occurred because an operation was attempted on a closed session. */
64
+ readonly SESSION_CLOSED: "session-closed";
65
+ /** An error associated with a Content object. */
66
+ readonly INVALID_CONTENT: "invalid-content";
67
+ /** An error due to the Firebase API not being enabled in the Console. */
68
+ readonly API_NOT_ENABLED: "api-not-enabled";
69
+ /** An error due to invalid Schema input. */
70
+ readonly INVALID_SCHEMA: "invalid-schema";
71
+ /** An error occurred due to a missing Firebase API key. */
72
+ readonly NO_API_KEY: "no-api-key";
73
+ /** An error occurred due to a missing Firebase app ID. */
74
+ readonly NO_APP_ID: "no-app-id";
75
+ /** An error occurred due to a model name not being specified during initialization. */
76
+ readonly NO_MODEL: "no-model";
77
+ /** An error occurred due to a missing project ID. */
78
+ readonly NO_PROJECT_ID: "no-project-id";
79
+ /** An error occurred while parsing. */
80
+ readonly PARSE_FAILED: "parse-failed";
81
+ /** An error occurred due an attempt to use an unsupported feature. */
82
+ readonly UNSUPPORTED: "unsupported";
83
+ };
84
+ /**
85
+ * Standardized error codes that {@link AIError} can have.
86
+ *
87
+ * @public
88
+ */
89
+ export type AIErrorCode = (typeof AIErrorCode)[keyof typeof AIErrorCode];
@@ -0,0 +1,57 @@
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 { Tool, GenerationConfig, Citation, FinishReason, GroundingMetadata, PromptFeedback, SafetyRating, UsageMetadata, URLContextMetadata } from '../public-types';
18
+ import { Content, Part } from './content';
19
+ /**
20
+ * @internal
21
+ */
22
+ export interface GoogleAICountTokensRequest {
23
+ generateContentRequest: {
24
+ model: string;
25
+ contents: Content[];
26
+ systemInstruction?: string | Part | Content;
27
+ tools?: Tool[];
28
+ generationConfig?: GenerationConfig;
29
+ };
30
+ }
31
+ /**
32
+ * @internal
33
+ */
34
+ export interface GoogleAIGenerateContentResponse {
35
+ candidates?: GoogleAIGenerateContentCandidate[];
36
+ promptFeedback?: PromptFeedback;
37
+ usageMetadata?: UsageMetadata;
38
+ }
39
+ /**
40
+ * @internal
41
+ */
42
+ export interface GoogleAIGenerateContentCandidate {
43
+ index: number;
44
+ content: Content;
45
+ finishReason?: FinishReason;
46
+ finishMessage?: string;
47
+ safetyRatings?: SafetyRating[];
48
+ citationMetadata?: GoogleAICitationMetadata;
49
+ groundingMetadata?: GroundingMetadata;
50
+ urlContextMetadata?: URLContextMetadata;
51
+ }
52
+ /**
53
+ * @internal
54
+ */
55
+ export interface GoogleAICitationMetadata {
56
+ citationSources: Citation[];
57
+ }
@@ -0,0 +1,18 @@
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
+ export * from './requests';
18
+ export * from './responses';