TemplateGenerativeModel

@PublicPreviewAPI
class TemplateGenerativeModel


Represents a multimodal model (like Gemini), capable of generating content based on various templated input types.

Summary

Public functions

suspend GenerateContentResponse
generateContent(templateId: String, inputs: Map<StringAny>)

Generates content from a prompt template and inputs.

Flow<GenerateContentResponse>
generateContentStream(templateId: String, inputs: Map<StringAny>)

Generates content as a stream from a prompt template and inputs.

Public functions

generateContent

suspend fun generateContent(templateId: String, inputs: Map<StringAny>): GenerateContentResponse

Generates content from a prompt template and inputs.

Parameters
templateId: String

The ID of the prompt template to use.

inputs: Map<StringAny>

A map of variables to substitute into the template.

Returns
GenerateContentResponse

The content generated by the model.

Throws
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException

if the request failed.

See also
FirebaseAIException

for types of errors.

generateContentStream

fun generateContentStream(templateId: String, inputs: Map<StringAny>): Flow<GenerateContentResponse>

Generates content as a stream from a prompt template and inputs.

Parameters
templateId: String

The ID of the prompt template to use.

inputs: Map<StringAny>

A map of variables to substitute into the template.

Returns
Flow<GenerateContentResponse>

A Flow which will emit responses as they are returned by the model.

Throws
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException

if the request failed.

See also
FirebaseAIException

for types of errors.