-
Notifications
You must be signed in to change notification settings - Fork 986
feat(ai): server prompt templates #9351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dlarocque
wants to merge
10
commits into
main
Choose a base branch
from
dl/prompt-templates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,759
−530
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
82a57d6
feat(ai): server prompt templates
dlarocque 7ede799
Update changeset
dlarocque d078103
Merge branch 'main' into dl/prompt-templates
dlarocque 40aa3cf
revert node test fixes
dlarocque 2a4b9a9
Review fixes
dlarocque 503fa59
Remove Chat
dlarocque b955946
Fix task ref
dlarocque 47ee394
Run formatter and generate docs
dlarocque 7ec4544
Merge branch 'main' into dl/prompt-templates
dlarocque 7e52134
Fix docs
dlarocque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'firebase': minor | ||
| '@firebase/ai': minor | ||
| --- | ||
|
|
||
| Add support for Server Prompt Templates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| Project: /docs/reference/js/_project.yaml | ||
| Book: /docs/reference/_book.yaml | ||
| page_type: reference | ||
|
|
||
| {% comment %} | ||
| DO NOT EDIT THIS FILE! | ||
| This is generated by the JS SDK team, and any local changes will be | ||
| overwritten. Changes should be made in the source code at | ||
| https://github.com/firebase/firebase-js-sdk | ||
| {% endcomment %} | ||
|
|
||
| # TemplateGenerativeModel class | ||
| > 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. | ||
| > | ||
|
|
||
| [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)<!-- -->. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| export declare class TemplateGenerativeModel | ||
| ``` | ||
|
|
||
| ## Constructors | ||
|
|
||
| | Constructor | Modifiers | Description | | ||
| | --- | --- | --- | | ||
| | [(constructor)(ai, requestOptions)](./ai.templategenerativemodel.md#templategenerativemodelconstructor) | | <b><i>(Public Preview)</i></b> Constructs a new instance of the <code>TemplateGenerativeModel</code> class | | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Modifiers | Type | Description | | ||
| | --- | --- | --- | --- | | ||
| | [requestOptions](./ai.templategenerativemodel.md#templategenerativemodelrequestoptions) | | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | <b><i>(Public Preview)</i></b> Additional options to use when making requests. | | ||
|
|
||
| ## Methods | ||
|
|
||
| | Method | Modifiers | Description | | ||
| | --- | --- | --- | | ||
| | [generateContent(templateId, templateVariables)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontent) | | <b><i>(Public Preview)</i></b> Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. | | ||
| | [generateContentStream(templateId, templateVariables)](./ai.templategenerativemodel.md#templategenerativemodelgeneratecontentstream) | | <b><i>(Public Preview)</i></b> Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | | ||
|
|
||
| ## TemplateGenerativeModel.(constructor) | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Constructs a new instance of the `TemplateGenerativeModel` class | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| constructor(ai: AI, requestOptions?: RequestOptions); | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | ai | [AI](./ai.ai.md#ai_interface) | | | ||
| | requestOptions | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | | | ||
|
|
||
| ## TemplateGenerativeModel.requestOptions | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Additional options to use when making requests. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| requestOptions?: RequestOptions; | ||
| ``` | ||
|
|
||
| ## TemplateGenerativeModel.generateContent() | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| generateContent(templateId: string, templateVariables: object): Promise<GenerateContentResult>; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | templateId | string | The ID of the server-side template to execute. | | ||
| | templateVariables | object | A key-value map of variables to populate the template with. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| Promise<[GenerateContentResult](./ai.generatecontentresult.md#generatecontentresult_interface)<!-- -->> | ||
|
|
||
| ## TemplateGenerativeModel.generateContentStream() | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| generateContentStream(templateId: string, templateVariables: object): Promise<GenerateContentStreamResult>; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | templateId | string | The ID of the server-side template to execute. | | ||
| | templateVariables | object | A key-value map of variables to populate the template with. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| Promise<[GenerateContentStreamResult](./ai.generatecontentstreamresult.md#generatecontentstreamresult_interface)<!-- -->> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| Project: /docs/reference/js/_project.yaml | ||
| Book: /docs/reference/_book.yaml | ||
| page_type: reference | ||
|
|
||
| {% comment %} | ||
| DO NOT EDIT THIS FILE! | ||
| This is generated by the JS SDK team, and any local changes will be | ||
| overwritten. Changes should be made in the source code at | ||
| https://github.com/firebase/firebase-js-sdk | ||
| {% endcomment %} | ||
|
|
||
| # TemplateImagenModel class | ||
| > 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. | ||
| > | ||
|
|
||
| Class for Imagen model APIs that execute on a server-side template. | ||
|
|
||
| This class should only be instantiated with [getTemplateImagenModel()](./ai.md#gettemplateimagenmodel_9476bbc)<!-- -->. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| export declare class TemplateImagenModel | ||
| ``` | ||
|
|
||
| ## Constructors | ||
|
|
||
| | Constructor | Modifiers | Description | | ||
| | --- | --- | --- | | ||
| | [(constructor)(ai, requestOptions)](./ai.templateimagenmodel.md#templateimagenmodelconstructor) | | <b><i>(Public Preview)</i></b> Constructs a new instance of the <code>TemplateImagenModel</code> class | | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Modifiers | Type | Description | | ||
| | --- | --- | --- | --- | | ||
| | [requestOptions](./ai.templateimagenmodel.md#templateimagenmodelrequestoptions) | | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | <b><i>(Public Preview)</i></b> Additional options to use when making requests. | | ||
|
|
||
| ## Methods | ||
|
|
||
| | Method | Modifiers | Description | | ||
| | --- | --- | --- | | ||
| | [generateImages(templateId, templateVariables)](./ai.templateimagenmodel.md#templateimagenmodelgenerateimages) | | <b><i>(Public Preview)</i></b> Makes a single call to the model and returns an object containing a single [ImagenGenerationResponse](./ai.imagengenerationresponse.md#imagengenerationresponse_interface)<!-- -->. | | ||
|
|
||
| ## TemplateImagenModel.(constructor) | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Constructs a new instance of the `TemplateImagenModel` class | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| constructor(ai: AI, requestOptions?: RequestOptions); | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | ai | [AI](./ai.ai.md#ai_interface) | | | ||
| | requestOptions | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | | | ||
|
|
||
| ## TemplateImagenModel.requestOptions | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Additional options to use when making requests. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| requestOptions?: RequestOptions; | ||
| ``` | ||
|
|
||
| ## TemplateImagenModel.generateImages() | ||
|
|
||
| > 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. | ||
| > | ||
|
|
||
| Makes a single call to the model and returns an object containing a single [ImagenGenerationResponse](./ai.imagengenerationresponse.md#imagengenerationresponse_interface)<!-- -->. | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| generateImages(templateId: string, templateVariables: object): Promise<ImagenGenerationResponse<ImagenInlineImage>>; | ||
| ``` | ||
|
|
||
| #### Parameters | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --- | --- | --- | | ||
| | templateId | string | The ID of the server-side template to execute. | | ||
| | templateVariables | object | A key-value map of variables to populate the template with. | | ||
|
|
||
| <b>Returns:</b> | ||
|
|
||
| Promise<[ImagenGenerationResponse](./ai.imagengenerationresponse.md#imagengenerationresponse_interface)<!-- --><[ImagenInlineImage](./ai.imageninlineimage.md#imageninlineimage_interface)<!-- -->>> | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.