Class GenerativeModel (0.5.0)

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

Package

@google-cloud/vertexai

Constructors

(constructor)(getGenerativeModelParams)

  constructor 
 ( 
 getGenerativeModelParams 
 : 
  
 GetGenerativeModelParams 
 ); 
 

Constructs a new instance of the GenerativeModel class

Parameter
Name
Description

Properties

generation_config

  generation_config 
 ?: 
  
 GenerationConfig 
 ; 
 

model

  model 
 : 
  
 string 
 ; 
 

requestOptions

  requestOptions 
 ?: 
  
 RequestOptions 
 ; 
 

safety_settings

  safety_settings 
 ?: 
  
 SafetySetting 
 []; 
 

token

  get 
  
 token 
 () 
 : 
  
 Promise<any> 
 ; 
 

Gets access token from GoogleAuth. Throws GoogleAuthError when fails.

tools

  tools 
 ?: 
  
 Tool 
 []; 
 

Methods

countTokens(request)

  countTokens 
 ( 
 request 
 : 
  
 CountTokensRequest 
 ) 
 : 
  
 Promise<CountTokensResponse> 
 ; 
 

Makes a async request to count tokens.

Parameter
Name
Description
request
CountTokensRequest

A CountTokensRequest object with the request contents.

Returns
Type
Description
Promise < CountTokensResponse >

The CountTokensResponse object with the token count.

generateContent(request)

  generateContent 
 ( 
 request 
 : 
  
 GenerateContentRequest 
  
 | 
  
 string 
 ) 
 : 
  
 Promise<GenerateContentResult> 
 ; 
 

Makes a async call to generate content.

Parameter
Name
Description
request
GenerateContentRequest | string

A GenerateContentRequest object with the request contents.

Returns
Type
Description
Promise < GenerateContentResult >

The GenerateContentResponse object with the response candidates.

generateContentStream(request)

  generateContentStream 
 ( 
 request 
 : 
  
 GenerateContentRequest 
  
 | 
  
 string 
 ) 
 : 
  
 Promise<StreamGenerateContentResult> 
 ; 
 

Makes an async stream request to generate content. The response will be returned in stream.

Parameter
Name
Description
Returns
Type
Description

{Promise

startChat(request)

  startChat 
 ( 
 request 
 ?: 
  
 StartChatParams 
 ) 
 : 
  
 ChatSession 
 ; 
 

Instantiates a ChatSession. This method doesn't make any call to remote endpoint. Any call to remote endpoint is implemented in ChatSession class

Parameter
Name
Description
request
Returns
Type
Description

{ChatSession} ChatSession

Create a Mobile Website
View Site in Mobile | Classic
Share by: