GenerativeModel
class GenerativeModel
Represents a multimodal model (like Gemini), capable of generating content based on various input types.
Summary
Public functions |
|
|---|---|
suspend CountTokensResponse |
countTokens(prompt: Bitmap)Counts the number of tokens in an image prompt using the model's tokenizer. |
suspend CountTokensResponse |
countTokens(vararg prompt: Content)Counts the number of tokens in a prompt using the model's tokenizer. |
suspend CountTokensResponse |
countTokens(prompt: String)Counts the number of tokens in a text prompt using the model's tokenizer. |
suspend GenerateContentResponse |
generateContent(prompt: Bitmap)Generates new content from the image input given to the model as a prompt. |
suspend GenerateContentResponse |
generateContent(vararg prompt: Content)Generates new content from the input |
suspend GenerateContentResponse |
generateContent(prompt: String)Generates new content from the text input given to the model as a prompt. |
Flow<GenerateContentResponse> |
generateContentStream(prompt: Bitmap)Generates new content as a stream from the image input given to the model as a prompt. |
Flow<GenerateContentResponse> |
generateContentStream(vararg prompt: Content)Generates new content as a stream from the input |
Flow<GenerateContentResponse> |
generateContentStream(prompt: String)Generates new content as a stream from the text input given to the model as a prompt. |
Chat |
Creates a |
Public functions
countTokens
suspend fun countTokens(prompt: Bitmap): CountTokensResponse
Counts the number of tokens in an image prompt using the model's tokenizer.
| Parameters | |
|---|---|
prompt: Bitmap |
The image given to the model as a prompt. |
| Returns | |
|---|---|
CountTokensResponse |
The |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
countTokens
suspend fun countTokens(vararg prompt: Content): CountTokensResponse
Counts the number of tokens in a prompt using the model's tokenizer.
| Parameters | |
|---|---|
vararg prompt: Content |
The input(s) given to the model as a prompt. |
| Returns | |
|---|---|
CountTokensResponse |
The |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
countTokens
suspend fun countTokens(prompt: String): CountTokensResponse
Counts the number of tokens in a text prompt using the model's tokenizer.
| Parameters | |
|---|---|
prompt: String |
The text given to the model as a prompt. |
| Returns | |
|---|---|
CountTokensResponse |
The |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContent
suspend fun generateContent(prompt: Bitmap): GenerateContentResponse
Generates new content from the image input given to the model as a prompt.
| Parameters | |
|---|---|
prompt: Bitmap |
The image to be converted into a single piece of |
| Returns | |
|---|---|
GenerateContentResponse |
A |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContent
suspend fun generateContent(vararg prompt: Content): GenerateContentResponse
Generates new content from the input Content given to the model as a prompt.
| Parameters | |
|---|---|
vararg prompt: Content |
The input(s) given to the model as a prompt. |
| Returns | |
|---|---|
GenerateContentResponse |
The content generated by the model. |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContent
suspend fun generateContent(prompt: String): GenerateContentResponse
Generates new content from the text input given to the model as a prompt.
| Parameters | |
|---|---|
prompt: String |
The text to be send to the model as a prompt. |
| Returns | |
|---|---|
GenerateContentResponse |
The content generated by the model. |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContentStream
fun generateContentStream(prompt: Bitmap): Flow<GenerateContentResponse>
Generates new content as a stream from the image input given to the model as a prompt.
| Parameters | |
|---|---|
prompt: Bitmap |
The image to be converted into a single piece of |
| Returns | |
|---|---|
Flow<GenerateContentResponse> |
A |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContentStream
fun generateContentStream(vararg prompt: Content): Flow<GenerateContentResponse>
Generates new content as a stream from the input Content given to the model as a prompt.
| Parameters | |
|---|---|
vararg prompt: Content |
The input(s) given to the model as a prompt. |
| Returns | |
|---|---|
Flow<GenerateContentResponse> |
A |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |
generateContentStream
fun generateContentStream(prompt: String): Flow<GenerateContentResponse>
Generates new content as a stream from the text input given to the model as a prompt.
| Parameters | |
|---|---|
prompt: String |
The text to be send to the model as a prompt. |
| Returns | |
|---|---|
Flow<GenerateContentResponse> |
A |
| Throws | |
|---|---|
com.google.firebase.vertexai.type.FirebaseVertexAIException: com.google.firebase.vertexai.type.FirebaseVertexAIException |
if the request failed. |
| See also | |
|---|---|
FirebaseVertexAIException |
for types of errors. |