Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
Class for generative model APIs.
Signature:
export declare class GenerativeModel extends VertexAIModel
Extends: VertexAIModel
Constructor | Modifiers | Description |
---|---|---|
(constructor)(vertexAI, modelParams, requestOptions) | Constructs a new instance of the GenerativeModel class |
Property | Modifiers | Type | Description |
---|---|---|---|
generationConfig | GenerationConfig | ||
requestOptions | RequestOptions | ||
safetySettings | SafetySetting[] | ||
systemInstruction | Content | ||
toolConfig | ToolConfig | ||
tools | Tool[] |
Method | Modifiers | Description |
---|---|---|
countTokens(request) | Counts the tokens in the provided request. | |
generateContent(request) | Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse. | |
generateContentStream(request) | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | |
startChat(startChatParams) | Gets a new ChatSession instance which can be used for multi-turn chats. |
Constructs a new instance of the GenerativeModel
class
Signature:
constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions);
Parameter | Type | Description |
---|---|---|
vertexAI | VertexAI | |
modelParams | ModelParams | |
requestOptions | RequestOptions |
Signature:
generationConfig: GenerationConfig;
Signature:
requestOptions?: RequestOptions;
Signature:
safetySettings: SafetySetting[];
Signature:
systemInstruction?: Content;
Signature:
toolConfig?: ToolConfig;
Signature:
tools?: Tool[];
Counts the tokens in the provided request.
Signature:
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
Parameter | Type | Description |
---|---|---|
request | CountTokensRequest | string | Array<string | Part> |
Returns:
Promise<CountTokensResponse>
Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse.
Signature:
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
Parameter | Type | Description |
---|---|---|
request | GenerateContentRequest | string | Array<string | Part> |
Returns:
Promise<GenerateContentResult>
Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
Signature:
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
Parameter | Type | Description |
---|---|---|
request | GenerateContentRequest | string | Array<string | Part> |
Returns:
Promise<GenerateContentStreamResult>
Gets a new ChatSession instance which can be used for multi-turn chats.
Signature:
startChat(startChatParams?: StartChatParams): ChatSession;
Parameter | Type | Description |
---|---|---|
startChatParams | StartChatParams |
Returns: