Class GenerativeModel (0.2.1)

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

Package

@google-cloud/vertexai

Constructors

(constructor)(vertex_instance, model, generation_config, safety_settings)

constructor(vertex_instance: VertexAI_Preview, model: string, generation_config?: GenerationConfig, safety_settings?: SafetySetting[]);

Constructs a new instance of the GenerativeModel class

Parameters
Name Description
vertex_instance VertexAI_Preview

VertexAI_Preview

model string

model name

generation_config GenerationConfig

Optional. GenerationConfig

safety_settings SafetySetting[]

Optional. SafetySetting

Properties

generation_config

generation_config?: GenerationConfig;

model

model: string;

safety_settings

safety_settings?: SafetySetting[];

Methods

countTokens(request)

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

Make a async request to count tokens.

Parameter
Name Description
request CountTokensRequest

A CountTokensRequest object with the request contents. The CountTokensResponse object with the token count.

Returns
Type Description
Promise<CountTokensResponse>

generateContent(request)

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

Make a async call to generate content.

Parameter
Name Description
request GenerateContentRequest | string

A GenerateContentRequest object with the request contents. The GenerateContentResponse object with the response candidates.

Returns
Type Description
Promise<GenerateContentResult>

generateContentStream(request)

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

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

Parameter
Name Description
request GenerateContentRequest | string

GenerateContentRequest {Promise

Returns
Type Description
Promise<StreamGenerateContentResult>

startChat(request)

startChat(request?: StartChatParams): ChatSession;

Instantiate 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 StartChatParams
Returns
Type Description
ChatSession