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<String, Any>)Generates content from a prompt template and inputs. |
Flow<GenerateContentResponse> |
generateContentStream(templateId: String, inputs: Map<String, Any>)Generates content as a stream from a prompt template and inputs. |
TemplateChat |
Creates a |
Public functions
generateContent
suspend fun generateContent(templateId: String, inputs: Map<String, Any>): GenerateContentResponse
Generates content from a prompt template and inputs.
| Parameters | |
|---|---|
templateId: String |
The ID of the prompt template to use. |
inputs: Map<String, Any> |
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<String, Any>): 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<String, Any> |
A map of variables to substitute into the template. |
| Returns | |
|---|---|
Flow<GenerateContentResponse> |
A |
| Throws | |
|---|---|
com.google.firebase.ai.type.FirebaseAIException: com.google.firebase.ai.type.FirebaseAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseAIException |
for types of errors. |
startChat
@PublicPreviewAPI
fun startChat(
templateId: String,
inputs: Map<String, Any>,
history: List<Content> = emptyList()
): TemplateChat
Creates a TemplateChat instance using this model with the optionally provided history.
| Parameters | |
|---|---|
templateId: String |
The ID of the prompt template to use. |
inputs: Map<String, Any> |
A map of variables to substitute into the template for the session. |
history: List<Content> = emptyList() |
Prior history in the conversation. |
| Returns | |
|---|---|
TemplateChat |
The initialized |