Back to Firebase Js Sdk

TemplateGenerativeModel class

docs-devsite/ai.templategenerativemodel.md

12.12.16.4 KB
Original Source

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 APIs that execute on a server-side template.

This class should only be instantiated with getTemplateGenerativeModel()<!-- -->.

<b>Signature:</b>

typescript
export declare class TemplateGenerativeModel 

Constructors

ConstructorModifiersDescription
(constructor)(ai, requestOptions)<b><i>(Public Preview)</i></b> Constructs a new instance of the <code>TemplateGenerativeModel</code> class

Properties

PropertyModifiersTypeDescription
requestOptionsRequestOptions<b><i>(Public Preview)</i></b> Additional options to use when making requests.

Methods

MethodModifiersDescription
generateContent(templateId, templateVariables, singleRequestOptions)<b><i>(Public Preview)</i></b> Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse<!-- -->.
generateContentStream(templateId, templateVariables, singleRequestOptions)<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.
startChat(params)<b><i>(Public Preview)</i></b> Starts a TemplateChatSession that will use this template to respond to messages.

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

ParameterTypeDescription
aiAI
requestOptionsRequestOptions

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<!-- -->.

<b>Signature:</b>

typescript
generateContent(templateId: string, templateVariables: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;

Parameters

ParameterTypeDescription
templateIdstringThe ID of the server-side template to execute.
templateVariablesRecord<string, unknown>A key-value map of variables to populate the template with.
singleRequestOptionsSingleRequestOptions

<b>Returns:</b>

Promise<GenerateContentResult<!-- -->>

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: Record<string, unknown>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;

Parameters

ParameterTypeDescription
templateIdstringThe ID of the server-side template to execute.
templateVariablesRecord<string, unknown>A key-value map of variables to populate the template with.
singleRequestOptionsSingleRequestOptions

<b>Returns:</b>

Promise<GenerateContentStreamResult<!-- -->>

TemplateGenerativeModel.startChat()

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.

Starts a TemplateChatSession that will use this template to respond to messages.

<b>Signature:</b>

typescript
startChat(params: StartTemplateChatParams): TemplateChatSession;

Parameters

ParameterTypeDescription
paramsStartTemplateChatParamsConfigurations for the chat, including the template ID and input variables.

<b>Returns:</b>

TemplateChatSession