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 |
---|---|
ChatSession | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
GenerativeModel | Class for generative model APIs. |
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 | |
FunctionDeclarationSchemaType | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ |
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. |
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. |
FunctionDeclarationSchema | Schema for parameters passed to FunctionDeclaration.parameters. |
FunctionDeclarationSchemaProperty | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. |
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(). |
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. |
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. |
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;
BlockReason
Reason that a prompt was blocked.
Signature:
export declare enum BlockReason
Enumeration Members
Member | Value | Description |
---|---|---|
BLOCKED_REASON_UNSPECIFIED | "BLOCKED_REASON_UNSPECIFIED" |
|
OTHER | "OTHER" |
|
SAFETY | "SAFETY" |
FinishReason
Reason that a candidate finished.
Signature:
export declare enum FinishReason
Enumeration Members
Member | Value | Description |
---|---|---|
FINISH_REASON_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED" |
|
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" |
|
MODE_UNSPECIFIED | "MODE_UNSPECIFIED" |
|
NONE | "NONE" |
FunctionDeclarationSchemaType
Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/
Signature:
export declare enum FunctionDeclarationSchemaType
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. |
HarmBlockMethod
Signature:
export declare enum HarmBlockMethod
Enumeration Members
Member | Value | Description |
---|---|---|
HARM_BLOCK_METHOD_UNSPECIFIED | "HARM_BLOCK_METHOD_UNSPECIFIED" |
|
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" |
|
HARM_BLOCK_THRESHOLD_UNSPECIFIED | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" |
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" |
|
HARM_CATEGORY_UNSPECIFIED | "HARM_CATEGORY_UNSPECIFIED" |
HarmProbability
Probability that a prompt or candidate matches a harm category.
Signature:
export declare enum HarmProbability
Enumeration Members
Member | Value | Description |
---|---|---|
HARM_PROBABILITY_UNSPECIFIED | "HARM_PROBABILITY_UNSPECIFIED" |
|
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" |
|
HARM_SEVERITY_UNSPECIFIED | "HARM_SEVERITY_UNSPECIFIED" |
VertexAIErrorCode
Standardized error codes that VertexAIError can have.
Signature:
export declare const enum VertexAIErrorCode
Enumeration Members
Member | Value | Description |
---|---|---|
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. |
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. |