Skip to content

Commit 361f22b

Browse files
committed
Merge branch 'main' into telemetry
2 parents faee34d + b228a2a commit 361f22b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1787
-1019
lines changed

.changeset/metal-ties-cry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/ai': minor
4+
---
5+
6+
Add support for server prompt templates.

.changeset/wild-snakes-bathe.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
pushd functions
6969
npm install
7070
popd
71-
npx firebase-tools@13.0.2 deploy --only functions:callTest --project jscore-sandbox-141b5 --token $FIREBASE_CLI_TOKEN
71+
npx firebase-tools@14.24.2 deploy --only functions:callTest --project jscore-sandbox-141b5 --token $FIREBASE_CLI_TOKEN
7272
working-directory: ./config
7373
env:
7474
FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}

common/api-review/ai.api.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export interface AudioTranscriptionConfig {
100100
export abstract class Backend {
101101
protected constructor(type: BackendType);
102102
readonly backendType: BackendType;
103+
// @internal (undocumented)
104+
abstract _getModelPath(project: string, model: string): string;
105+
// @internal (undocumented)
106+
abstract _getTemplatePath(project: string, templateId: string): string;
103107
}
104108

105109
// @public
@@ -567,9 +571,19 @@ export function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOp
567571
// @beta
568572
export function getLiveGenerativeModel(ai: AI, modelParams: LiveModelParams): LiveGenerativeModel;
569573

574+
// @beta
575+
export function getTemplateGenerativeModel(ai: AI, requestOptions?: RequestOptions): TemplateGenerativeModel;
576+
577+
// @beta
578+
export function getTemplateImagenModel(ai: AI, requestOptions?: RequestOptions): TemplateImagenModel;
579+
570580
// @public
571581
export class GoogleAIBackend extends Backend {
572582
constructor();
583+
// @internal (undocumented)
584+
_getModelPath(project: string, model: string): string;
585+
// @internal (undocumented)
586+
_getTemplatePath(project: string, templateId: string): string;
573587
}
574588

575589
// Warning: (ae-internal-missing-underscore) The name "GoogleAICitationMetadata" should be prefixed with an underscore because the declaration is marked as @internal
@@ -1314,6 +1328,25 @@ export class StringSchema extends Schema {
13141328
toJSON(): SchemaRequest;
13151329
}
13161330

1331+
// @beta
1332+
export class TemplateGenerativeModel {
1333+
constructor(ai: AI, requestOptions?: RequestOptions);
1334+
// @internal (undocumented)
1335+
_apiSettings: ApiSettings;
1336+
generateContent(templateId: string, templateVariables: object): Promise<GenerateContentResult>;
1337+
generateContentStream(templateId: string, templateVariables: object): Promise<GenerateContentStreamResult>;
1338+
requestOptions?: RequestOptions;
1339+
}
1340+
1341+
// @beta
1342+
export class TemplateImagenModel {
1343+
constructor(ai: AI, requestOptions?: RequestOptions);
1344+
// @internal (undocumented)
1345+
_apiSettings: ApiSettings;
1346+
generateImages(templateId: string, templateVariables: object): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
1347+
requestOptions?: RequestOptions;
1348+
}
1349+
13171350
// @public
13181351
export interface TextPart {
13191352
// (undocumented)
@@ -1412,6 +1445,10 @@ export interface UsageMetadata {
14121445
// @public
14131446
export class VertexAIBackend extends Backend {
14141447
constructor(location?: string);
1448+
// @internal (undocumented)
1449+
_getModelPath(project: string, model: string): string;
1450+
// @internal (undocumented)
1451+
_getTemplatePath(project: string, templateId: string): string;
14151452
readonly location: string;
14161453
}
14171454

common/api-review/remote-config.api.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
4141
export interface FetchResponse {
4242
config?: FirebaseRemoteConfigObject;
4343
eTag?: string;
44-
experiments?: FirebaseExperimentDescription[];
4544
status: number;
4645
templateVersion?: number;
4746
}
@@ -52,22 +51,6 @@ export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
5251
// @public
5352
export type FetchType = 'BASE' | 'REALTIME';
5453

55-
// @public
56-
export interface FirebaseExperimentDescription {
57-
// (undocumented)
58-
affectedParameterKeys?: string[];
59-
// (undocumented)
60-
experimentId: string;
61-
// (undocumented)
62-
experimentStartTime: string;
63-
// (undocumented)
64-
timeToLiveMillis: string;
65-
// (undocumented)
66-
triggerTimeoutMillis: string;
67-
// (undocumented)
68-
variantId: string;
69-
}
70-
7154
// @public
7255
export interface FirebaseRemoteConfigObject {
7356
// (undocumented)

config/firebase.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"indexes": "firestore.indexes.json"
88
},
99
"functions": {
10-
"runtime": "nodejs18"
10+
"runtime": "nodejs20"
1111
}
1212
}

config/functions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
const assert = require('assert');
1919
const cors = require('cors')({ origin: true });
20-
const functions = require('firebase-functions');
20+
const functions = require('firebase-functions/v1');
2121

2222
/*
2323
* These backend test helpers are copied from the iOS and Android SDKs, but are

config/functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dependencies": {
55
"cors": "2.8.5",
66
"firebase-admin": "11.11.1",
7-
"firebase-functions": "3.24.1"
7+
"firebase-functions": "^7.0.0"
88
},
99
"private": true,
1010
"engines": {

docs-devsite/_toc.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ toc:
198198
path: /docs/reference/js/ai.startchatparams.md
199199
- title: StringSchema
200200
path: /docs/reference/js/ai.stringschema.md
201+
- title: TemplateGenerativeModel
202+
path: /docs/reference/js/ai.templategenerativemodel.md
203+
- title: TemplateImagenModel
204+
path: /docs/reference/js/ai.templateimagenmodel.md
201205
- title: TextPart
202206
path: /docs/reference/js/ai.textpart.md
203207
- title: ThinkingConfig
@@ -661,8 +665,6 @@ toc:
661665
path: /docs/reference/js/remote-config.customsignals.md
662666
- title: FetchResponse
663667
path: /docs/reference/js/remote-config.fetchresponse.md
664-
- title: FirebaseExperimentDescription
665-
path: /docs/reference/js/remote-config.firebaseexperimentdescription.md
666668
- title: FirebaseRemoteConfigObject
667669
path: /docs/reference/js/remote-config.firebaseremoteconfigobject.md
668670
- title: RemoteConfig

docs-devsite/ai.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The Firebase AI Web SDK.
2222
| [getGenerativeModel(ai, modelParams, requestOptions)](./ai.md#getgenerativemodel_c63f46a) | Returns a [GenerativeModel](./ai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. |
2323
| [getImagenModel(ai, modelParams, requestOptions)](./ai.md#getimagenmodel_e1f6645) | Returns an [ImagenModel](./ai.imagenmodel.md#imagenmodel_class) class with methods for using Imagen.<!-- -->Only Imagen 3 models (named <code>imagen-3.0-*</code>) are supported. |
2424
| [getLiveGenerativeModel(ai, modelParams)](./ai.md#getlivegenerativemodel_f2099ac) | <b><i>(Public Preview)</i></b> Returns a [LiveGenerativeModel](./ai.livegenerativemodel.md#livegenerativemodel_class) class for real-time, bidirectional communication.<!-- -->The Live API is only supported in modern browser windows and Node &gt;<!-- -->= 22. |
25+
| [getTemplateGenerativeModel(ai, requestOptions)](./ai.md#gettemplategenerativemodel_9476bbc) | <b><i>(Public Preview)</i></b> Returns a [TemplateGenerativeModel](./ai.templategenerativemodel.md#templategenerativemodel_class) class for executing server-side templates. |
26+
| [getTemplateImagenModel(ai, requestOptions)](./ai.md#gettemplateimagenmodel_9476bbc) | <b><i>(Public Preview)</i></b> Returns a [TemplateImagenModel](./ai.templateimagenmodel.md#templateimagenmodel_class) class for executing server-side Imagen templates. |
2527
| <b>function(liveSession, ...)</b> |
2628
| [startAudioConversation(liveSession, options)](./ai.md#startaudioconversation_01c8e7f) | <b><i>(Public Preview)</i></b> Starts a real-time, bidirectional audio conversation with the model. This helper function manages the complexities of microphone access, audio recording, playback, and interruptions. |
2729

@@ -47,6 +49,8 @@ The Firebase AI Web SDK.
4749
| [ObjectSchema](./ai.objectschema.md#objectschema_class) | Schema class for "object" types. The <code>properties</code> param must be a map of <code>Schema</code> objects. |
4850
| [Schema](./ai.schema.md#schema_class) | Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with <code>JSON.stringify()</code> into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) |
4951
| [StringSchema](./ai.stringschema.md#stringschema_class) | Schema class for "string" types. Can be used with or without enum values. |
52+
| [TemplateGenerativeModel](./ai.templategenerativemodel.md#templategenerativemodel_class) | <b><i>(Public Preview)</i></b> [GenerativeModel](./ai.generativemodel.md#generativemodel_class) APIs that execute on a server-side template.<!-- -->This class should only be instantiated with [getTemplateGenerativeModel()](./ai.md#gettemplategenerativemodel_9476bbc)<!-- -->. |
53+
| [TemplateImagenModel](./ai.templateimagenmodel.md#templateimagenmodel_class) | <b><i>(Public Preview)</i></b> Class for Imagen model APIs that execute on a server-side template.<!-- -->This class should only be instantiated with [getTemplateImagenModel()](./ai.md#gettemplateimagenmodel_9476bbc)<!-- -->. |
5054
| [VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class) | Configuration class for the Vertex AI Gemini API.<!-- -->Use this with [AIOptions](./ai.aioptions.md#aioptions_interface) when initializing the AI service via [getAI()](./ai.md#getai_a94a413) to specify the Vertex AI Gemini API as the backend. |
5155

5256
## Interfaces
@@ -341,6 +345,54 @@ export declare function getLiveGenerativeModel(ai: AI, modelParams: LiveModelPar
341345

342346
If the `apiKey` or `projectId` fields are missing in your Firebase config.
343347

348+
### getTemplateGenerativeModel(ai, requestOptions) {:#gettemplategenerativemodel_9476bbc}
349+
350+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
351+
>
352+
353+
Returns a [TemplateGenerativeModel](./ai.templategenerativemodel.md#templategenerativemodel_class) class for executing server-side templates.
354+
355+
<b>Signature:</b>
356+
357+
```typescript
358+
export declare function getTemplateGenerativeModel(ai: AI, requestOptions?: RequestOptions): TemplateGenerativeModel;
359+
```
360+
361+
#### Parameters
362+
363+
| Parameter | Type | Description |
364+
| --- | --- | --- |
365+
| ai | [AI](./ai.ai.md#ai_interface) | An [AI](./ai.ai.md#ai_interface) instance. |
366+
| requestOptions | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | Additional options to use when making requests. |
367+
368+
<b>Returns:</b>
369+
370+
[TemplateGenerativeModel](./ai.templategenerativemodel.md#templategenerativemodel_class)
371+
372+
### getTemplateImagenModel(ai, requestOptions) {:#gettemplateimagenmodel_9476bbc}
373+
374+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
375+
>
376+
377+
Returns a [TemplateImagenModel](./ai.templateimagenmodel.md#templateimagenmodel_class) class for executing server-side Imagen templates.
378+
379+
<b>Signature:</b>
380+
381+
```typescript
382+
export declare function getTemplateImagenModel(ai: AI, requestOptions?: RequestOptions): TemplateImagenModel;
383+
```
384+
385+
#### Parameters
386+
387+
| Parameter | Type | Description |
388+
| --- | --- | --- |
389+
| ai | [AI](./ai.ai.md#ai_interface) | An [AI](./ai.ai.md#ai_interface) instance. |
390+
| requestOptions | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | Additional options to use when making requests. |
391+
392+
<b>Returns:</b>
393+
394+
[TemplateImagenModel](./ai.templateimagenmodel.md#templateimagenmodel_class)
395+
344396
## function(liveSession, ...)
345397

346398
### startAudioConversation(liveSession, options) {:#startaudioconversation_01c8e7f}

0 commit comments

Comments
 (0)