@firebase/ai 2.2.1 → 2.3.0-canary.0ffcb26af
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 +280 -32
- package/dist/ai.d.ts +287 -32
- package/dist/esm/index.esm.js +2820 -2659
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/factory-browser.d.ts +19 -0
- package/dist/esm/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/esm/src/types/chrome-adapter.d.ts +2 -2
- package/dist/esm/src/types/content.d.ts +81 -2
- package/dist/esm/src/types/enums.d.ts +53 -4
- package/dist/esm/src/types/googleai.d.ts +2 -1
- package/dist/esm/src/types/language-model.d.ts +10 -20
- package/dist/esm/src/types/requests.d.ts +35 -7
- package/dist/esm/src/types/responses.d.ts +92 -0
- package/dist/index.cjs.js +2769 -2605
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +169 -22
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +167 -23
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/factory-browser.d.ts +19 -0
- package/dist/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/src/types/chrome-adapter.d.ts +2 -2
- package/dist/src/types/content.d.ts +81 -2
- package/dist/src/types/enums.d.ts +53 -4
- package/dist/src/types/googleai.d.ts +2 -1
- package/dist/src/types/language-model.d.ts +10 -20
- package/dist/src/types/requests.d.ts +35 -7
- package/dist/src/types/responses.d.ts +92 -0
- package/package.json +10 -9
|
@@ -0,0 +1,19 @@
|
|
|
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 { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
18
|
+
import { AIService } from './service';
|
|
19
|
+
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 { GenerateContentRequest, ChromeAdapter } from '../types';
|
|
18
|
+
/**
|
|
19
|
+
* Dispatches a request to the appropriate backend (on-device or in-cloud)
|
|
20
|
+
* based on the inference mode.
|
|
21
|
+
*
|
|
22
|
+
* @param request - The request to be sent.
|
|
23
|
+
* @param chromeAdapter - The on-device model adapter.
|
|
24
|
+
* @param onDeviceCall - The function to call for on-device inference.
|
|
25
|
+
* @param inCloudCall - The function to call for in-cloud inference.
|
|
26
|
+
* @returns The response from the backend.
|
|
27
|
+
*/
|
|
28
|
+
export declare function callCloudOrDevice<Response>(request: GenerateContentRequest, chromeAdapter: ChromeAdapter | undefined, onDeviceCall: () => Promise<Response>, inCloudCall: () => Promise<Response>): Promise<Response>;
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { CountTokensRequest, GenerateContentRequest } from './requests';
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Defines an inference "backend" that uses Chrome's on-device model,
|
|
20
20
|
* and encapsulates logic for detecting when on-device inference is
|
|
21
21
|
* possible.
|
|
22
22
|
*
|
|
23
23
|
* These methods should not be called directly by the user.
|
|
24
24
|
*
|
|
25
|
-
* @
|
|
25
|
+
* @beta
|
|
26
26
|
*/
|
|
27
27
|
export interface ChromeAdapter {
|
|
28
28
|
/**
|
|
@@ -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 { Role } from './enums';
|
|
17
|
+
import { Language, Outcome, Role } from './enums';
|
|
18
18
|
/**
|
|
19
19
|
* Content type for both prompts and response candidates.
|
|
20
20
|
* @public
|
|
@@ -28,7 +28,7 @@ export interface Content {
|
|
|
28
28
|
* part types.
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
|
|
31
|
+
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
|
|
32
32
|
/**
|
|
33
33
|
* Content part interface if the part represents a text string.
|
|
34
34
|
* @public
|
|
@@ -43,6 +43,8 @@ export interface TextPart {
|
|
|
43
43
|
* @internal
|
|
44
44
|
*/
|
|
45
45
|
thoughtSignature?: string;
|
|
46
|
+
executableCode?: never;
|
|
47
|
+
codeExecutionResult?: never;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
50
|
* Content part interface if the part represents an image.
|
|
@@ -62,6 +64,8 @@ export interface InlineDataPart {
|
|
|
62
64
|
* @internal
|
|
63
65
|
*/
|
|
64
66
|
thoughtSignature?: never;
|
|
67
|
+
executableCode?: never;
|
|
68
|
+
codeExecutionResult?: never;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Describes the input video content.
|
|
@@ -93,6 +97,8 @@ export interface FunctionCallPart {
|
|
|
93
97
|
* @internal
|
|
94
98
|
*/
|
|
95
99
|
thoughtSignature?: never;
|
|
100
|
+
executableCode?: never;
|
|
101
|
+
codeExecutionResult?: never;
|
|
96
102
|
}
|
|
97
103
|
/**
|
|
98
104
|
* Content part interface if the part represents {@link FunctionResponse}.
|
|
@@ -108,6 +114,8 @@ export interface FunctionResponsePart {
|
|
|
108
114
|
* @internal
|
|
109
115
|
*/
|
|
110
116
|
thoughtSignature?: never;
|
|
117
|
+
executableCode?: never;
|
|
118
|
+
codeExecutionResult?: never;
|
|
111
119
|
}
|
|
112
120
|
/**
|
|
113
121
|
* Content part interface if the part represents {@link FileData}
|
|
@@ -124,6 +132,77 @@ export interface FileDataPart {
|
|
|
124
132
|
* @internal
|
|
125
133
|
*/
|
|
126
134
|
thoughtSignature?: never;
|
|
135
|
+
executableCode?: never;
|
|
136
|
+
codeExecutionResult?: never;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Represents the code that is executed by the model.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export interface ExecutableCodePart {
|
|
144
|
+
text?: never;
|
|
145
|
+
inlineData?: never;
|
|
146
|
+
functionCall?: never;
|
|
147
|
+
functionResponse?: never;
|
|
148
|
+
fileData: never;
|
|
149
|
+
thought?: never;
|
|
150
|
+
/**
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
thoughtSignature?: never;
|
|
154
|
+
executableCode?: ExecutableCode;
|
|
155
|
+
codeExecutionResult?: never;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Represents the code execution result from the model.
|
|
159
|
+
*
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
export interface CodeExecutionResultPart {
|
|
163
|
+
text?: never;
|
|
164
|
+
inlineData?: never;
|
|
165
|
+
functionCall?: never;
|
|
166
|
+
functionResponse?: never;
|
|
167
|
+
fileData: never;
|
|
168
|
+
thought?: never;
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
thoughtSignature?: never;
|
|
173
|
+
executableCode?: never;
|
|
174
|
+
codeExecutionResult?: CodeExecutionResult;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* An interface for executable code returned by the model.
|
|
178
|
+
*
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
export interface ExecutableCode {
|
|
182
|
+
/**
|
|
183
|
+
* The programming language of the code.
|
|
184
|
+
*/
|
|
185
|
+
language?: Language;
|
|
186
|
+
/**
|
|
187
|
+
* The source code to be executed.
|
|
188
|
+
*/
|
|
189
|
+
code?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The results of code execution run by the model.
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
export interface CodeExecutionResult {
|
|
197
|
+
/**
|
|
198
|
+
* The result of the code execution.
|
|
199
|
+
*/
|
|
200
|
+
outcome?: Outcome;
|
|
201
|
+
/**
|
|
202
|
+
* The output from the code execution, or an error message
|
|
203
|
+
* if it failed.
|
|
204
|
+
*/
|
|
205
|
+
output?: string;
|
|
127
206
|
}
|
|
128
207
|
/**
|
|
129
208
|
* A predicted {@link FunctionCall} returned from the model
|
|
@@ -317,18 +317,67 @@ export declare const ResponseModality: {
|
|
|
317
317
|
*/
|
|
318
318
|
export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality];
|
|
319
319
|
/**
|
|
320
|
-
* <b>(EXPERIMENTAL)</b>
|
|
321
320
|
* Determines whether inference happens on-device or in-cloud.
|
|
322
|
-
*
|
|
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
|
|
323
339
|
*/
|
|
324
340
|
export declare const InferenceMode: {
|
|
325
341
|
readonly PREFER_ON_DEVICE: "prefer_on_device";
|
|
326
342
|
readonly ONLY_ON_DEVICE: "only_on_device";
|
|
327
343
|
readonly ONLY_IN_CLOUD: "only_in_cloud";
|
|
344
|
+
readonly PREFER_IN_CLOUD: "prefer_in_cloud";
|
|
328
345
|
};
|
|
329
346
|
/**
|
|
330
|
-
* <b>(EXPERIMENTAL)</b>
|
|
331
347
|
* Determines whether inference happens on-device or in-cloud.
|
|
332
|
-
*
|
|
348
|
+
*
|
|
349
|
+
* @beta
|
|
333
350
|
*/
|
|
334
351
|
export type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
352
|
+
/**
|
|
353
|
+
* Represents the result of the code execution.
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
export declare const Outcome: {
|
|
358
|
+
UNSPECIFIED: string;
|
|
359
|
+
OK: string;
|
|
360
|
+
FAILED: string;
|
|
361
|
+
DEADLINE_EXCEEDED: string;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* Represents the result of the code execution.
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
*/
|
|
368
|
+
export type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
369
|
+
/**
|
|
370
|
+
* The programming language of the code.
|
|
371
|
+
*
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
export declare const Language: {
|
|
375
|
+
UNSPECIFIED: string;
|
|
376
|
+
PYTHON: string;
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* The programming language of the code.
|
|
380
|
+
*
|
|
381
|
+
* @public
|
|
382
|
+
*/
|
|
383
|
+
export type Language = (typeof Language)[keyof typeof Language];
|
|
@@ -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 } from '../public-types';
|
|
17
|
+
import { Tool, GenerationConfig, Citation, FinishReason, GroundingMetadata, PromptFeedback, SafetyRating, UsageMetadata, URLContextMetadata } from '../public-types';
|
|
18
18
|
import { Content, Part } from './content';
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
@@ -47,6 +47,7 @@ export interface GoogleAIGenerateContentCandidate {
|
|
|
47
47
|
safetyRatings?: SafetyRating[];
|
|
48
48
|
citationMetadata?: GoogleAICitationMetadata;
|
|
49
49
|
groundingMetadata?: GroundingMetadata;
|
|
50
|
+
urlContextMetadata?: URLContextMetadata;
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* @internal
|
|
@@ -39,9 +39,8 @@ export declare enum Availability {
|
|
|
39
39
|
'AVAILABLE' = "available"
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* <b>(EXPERIMENTAL)</b>
|
|
43
42
|
* Configures the creation of an on-device language model session.
|
|
44
|
-
* @
|
|
43
|
+
* @beta
|
|
45
44
|
*/
|
|
46
45
|
export interface LanguageModelCreateCoreOptions {
|
|
47
46
|
topK?: number;
|
|
@@ -49,69 +48,60 @@ export interface LanguageModelCreateCoreOptions {
|
|
|
49
48
|
expectedInputs?: LanguageModelExpected[];
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
|
-
* <b>(EXPERIMENTAL)</b>
|
|
53
51
|
* Configures the creation of an on-device language model session.
|
|
54
|
-
* @
|
|
52
|
+
* @beta
|
|
55
53
|
*/
|
|
56
54
|
export interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
|
|
57
55
|
signal?: AbortSignal;
|
|
58
56
|
initialPrompts?: LanguageModelMessage[];
|
|
59
57
|
}
|
|
60
58
|
/**
|
|
61
|
-
* <b>(EXPERIMENTAL)</b>
|
|
62
59
|
* Options for an on-device language model prompt.
|
|
63
|
-
* @
|
|
60
|
+
* @beta
|
|
64
61
|
*/
|
|
65
62
|
export interface LanguageModelPromptOptions {
|
|
66
63
|
responseConstraint?: object;
|
|
67
64
|
}
|
|
68
65
|
/**
|
|
69
|
-
* <b>(EXPERIMENTAL)</b>
|
|
70
66
|
* Options for the expected inputs for an on-device language model.
|
|
71
|
-
* @
|
|
67
|
+
* @beta
|
|
72
68
|
*/ export interface LanguageModelExpected {
|
|
73
69
|
type: LanguageModelMessageType;
|
|
74
70
|
languages?: string[];
|
|
75
71
|
}
|
|
76
72
|
/**
|
|
77
|
-
* <b>(EXPERIMENTAL)</b>
|
|
78
73
|
* An on-device language model prompt.
|
|
79
|
-
* @
|
|
74
|
+
* @beta
|
|
80
75
|
*/
|
|
81
76
|
export type LanguageModelPrompt = LanguageModelMessage[];
|
|
82
77
|
/**
|
|
83
|
-
* <b>(EXPERIMENTAL)</b>
|
|
84
78
|
* An on-device language model message.
|
|
85
|
-
* @
|
|
79
|
+
* @beta
|
|
86
80
|
*/
|
|
87
81
|
export interface LanguageModelMessage {
|
|
88
82
|
role: LanguageModelMessageRole;
|
|
89
83
|
content: LanguageModelMessageContent[];
|
|
90
84
|
}
|
|
91
85
|
/**
|
|
92
|
-
* <b>(EXPERIMENTAL)</b>
|
|
93
86
|
* An on-device language model content object.
|
|
94
|
-
* @
|
|
87
|
+
* @beta
|
|
95
88
|
*/
|
|
96
89
|
export interface LanguageModelMessageContent {
|
|
97
90
|
type: LanguageModelMessageType;
|
|
98
91
|
value: LanguageModelMessageContentValue;
|
|
99
92
|
}
|
|
100
93
|
/**
|
|
101
|
-
* <b>(EXPERIMENTAL)</b>
|
|
102
94
|
* Allowable roles for on-device language model usage.
|
|
103
|
-
* @
|
|
95
|
+
* @beta
|
|
104
96
|
*/
|
|
105
97
|
export type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
|
|
106
98
|
/**
|
|
107
|
-
* <b>(EXPERIMENTAL)</b>
|
|
108
99
|
* Allowable types for on-device language model messages.
|
|
109
|
-
* @
|
|
100
|
+
* @beta
|
|
110
101
|
*/
|
|
111
102
|
export type LanguageModelMessageType = 'text' | 'image' | 'audio';
|
|
112
103
|
/**
|
|
113
|
-
* <b>(EXPERIMENTAL)</b>
|
|
114
104
|
* Content formats that can be provided as on-device message content.
|
|
115
|
-
* @
|
|
105
|
+
* @beta
|
|
116
106
|
*/
|
|
117
107
|
export type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
|
|
@@ -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;
|
|
221
|
+
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
|
|
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}.
|
|
@@ -262,8 +262,6 @@ export interface GoogleSearchTool {
|
|
|
262
262
|
/**
|
|
263
263
|
* Specifies the Google Search configuration.
|
|
264
264
|
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
265
|
-
* Specifies the Google Search configuration. Currently, this is an empty object, but it's
|
|
266
|
-
* reserved for future configuration options.
|
|
267
265
|
*
|
|
268
266
|
* When using this feature, you are required to comply with the "Grounding with Google Search"
|
|
269
267
|
* usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
|
|
@@ -272,6 +270,18 @@ export interface GoogleSearchTool {
|
|
|
272
270
|
*/
|
|
273
271
|
googleSearch: GoogleSearch;
|
|
274
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* A tool that enables the model to use code execution.
|
|
275
|
+
*
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
export interface CodeExecutionTool {
|
|
279
|
+
/**
|
|
280
|
+
* Specifies the Google Search configuration.
|
|
281
|
+
* Currently, this is an empty object, but it's reserved for future configuration options.
|
|
282
|
+
*/
|
|
283
|
+
codeExecution: {};
|
|
284
|
+
}
|
|
275
285
|
/**
|
|
276
286
|
* Specifies the Google Search configuration.
|
|
277
287
|
*
|
|
@@ -281,6 +291,26 @@ export interface GoogleSearchTool {
|
|
|
281
291
|
*/
|
|
282
292
|
export interface GoogleSearch {
|
|
283
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
|
+
}
|
|
284
314
|
/**
|
|
285
315
|
* A `FunctionDeclarationsTool` is a piece of code that enables the system to
|
|
286
316
|
* interact with external systems to perform an action, or set of actions,
|
|
@@ -315,19 +345,17 @@ export interface FunctionCallingConfig {
|
|
|
315
345
|
allowedFunctionNames?: string[];
|
|
316
346
|
}
|
|
317
347
|
/**
|
|
318
|
-
* <b>(EXPERIMENTAL)</b>
|
|
319
348
|
* Encapsulates configuration for on-device inference.
|
|
320
349
|
*
|
|
321
|
-
* @
|
|
350
|
+
* @beta
|
|
322
351
|
*/
|
|
323
352
|
export interface OnDeviceParams {
|
|
324
353
|
createOptions?: LanguageModelCreateOptions;
|
|
325
354
|
promptOptions?: LanguageModelPromptOptions;
|
|
326
355
|
}
|
|
327
356
|
/**
|
|
328
|
-
* <b>(EXPERIMENTAL)</b>
|
|
329
357
|
* Configures hybrid inference.
|
|
330
|
-
* @
|
|
358
|
+
* @beta
|
|
331
359
|
*/
|
|
332
360
|
export interface HybridParams {
|
|
333
361
|
/**
|
|
@@ -102,8 +102,16 @@ 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;
|
|
105
109
|
promptTokensDetails?: ModalityTokenCount[];
|
|
106
110
|
candidatesTokensDetails?: ModalityTokenCount[];
|
|
111
|
+
/**
|
|
112
|
+
* A list of tokens used by tools, broken down by modality.
|
|
113
|
+
*/
|
|
114
|
+
toolUsePromptTokensDetails?: ModalityTokenCount[];
|
|
107
115
|
}
|
|
108
116
|
/**
|
|
109
117
|
* Represents token counting info for a single modality.
|
|
@@ -143,6 +151,7 @@ export interface GenerateContentCandidate {
|
|
|
143
151
|
safetyRatings?: SafetyRating[];
|
|
144
152
|
citationMetadata?: CitationMetadata;
|
|
145
153
|
groundingMetadata?: GroundingMetadata;
|
|
154
|
+
urlContextMetadata?: URLContextMetadata;
|
|
146
155
|
}
|
|
147
156
|
/**
|
|
148
157
|
* Citation metadata that may be found on a {@link GenerateContentCandidate}.
|
|
@@ -323,6 +332,89 @@ export interface Segment {
|
|
|
323
332
|
*/
|
|
324
333
|
text: string;
|
|
325
334
|
}
|
|
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];
|
|
326
418
|
/**
|
|
327
419
|
* @public
|
|
328
420
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-canary.0ffcb26af",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dev": "rollup -c -w",
|
|
36
36
|
"update-responses": "../../scripts/update_vertexai_responses.sh",
|
|
37
37
|
"testsetup": "yarn update-responses && yarn ts-node ./test-utils/convert-mocks.ts",
|
|
38
|
-
"test": "run-p --npm-path npm lint test:browser",
|
|
38
|
+
"test": "run-p --npm-path npm lint type-check test:browser",
|
|
39
39
|
"test:ci": "yarn testsetup && node ../../scripts/run_tests_in_ci.js -s test",
|
|
40
40
|
"test:skip-clone": "karma start",
|
|
41
41
|
"test:browser": "yarn testsetup && karma start",
|
|
@@ -44,22 +44,23 @@
|
|
|
44
44
|
"test:integration:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha integration/**/*.test.ts --config ../../config/mocharc.node.js",
|
|
45
45
|
"api-report": "api-extractor run --local --verbose",
|
|
46
46
|
"typings:public": "node ../../scripts/build/use_typings.js ./dist/ai-public.d.ts",
|
|
47
|
+
"type-check": "yarn tsc --noEmit",
|
|
47
48
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"@firebase/app": "0.
|
|
51
|
-
"@firebase/app-types": "0.
|
|
51
|
+
"@firebase/app": "0.14.3-canary.0ffcb26af",
|
|
52
|
+
"@firebase/app-types": "0.9.3-canary.0ffcb26af"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@firebase/app-check-interop-types": "0.3.3",
|
|
55
|
-
"@firebase/component": "0.7.0",
|
|
56
|
-
"@firebase/logger": "0.5.0",
|
|
57
|
-
"@firebase/util": "1.13.0",
|
|
55
|
+
"@firebase/app-check-interop-types": "0.3.3-canary.0ffcb26af",
|
|
56
|
+
"@firebase/component": "0.7.0-canary.0ffcb26af",
|
|
57
|
+
"@firebase/logger": "0.5.0-canary.0ffcb26af",
|
|
58
|
+
"@firebase/util": "1.13.0-canary.0ffcb26af",
|
|
58
59
|
"tslib": "^2.1.0"
|
|
59
60
|
},
|
|
60
61
|
"license": "Apache-2.0",
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@firebase/app": "0.14.
|
|
63
|
+
"@firebase/app": "0.14.3-canary.0ffcb26af",
|
|
63
64
|
"@rollup/plugin-json": "6.1.0",
|
|
64
65
|
"rollup": "2.79.2",
|
|
65
66
|
"rollup-plugin-replace": "2.2.0",
|