@firebase/ai 2.3.0-canary.0ffcb26af → 2.3.0-canary.1bcf83d7f
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 +1 -119
- package/dist/ai.d.ts +1 -120
- package/dist/esm/index.esm.js +3 -54
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/types/googleai.d.ts +1 -2
- package/dist/esm/src/types/requests.d.ts +1 -21
- package/dist/esm/src/types/responses.d.ts +0 -92
- package/dist/index.cjs.js +2 -54
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +2 -54
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +3 -54
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/types/googleai.d.ts +1 -2
- package/dist/src/types/requests.d.ts +1 -21
- package/dist/src/types/responses.d.ts +0 -92
- package/package.json +8 -8
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { Tool, GenerationConfig, Citation, FinishReason, GroundingMetadata, PromptFeedback, SafetyRating, UsageMetadata
|
|
17
|
+
import { Tool, GenerationConfig, Citation, FinishReason, GroundingMetadata, PromptFeedback, SafetyRating, UsageMetadata } from '../public-types';
|
|
18
18
|
import { Content, Part } from './content';
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
@@ -47,7 +47,6 @@ export interface GoogleAIGenerateContentCandidate {
|
|
|
47
47
|
safetyRatings?: SafetyRating[];
|
|
48
48
|
citationMetadata?: GoogleAICitationMetadata;
|
|
49
49
|
groundingMetadata?: GroundingMetadata;
|
|
50
|
-
urlContextMetadata?: URLContextMetadata;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* @internal
|
|
@@ -218,7 +218,7 @@ export interface RequestOptions {
|
|
|
218
218
|
* Defines a tool that model can call to access external knowledge.
|
|
219
219
|
* @public
|
|
220
220
|
*/
|
|
221
|
-
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool
|
|
221
|
+
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
|
|
222
222
|
/**
|
|
223
223
|
* Structured representation of a function declaration as defined by the
|
|
224
224
|
* {@link https://spec.openapis.org/oas/v3.0.3 | OpenAPI 3.0 specification}.
|
|
@@ -291,26 +291,6 @@ export interface CodeExecutionTool {
|
|
|
291
291
|
*/
|
|
292
292
|
export interface GoogleSearch {
|
|
293
293
|
}
|
|
294
|
-
/**
|
|
295
|
-
* A tool that allows you to provide additional context to the models in the form of public web
|
|
296
|
-
* URLs. By including URLs in your request, the Gemini model will access the content from those
|
|
297
|
-
* pages to inform and enhance its response.
|
|
298
|
-
*
|
|
299
|
-
* @beta
|
|
300
|
-
*/
|
|
301
|
-
export interface URLContextTool {
|
|
302
|
-
/**
|
|
303
|
-
* Specifies the URL Context configuration.
|
|
304
|
-
*/
|
|
305
|
-
urlContext: URLContext;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Specifies the URL Context configuration.
|
|
309
|
-
*
|
|
310
|
-
* @beta
|
|
311
|
-
*/
|
|
312
|
-
export interface URLContext {
|
|
313
|
-
}
|
|
314
294
|
/**
|
|
315
295
|
* A `FunctionDeclarationsTool` is a piece of code that enables the system to
|
|
316
296
|
* interact with external systems to perform an action, or set of actions,
|
|
@@ -102,16 +102,8 @@ export interface UsageMetadata {
|
|
|
102
102
|
*/
|
|
103
103
|
thoughtsTokenCount?: number;
|
|
104
104
|
totalTokenCount: number;
|
|
105
|
-
/**
|
|
106
|
-
* The number of tokens used by tools.
|
|
107
|
-
*/
|
|
108
|
-
toolUsePromptTokenCount?: number;
|
|
109
105
|
promptTokensDetails?: ModalityTokenCount[];
|
|
110
106
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
111
|
-
/**
|
|
112
|
-
* A list of tokens used by tools, broken down by modality.
|
|
113
|
-
*/
|
|
114
|
-
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
115
107
|
}
|
|
116
108
|
/**
|
|
117
109
|
* Represents token counting info for a single modality.
|
|
@@ -151,7 +143,6 @@ export interface GenerateContentCandidate {
|
|
|
151
143
|
safetyRatings?: SafetyRating[];
|
|
152
144
|
citationMetadata?: CitationMetadata;
|
|
153
145
|
groundingMetadata?: GroundingMetadata;
|
|
154
|
-
urlContextMetadata?: URLContextMetadata;
|
|
155
146
|
}
|
|
156
147
|
/**
|
|
157
148
|
* Citation metadata that may be found on a {@link GenerateContentCandidate}.
|
|
@@ -332,89 +323,6 @@ export interface Segment {
|
|
|
332
323
|
*/
|
|
333
324
|
text: string;
|
|
334
325
|
}
|
|
335
|
-
/**
|
|
336
|
-
* Metadata related to {@link URLContextTool}.
|
|
337
|
-
*
|
|
338
|
-
* @beta
|
|
339
|
-
*/
|
|
340
|
-
export interface URLContextMetadata {
|
|
341
|
-
/**
|
|
342
|
-
* List of URL metadata used to provide context to the Gemini model.
|
|
343
|
-
*/
|
|
344
|
-
urlMetadata: URLMetadata[];
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Metadata for a single URL retrieved by the {@link URLContextTool} tool.
|
|
348
|
-
*
|
|
349
|
-
* @beta
|
|
350
|
-
*/
|
|
351
|
-
export interface URLMetadata {
|
|
352
|
-
/**
|
|
353
|
-
* The retrieved URL.
|
|
354
|
-
*/
|
|
355
|
-
retrievedUrl?: string;
|
|
356
|
-
/**
|
|
357
|
-
* The status of the URL retrieval.
|
|
358
|
-
*/
|
|
359
|
-
urlRetrievalStatus?: URLRetrievalStatus;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* The status of a URL retrieval.
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
* <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
|
|
366
|
-
* <br/>
|
|
367
|
-
* <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
|
|
368
|
-
* <br/>
|
|
369
|
-
* <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
|
|
370
|
-
* <br/>
|
|
371
|
-
* <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
|
|
372
|
-
* <br/>
|
|
373
|
-
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
374
|
-
* <br/>
|
|
375
|
-
*
|
|
376
|
-
* @beta
|
|
377
|
-
*/
|
|
378
|
-
export declare const URLRetrievalStatus: {
|
|
379
|
-
/**
|
|
380
|
-
* Unspecified retrieval status.
|
|
381
|
-
*/
|
|
382
|
-
URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
|
|
383
|
-
/**
|
|
384
|
-
* The URL retrieval was successful.
|
|
385
|
-
*/
|
|
386
|
-
URL_RETRIEVAL_STATUS_SUCCESS: string;
|
|
387
|
-
/**
|
|
388
|
-
* The URL retrieval failed.
|
|
389
|
-
*/
|
|
390
|
-
URL_RETRIEVAL_STATUS_ERROR: string;
|
|
391
|
-
/**
|
|
392
|
-
* The URL retrieval failed because the content is behind a paywall.
|
|
393
|
-
*/
|
|
394
|
-
URL_RETRIEVAL_STATUS_PAYWALL: string;
|
|
395
|
-
/**
|
|
396
|
-
* The URL retrieval failed because the content is unsafe.
|
|
397
|
-
*/
|
|
398
|
-
URL_RETRIEVAL_STATUS_UNSAFE: string;
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* The status of a URL retrieval.
|
|
402
|
-
*
|
|
403
|
-
* @remarks
|
|
404
|
-
* <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
|
|
405
|
-
* <br/>
|
|
406
|
-
* <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
|
|
407
|
-
* <br/>
|
|
408
|
-
* <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
|
|
409
|
-
* <br/>
|
|
410
|
-
* <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
|
|
411
|
-
* <br/>
|
|
412
|
-
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
413
|
-
* <br/>
|
|
414
|
-
*
|
|
415
|
-
* @beta
|
|
416
|
-
*/
|
|
417
|
-
export type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
|
|
418
326
|
/**
|
|
419
327
|
* @public
|
|
420
328
|
*/
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
|
|
|
8
8
|
var logger$1 = require('@firebase/logger');
|
|
9
9
|
|
|
10
10
|
var name = "@firebase/ai";
|
|
11
|
-
var version = "2.3.0-canary.
|
|
11
|
+
var version = "2.3.0-canary.1bcf83d7f";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -420,45 +420,6 @@ const Language = {
|
|
|
420
420
|
* See the License for the specific language governing permissions and
|
|
421
421
|
* limitations under the License.
|
|
422
422
|
*/
|
|
423
|
-
/**
|
|
424
|
-
* The status of a URL retrieval.
|
|
425
|
-
*
|
|
426
|
-
* @remarks
|
|
427
|
-
* <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
|
|
428
|
-
* <br/>
|
|
429
|
-
* <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
|
|
430
|
-
* <br/>
|
|
431
|
-
* <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
|
|
432
|
-
* <br/>
|
|
433
|
-
* <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
|
|
434
|
-
* <br/>
|
|
435
|
-
* <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
|
|
436
|
-
* <br/>
|
|
437
|
-
*
|
|
438
|
-
* @beta
|
|
439
|
-
*/
|
|
440
|
-
const URLRetrievalStatus = {
|
|
441
|
-
/**
|
|
442
|
-
* Unspecified retrieval status.
|
|
443
|
-
*/
|
|
444
|
-
URL_RETRIEVAL_STATUS_UNSPECIFIED: 'URL_RETRIEVAL_STATUS_UNSPECIFIED',
|
|
445
|
-
/**
|
|
446
|
-
* The URL retrieval was successful.
|
|
447
|
-
*/
|
|
448
|
-
URL_RETRIEVAL_STATUS_SUCCESS: 'URL_RETRIEVAL_STATUS_SUCCESS',
|
|
449
|
-
/**
|
|
450
|
-
* The URL retrieval failed.
|
|
451
|
-
*/
|
|
452
|
-
URL_RETRIEVAL_STATUS_ERROR: 'URL_RETRIEVAL_STATUS_ERROR',
|
|
453
|
-
/**
|
|
454
|
-
* The URL retrieval failed because the content is behind a paywall.
|
|
455
|
-
*/
|
|
456
|
-
URL_RETRIEVAL_STATUS_PAYWALL: 'URL_RETRIEVAL_STATUS_PAYWALL',
|
|
457
|
-
/**
|
|
458
|
-
* The URL retrieval failed because the content is unsafe.
|
|
459
|
-
*/
|
|
460
|
-
URL_RETRIEVAL_STATUS_UNSAFE: 'URL_RETRIEVAL_STATUS_UNSAFE'
|
|
461
|
-
};
|
|
462
423
|
/**
|
|
463
424
|
* The types of responses that can be returned by {@link LiveSession.receive}.
|
|
464
425
|
*
|
|
@@ -1929,8 +1890,7 @@ function mapGenerateContentCandidates(candidates) {
|
|
|
1929
1890
|
finishMessage: candidate.finishMessage,
|
|
1930
1891
|
safetyRatings: mappedSafetyRatings,
|
|
1931
1892
|
citationMetadata,
|
|
1932
|
-
groundingMetadata: candidate.groundingMetadata
|
|
1933
|
-
urlContextMetadata: candidate.urlContextMetadata
|
|
1893
|
+
groundingMetadata: candidate.groundingMetadata
|
|
1934
1894
|
};
|
|
1935
1895
|
mappedCandidates.push(mappedCandidate);
|
|
1936
1896
|
});
|
|
@@ -2100,17 +2060,6 @@ function aggregateResponses(responses) {
|
|
|
2100
2060
|
candidate.safetyRatings;
|
|
2101
2061
|
aggregatedResponse.candidates[i].groundingMetadata =
|
|
2102
2062
|
candidate.groundingMetadata;
|
|
2103
|
-
// The urlContextMetadata object is defined in the first chunk of the response stream.
|
|
2104
|
-
// In all subsequent chunks, the urlContextMetadata object will be undefined. We need to
|
|
2105
|
-
// make sure that we don't overwrite the first value urlContextMetadata object with undefined.
|
|
2106
|
-
// FIXME: What happens if we receive a second, valid urlContextMetadata object?
|
|
2107
|
-
const urlContextMetadata = candidate.urlContextMetadata;
|
|
2108
|
-
if (typeof urlContextMetadata === 'object' &&
|
|
2109
|
-
urlContextMetadata !== null &&
|
|
2110
|
-
Object.keys(urlContextMetadata).length > 0) {
|
|
2111
|
-
aggregatedResponse.candidates[i].urlContextMetadata =
|
|
2112
|
-
urlContextMetadata;
|
|
2113
|
-
}
|
|
2114
2063
|
/**
|
|
2115
2064
|
* Candidates should always have content and parts, but this handles
|
|
2116
2065
|
* possible malformed responses.
|
|
@@ -4129,7 +4078,6 @@ exports.ResponseModality = ResponseModality;
|
|
|
4129
4078
|
exports.Schema = Schema;
|
|
4130
4079
|
exports.SchemaType = SchemaType;
|
|
4131
4080
|
exports.StringSchema = StringSchema;
|
|
4132
|
-
exports.URLRetrievalStatus = URLRetrievalStatus;
|
|
4133
4081
|
exports.VertexAIBackend = VertexAIBackend;
|
|
4134
4082
|
exports.getAI = getAI;
|
|
4135
4083
|
exports.getGenerativeModel = getGenerativeModel;
|