Package @google-cloud/vertexai (0.2.1)

Classes

ChatSession

Chat session to make multi-turn send message request. sendMessage method makes async call to get response of a chat message. sendMessageStream method makes async call to stream response of a chat message.

ClientError

ClientError is thrown when http 4XX status is received. For details please refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses

GenerativeModel

Base class for generative models. NOTE: this class should not be instantiated directly. Use vertexai.preview.getGenerativeModel() instead.

GoogleAuthError

GoogleAuthError is thrown when there is authentication issue with the request

GoogleGenerativeAIError

GoogleGenerativeAIError is thrown when http response is not ok and status code is not 4XX For details please refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

VertexAI_Preview

VertexAI class internal implementation for authentication.

VertexAI

Base class for authenticating to Vertex, creates the preview namespace.

Interfaces

BaseModelParams

Base params for initializing a model or calling GenerateContent. {SafetySetting[]} - [safety_settings] Array of SafetySetting {GenerationConfig} - [generation_config] GenerationConfig

BasePart

A part of a turn in a conversation with the model with a fixed MIME type. It has one of the following mutually exclusive fields: 1. text 2. inline_data 3. file_data

CitationMetadata

A collection of source attributions for a piece of content. {CitationSource[]} - citationSources. Array of CitationSource

CitationSource

Source attributions for content. {number} - [startIndex] Start index into the content. {number} - [endIndex] End index into the content. {string} - [url] Url reference of the attribution. {string} - [license] License of the attribution.

Content

The base structured datatype containing multi-part content of a message. {Part[]} - parts. Array of Part {string} - [role]. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset.

CountTokensRequest

Params used to call the countTokens method. {Content[]} - contents. Array of Content

CountTokensResponse

Response returned from countTokens method. {number} - totalTokens. The total number of tokens counted across all instances from the request. {number} - [totalBillableCharacters]. The total number of billable characters counted across all instances from the request.

FileData

URI based data. {string} - mime_type. The IANA standard MIME type of the source data. {string} - file_uri. URI of the file.

FileDataPart

A file data part of a conversation with the model. {never} - [text]. text is not expected for FileDataPart. {never} - [inline_data]. inline_data is not expected for FileDataPart. {FileData} - file_data. Only this property is expected for FileDataPart. FileData

GenerateContentCandidate

A response candidate generated from the model. {Content} - content. Content {number} - [index]. The index of the candidate in the GenerateContentResponse {FinishReason} - [finishReason]. FinishReason {string} - [finishMessage]. {SafetyRating[]} - [safetyRatings]. Array of SafetyRating {CitationMetadata} - [citationMetadata]. CitationMetadata

GenerateContentRequest

Params used to call the generateContent method. {Content[]} - contents. Array of Content

GenerateContentResponse

Response from the model supporting multiple candidates {GenerateContentCandidate} - candidates. GenerateContentCandidate {PromptFeedback} - [promptFeedback]. This is only populated if there are no candidates due to a safety block PromptFeedback {UsageMetadata} - [usageMetadata]. UsageMetadata

GenerateContentResult

Wrapper for respones from a generateContent request {GenerateContentResponse} - response. All GenerateContentResponses received so far GenerateContentResponse

GenerationConfig

Configuration options for model generation and outputs {number} - [candidate_count] Number of candidates to generate. {string[]} - [stop_sequences] Stop sequences. {number} - [max_output_tokens] The maximum number of output tokens to generate per message. {number} - [temperature] Controls the randomness of predictions. {number} - [top_p] If specified, nucleus sampling will be used. {number} - [top_k] If specified, top-k sampling will be used.

GenerativeContentBlob

Raw media bytes sent directly in the request. Text should not be sent as raw bytes. {string} - mime_type. The MIME type of the source data. The only accepted values: "image/png" or "image/jpeg". {string} - data. data must be base64 string

InlineDataPart

An inline data part of a conversation with the model. {never} - [text]. text is not expected for InlineDataPart. {GenerativeContentBlob} - inline_data. Only this property is expected for InlineDataPart. GenerativeContentBlob {never} - [file_data]. file_data is not expected for InlineDataPart.

ModelParams

