com.google.firebase.vertexai.type

Interfaces

Part

Interface representing data sent to and received from requests.

Classes

BlobPart

Represents binary data with an associated MIME type sent to and received from requests.

Candidate

A response generated by the model.

CitationMetadata

Provides citation metadata for sourcing of content provided by the model between a given startIndex and endIndex.

Content

Represents content sent to and received from the model.

Content.Builder

Builder class to facilitate constructing complex Content objects.

CountTokensResponse

Represents a response measuring model input.

FourParameterFunction

A declared four param function, including implementation, that a model can be given access to in order to gain info or complete tasks.

FunctionCallPart

Represents function call name and params received from requests.

FunctionCallingConfig

Contains configuration for function calling from the model.

FunctionDeclaration

A declared function, including implementation, that a model can be given access to in order to gain info or complete tasks.

FunctionParameter
FunctionResponsePart

Represents function call output to be returned to the model when it requests a function call.

FunctionType

Represents and passes the type information for an automated function call.

GenerateContentResponse

Represents a response from the model.

GenerationConfig

Configuration parameters to use for content generation.

GenerationConfig.Builder

Builder for creating a GenerationConfig.

ImagePart

Represents image data sent to and received from requests.

NoParameterFunction

A declared zero param function, including implementation, that a model can be given access to in order to gain info or complete tasks.

OneParameterFunction

A declared one param function, including implementation, that a model can be given access to in order to gain info or complete tasks.

PromptFeedback

Feedback on the prompt provided in the request.

RequestOptions

Configurable options unique to how requests to the backend are performed.

SafetyRating

Safety rating corresponding to a generated content.

SafetySetting

A configuration for a BlockThreshold of some HarmCategory allowed and blocked in responses.

Schema

Represents a parameter for a declared function

TextPart

Represents text or string based data sent to and received from requests.

ThreeParameterFunction

A declared three param function, including implementation, that a model can be given access to in order to gain info or complete tasks.

Tool

Contains a set of function declarations that the model has access to.

ToolConfig

Contains configuration for the function calling tools of the model.

TwoParameterFunction

A declared two param function, including implementation, that a model can be given access to in order to gain info or complete tasks.

UsageMetadata

Usage metadata about response(s).

Exceptions

FirebaseVertexAIException

Parent class for any errors that occur from the FirebaseVertexAI SDK.

InvalidAPIKeyException

The server responded that the API Key is not valid.

InvalidLocationException

The specified Vertex AI location is invalid.

InvalidStateException

Some form of state occurred that shouldn't have.

PromptBlockedException

A request was blocked for some reason.

RequestTimeoutException

A request took too long to complete.

ResponseStoppedException

A request was stopped during generation for some reason.

SerializationException

Something went wrong while trying to deserialize a response from the server.

ServerException

The server responded with a non 200 response code.

UnknownException

Catch all case for exceptions not explicitly expected.

UnsupportedUserLocationException

The user's location (region) is not supported by the API.

Enums

BlockReason

Describes why content was blocked.

BlockThreshold

Represents the threshold for some HarmCategory that is allowed and blocked by SafetySetting.

FinishReason

The reason for content finishing.

FunctionCallingConfig.Mode

Configuration for dictating when the model should call the attached function.

HarmCategory

Category for a given harm rating.

HarmProbability

Represents the probability that some HarmCategory is applicable in a SafetyRating.

HarmSeverity

Represents the severity of a HarmCategory being applicable in a SafetyRating.

Top-level functions summary

Content
content(role: String?, init: Content.Builder.() -> Unit)

Function to construct content sent to and received in a DSL-like manner.

FourParameterFunction<T, U, W, Z>
<T : Any?, U : Any?, W : Any?, Z : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    arg3: Schema<W>,
    arg4: Schema<Z>,
    function: suspend (T, U, W, Z) -> JSONObject
)

Defines a function with four parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

ThreeParameterFunction<T, U, W>
<T : Any?, U : Any?, W : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    arg3: Schema<W>,
    function: suspend (T, U, W) -> JSONObject
)

Defines a function with three parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

TwoParameterFunction<T, U>
<T : Any?, U : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    function: suspend (T, U) -> JSONObject
)

Defines a function with two parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

OneParameterFunction<T>
<T : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    function: suspend (T) -> JSONObject
)

Defines a function with one parameter, including its implementation, that a model can be given access to in order to gain info or complete tasks.

NoParameterFunction
defineFunction(
    name: String,
    description: String,
    function: suspend () -> JSONObject
)

Defines a function with zero parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

GenerationConfig

Helper method to construct a GenerationConfig in a DSL-like manner.

Extension functions summary

BlobPart?

Returns the part as a BlobPart if it represents a blob, and null otherwise

Bitmap?

Returns the part as a Bitmap if it represents an image, and null otherwise

String?

Returns the part as a String if it represents text, and null otherwise

Top-level functions

content

fun content(role: String? = "user", init: Content.Builder.() -> Unit): Content

Function to construct content sent to and received in a DSL-like manner.

Contains a collection of text, image, and binary parts.

Example usage:

content("user") {
text("Example string")
)

defineFunction

fun <T : Any?, U : Any?, W : Any?, Z : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    arg3: Schema<W>,
    arg4: Schema<Z>,
    function: suspend (T, U, W, Z) -> JSONObject
): FourParameterFunction<T, U, W, Z>

Defines a function with four parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

Parameters
name: String

The name of the function call, this should be clear and descriptive for the model

description: String

A description of what the function does and its output.

arg1: Schema<T>

A description of the first function parameter

arg2: Schema<U>

A description of the second function parameter

arg3: Schema<W>

A description of the third function parameter

arg4: Schema<Z>

A description of the fourth function parameter

function: suspend (T, U, W, Z) -> JSONObject

the function implementation

defineFunction

fun <T : Any?, U : Any?, W : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    arg3: Schema<W>,
    function: suspend (T, U, W) -> JSONObject
): ThreeParameterFunction<T, U, W>

Defines a function with three parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

Parameters
name: String

The name of the function call, this should be clear and descriptive for the model

description: String

A description of what the function does and its output.

arg1: Schema<T>

A description of the first function parameter

arg2: Schema<U>

A description of the second function parameter

arg3: Schema<W>

A description of the third function parameter

function: suspend (T, U, W) -> JSONObject

the function implementation

defineFunction

fun <T : Any?, U : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    arg2: Schema<U>,
    function: suspend (T, U) -> JSONObject
): TwoParameterFunction<T, U>

Defines a function with two parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

Parameters
name: String

The name of the function call, this should be clear and descriptive for the model

description: String

A description of what the function does and its output.

arg1: Schema<T>

A description of the first function parameter

arg2: Schema<U>

A description of the second function parameter

function: suspend (T, U) -> JSONObject

the function implementation

defineFunction

fun <T : Any?> defineFunction(
    name: String,
    description: String,
    arg1: Schema<T>,
    function: suspend (T) -> JSONObject
): OneParameterFunction<T>

Defines a function with one parameter, including its implementation, that a model can be given access to in order to gain info or complete tasks.

Parameters
name: String

The name of the function call, this should be clear and descriptive for the model

description: String

A description of what the function does and its output.

arg1: Schema<T>

A description of the first function parameter

function: suspend (T) -> JSONObject

the function implementation

defineFunction

fun defineFunction(
    name: String,
    description: String,
    function: suspend () -> JSONObject
): NoParameterFunction

Defines a function with zero parameters, including its implementation, that a model can be given access to in order to gain info or complete tasks.

Parameters
name: String

The name of the function call, this should be clear and descriptive for the model

description: String

A description of what the function does and its output.

function: suspend () -> JSONObject

the function implementation

generationConfig

fun generationConfig(init: GenerationConfig.Builder.() -> Unit): GenerationConfig

Helper method to construct a GenerationConfig in a DSL-like manner.

Example Usage:

generationConfig {
temperature = 0.75f
topP = 0.5f
topK = 30
candidateCount = 4
maxOutputTokens = 300
stopSequences = listOf("in conclusion", "-----", "do you need")
}

Extension functions

asBlobPartOrNull

fun Part.asBlobPartOrNull(): BlobPart?

Returns the part as a BlobPart if it represents a blob, and null otherwise

asImageOrNull

fun Part.asImageOrNull(): Bitmap?

Returns the part as a Bitmap if it represents an image, and null otherwise

asTextOrNull

fun Part.asTextOrNull(): String?

Returns the part as a String if it represents text, and null otherwise