GenerativeModel
public final class GenerativeModel
Represents a multimodal model (like Gemini), capable of generating content based on various input types.
Summary
Public methods |
|
|---|---|
final @NonNull CountTokensResponse |
countTokens(@NonNull Bitmap prompt)Counts the number of tokens in an image prompt using the model's tokenizer. |
final @NonNull CountTokensResponse |
countTokens(@NonNull Content prompt)Counts the number of tokens in a prompt using the model's tokenizer. |
final @NonNull CountTokensResponse |
countTokens(@NonNull String prompt)Counts the number of tokens in a text prompt using the model's tokenizer. |
final @NonNull GenerateContentResponse |
generateContent(@NonNull Bitmap prompt)Generates new content from the image input given to the model as a prompt. |
final @NonNull GenerateContentResponse |
generateContent(@NonNull Content prompt)Generates new content from the input |
final @NonNull GenerateContentResponse |
generateContent(@NonNull String prompt)Generates new content from the text input given to the model as a prompt. |
final @NonNull Flow<@NonNull GenerateContentResponse> |
generateContentStream(@NonNull Bitmap prompt)Generates new content as a stream from the image input given to the model as a prompt. |
final @NonNull Flow<@NonNull GenerateContentResponse> |
generateContentStream(@NonNull Content prompt)Generates new content as a stream from the input |
final @NonNull Flow<@NonNull GenerateContentResponse> |
generateContentStream(@NonNull String prompt)Generates new content as a stream from the text input given to the model as a prompt. |
final @NonNull Chat |
Creates a |
Public methods
countTokens
public final @NonNull CountTokensResponse countTokens(@NonNull Bitmap prompt)
Counts the number of tokens in an image prompt using the model's tokenizer.
| Returns | |
|---|---|
@NonNull 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
public final @NonNull CountTokensResponse countTokens(@NonNull Content prompt)
Counts the number of tokens in a prompt using the model's tokenizer.
| Returns | |
|---|---|
@NonNull 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
public final @NonNull CountTokensResponse countTokens(@NonNull String prompt)
Counts the number of tokens in a text prompt using the model's tokenizer.
| Returns | |
|---|---|
@NonNull 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
public final @NonNull GenerateContentResponse generateContent(@NonNull Bitmap prompt)
Generates new content from the image input given to the model as a prompt.
| Parameters | |
|---|---|
@NonNull Bitmap prompt |
The image to be converted into a single piece of |
| Returns | |
|---|---|
@NonNull 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
public final @NonNull GenerateContentResponse generateContent(@NonNull Content prompt)
Generates new content from the input Content given to the model as a prompt.
| Returns | |
|---|---|
@NonNull 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
public final @NonNull GenerateContentResponse generateContent(@NonNull String prompt)
Generates new content from the text input given to the model as a prompt.
| Returns | |
|---|---|
@NonNull 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
public final @NonNull Flow<@NonNull GenerateContentResponse> generateContentStream(@NonNull Bitmap prompt)
Generates new content as a stream from the image input given to the model as a prompt.
| Parameters | |
|---|---|
@NonNull Bitmap prompt |
The image to be converted into a single piece of |
| Returns | |
|---|---|
@NonNull Flow<@NonNull 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
public final @NonNull Flow<@NonNull GenerateContentResponse> generateContentStream(@NonNull Content prompt)
Generates new content as a stream from the input Content given to the model as a prompt.
| Returns | |
|---|---|
@NonNull Flow<@NonNull 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
public final @NonNull Flow<@NonNull GenerateContentResponse> generateContentStream(@NonNull String prompt)
Generates new content as a stream from the text input given to the model as a prompt.
| Returns | |
|---|---|
@NonNull Flow<@NonNull 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. |