Configuration for initializing a model, for example via getGenerativeModel {string} model - model name.

PromptFeedback

Content filter results for a prompt sent in the request. {BlockedReason} - block_reason. {SafetyRating[]} - safety_ratings. Array of SafetyRating {string} - block_reason_message. A readable block reason message.

SafetyRating

Safety rating corresponding to the generated content. {HarmCategory} - category. HarmCategory {HarmProbability} - probability. HarmProbability

SafetySetting

Safety feedback for an entire request. {HarmCategory} - category. HarmCategory {HarmBlockThreshold} - threshold. HarmBlockThreshold

StartChatParams

Params to initiate a multiturn chat with the model via startChat {Content[]} - [history] history of the chat session. Content {SafetySetting[]} - [safety_settings] Array of SafetySetting {GenerationConfig} - [generation_config] GenerationConfig

StartChatSessionRequest

All params passed to initiate multiturn chat via startChat {VertexAI_Preview} - _vertex_instance VertexAI_Preview {GenerativeModel} - _model_instance GenerativeModel

StreamGenerateContentResult

Wrapper for respones from a generateContent method when steam parameter is true {Promise

TextPart

A text part of a conversation with the model. {string} - text. Only this propery is expected for TextPart. {never} - [inline_data]. inline_data is not expected for TextPart. {never} - [file_data]. file_data is not expected for TextPart.

UsageMetadata

Usage metadata about response(s). {number} - [prompt_token_count]. Number of tokens in the request. {number} - [candidates_token_count]. Number of tokens in the response(s). {number} - [totalTokenCount]. Total number of tokens.

VertexInit

Params used to initialize the Vertex SDK @param{string} project - the project name of your Google Cloud project. It is not the numeric project ID. @param{string} location - the location of your project. @param{string} [apiEndpoint] - If not specified, a default value will be resolved by SDK.

Enums

BlockedReason

{string} The reason why the reponse is blocked. Values: BLOCKED_REASON_UNSPECIFIED Unspecified blocked reason. SAFETY Candidates blocked due to safety. OTHER Candidates blocked due to other reason.

FinishReason

{string} The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens. Values: FINISH_REASON_UNSPECIFIED The finish reason is unspecified. STOP: Natural stop point of the model or provided stop sequence. MAX_TOKENS: The maximum number of tokens as specified in the request was reached. SAFETY: The token generation was stopped as the response was flagged for safety reasons. NOTE: When streaming the Candidate.content will be empty if content filters blocked the output. RECITATION: The token generation was stopped as the response was flagged for unauthorized citations. OTHER: All other reasons that stopped the token generation

HarmBlockThreshold

{string} Probability based thresholds levels for blocking. Values: HARM_BLOCK_THRESHOLD_UNSPECIFIED: Unspecified harm block threshold. BLOCK_LOW_AND_ABOVE: Block low threshold and above (i.e. block more). BLOCK_MEDIUM_AND_ABOVE: Block medium threshold and above. BLOCK_ONLY_HIGH: Block only high threshold (i.e. block less). BLOCK_NONE: Block none.

HarmCategory

{string} Harm categories that will block the content. Values: HARM_CATEGORY_UNSPECIFIED: The harm category is unspecified. HARM_CATEGORY_HATE_SPEECH: The harm category is hate speech. HARM_CATEGORY_DANGEROUS_CONTENT: The harm category is dangerous content. HARM_CATEGORY_HARASSMENT: The harm category is harassment. HARM_CATEGORY_SEXUALLY_EXPLICIT: The harm category is sexually explicit content.

HarmProbability

{string} Harm probability levels in the content. Values: HARM_PROBABILITY_UNSPECIFIED: Harm probability unspecified. NEGLIGIBLE: Negligible level of harm. LOW: Low level of harm. MEDIUM: Medium level of harm. HIGH: High level of harm.

Type Aliases

Part

export declare type Part = TextPart | InlineDataPart | FileDataPart;

A datatype containing media that is part of a multi-part Content message. A Part is a union type of TextPart, InlineDataPart and FileDataPart A Part has one of the following mutually exclusive fields: 1. text 2. inline_data 3. file_data