The Vertex AI in Firebase Web SDK.
Functions
Function | Description |
---|---|
function(app, ...) | |
getVertexAI(app, options) | Returns a VertexAI instance for the given app. |
function(vertexAI, ...) | |
getGenerativeModel(vertexAI, modelParams, requestOptions) | Returns a GenerativeModel class with methods for inference and other functionality. |
Classes
Class | Description |
---|---|
ArraySchema | Schema class for "array" types. The items param should refer to the type of item that can be a member of the array. |
BooleanSchema | Schema class for "boolean" types. |
ChatSession | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
GenerativeModel | Class for generative model APIs. |
IntegerSchema | Schema class for "integer" types. |
NumberSchema | Schema class for "number" types. |
ObjectSchema | Schema class for "object" types. The properties param must be a map of Schema objects. |
Schema | Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with JSON.stringify() into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.) |
StringSchema | Schema class for "string" types. Can be used with or without enum values. |
VertexAIError | Error class for the Vertex AI in Firebase SDK. |
Enumerations
Enumeration | Description |
---|---|
BlockReason | Reason that a prompt was blocked. |
FinishReason | Reason that a candidate finished. |
FunctionCallingMode | |
HarmBlockMethod | |
HarmBlockThreshold | Threshold above which a prompt or candidate will be blocked. |
HarmCategory | Harm categories that would cause prompts or candidates to be blocked. |
HarmProbability | Probability that a prompt or candidate matches a harm category. |
HarmSeverity | Harm severity levels. |
SchemaType | Contains the list of OpenAPI data types as defined by the OpenAPI specification |
VertexAIErrorCode | Standardized error codes that VertexAIError can have. |
Interfaces
Interface | Description |
---|---|
BaseParams | Base parameters for a number of methods. |
Citation | A single citation. |
CitationMetadata | Citation metadata that may be found on a GenerateContentCandidate . |
Content | Content type for both prompts and response candidates. |
CountTokensRequest | Params for calling GenerativeModel.countTokens() |
CountTokensResponse | Response from calling GenerativeModel.countTokens(). |
CustomErrorData | Details object that contains data originating from a bad HTTP response. |
Date_2 | Protobuf google.type.Date |
EnhancedGenerateContentResponse | Response object wrapped with helper methods. |
ErrorDetails | Details object that may be included in an error response. |
FileData | Data pointing to a file uploaded on Google Cloud Storage. |
FileDataPart | Content part interface if the part represents FileData |
FunctionCall | A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values. |
FunctionCallingConfig | |
FunctionCallPart | Content part interface if the part represents a FunctionCall . |
FunctionDeclaration | Structured representation of a function declaration as defined by the OpenAPI 3.0 specification. Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. |
FunctionDeclarationsTool | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. |
FunctionResponse | The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a FunctionCall made based on model prediction. |
FunctionResponsePart | Content part interface if the part represents FunctionResponse . |
GenerateContentCandidate | A candidate returned as part of a GenerateContentResponse . |
GenerateContentRequest | Request sent through GenerativeModel.generateContent() |
GenerateContentResponse | Individual response from GenerativeModel.generateContent() and GenerativeModel.generateContentStream(). generateContentStream() will return one in each chunk until the stream is done. |
GenerateContentResult | Result object returned from GenerativeModel.generateContent() call. |
GenerateContentStreamResult | Result object returned from GenerativeModel.generateContentStream() call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. |
GenerationConfig | Config options for content-related requests |
GenerativeContentBlob | Interface for sending an image. |
GroundingAttribution | |
GroundingMetadata | Metadata returned to client when grounding is enabled. |
InlineDataPart | Content part interface if the part represents an image. |
ModelParams | Params passed to getGenerativeModel() . |
ObjectSchemaInterface | Interface for ObjectSchema class. |
PromptFeedback | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings . |
RequestOptions | Params passed to getGenerativeModel() . |
RetrievedContextAttribution | |
SafetyRating | A safety rating associated with a GenerateContentCandidate |
SafetySetting | Safety setting that can be sent as part of request parameters. |
SchemaInterface | Interface for Schema class. |
SchemaParams | Params passed to Schema static methods to create specific Schema classes. |
SchemaRequest | Final format for Schema params passed to backend requests. |
SchemaShared | Basic Schema properties shared across several Schema-related types. |
Segment | |
StartChatParams | Params for GenerativeModel.startChat(). |
TextPart | Content part interface if the part represents a text string. |
ToolConfig | Tool config. This config is shared for all tools provided in the request. |
UsageMetadata | Usage metadata about a GenerateContentResponse . |
VertexAI | An instance of the Vertex AI in Firebase SDK. |
VertexAIOptions | Options when initializing the Vertex AI in Firebase SDK. |
VideoMetadata | Describes the input video content. |
WebAttribution |
Variables
Variable | Description |
---|---|
POSSIBLE_ROLES | Possible roles. |
Type Aliases
Type Alias | Description |
---|---|
Part | Content part - includes text, image/video, or function call/response part types. |
Role | Role is the producer of the content. |
Tool | Defines a tool that model can call to access external knowledge. |
TypedSchema | A type that includes all specific Schema types. |
function(app, ...)
getVertexAI(app, options)
Returns a VertexAI
instance for the given app.
Signature:
export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI;
Parameters
Parameter | Type | Description |
---|---|---|
app | FirebaseApp | The FirebaseApp to use. |
options | VertexAIOptions |
Returns:
function(vertexAI, ...)
getGenerativeModel(vertexAI, modelParams, requestOptions)
Returns a GenerativeModel
class with methods for inference and other functionality.
Signature:
export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
Parameters
Parameter | Type | Description |
---|---|---|
vertexAI | VertexAI | |
modelParams | ModelParams | |
requestOptions | RequestOptions |
Returns:
POSSIBLE_ROLES
Possible roles.
Signature:
POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]
Part
Content part - includes text, image/video, or function call/response part types.
Signature:
export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
Role
Role is the producer of the content.
Signature:
export declare type Role = (typeof POSSIBLE_ROLES)[number];
Tool
Defines a tool that model can call to access external knowledge.
Signature:
export declare type Tool = FunctionDeclarationsTool;
TypedSchema
A type that includes all specific Schema types.
Signature:
export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema;
BlockReason
Reason that a prompt was blocked.
Signature:
export declare enum BlockReason
Enumeration Members
Member | Value | Description |
---|---|---|
OTHER | "OTHER" |
|
SAFETY | "SAFETY" |
FinishReason
Reason that a candidate finished.
Signature:
export declare enum FinishReason
Enumeration Members
Member | Value | Description |
---|---|---|
MAX_TOKENS | "MAX_TOKENS" |
|
OTHER | "OTHER" |
|
RECITATION | "RECITATION" |
|
SAFETY | "SAFETY" |
|
STOP | "STOP" |
FunctionCallingMode
Signature:
export declare enum FunctionCallingMode
Enumeration Members
Member | Value | Description |
---|---|---|
ANY | "ANY" |
|
AUTO | "AUTO" |
|
NONE | "NONE" |
HarmBlockMethod
Signature:
export declare enum HarmBlockMethod
Enumeration Members
Member | Value | Description |
---|---|---|
PROBABILITY | "PROBABILITY" |
|
SEVERITY | "SEVERITY" |
HarmBlockThreshold
Threshold above which a prompt or candidate will be blocked.
Signature:
export declare enum HarmBlockThreshold
Enumeration Members
Member | Value | Description |
---|---|---|
BLOCK_LOW_AND_ABOVE | "BLOCK_LOW_AND_ABOVE" |
|
BLOCK_MEDIUM_AND_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" |
|
BLOCK_NONE | "BLOCK_NONE" |
|
BLOCK_ONLY_HIGH | "BLOCK_ONLY_HIGH" |
HarmCategory
Harm categories that would cause prompts or candidates to be blocked.
Signature:
export declare enum HarmCategory
Enumeration Members
Member | Value | Description |
---|---|---|
HARM_CATEGORY_DANGEROUS_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" |
|
HARM_CATEGORY_HARASSMENT | "HARM_CATEGORY_HARASSMENT" |
|
HARM_CATEGORY_HATE_SPEECH | "HARM_CATEGORY_HATE_SPEECH" |
|
HARM_CATEGORY_SEXUALLY_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" |
HarmProbability
Probability that a prompt or candidate matches a harm category.
Signature:
export declare enum HarmProbability
Enumeration Members
Member | Value | Description |
---|---|---|
HIGH | "HIGH" |
|
LOW | "LOW" |
|
MEDIUM | "MEDIUM" |
|
NEGLIGIBLE | "NEGLIGIBLE" |
HarmSeverity
Harm severity levels.
Signature:
export declare enum HarmSeverity
Enumeration Members
Member | Value | Description |
---|---|---|
HARM_SEVERITY_HIGH | "HARM_SEVERITY_HIGH" |
|
HARM_SEVERITY_LOW | "HARM_SEVERITY_LOW" |
|
HARM_SEVERITY_MEDIUM | "HARM_SEVERITY_MEDIUM" |
|
HARM_SEVERITY_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" |
SchemaType
Contains the list of OpenAPI data types as defined by the OpenAPI specification
Signature:
export declare enum SchemaType
Enumeration Members
Member | Value | Description |
---|---|---|
ARRAY | "array" |
Array type. |
BOOLEAN | "boolean" |
Boolean type. |
INTEGER | "integer" |
Integer type. |
NUMBER | "number" |
Number type. |
OBJECT | "object" |
Object type. |
STRING | "string" |
String type. |
VertexAIErrorCode
Standardized error codes that VertexAIError
can have.
Signature:
export declare const enum VertexAIErrorCode
Enumeration Members
Member | Value | Description |
---|---|---|
API_NOT_ENABLED | "api-not-enabled" |
An error due to the Firebase API not being enabled in the Console. |
ERROR | "error" |
A generic error occurred. |
FETCH_ERROR | "fetch-error" |
An error occurred while performing a fetch. |
INVALID_CONTENT | "invalid-content" |
An error associated with a Content object. |
INVALID_SCHEMA | "invalid-schema" |
An error due to invalid Schema input. |
NO_API_KEY | "no-api-key" |
An error occurred due to a missing Firebase API key. |
NO_MODEL | "no-model" |
An error occurred due to a model name not being specified during initialization. |
NO_PROJECT_ID | "no-project-id" |
An error occurred due to a missing project ID. |
PARSE_FAILED | "parse-failed" |
An error occurred while parsing. |
REQUEST_ERROR | "request-error" |
An error occurred in a request. |
RESPONSE_ERROR | "response-error" |
An error occurred in a response. |