Skip to content

Commit 57c7798

Browse files
committed
Merge branch 'main' into telemetry
2 parents fca2b18 + 9b63cd6 commit 57c7798

29 files changed

+665
-118
lines changed

.changeset/brave-llamas-impress.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/ai': minor
3+
'firebase': minor
4+
---
5+
6+
Add `thoughtSummary()` convenience method to `EnhancedGenerateContentResponse`.

.changeset/nasty-rings-drop.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/ai': minor
3+
'firebase': minor
4+
---
5+
6+
Add App Check limited use token option to `getAI()`.

common/api-review/ai.api.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
44
55
```ts
66

7+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
78
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
9+
import { ComponentContainer } from '@firebase/component';
810
import { FirebaseApp } from '@firebase/app';
11+
import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
12+
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
13+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
914
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
1015
import { FirebaseError } from '@firebase/util';
16+
import { _FirebaseService } from '@firebase/app';
17+
import { InstanceFactoryOptions } from '@firebase/component';
18+
import { Provider } from '@firebase/component';
1119

1220
// @public
1321
export interface AI {
1422
app: FirebaseApp;
1523
backend: Backend;
1624
// @deprecated (undocumented)
1725
location: string;
26+
options?: AIOptions;
1827
}
1928

2029
// @public
@@ -53,15 +62,16 @@ export abstract class AIModel {
5362
// Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts
5463
//
5564
// @internal (undocumented)
56-
protected _apiSettings: ApiSettings;
65+
_apiSettings: ApiSettings;
5766
readonly model: string;
5867
// @internal
5968
static normalizeModelName(modelName: string, backendType: BackendType): string;
6069
}
6170

6271
// @public
6372
export interface AIOptions {
64-
backend: Backend;
73+
backend?: Backend;
74+
useLimitedUseAppCheckTokens?: boolean;
6575
}
6676

6777
// @public
@@ -213,10 +223,10 @@ export { Date_2 as Date }
213223

214224
// @public
215225
export interface EnhancedGenerateContentResponse extends GenerateContentResponse {
216-
// (undocumented)
217226
functionCalls: () => FunctionCall[] | undefined;
218227
inlineDataParts: () => InlineDataPart[] | undefined;
219228
text: () => string;
229+
thoughtSummary: () => string | undefined;
220230
}
221231

222232
// @public
@@ -229,6 +239,11 @@ export interface ErrorDetails {
229239
reason?: string;
230240
}
231241

242+
// Warning: (ae-forgotten-export) The symbol "AIService" needs to be exported by the entry point index.d.ts
243+
//
244+
// @public (undocumented)
245+
export function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
246+
232247
// @public
233248
export interface FileData {
234249
// (undocumented)
@@ -249,6 +264,10 @@ export interface FileDataPart {
249264
inlineData?: never;
250265
// (undocumented)
251266
text?: never;
267+
// (undocumented)
268+
thought?: boolean;
269+
// @internal (undocumented)
270+
thoughtSignature?: never;
252271
}
253272

254273
// @public
@@ -303,6 +322,10 @@ export interface FunctionCallPart {
303322
inlineData?: never;
304323
// (undocumented)
305324
text?: never;
325+
// (undocumented)
326+
thought?: boolean;
327+
// @internal (undocumented)
328+
thoughtSignature?: never;
306329
}
307330

308331
// @public
@@ -335,6 +358,10 @@ export interface FunctionResponsePart {
335358
inlineData?: never;
336359
// (undocumented)
337360
text?: never;
361+
// (undocumented)
362+
thought?: boolean;
363+
// @internal (undocumented)
364+
thoughtSignature?: never;
338365
}
339366

340367
// @public
@@ -717,6 +744,10 @@ export interface InlineDataPart {
717744
inlineData: GenerativeContentBlob;
718745
// (undocumented)
719746
text?: never;
747+
// (undocumented)
748+
thought?: boolean;
749+
// @internal (undocumented)
750+
thoughtSignature?: never;
720751
videoMetadata?: VideoMetadata;
721752
}
722753

@@ -1048,10 +1079,15 @@ export interface TextPart {
10481079
inlineData?: never;
10491080
// (undocumented)
10501081
text: string;
1082+
// (undocumented)
1083+
thought?: boolean;
1084+
// @internal (undocumented)
1085+
thoughtSignature?: string;
10511086
}
10521087

10531088
// @public
10541089
export interface ThinkingConfig {
1090+
includeThoughts?: boolean;
10551091
thinkingBudget?: number;
10561092
}
10571093

docs-devsite/ai.ai.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface AI
2727
| [app](./ai.ai.md#aiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [AI](./ai.ai.md#ai_interface) instance is associated with. |
2828
| [backend](./ai.ai.md#aibackend) | [Backend](./ai.backend.md#backend_class) | A [Backend](./ai.backend.md#backend_class) instance that specifies the configuration for the target backend, either the Gemini Developer API (using [GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->) or the Vertex AI Gemini API (using [VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class)<!-- -->). |
2929
| [location](./ai.ai.md#ailocation) | string | |
30+
| [options](./ai.ai.md#aioptions) | [AIOptions](./ai.aioptions.md#aioptions_interface) | Options applied to this [AI](./ai.ai.md#ai_interface) instance. |
3031

3132
## AI.app
3233

@@ -62,3 +63,13 @@ backend: Backend;
6263
```typescript
6364
location: string;
6465
```
66+
67+
## AI.options
68+
69+
Options applied to this [AI](./ai.ai.md#ai_interface) instance.
70+
71+
<b>Signature:</b>
72+
73+
```typescript
74+
options?: AIOptions;
75+
```

docs-devsite/ai.aioptions.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,25 @@ export interface AIOptions
2222

2323
| Property | Type | Description |
2424
| --- | --- | --- |
25-
| [backend](./ai.aioptions.md#aioptionsbackend) | [Backend](./ai.backend.md#backend_class) | The backend configuration to use for the AI service instance. |
25+
| [backend](./ai.aioptions.md#aioptionsbackend) | [Backend](./ai.backend.md#backend_class) | The backend configuration to use for the AI service instance. Defaults to the Gemini Developer API backend ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->). |
26+
| [useLimitedUseAppCheckTokens](./ai.aioptions.md#aioptionsuselimiteduseappchecktokens) | boolean | Whether to use App Check limited use tokens. Defaults to false. |
2627

2728
## AIOptions.backend
2829

29-
The backend configuration to use for the AI service instance.
30+
The backend configuration to use for the AI service instance. Defaults to the Gemini Developer API backend ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->).
3031

3132
<b>Signature:</b>
3233

3334
```typescript
34-
backend: Backend;
35+
backend?: Backend;
36+
```
37+
38+
## AIOptions.useLimitedUseAppCheckTokens
39+
40+
Whether to use App Check limited use tokens. Defaults to false.
41+
42+
<b>Signature:</b>
43+
44+
```typescript
45+
useLimitedUseAppCheckTokens?: boolean;
3546
```

docs-devsite/ai.enhancedgeneratecontentresponse.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
2323
2424
| Property | Type | Description |
2525
| --- | --- | --- |
26-
| [functionCalls](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () =&gt; [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->\[\] \| undefined | |
27-
| [inlineDataParts](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponseinlinedataparts) | () =&gt; [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface)<!-- -->\[\] \| undefined | Aggregates and returns all [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface)<!-- -->s from the [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->'s first candidate. |
26+
| [functionCalls](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () =&gt; [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->\[\] \| undefined | Aggregates and returns every [FunctionCall](./ai.functioncall.md#functioncall_interface) from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
27+
| [inlineDataParts](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponseinlinedataparts) | () =&gt; [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface)<!-- -->\[\] \| undefined | Aggregates and returns every [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface) from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
2828
| [text](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () =&gt; string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. |
29+
| [thoughtSummary](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsethoughtsummary) | () =&gt; string \| undefined | Aggregates and returns every [TextPart](./ai.textpart.md#textpart_interface) with their <code>thought</code> property set to <code>true</code> from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
2930
3031
## EnhancedGenerateContentResponse.functionCalls
3132
33+
Aggregates and returns every [FunctionCall](./ai.functioncall.md#functioncall_interface) from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->.
34+
3235
<b>Signature:</b>
3336
3437
```typescript
@@ -37,7 +40,7 @@ functionCalls: () => FunctionCall[] | undefined;
3740
3841
## EnhancedGenerateContentResponse.inlineDataParts
3942
40-
Aggregates and returns all [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface)<!-- -->s from the [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->'s first candidate.
43+
Aggregates and returns every [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface) from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->.
4144
4245
<b>Signature:</b>
4346
@@ -54,3 +57,17 @@ Returns the text string from the response, if available. Throws if the prompt or
5457
```typescript
5558
text: () => string;
5659
```
60+
61+
## EnhancedGenerateContentResponse.thoughtSummary
62+
63+
Aggregates and returns every [TextPart](./ai.textpart.md#textpart_interface) with their `thought` property set to `true` from the first candidate of [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->.
64+
65+
Thought summaries provide a brief overview of the model's internal thinking process, offering insight into how it arrived at the final answer. This can be useful for debugging, understanding the model's reasoning, and verifying its accuracy.
66+
67+
Thoughts will only be included if [ThinkingConfig.includeThoughts](./ai.thinkingconfig.md#thinkingconfigincludethoughts) is set to `true`<!-- -->.
68+
69+
<b>Signature:</b>
70+
71+
```typescript
72+
thoughtSummary: () => string | undefined;
73+
```

docs-devsite/ai.filedatapart.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface FileDataPart
2727
| [functionResponse](./ai.filedatapart.md#filedatapartfunctionresponse) | never | |
2828
| [inlineData](./ai.filedatapart.md#filedatapartinlinedata) | never | |
2929
| [text](./ai.filedatapart.md#filedataparttext) | never | |
30+
| [thought](./ai.filedatapart.md#filedatapartthought) | boolean | |
3031

3132
## FileDataPart.fileData
3233

@@ -67,3 +68,11 @@ inlineData?: never;
6768
```typescript
6869
text?: never;
6970
```
71+
72+
## FileDataPart.thought
73+
74+
<b>Signature:</b>
75+
76+
```typescript
77+
thought?: boolean;
78+
```

docs-devsite/ai.functioncallpart.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface FunctionCallPart
2626
| [functionResponse](./ai.functioncallpart.md#functioncallpartfunctionresponse) | never | |
2727
| [inlineData](./ai.functioncallpart.md#functioncallpartinlinedata) | never | |
2828
| [text](./ai.functioncallpart.md#functioncallparttext) | never | |
29+
| [thought](./ai.functioncallpart.md#functioncallpartthought) | boolean | |
2930

3031
## FunctionCallPart.functionCall
3132

@@ -58,3 +59,11 @@ inlineData?: never;
5859
```typescript
5960
text?: never;
6061
```
62+
63+
## FunctionCallPart.thought
64+
65+
<b>Signature:</b>
66+
67+
```typescript
68+
thought?: boolean;
69+
```

docs-devsite/ai.functionresponsepart.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface FunctionResponsePart
2626
| [functionResponse](./ai.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./ai.functionresponse.md#functionresponse_interface) | |
2727
| [inlineData](./ai.functionresponsepart.md#functionresponsepartinlinedata) | never | |
2828
| [text](./ai.functionresponsepart.md#functionresponseparttext) | never | |
29+
| [thought](./ai.functionresponsepart.md#functionresponsepartthought) | boolean | |
2930

3031
## FunctionResponsePart.functionCall
3132

@@ -58,3 +59,11 @@ inlineData?: never;
5859
```typescript
5960
text?: never;
6061
```
62+
63+
## FunctionResponsePart.thought
64+
65+
<b>Signature:</b>
66+
67+
```typescript
68+
thought?: boolean;
69+
```

docs-devsite/ai.inlinedatapart.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface InlineDataPart
2626
| [functionResponse](./ai.inlinedatapart.md#inlinedatapartfunctionresponse) | never | |
2727
| [inlineData](./ai.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./ai.generativecontentblob.md#generativecontentblob_interface) | |
2828
| [text](./ai.inlinedatapart.md#inlinedataparttext) | never | |
29+
| [thought](./ai.inlinedatapart.md#inlinedatapartthought) | boolean | |
2930
| [videoMetadata](./ai.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./ai.videometadata.md#videometadata_interface) | Applicable if <code>inlineData</code> is a video. |
3031

3132
## InlineDataPart.functionCall
@@ -60,6 +61,14 @@ inlineData: GenerativeContentBlob;
6061
text?: never;
6162
```
6263

64+
## InlineDataPart.thought
65+
66+
<b>Signature:</b>
67+
68+
```typescript
69+
thought?: boolean;
70+
```
71+
6372
## InlineDataPart.videoMetadata
6473

6574
Applicable if `inlineData` is a video.

0 commit comments

Comments
 (0)