@google-cloud/vertexai
Advanced tools
Comparing version 1.4.0 to 1.4.1
{ | ||
".": "1.4.0" | ||
".": "1.4.1" | ||
} |
@@ -17,2 +17,3 @@ /** | ||
*/ | ||
import { GenerateContentRequest, GenerateContentResult, GenerationConfig, RequestOptions, SafetySetting, StreamGenerateContentResult, Tool } from '../types/content'; | ||
/** | ||
@@ -23,3 +24,2 @@ * Make a async call to generate content. | ||
*/ | ||
import { GenerateContentRequest, GenerateContentResult, GenerationConfig, RequestOptions, SafetySetting, StreamGenerateContentResult, Tool } from '../types/content'; | ||
export declare function generateContent(location: string, resourcePath: string, token: Promise<string | null | undefined>, request: GenerateContentRequest | string, apiEndpoint?: string, generationConfig?: GenerationConfig, safetySettings?: SafetySetting[], tools?: Tool[], requestOptions?: RequestOptions): Promise<GenerateContentResult>; | ||
@@ -26,0 +26,0 @@ /** |
@@ -25,2 +25,7 @@ "use strict"; | ||
const pre_fetch_processing_1 = require("./pre_fetch_processing"); | ||
/** | ||
* Make a async call to generate content. | ||
* @param request A GenerateContentRequest object with the request contents. | ||
* @returns The GenerateContentResponse object with the response candidates. | ||
*/ | ||
async function generateContent(location, resourcePath, token, request, apiEndpoint, generationConfig, safetySettings, tools, requestOptions) { | ||
@@ -27,0 +32,0 @@ var _a, _b, _c; |
@@ -21,4 +21,4 @@ /** | ||
declare class GoogleAuthError extends Error { | ||
readonly stackTrace: any; | ||
constructor(message: string, stackTrace?: any); | ||
readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error); | ||
} | ||
@@ -30,4 +30,4 @@ /** | ||
declare class ClientError extends Error { | ||
readonly stackTrace: any; | ||
constructor(message: string, stackTrace?: any); | ||
readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error); | ||
} | ||
@@ -39,4 +39,4 @@ /** | ||
declare class GoogleGenerativeAIError extends Error { | ||
readonly stackTrace: any; | ||
constructor(message: string, stackTrace?: any); | ||
readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error); | ||
} | ||
@@ -47,5 +47,5 @@ /** | ||
declare class IllegalArgumentError extends Error { | ||
readonly stackTrace: any; | ||
constructor(message: string, stackTrace?: any); | ||
readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error); | ||
} | ||
export { ClientError, GoogleAuthError, GoogleGenerativeAIError, IllegalArgumentError, }; |
@@ -24,5 +24,4 @@ "use strict"; | ||
class GoogleAuthError extends Error { | ||
constructor(message, stackTrace = undefined) { | ||
super(message); | ||
this.stackTrace = undefined; | ||
constructor(message, stackTrace) { | ||
super(message, { cause: stackTrace }); | ||
this.message = constructErrorMessage('GoogleAuthError', message); | ||
@@ -39,5 +38,4 @@ this.name = 'GoogleAuthError'; | ||
class ClientError extends Error { | ||
constructor(message, stackTrace = undefined) { | ||
super(message); | ||
this.stackTrace = undefined; | ||
constructor(message, stackTrace) { | ||
super(message, { cause: stackTrace }); | ||
this.message = constructErrorMessage('ClientError', message); | ||
@@ -54,5 +52,4 @@ this.name = 'ClientError'; | ||
class GoogleGenerativeAIError extends Error { | ||
constructor(message, stackTrace = undefined) { | ||
super(message); | ||
this.stackTrace = undefined; | ||
constructor(message, stackTrace) { | ||
super(message, { cause: stackTrace }); | ||
this.message = constructErrorMessage('GoogleGenerativeAIError', message); | ||
@@ -68,5 +65,4 @@ this.name = 'GoogleGenerativeAIError'; | ||
class IllegalArgumentError extends Error { | ||
constructor(message, stackTrace = undefined) { | ||
super(message); | ||
this.stackTrace = undefined; | ||
constructor(message, stackTrace) { | ||
super(message, { cause: stackTrace }); | ||
this.message = constructErrorMessage('IllegalArgumentError', message); | ||
@@ -73,0 +69,0 @@ this.name = 'IllegalArgumentError'; |
@@ -23,3 +23,3 @@ /** | ||
export declare const SYSTEM_ROLE = "system"; | ||
export declare const USER_AGENT = "model-builder/1.4.0 grpc-node/1.4.0"; | ||
export declare const USER_AGENT = "model-builder/1.4.1 grpc-node/1.4.1"; | ||
export declare const CREDENTIAL_ERROR_MESSAGE = "\nUnable to authenticate your request \nDepending on your run time environment, you can get authentication by \n- if in local instance or cloud shell: `!gcloud auth login` \n- if in Colab: \n -`from google.colab import auth` \n -`auth.authenticate_user()` \n- if in service account or other: please follow guidance in https://cloud.google.com/docs/authentication"; |
@@ -27,3 +27,3 @@ "use strict"; | ||
const USER_AGENT_PRODUCT = 'model-builder'; | ||
const CLIENT_LIBRARY_VERSION = '1.4.0'; // x-release-please-version | ||
const CLIENT_LIBRARY_VERSION = '1.4.1'; // x-release-please-version | ||
const CLIENT_LIBRARY_LANGUAGE = `grpc-node/${CLIENT_LIBRARY_VERSION}`; | ||
@@ -30,0 +30,0 @@ exports.USER_AGENT = `${USER_AGENT_PRODUCT}/${CLIENT_LIBRARY_VERSION} ${CLIENT_LIBRARY_LANGUAGE}`; |
# Changelog | ||
## [1.4.1](https://github.com/googleapis/nodejs-vertexai/compare/v1.4.0...v1.4.1) (2024-08-09) | ||
### Bug Fixes | ||
* Fix docstring order and add node version badge in README ([d330fe3](https://github.com/googleapis/nodejs-vertexai/commit/d330fe3352713226794ac3e8c7a7a21474a32ec1)) | ||
## [1.4.0](https://github.com/googleapis/nodejs-vertexai/compare/v1.3.0...v1.4.0) (2024-07-15) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@google-cloud/vertexai", | ||
"description": "Vertex Generative AI client for Node.js", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google LLC", |
[](https://www.npmjs.com/package/@google-cloud/vertexai) | ||
[](https://www.npmjs.com/package/@google-cloud/vertexai) | ||
@@ -22,5 +23,11 @@ # Vertex AI SDK for Node.js quickstart | ||
1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). | ||
1. [Set up authentication with a service account](https://cloud.google.com/docs/authentication/getting-started) | ||
so you can access the API from your local workstation. | ||
1. [Install the gcloud CLI](https://cloud.google.com/sdk/docs/install). | ||
1. [Initialize the gcloud CLI](https://cloud.google.com/sdk/docs/initializing). | ||
1. Create local authentication credentials for your user account: | ||
```sh | ||
gcloud auth application-default login | ||
``` | ||
1. Official documentation is available in the [Vertex AI SDK Overview](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/nodejs/latest/overview) page. From here, a complete list of documentation on classes, interfaces, and enums are available. | ||
## Install the SDK | ||
@@ -62,3 +69,7 @@ | ||
generationConfig: {maxOutputTokens: 256}, | ||
}); | ||
systemInstruction: { | ||
role: 'system', | ||
parts: [{"text": `For example, you are a helpful customer service agent.`}] | ||
}, | ||
}); | ||
@@ -426,3 +437,37 @@ const generativeVisionModel = vertexAI.getGenerativeModel({ | ||
``` | ||
## System Instruction | ||
You can include an optional system instruction when instantiating a generative model to provide additional context to the model. | ||
The system instruction can also be passed to individual text prompt requests. | ||
### Include system instruction in generative model instantiation | ||
```javascript | ||
const generativeModel = vertexAI.getGenerativeModel({ | ||
model: textModel, | ||
// The following parameter is optional. | ||
systemInstruction: { | ||
role: 'system', | ||
parts: [{"text": `For example, you are a helpful customer service agent.`}] | ||
}, | ||
}); | ||
``` | ||
### Include system instruction in text prompt request | ||
```javascript | ||
async function generateContent() { | ||
const request = { | ||
contents: [{role: 'user', parts: [{text: 'How are you doing today?'}]}], | ||
systemInstruction: { role: 'system', parts: [{ text: `For example, you are a helpful customer service agent.` }] }, | ||
}; | ||
const result = await generativeModel.generateContent(request); | ||
const response = result.response; | ||
console.log('Response: ', JSON.stringify(response)); | ||
}; | ||
generateContent(); | ||
``` | ||
## License | ||
@@ -429,0 +474,0 @@ |
@@ -18,8 +18,2 @@ /** | ||
/** | ||
* Make a async call to generate content. | ||
* @param request A GenerateContentRequest object with the request contents. | ||
* @returns The GenerateContentResponse object with the response candidates. | ||
*/ | ||
import { | ||
@@ -51,2 +45,7 @@ GenerateContentRequest, | ||
/** | ||
* Make a async call to generate content. | ||
* @param request A GenerateContentRequest object with the request contents. | ||
* @returns The GenerateContentResponse object with the response candidates. | ||
*/ | ||
export async function generateContent( | ||
@@ -53,0 +52,0 @@ location: string, |
@@ -22,5 +22,5 @@ /** | ||
class GoogleAuthError extends Error { | ||
public readonly stackTrace: any = undefined; | ||
constructor(message: string, stackTrace: any = undefined) { | ||
super(message); | ||
public readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error) { | ||
super(message, {cause: stackTrace}); | ||
this.message = constructErrorMessage('GoogleAuthError', message); | ||
@@ -37,5 +37,5 @@ this.name = 'GoogleAuthError'; | ||
class ClientError extends Error { | ||
public readonly stackTrace: any = undefined; | ||
constructor(message: string, stackTrace: any = undefined) { | ||
super(message); | ||
public readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error) { | ||
super(message, {cause: stackTrace}); | ||
this.message = constructErrorMessage('ClientError', message); | ||
@@ -52,5 +52,5 @@ this.name = 'ClientError'; | ||
class GoogleGenerativeAIError extends Error { | ||
public readonly stackTrace: any = undefined; | ||
constructor(message: string, stackTrace: any = undefined) { | ||
super(message); | ||
public readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error) { | ||
super(message, {cause: stackTrace}); | ||
this.message = constructErrorMessage('GoogleGenerativeAIError', message); | ||
@@ -66,5 +66,5 @@ this.name = 'GoogleGenerativeAIError'; | ||
class IllegalArgumentError extends Error { | ||
public readonly stackTrace: any = undefined; | ||
constructor(message: string, stackTrace: any = undefined) { | ||
super(message); | ||
public readonly stackTrace?: Error; | ||
constructor(message: string, stackTrace?: Error) { | ||
super(message, {cause: stackTrace}); | ||
this.message = constructErrorMessage('IllegalArgumentError', message); | ||
@@ -71,0 +71,0 @@ this.name = 'IllegalArgumentError'; |
@@ -24,3 +24,3 @@ /** | ||
const USER_AGENT_PRODUCT = 'model-builder'; | ||
const CLIENT_LIBRARY_VERSION = '1.4.0'; // x-release-please-version | ||
const CLIENT_LIBRARY_VERSION = '1.4.1'; // x-release-please-version | ||
const CLIENT_LIBRARY_LANGUAGE = `grpc-node/${CLIENT_LIBRARY_VERSION}`; | ||
@@ -27,0 +27,0 @@ export const USER_AGENT = `${USER_AGENT_PRODUCT}/${CLIENT_LIBRARY_VERSION} ${CLIENT_LIBRARY_LANGUAGE}`; |
@@ -8,3 +8,3 @@ { | ||
"lib": [ | ||
"es2018", | ||
"es2022", | ||
"dom", | ||
@@ -11,0 +11,0 @@ "dom.iterable" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1177503
163
21883
473