@firebase/ai 2.1.0-canary.5501791d0 → 2.1.0-canary.9b63cd60e
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 +75 -4
- package/dist/ai.d.ts +90 -5
- package/dist/esm/index.esm.js +90 -60
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/index.d.ts +3 -0
- package/dist/esm/src/models/ai-model.d.ts +1 -1
- package/dist/esm/src/public-types.d.ts +10 -1
- package/dist/esm/src/requests/response-helpers.d.ts +9 -5
- package/dist/esm/src/service.d.ts +4 -1
- package/dist/esm/src/types/content.d.ts +25 -0
- package/dist/esm/src/types/requests.d.ts +9 -0
- package/dist/esm/src/types/responses.d.ts +23 -4
- package/dist/index.cjs.js +90 -59
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +77 -48
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +77 -48
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/models/ai-model.d.ts +1 -1
- package/dist/src/public-types.d.ts +10 -1
- package/dist/src/requests/response-helpers.d.ts +9 -5
- package/dist/src/service.d.ts +4 -1
- package/dist/src/types/content.d.ts +25 -0
- package/dist/src/types/requests.d.ts +9 -0
- package/dist/src/types/responses.d.ts +23 -4
- package/package.json +8 -8
package/dist/src/index.d.ts
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
+
import { AIService } from './service';
|
|
7
|
+
import { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
6
8
|
declare global {
|
|
7
9
|
interface Window {
|
|
8
10
|
[key: string]: unknown;
|
|
9
11
|
}
|
|
10
12
|
}
|
|
13
|
+
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
|
11
14
|
export * from './api';
|
|
12
15
|
export * from './public-types';
|
|
@@ -35,6 +35,10 @@ export interface AI {
|
|
|
35
35
|
* Vertex AI Gemini API (using {@link VertexAIBackend}).
|
|
36
36
|
*/
|
|
37
37
|
backend: Backend;
|
|
38
|
+
/**
|
|
39
|
+
* Options applied to this {@link AI} instance.
|
|
40
|
+
*/
|
|
41
|
+
options?: AIOptions;
|
|
38
42
|
/**
|
|
39
43
|
* @deprecated use `AI.backend.location` instead.
|
|
40
44
|
*
|
|
@@ -83,6 +87,11 @@ export type BackendType = (typeof BackendType)[keyof typeof BackendType];
|
|
|
83
87
|
export interface AIOptions {
|
|
84
88
|
/**
|
|
85
89
|
* The backend configuration to use for the AI service instance.
|
|
90
|
+
* Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
|
|
86
91
|
*/
|
|
87
|
-
backend
|
|
92
|
+
backend?: Backend;
|
|
93
|
+
/**
|
|
94
|
+
* Whether to use App Check limited use tokens. Defaults to false.
|
|
95
|
+
*/
|
|
96
|
+
useLimitedUseAppCheckTokens?: boolean;
|
|
88
97
|
}
|
|
@@ -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 { EnhancedGenerateContentResponse, FunctionCall, GenerateContentResponse, ImagenGCSImage, ImagenInlineImage, InlineDataPart } from '../types';
|
|
17
|
+
import { EnhancedGenerateContentResponse, FunctionCall, GenerateContentResponse, ImagenGCSImage, ImagenInlineImage, InlineDataPart, Part } from '../types';
|
|
18
18
|
/**
|
|
19
19
|
* Creates an EnhancedGenerateContentResponse object that has helper functions and
|
|
20
20
|
* other modifications that improve usability.
|
|
@@ -26,15 +26,19 @@ export declare function createEnhancedContentResponse(response: GenerateContentR
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function addHelpers(response: GenerateContentResponse): EnhancedGenerateContentResponse;
|
|
28
28
|
/**
|
|
29
|
-
* Returns all text
|
|
29
|
+
* Returns all text from the first candidate's parts, filtering by whether
|
|
30
|
+
* `partFilter()` returns true.
|
|
31
|
+
*
|
|
32
|
+
* @param response - The `GenerateContentResponse` from which to extract text.
|
|
33
|
+
* @param partFilter - Only return `Part`s for which this returns true
|
|
30
34
|
*/
|
|
31
|
-
export declare function getText(response: GenerateContentResponse): string;
|
|
35
|
+
export declare function getText(response: GenerateContentResponse, partFilter: (part: Part) => boolean): string;
|
|
32
36
|
/**
|
|
33
|
-
* Returns {@link FunctionCall}
|
|
37
|
+
* Returns every {@link FunctionCall} associated with first candidate.
|
|
34
38
|
*/
|
|
35
39
|
export declare function getFunctionCalls(response: GenerateContentResponse): FunctionCall[] | undefined;
|
|
36
40
|
/**
|
|
37
|
-
* Returns {@link InlineDataPart}
|
|
41
|
+
* Returns every {@link InlineDataPart} in the first candidate if present.
|
|
38
42
|
*
|
|
39
43
|
* @internal
|
|
40
44
|
*/
|
package/dist/src/service.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirebaseApp, _FirebaseService } from '@firebase/app';
|
|
18
|
-
import { AI } from './public-types';
|
|
18
|
+
import { AI, AIOptions } from './public-types';
|
|
19
19
|
import { AppCheckInternalComponentName, FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
|
20
20
|
import { Provider } from '@firebase/component';
|
|
21
21
|
import { FirebaseAuthInternal, FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
@@ -25,7 +25,10 @@ export declare class AIService implements AI, _FirebaseService {
|
|
|
25
25
|
backend: Backend;
|
|
26
26
|
auth: FirebaseAuthInternal | null;
|
|
27
27
|
appCheck: FirebaseAppCheckInternal | null;
|
|
28
|
+
_options?: Omit<AIOptions, 'backend'>;
|
|
28
29
|
location: string;
|
|
29
30
|
constructor(app: FirebaseApp, backend: Backend, authProvider?: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>);
|
|
30
31
|
_delete(): Promise<void>;
|
|
32
|
+
set options(optionsToSet: AIOptions);
|
|
33
|
+
get options(): AIOptions | undefined;
|
|
31
34
|
}
|
|
@@ -38,6 +38,11 @@ export interface TextPart {
|
|
|
38
38
|
inlineData?: never;
|
|
39
39
|
functionCall?: never;
|
|
40
40
|
functionResponse?: never;
|
|
41
|
+
thought?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
thoughtSignature?: string;
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* Content part interface if the part represents an image.
|
|
@@ -52,6 +57,11 @@ export interface InlineDataPart {
|
|
|
52
57
|
* Applicable if `inlineData` is a video.
|
|
53
58
|
*/
|
|
54
59
|
videoMetadata?: VideoMetadata;
|
|
60
|
+
thought?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
thoughtSignature?: never;
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
57
67
|
* Describes the input video content.
|
|
@@ -78,6 +88,11 @@ export interface FunctionCallPart {
|
|
|
78
88
|
inlineData?: never;
|
|
79
89
|
functionCall: FunctionCall;
|
|
80
90
|
functionResponse?: never;
|
|
91
|
+
thought?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
thoughtSignature?: never;
|
|
81
96
|
}
|
|
82
97
|
/**
|
|
83
98
|
* Content part interface if the part represents {@link FunctionResponse}.
|
|
@@ -88,6 +103,11 @@ export interface FunctionResponsePart {
|
|
|
88
103
|
inlineData?: never;
|
|
89
104
|
functionCall?: never;
|
|
90
105
|
functionResponse: FunctionResponse;
|
|
106
|
+
thought?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
thoughtSignature?: never;
|
|
91
111
|
}
|
|
92
112
|
/**
|
|
93
113
|
* Content part interface if the part represents {@link FileData}
|
|
@@ -99,6 +119,11 @@ export interface FileDataPart {
|
|
|
99
119
|
functionCall?: never;
|
|
100
120
|
functionResponse?: never;
|
|
101
121
|
fileData: FileData;
|
|
122
|
+
thought?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
thoughtSignature?: never;
|
|
102
127
|
}
|
|
103
128
|
/**
|
|
104
129
|
* A predicted {@link FunctionCall} returned from the model
|
|
@@ -305,4 +305,13 @@ export interface ThinkingConfig {
|
|
|
305
305
|
* feature or if the specified budget is not within the model's supported range.
|
|
306
306
|
*/
|
|
307
307
|
thinkingBudget?: number;
|
|
308
|
+
/**
|
|
309
|
+
* Whether to include "thought summaries" in the model's response.
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
* Thought summaries provide a brief overview of the model's internal thinking process,
|
|
313
|
+
* offering insight into how it arrived at the final answer. This can be useful for
|
|
314
|
+
* debugging, understanding the model's reasoning, and verifying its accuracy.
|
|
315
|
+
*/
|
|
316
|
+
includeThoughts?: boolean;
|
|
308
317
|
}
|
|
@@ -48,15 +48,34 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
|
|
|
48
48
|
*/
|
|
49
49
|
text: () => string;
|
|
50
50
|
/**
|
|
51
|
-
* Aggregates and returns
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @returns An array of {@link InlineDataPart}s containing data from the response, if available.
|
|
51
|
+
* Aggregates and returns every {@link InlineDataPart} from the first candidate of
|
|
52
|
+
* {@link GenerateContentResponse}.
|
|
55
53
|
*
|
|
56
54
|
* @throws If the prompt or candidate was blocked.
|
|
57
55
|
*/
|
|
58
56
|
inlineDataParts: () => InlineDataPart[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Aggregates and returns every {@link FunctionCall} from the first candidate of
|
|
59
|
+
* {@link GenerateContentResponse}.
|
|
60
|
+
*
|
|
61
|
+
* @throws If the prompt or candidate was blocked.
|
|
62
|
+
*/
|
|
59
63
|
functionCalls: () => FunctionCall[] | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Aggregates and returns every {@link TextPart} with their `thought` property set
|
|
66
|
+
* to `true` from the first candidate of {@link GenerateContentResponse}.
|
|
67
|
+
*
|
|
68
|
+
* @throws If the prompt or candidate was blocked.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Thought summaries provide a brief overview of the model's internal thinking process,
|
|
72
|
+
* offering insight into how it arrived at the final answer. This can be useful for
|
|
73
|
+
* debugging, understanding the model's reasoning, and verifying its accuracy.
|
|
74
|
+
*
|
|
75
|
+
* Thoughts will only be included if {@link ThinkingConfig.includeThoughts} is
|
|
76
|
+
* set to `true`.
|
|
77
|
+
*/
|
|
78
|
+
thoughtSummary: () => string | undefined;
|
|
60
79
|
}
|
|
61
80
|
/**
|
|
62
81
|
* Individual response from {@link GenerativeModel.generateContent} and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "2.1.0-canary.
|
|
3
|
+
"version": "2.1.0-canary.9b63cd60e",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@firebase/app": "0.14.1-canary.
|
|
49
|
-
"@firebase/app-types": "0.9.3-canary.
|
|
48
|
+
"@firebase/app": "0.14.1-canary.9b63cd60e",
|
|
49
|
+
"@firebase/app-types": "0.9.3-canary.9b63cd60e"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@firebase/app-check-interop-types": "0.3.3-canary.
|
|
53
|
-
"@firebase/component": "0.7.0-canary.
|
|
54
|
-
"@firebase/logger": "0.5.0-canary.
|
|
55
|
-
"@firebase/util": "1.13.0-canary.
|
|
52
|
+
"@firebase/app-check-interop-types": "0.3.3-canary.9b63cd60e",
|
|
53
|
+
"@firebase/component": "0.7.0-canary.9b63cd60e",
|
|
54
|
+
"@firebase/logger": "0.5.0-canary.9b63cd60e",
|
|
55
|
+
"@firebase/util": "1.13.0-canary.9b63cd60e",
|
|
56
56
|
"tslib": "^2.1.0"
|
|
57
57
|
},
|
|
58
58
|
"license": "Apache-2.0",
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@firebase/app": "0.14.1-canary.
|
|
60
|
+
"@firebase/app": "0.14.1-canary.9b63cd60e",
|
|
61
61
|
"@rollup/plugin-json": "6.1.0",
|
|
62
62
|
"rollup": "2.79.2",
|
|
63
63
|
"rollup-plugin-replace": "2.2.0",
|