@google-cloud/vertexai
Advanced tools
Comparing version 1.5.0 to 1.6.0
{ | ||
".": "1.5.0" | ||
".": "1.6.0" | ||
} |
@@ -18,2 +18,3 @@ /** | ||
import { GenerateContentRequest, GenerateContentResult, GenerationConfig, RequestOptions, SafetySetting, StreamGenerateContentResult, Tool } from '../types/content'; | ||
import { ToolConfig } from '../types/tool'; | ||
/** | ||
@@ -24,3 +25,3 @@ * Make a async call to generate 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>; | ||
export declare function generateContent(location: string, resourcePath: string, token: Promise<string | null | undefined>, request: GenerateContentRequest | string, apiEndpoint?: string, generationConfig?: GenerationConfig, safetySettings?: SafetySetting[], tools?: Tool[], toolConfig?: ToolConfig, requestOptions?: RequestOptions): Promise<GenerateContentResult>; | ||
/** | ||
@@ -33,2 +34,2 @@ * Make an async stream request to generate content. The response will be | ||
*/ | ||
export declare function generateContentStream(location: string, resourcePath: string, token: Promise<string | null | undefined>, request: GenerateContentRequest | string, apiEndpoint?: string, generationConfig?: GenerationConfig, safetySettings?: SafetySetting[], tools?: Tool[], requestOptions?: RequestOptions): Promise<StreamGenerateContentResult>; | ||
export declare function generateContentStream(location: string, resourcePath: string, token: Promise<string | null | undefined>, request: GenerateContentRequest | string, apiEndpoint?: string, generationConfig?: GenerationConfig, safetySettings?: SafetySetting[], tools?: Tool[], toolConfig?: ToolConfig, requestOptions?: RequestOptions): Promise<StreamGenerateContentResult>; |
@@ -30,4 +30,4 @@ "use strict"; | ||
*/ | ||
async function generateContent(location, resourcePath, token, request, apiEndpoint, generationConfig, safetySettings, tools, requestOptions) { | ||
var _a, _b, _c; | ||
async function generateContent(location, resourcePath, token, request, apiEndpoint, generationConfig, safetySettings, tools, toolConfig, requestOptions) { | ||
var _a, _b, _c, _d; | ||
request = (0, pre_fetch_processing_1.formatContentRequest)(request, generationConfig, safetySettings); | ||
@@ -44,2 +44,3 @@ (0, pre_fetch_processing_1.validateGenerateContentRequest)(request); | ||
tools: (_c = request.tools) !== null && _c !== void 0 ? _c : tools, | ||
toolConfig: (_d = request.toolConfig) !== null && _d !== void 0 ? _d : toolConfig, | ||
}; | ||
@@ -71,4 +72,4 @@ const response = await (0, post_request_1.postRequest)({ | ||
*/ | ||
async function generateContentStream(location, resourcePath, token, request, apiEndpoint, generationConfig, safetySettings, tools, requestOptions) { | ||
var _a, _b, _c; | ||
async function generateContentStream(location, resourcePath, token, request, apiEndpoint, generationConfig, safetySettings, tools, toolConfig, requestOptions) { | ||
var _a, _b, _c, _d; | ||
request = (0, pre_fetch_processing_1.formatContentRequest)(request, generationConfig, safetySettings); | ||
@@ -85,2 +86,3 @@ (0, pre_fetch_processing_1.validateGenerateContentRequest)(request); | ||
tools: (_c = request.tools) !== null && _c !== void 0 ? _c : tools, | ||
toolConfig: (_d = request.toolConfig) !== null && _d !== void 0 ? _d : toolConfig, | ||
}; | ||
@@ -87,0 +89,0 @@ const response = await (0, post_request_1.postRequest)({ |
@@ -233,3 +233,2 @@ "use strict"; | ||
webSearchQueries: [], | ||
groundingAttributions: [], | ||
retrievalQueries: [], | ||
@@ -245,6 +244,2 @@ groundingChunks: [], | ||
} | ||
if (groundingMetadataChunk.groundingAttributions) { | ||
groundingMetadataAggregated.groundingAttributions = | ||
groundingMetadataAggregated.groundingAttributions.concat(groundingMetadataChunk.groundingAttributions); | ||
} | ||
if (groundingMetadataChunk.retrievalQueries) { | ||
@@ -251,0 +246,0 @@ groundingMetadataAggregated.retrievalQueries = |
@@ -168,2 +168,3 @@ "use strict"; | ||
const TEST_EMPTY_TOOLS = []; | ||
const TEST_EMPTY_TOOL_CONFIG = {}; | ||
const TEST_TOOLS_WITH_FUNCTION_DECLARATION = [ | ||
@@ -283,3 +284,3 @@ { | ||
}); | ||
await expectAsync((0, generate_content_1.generateContent)(TEST_LOCATION, TEST_RESOURCE_PATH, TEST_TOKEN_PROMISE, req, TEST_API_ENDPOINT, TEST_GENERATION_CONFIG, TEST_SAFETY_SETTINGS, TEST_EMPTY_TOOLS, TEST_REQUEST_OPTIONS)).toBeRejected(); | ||
await expectAsync((0, generate_content_1.generateContent)(TEST_LOCATION, TEST_RESOURCE_PATH, TEST_TOKEN_PROMISE, req, TEST_API_ENDPOINT, TEST_GENERATION_CONFIG, TEST_SAFETY_SETTINGS, TEST_EMPTY_TOOLS, TEST_EMPTY_TOOL_CONFIG, TEST_REQUEST_OPTIONS)).toBeRejected(); | ||
expect(fetchSpy.calls.allArgs()[0][1].signal).toBeInstanceOf(AbortSignal); | ||
@@ -458,3 +459,3 @@ }); | ||
}); | ||
await expectAsync((0, generate_content_1.generateContentStream)(TEST_LOCATION, TEST_RESOURCE_PATH, TEST_TOKEN_PROMISE, req, TEST_API_ENDPOINT, TEST_GENERATION_CONFIG, TEST_SAFETY_SETTINGS, TEST_EMPTY_TOOLS, TEST_REQUEST_OPTIONS)).toBeRejected(); | ||
await expectAsync((0, generate_content_1.generateContentStream)(TEST_LOCATION, TEST_RESOURCE_PATH, TEST_TOKEN_PROMISE, req, TEST_API_ENDPOINT, TEST_GENERATION_CONFIG, TEST_SAFETY_SETTINGS, TEST_EMPTY_TOOLS, TEST_EMPTY_TOOL_CONFIG, TEST_REQUEST_OPTIONS)).toBeRejected(); | ||
expect(fetchSpy.calls.allArgs()[0][1].signal).toBeInstanceOf(AbortSignal); | ||
@@ -461,0 +462,0 @@ }); |
@@ -186,14 +186,2 @@ "use strict"; | ||
webSearchQueries: ['query for former chunk for first candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for first candidate', | ||
title: 'title for former chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -259,14 +247,2 @@ { | ||
webSearchQueries: ['query for former chunk for second candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for second candidate', | ||
title: 'title for former chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -332,14 +308,2 @@ { | ||
webSearchQueries: ['query for later chunk for first candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for first candidate', | ||
title: 'title for later chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -374,14 +338,2 @@ { | ||
webSearchQueries: ['query for later chunk for second candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for second candidate', | ||
title: 'title for later chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -465,20 +417,2 @@ { | ||
], | ||
groundingAttributions: [ | ||
{ | ||
segment: { endIndex: 421 }, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for first candidate', | ||
title: 'title for former chunk for first candidate', | ||
}, | ||
}, | ||
{ | ||
segment: { endIndex: 421 }, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for first candidate', | ||
title: 'title for later chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
retrievalQueries: [], | ||
@@ -562,20 +496,2 @@ groundingChunks: [ | ||
], | ||
groundingAttributions: [ | ||
{ | ||
segment: { endIndex: 421 }, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for second candidate', | ||
title: 'title for former chunk for second candidate', | ||
}, | ||
}, | ||
{ | ||
segment: { endIndex: 421 }, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for second candidate', | ||
title: 'title for later chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
retrievalQueries: [], | ||
@@ -582,0 +498,0 @@ groundingChunks: [ |
@@ -37,2 +37,3 @@ /** | ||
private readonly tools?; | ||
private readonly toolConfig?; | ||
private readonly apiEndpoint?; | ||
@@ -117,2 +118,3 @@ private readonly systemInstruction?; | ||
private readonly tools?; | ||
private readonly toolConfig?; | ||
private readonly apiEndpoint?; | ||
@@ -119,0 +121,0 @@ private readonly systemInstruction?; |
@@ -51,2 +51,3 @@ "use strict"; | ||
this.tools = request.tools; | ||
this.toolConfig = request.toolConfig; | ||
this.apiEndpoint = request.apiEndpoint; | ||
@@ -95,5 +96,6 @@ this.requestOptions = requestOptions !== null && requestOptions !== void 0 ? requestOptions : {}; | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
}; | ||
const generateContentResult = await (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions).catch(e => { | ||
const generateContentResult = await (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions).catch(e => { | ||
throw e; | ||
@@ -152,5 +154,6 @@ }); | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
}; | ||
const streamGenerateContentResultPromise = (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions).catch(e => { | ||
const streamGenerateContentResultPromise = (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions).catch(e => { | ||
throw e; | ||
@@ -194,2 +197,3 @@ }); | ||
this.tools = request.tools; | ||
this.toolConfig = request.toolConfig; | ||
this.apiEndpoint = request.apiEndpoint; | ||
@@ -237,5 +241,6 @@ this.requestOptions = requestOptions !== null && requestOptions !== void 0 ? requestOptions : {}; | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
}; | ||
const generateContentResult = await (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions).catch(e => { | ||
const generateContentResult = await (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions).catch(e => { | ||
throw e; | ||
@@ -294,5 +299,6 @@ }); | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
}; | ||
const streamGenerateContentResultPromise = (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions).catch(e => { | ||
const streamGenerateContentResultPromise = (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), generateContentrequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions).catch(e => { | ||
throw e; | ||
@@ -299,0 +305,0 @@ }); |
@@ -30,2 +30,3 @@ /** | ||
private readonly tools?; | ||
private readonly toolConfig?; | ||
private readonly requestOptions?; | ||
@@ -150,2 +151,3 @@ private readonly systemInstruction?; | ||
private readonly tools?; | ||
private readonly toolConfig?; | ||
private readonly requestOptions?; | ||
@@ -152,0 +154,0 @@ private readonly systemInstruction?; |
@@ -47,2 +47,3 @@ "use strict"; | ||
this.tools = getGenerativeModelParams.tools; | ||
this.toolConfig = getGenerativeModelParams.toolConfig; | ||
this.requestOptions = (_a = getGenerativeModelParams.requestOptions) !== null && _a !== void 0 ? _a : {}; | ||
@@ -88,3 +89,3 @@ if (getGenerativeModelParams.systemInstruction) { | ||
const formulatedRequest = formulateSystemInstructionIntoGenerateContentRequest(request, this.systemInstruction); | ||
return (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions); | ||
return (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions); | ||
} | ||
@@ -118,3 +119,3 @@ /** | ||
const formulatedRequest = formulateSystemInstructionIntoGenerateContentRequest(request, this.systemInstruction); | ||
return (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions); | ||
return (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions); | ||
} | ||
@@ -175,2 +176,3 @@ /** | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -214,2 +216,3 @@ }; | ||
this.tools = getGenerativeModelParams.tools; | ||
this.toolConfig = getGenerativeModelParams.toolConfig; | ||
this.requestOptions = (_a = getGenerativeModelParams.requestOptions) !== null && _a !== void 0 ? _a : {}; | ||
@@ -254,3 +257,3 @@ if (getGenerativeModelParams.systemInstruction) { | ||
const formulatedRequest = formulateSystemInstructionIntoGenerateContentRequest(request, this.systemInstruction); | ||
return (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions); | ||
return (0, generate_content_1.generateContent)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions); | ||
} | ||
@@ -284,3 +287,3 @@ /** | ||
const formulatedRequest = formulateSystemInstructionIntoGenerateContentRequest(request, this.systemInstruction); | ||
return (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.requestOptions); | ||
return (0, generate_content_1.generateContentStream)(this.location, this.resourcePath, this.fetchToken(), formulatedRequest, this.apiEndpoint, this.generationConfig, this.safetySettings, this.tools, this.toolConfig, this.requestOptions); | ||
} | ||
@@ -287,0 +290,0 @@ /** |
@@ -18,2 +18,4 @@ /** | ||
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library'; | ||
import { ToolConfig } from './tool'; | ||
import { SchemaType, Schema } from './common'; | ||
/** | ||
@@ -110,2 +112,4 @@ * Params used to initialize the Vertex SDK. | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** Optional. The request options to use for generation. */ | ||
@@ -140,2 +144,4 @@ requestOptions?: RequestOptions; | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** | ||
@@ -157,2 +163,8 @@ * Optional. The user provided system instructions for the model. | ||
/** | ||
* Schema passed to `GenerationConfig.responseSchema` | ||
* @public | ||
*/ | ||
export interface ResponseSchema extends Schema { | ||
} | ||
/** | ||
* Configuration options for model generation and outputs. | ||
@@ -173,3 +185,9 @@ */ | ||
topK?: number; | ||
/** Optional. Output response mimetype of the generated candidate text. | ||
/** | ||
* Optional. Positive values penalize tokens that repeatedly appear in the generated text, decreasing the probability of repeating content. | ||
* This maximum value for frequencyPenalty is up to, but not including, 2.0. Its minimum value is -2.0. | ||
* Supported by gemini-1.5-pro and gemini-1.5-flash only. */ | ||
frequencyPenalty?: number; | ||
/** | ||
* Optional. Output response mimetype of the generated candidate text. | ||
* Supported mimetype: | ||
@@ -180,4 +198,11 @@ * - `text/plain`: (default) Text output. | ||
* otherwise the behavior is undefined. | ||
* This is a preview feature. */ | ||
*/ | ||
responseMimeType?: string; | ||
/** | ||
* Optional. The schema that generated candidate text must follow. For more | ||
* information, see | ||
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output. | ||
* If set, a compatible responseMimeType must also be set. | ||
*/ | ||
responseSchema?: ResponseSchema; | ||
} | ||
@@ -584,3 +609,6 @@ /** | ||
export declare interface SearchEntryPoint { | ||
/** Optional. Web content snippet that can be embedded in a web page or an app webview. */ | ||
/** | ||
* Optional. Web content snippet that can be embedded in a web page or an app | ||
* webview. | ||
*/ | ||
renderedContent?: string; | ||
@@ -614,3 +642,5 @@ /** Optional. Base64 encoded JSON representing array of tuple. */ | ||
web?: GroundingChunkWeb; | ||
/** Optional. Grounding chunk from context retrieved by the retrieval tools. */ | ||
/** | ||
* Optional. Grounding chunk from context retrieved by the retrieval tools. | ||
*/ | ||
retrievedContext?: GroundingChunkRetrievedContext; | ||
@@ -624,7 +654,9 @@ } | ||
partIndex?: number; | ||
/** Optional. Start index in the given Part, measured in bytes. | ||
/** | ||
* Optional. Start index in the given Part, measured in bytes. | ||
* Offset from the start of the Part, inclusive, starting at zero. | ||
*/ | ||
startIndex?: number; | ||
/** Optional. End index in the given Part, measured in bytes. | ||
/** | ||
* Optional. End index in the given Part, measured in bytes. | ||
* Offset from the start of the Part, exclusive, starting at zero. | ||
@@ -642,3 +674,4 @@ */ | ||
segment?: GroundingSupportSegment; | ||
/** Optional. A arrau of indices (into {@link GroundingChunk}) specifying the | ||
/** | ||
* Optional. A arrau of indices (into {@link GroundingChunk}) specifying the | ||
* citations associated with the claim. For instance [1,3,4] means | ||
@@ -649,3 +682,4 @@ * that grounding_chunk[1], grounding_chunk[3], | ||
groundingChunkIndices?: number[]; | ||
/** Confidence score of the support references. Ranges from 0 to 1. 1 is the | ||
/** | ||
* Confidence score of the support references. Ranges from 0 to 1. 1 is the | ||
* most confident. This list must have the same size as the | ||
@@ -664,9 +698,8 @@ * groundingChunkIndices. | ||
retrievalQueries?: string[]; | ||
/** @deprecated | ||
* Optional. Array of {@link GroundingAttribution} | ||
*/ | ||
groundingAttributions?: GroundingAttribution[]; | ||
/** Optional. Google search entry for the following-up web searches. {@link SearchEntryPoint} */ | ||
searchEntryPoint?: SearchEntryPoint; | ||
/** Optional. Array of supporting references retrieved from specified grounding source. {@link GroundingChunk}. */ | ||
/** | ||
* Optional. Array of supporting references retrieved from specified | ||
* grounding source. {@link GroundingChunk}. | ||
*/ | ||
groundingChunks?: GroundingChunk[]; | ||
@@ -678,19 +711,2 @@ /** Optional. Array of grounding support. {@link GroundingSupport}. */ | ||
* @deprecated | ||
* Grounding attribution. | ||
*/ | ||
export declare interface GroundingAttribution { | ||
/** Optional. Attribution from the web. */ | ||
web?: GroundingAttributionWeb; | ||
/** Optional. Attribution from context retrieved by the retrieval tools. */ | ||
retrievedContext?: GroundingAttributionRetrievedContext; | ||
/** Optional. Segment of the content this attribution belongs to. */ | ||
segment?: GroundingAttributionSegment; | ||
/** | ||
* Optional. Confidence score of the attribution. Ranges from 0 to 1. 1 is | ||
* the most confident. | ||
*/ | ||
confidenceScore?: number; | ||
} | ||
/** | ||
* @deprecated | ||
* Segment of the content this attribution belongs to. | ||
@@ -829,3 +845,6 @@ */ | ||
similarityTopK?: number; | ||
/** Optional. If set this field, results with vector distance smaller than this threshold will be returned. */ | ||
/** | ||
* Optional. If set this field, results with vector distance smaller than | ||
* this threshold will be returned. | ||
*/ | ||
vectorDistanceThreshold?: number; | ||
@@ -881,9 +900,2 @@ } | ||
export declare interface GoogleSearchRetrieval { | ||
/** | ||
* @deprecated groundingAttributions field in {@link GroundingMetadata} is also deprecated. | ||
* Optional. Disable using the result from this tool in detecting grounding | ||
* attribution. This does not affect how the result is given to the model for | ||
* generation. | ||
*/ | ||
disableAttribution?: boolean; | ||
} | ||
@@ -907,16 +919,11 @@ /** | ||
*/ | ||
export declare enum FunctionDeclarationSchemaType { | ||
/** String type. */ | ||
STRING = "STRING", | ||
/** Number type. */ | ||
NUMBER = "NUMBER", | ||
/** Integer type. */ | ||
INTEGER = "INTEGER", | ||
/** Boolean type. */ | ||
BOOLEAN = "BOOLEAN", | ||
/** Array type. */ | ||
ARRAY = "ARRAY", | ||
/** Object type. */ | ||
OBJECT = "OBJECT" | ||
} | ||
export declare type FunctionDeclarationSchemaType = SchemaType; | ||
export declare const FunctionDeclarationSchemaType: { | ||
STRING: SchemaType.STRING; | ||
NUMBER: SchemaType.NUMBER; | ||
INTEGER: SchemaType.INTEGER; | ||
BOOLEAN: SchemaType.BOOLEAN; | ||
ARRAY: SchemaType.ARRAY; | ||
OBJECT: SchemaType.OBJECT; | ||
}; | ||
/** | ||
@@ -927,3 +934,3 @@ * Schema for parameters passed to {@link FunctionDeclaration.parameters}. | ||
/** The type of the parameter. */ | ||
type: FunctionDeclarationSchemaType; | ||
type: SchemaType; | ||
/** The format of the parameter. */ | ||
@@ -939,31 +946,7 @@ properties: { | ||
/** | ||
* Schema is used to define the format of input/output data. | ||
* Represents a select subset of an OpenAPI 3.0 schema object. | ||
* FunctionDeclarationSchemaProperty is used to define the format of | ||
* input/output data. Represents a select subset of an OpenAPI 3.0 schema object. | ||
* More fields may be added in the future as needed. | ||
*/ | ||
export interface FunctionDeclarationSchemaProperty { | ||
/** | ||
* Optional. The type of the property. {@link | ||
* FunctionDeclarationSchemaType}. | ||
*/ | ||
type?: FunctionDeclarationSchemaType; | ||
/** Optional. The format of the property. */ | ||
format?: string; | ||
/** Optional. The description of the property. */ | ||
description?: string; | ||
/** Optional. Whether the property is nullable. */ | ||
nullable?: boolean; | ||
/** Optional. The items of the property. {@link FunctionDeclarationSchema} */ | ||
items?: FunctionDeclarationSchema; | ||
/** Optional. The enum of the property. */ | ||
enum?: string[]; | ||
/** Optional. Map of {@link FunctionDeclarationSchema}. */ | ||
properties?: { | ||
[k: string]: FunctionDeclarationSchema; | ||
}; | ||
/** Optional. Array of required property. */ | ||
required?: string[]; | ||
/** Optional. The example of the property. */ | ||
example?: unknown; | ||
} | ||
export type FunctionDeclarationSchemaProperty = Schema; | ||
/** | ||
@@ -981,2 +964,4 @@ * Params to initiate a multiturn chat with the model via startChat. | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** Optional. The base Vertex AI endpoint to use for the request. */ | ||
@@ -983,0 +968,0 @@ apiEndpoint?: string; |
@@ -20,2 +20,3 @@ "use strict"; | ||
exports.FunctionDeclarationSchemaType = exports.FinishReason = exports.BlockedReason = exports.HarmSeverity = exports.HarmProbability = exports.HarmBlockThreshold = exports.HarmCategory = void 0; | ||
const common_1 = require("./common"); | ||
/** | ||
@@ -140,21 +141,3 @@ * Harm categories that will block the content. | ||
})(FinishReason || (exports.FinishReason = FinishReason = {})); | ||
/** | ||
* Contains the list of OpenAPI data types | ||
* as defined by https://swagger.io/docs/specification/data-models/data-types/ | ||
*/ | ||
var FunctionDeclarationSchemaType; | ||
(function (FunctionDeclarationSchemaType) { | ||
/** String type. */ | ||
FunctionDeclarationSchemaType["STRING"] = "STRING"; | ||
/** Number type. */ | ||
FunctionDeclarationSchemaType["NUMBER"] = "NUMBER"; | ||
/** Integer type. */ | ||
FunctionDeclarationSchemaType["INTEGER"] = "INTEGER"; | ||
/** Boolean type. */ | ||
FunctionDeclarationSchemaType["BOOLEAN"] = "BOOLEAN"; | ||
/** Array type. */ | ||
FunctionDeclarationSchemaType["ARRAY"] = "ARRAY"; | ||
/** Object type. */ | ||
FunctionDeclarationSchemaType["OBJECT"] = "OBJECT"; | ||
})(FunctionDeclarationSchemaType || (exports.FunctionDeclarationSchemaType = FunctionDeclarationSchemaType = {})); | ||
exports.FunctionDeclarationSchemaType = { ...common_1.SchemaType }; | ||
//# sourceMappingURL=content.js.map |
@@ -19,2 +19,4 @@ /** | ||
export * from './errors'; | ||
export * from './tool'; | ||
export * from './common'; | ||
export { GenerateContentResponseHandler } from './generate_content_response_handler'; |
@@ -36,4 +36,6 @@ "use strict"; | ||
__exportStar(require("./errors"), exports); | ||
__exportStar(require("./tool"), exports); | ||
__exportStar(require("./common"), exports); | ||
var generate_content_response_handler_1 = require("./generate_content_response_handler"); | ||
Object.defineProperty(exports, "GenerateContentResponseHandler", { enumerable: true, get: function () { return generate_content_response_handler_1.GenerateContentResponseHandler; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -23,3 +23,3 @@ /** | ||
export declare const SYSTEM_ROLE = "system"; | ||
export declare const USER_AGENT = "model-builder/1.5.0 grpc-node/1.5.0"; | ||
export declare const USER_AGENT = "model-builder/1.6.0 grpc-node/1.6.0"; | ||
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.5.0'; // x-release-please-version | ||
const CLIENT_LIBRARY_VERSION = '1.6.0'; // 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}`; |
@@ -102,2 +102,3 @@ "use strict"; | ||
tools: modelParams.tools, | ||
toolConfig: modelParams.toolConfig, | ||
requestOptions: requestOptions, | ||
@@ -157,2 +158,3 @@ systemInstruction: modelParams.systemInstruction, | ||
tools: modelParams.tools, | ||
toolConfig: modelParams.toolConfig, | ||
requestOptions: requestOptions, | ||
@@ -159,0 +161,0 @@ systemInstruction: modelParams.systemInstruction, |
@@ -352,3 +352,2 @@ "use strict"; | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -369,3 +368,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -386,3 +384,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -403,3 +400,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -455,3 +451,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -472,3 +467,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -489,3 +483,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -506,3 +499,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -620,3 +612,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -637,3 +628,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -653,3 +643,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -670,3 +659,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}`); | ||
@@ -783,3 +771,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}`); | ||
@@ -800,3 +787,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}`); | ||
@@ -816,3 +802,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}`); | ||
@@ -833,3 +818,2 @@ } | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}`); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(`sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}`); | ||
@@ -836,0 +820,0 @@ } |
# Changelog | ||
## [1.6.0](https://github.com/googleapis/nodejs-vertexai/compare/v1.5.0...v1.6.0) (2024-08-26) | ||
### Features | ||
* Add responseSchema to GenerateContentRequest. ([d3715da](https://github.com/googleapis/nodejs-vertexai/commit/d3715daa793fda8063b379d16a0bf844a90b4087)) | ||
* Add tool config ([f618132](https://github.com/googleapis/nodejs-vertexai/commit/f618132b7b5f9a05ba32b5968ccec14c9c18baaa)) | ||
## [1.5.0](https://github.com/googleapis/nodejs-vertexai/compare/v1.4.1...v1.5.0) (2024-08-21) | ||
@@ -4,0 +12,0 @@ |
{ | ||
"name": "@google-cloud/vertexai", | ||
"description": "Vertex Generative AI client for Node.js", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"license": "Apache-2.0", | ||
@@ -22,17 +22,17 @@ "author": "Google LLC", | ||
"fix": "gts fix", | ||
"test": "jasmine build/test/*.js --reporter=test/spec/reporter.js", | ||
"system-test": "jasmine build/system_test/*.js --reporter=test/spec/reporter.js", | ||
"test": "npm run test:src && npm run test:test", | ||
"test:test": "jasmine build/test/*.js --reporter=test/spec/reporter.js", | ||
"test:src": "jasmine build/src/functions/test/*.js build/src/models/test/*.js --reporter=test/spec/reporter.js", | ||
"test:system": "jasmine build/system_test/*.js --reporter=test/spec/reporter.js", | ||
"lint": "gts lint", | ||
"clean-js-files": "find . -type f -name \"*.js\" -exec rm -f {} +", | ||
"clean-js-map-files": "find . -type f -name \"*.js.map\" -exec rm -f {} +", | ||
"clean-d-ts-files": "find . -type f -name \"*.d.ts\" -exec rm -f {} +", | ||
"clean-after-pack": "echo \"cleaning\" && rm -rf node_modules/ && npm run clean-js-files && npm run clean-js-map-files && npm run clean-d-ts-files", | ||
"prepare": "if [ \"${CUSTOM_PACK}\" ]; then echo \"custom compile\" && npm run compile:oss; else npm run compile; fi", | ||
"pretest": "npm run compile", | ||
"posttest": "npm run lint", | ||
"postpack": "if [ \"${CLEAN}\" ]; then npm run clean-after-pack; fi", | ||
"cover": "npm run cover:unit && npm run cover:integration && npm run cover:report", | ||
"cover:unit": "nyc npm run test", | ||
"cover:integration": "nyc --no-clean npm run system-test", | ||
"cover:report": "nyc report --reporter=lcov" | ||
"cover:integration": "nyc --no-clean npm run test:system", | ||
"cover:report": "nyc report --reporter=lcov", | ||
"prepare": "npm run compile", | ||
"pretest": "npm run compile", | ||
"posttest": "npm run lint" | ||
}, | ||
@@ -39,0 +39,0 @@ "dependencies": { |
@@ -28,2 +28,3 @@ /** | ||
import {GoogleGenerativeAIError} from '../types/errors'; | ||
import {ToolConfig} from '../types/tool'; | ||
import * as constants from '../util/constants'; | ||
@@ -59,2 +60,3 @@ | ||
tools?: Tool[], | ||
toolConfig?: ToolConfig, | ||
requestOptions?: RequestOptions | ||
@@ -78,2 +80,3 @@ ): Promise<GenerateContentResult> { | ||
tools: request.tools ?? tools, | ||
toolConfig: request.toolConfig ?? toolConfig, | ||
}; | ||
@@ -114,2 +117,3 @@ const response: Response | undefined = await postRequest({ | ||
tools?: Tool[], | ||
toolConfig?: ToolConfig, | ||
requestOptions?: RequestOptions | ||
@@ -132,2 +136,3 @@ ): Promise<StreamGenerateContentResult> { | ||
tools: request.tools ?? tools, | ||
toolConfig: request.toolConfig ?? toolConfig, | ||
}; | ||
@@ -134,0 +139,0 @@ const response = await postRequest({ |
@@ -298,3 +298,2 @@ /** | ||
webSearchQueries: [], | ||
groundingAttributions: [], | ||
retrievalQueries: [], | ||
@@ -314,8 +313,2 @@ groundingChunks: [], | ||
} | ||
if (groundingMetadataChunk.groundingAttributions) { | ||
groundingMetadataAggregated.groundingAttributions = | ||
groundingMetadataAggregated.groundingAttributions!.concat( | ||
groundingMetadataChunk.groundingAttributions | ||
); | ||
} | ||
if (groundingMetadataChunk.retrievalQueries) { | ||
@@ -322,0 +315,0 @@ groundingMetadataAggregated.retrievalQueries = |
@@ -34,2 +34,3 @@ /** | ||
Tool, | ||
ToolConfig, | ||
} from '../../types'; | ||
@@ -197,2 +198,4 @@ import {constants} from '../../util'; | ||
const TEST_EMPTY_TOOL_CONFIG: ToolConfig = {}; | ||
const TEST_TOOLS_WITH_FUNCTION_DECLARATION: Tool[] = [ | ||
@@ -371,2 +374,3 @@ { | ||
TEST_EMPTY_TOOLS, | ||
TEST_EMPTY_TOOL_CONFIG, | ||
TEST_REQUEST_OPTIONS | ||
@@ -690,2 +694,3 @@ ) | ||
TEST_EMPTY_TOOLS, | ||
TEST_EMPTY_TOOL_CONFIG, | ||
TEST_REQUEST_OPTIONS | ||
@@ -692,0 +697,0 @@ ) |
@@ -204,14 +204,2 @@ /** | ||
webSearchQueries: ['query for former chunk for first candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for first candidate', | ||
title: 'title for former chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -277,14 +265,2 @@ { | ||
webSearchQueries: ['query for former chunk for second candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for second candidate', | ||
title: 'title for former chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -350,14 +326,2 @@ { | ||
webSearchQueries: ['query for later chunk for first candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for first candidate', | ||
title: 'title for later chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -393,14 +357,2 @@ { | ||
webSearchQueries: ['query for later chunk for second candidate'], | ||
groundingAttributions: [ | ||
{ | ||
segment: { | ||
endIndex: 421, | ||
}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for second candidate', | ||
title: 'title for later chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
groundingChunks: [ | ||
@@ -487,20 +439,2 @@ { | ||
], | ||
groundingAttributions: [ | ||
{ | ||
segment: {endIndex: 421}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for first candidate', | ||
title: 'title for former chunk for first candidate', | ||
}, | ||
}, | ||
{ | ||
segment: {endIndex: 421}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for first candidate', | ||
title: 'title for later chunk for first candidate', | ||
}, | ||
}, | ||
], | ||
retrievalQueries: [], | ||
@@ -585,20 +519,2 @@ groundingChunks: [ | ||
], | ||
groundingAttributions: [ | ||
{ | ||
segment: {endIndex: 421}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for former chunk for second candidate', | ||
title: 'title for former chunk for second candidate', | ||
}, | ||
}, | ||
{ | ||
segment: {endIndex: 421}, | ||
confidenceScore: 0.8585608, | ||
web: { | ||
uri: 'url for later chunk for second candidate', | ||
title: 'title for later chunk for second candidate', | ||
}, | ||
}, | ||
], | ||
retrievalQueries: [], | ||
@@ -605,0 +521,0 @@ groundingChunks: [ |
@@ -38,2 +38,3 @@ /** | ||
} from '../types/content'; | ||
import {ToolConfig} from '../types'; | ||
import {ClientError, GoogleAuthError} from '../types/errors'; | ||
@@ -61,2 +62,3 @@ import {constants} from '../util'; | ||
private readonly tools?: Tool[]; | ||
private readonly toolConfig?: ToolConfig; | ||
private readonly apiEndpoint?: string; | ||
@@ -85,2 +87,3 @@ private readonly systemInstruction?: Content; | ||
this.tools = request.tools; | ||
this.toolConfig = request.toolConfig; | ||
this.apiEndpoint = request.apiEndpoint; | ||
@@ -136,2 +139,3 @@ this.requestOptions = requestOptions ?? {}; | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -149,2 +153,3 @@ }; | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -221,2 +226,3 @@ ).catch(e => { | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -234,2 +240,3 @@ }; | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -271,2 +278,3 @@ ).catch(e => { | ||
private readonly tools?: Tool[]; | ||
private readonly toolConfig?: ToolConfig; | ||
private readonly apiEndpoint?: string; | ||
@@ -295,2 +303,3 @@ private readonly systemInstruction?: Content; | ||
this.tools = request.tools; | ||
this.toolConfig = request.toolConfig; | ||
this.apiEndpoint = request.apiEndpoint; | ||
@@ -345,2 +354,3 @@ this.requestOptions = requestOptions ?? {}; | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -358,2 +368,3 @@ }; | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -431,2 +442,3 @@ ).catch(e => { | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -444,2 +456,3 @@ }; | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -446,0 +459,0 @@ ).catch(e => { |
@@ -42,2 +42,3 @@ /** | ||
} from '../types/content'; | ||
import {ToolConfig} from '../types/tool'; | ||
import {ClientError, GoogleAuthError} from '../types/errors'; | ||
@@ -59,2 +60,3 @@ import {constants} from '../util'; | ||
private readonly tools?: Tool[]; | ||
private readonly toolConfig?: ToolConfig; | ||
private readonly requestOptions?: RequestOptions; | ||
@@ -82,2 +84,3 @@ private readonly systemInstruction?: Content; | ||
this.tools = getGenerativeModelParams.tools; | ||
this.toolConfig = getGenerativeModelParams.toolConfig; | ||
this.requestOptions = getGenerativeModelParams.requestOptions ?? {}; | ||
@@ -146,2 +149,3 @@ if (getGenerativeModelParams.systemInstruction) { | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -193,2 +197,3 @@ ); | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -259,2 +264,3 @@ ); | ||
tools: this.tools, | ||
toolConfig: this.toolConfig, | ||
systemInstruction: this.systemInstruction, | ||
@@ -289,2 +295,3 @@ }; | ||
private readonly tools?: Tool[]; | ||
private readonly toolConfig?: ToolConfig; | ||
private readonly requestOptions?: RequestOptions; | ||
@@ -312,2 +319,3 @@ private readonly systemInstruction?: Content; | ||
this.tools = getGenerativeModelParams.tools; | ||
this.toolConfig = getGenerativeModelParams.toolConfig; | ||
this.requestOptions = getGenerativeModelParams.requestOptions ?? {}; | ||
@@ -375,2 +383,3 @@ if (getGenerativeModelParams.systemInstruction) { | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -422,2 +431,3 @@ ); | ||
this.tools, | ||
this.toolConfig, | ||
this.requestOptions | ||
@@ -424,0 +434,0 @@ ); |
@@ -20,2 +20,4 @@ /** | ||
import {GoogleAuth, GoogleAuthOptions} from 'google-auth-library'; | ||
import {ToolConfig} from './tool'; | ||
import {SchemaType, Schema} from './common'; | ||
@@ -117,2 +119,4 @@ /** | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** Optional. The request options to use for generation. */ | ||
@@ -149,2 +153,4 @@ requestOptions?: RequestOptions; | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** | ||
@@ -168,2 +174,9 @@ * Optional. The user provided system instructions for the model. | ||
/** | ||
* Schema passed to `GenerationConfig.responseSchema` | ||
* @public | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ResponseSchema extends Schema {} | ||
/** | ||
* Configuration options for model generation and outputs. | ||
@@ -184,3 +197,9 @@ */ | ||
topK?: number; | ||
/** Optional. Output response mimetype of the generated candidate text. | ||
/** | ||
* Optional. Positive values penalize tokens that repeatedly appear in the generated text, decreasing the probability of repeating content. | ||
* This maximum value for frequencyPenalty is up to, but not including, 2.0. Its minimum value is -2.0. | ||
* Supported by gemini-1.5-pro and gemini-1.5-flash only. */ | ||
frequencyPenalty?: number; | ||
/** | ||
* Optional. Output response mimetype of the generated candidate text. | ||
* Supported mimetype: | ||
@@ -191,4 +210,12 @@ * - `text/plain`: (default) Text output. | ||
* otherwise the behavior is undefined. | ||
* This is a preview feature. */ | ||
*/ | ||
responseMimeType?: string; | ||
/** | ||
* Optional. The schema that generated candidate text must follow. For more | ||
* information, see | ||
* https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output. | ||
* If set, a compatible responseMimeType must also be set. | ||
*/ | ||
responseSchema?: ResponseSchema; | ||
} | ||
@@ -627,3 +654,6 @@ | ||
export declare interface SearchEntryPoint { | ||
/** Optional. Web content snippet that can be embedded in a web page or an app webview. */ | ||
/** | ||
* Optional. Web content snippet that can be embedded in a web page or an app | ||
* webview. | ||
*/ | ||
renderedContent?: string; | ||
@@ -660,3 +690,5 @@ /** Optional. Base64 encoded JSON representing array of tuple. */ | ||
web?: GroundingChunkWeb; | ||
/** Optional. Grounding chunk from context retrieved by the retrieval tools. */ | ||
/** | ||
* Optional. Grounding chunk from context retrieved by the retrieval tools. | ||
*/ | ||
retrievedContext?: GroundingChunkRetrievedContext; | ||
@@ -671,7 +703,9 @@ } | ||
partIndex?: number; | ||
/** Optional. Start index in the given Part, measured in bytes. | ||
/** | ||
* Optional. Start index in the given Part, measured in bytes. | ||
* Offset from the start of the Part, inclusive, starting at zero. | ||
*/ | ||
startIndex?: number; | ||
/** Optional. End index in the given Part, measured in bytes. | ||
/** | ||
* Optional. End index in the given Part, measured in bytes. | ||
* Offset from the start of the Part, exclusive, starting at zero. | ||
@@ -690,3 +724,4 @@ */ | ||
segment?: GroundingSupportSegment; | ||
/** Optional. A arrau of indices (into {@link GroundingChunk}) specifying the | ||
/** | ||
* Optional. A arrau of indices (into {@link GroundingChunk}) specifying the | ||
* citations associated with the claim. For instance [1,3,4] means | ||
@@ -697,3 +732,4 @@ * that grounding_chunk[1], grounding_chunk[3], | ||
groundingChunkIndices?: number[]; | ||
/** Confidence score of the support references. Ranges from 0 to 1. 1 is the | ||
/** | ||
* Confidence score of the support references. Ranges from 0 to 1. 1 is the | ||
* most confident. This list must have the same size as the | ||
@@ -713,9 +749,8 @@ * groundingChunkIndices. | ||
retrievalQueries?: string[]; | ||
/** @deprecated | ||
* Optional. Array of {@link GroundingAttribution} | ||
*/ | ||
groundingAttributions?: GroundingAttribution[]; | ||
/** Optional. Google search entry for the following-up web searches. {@link SearchEntryPoint} */ | ||
searchEntryPoint?: SearchEntryPoint; | ||
/** Optional. Array of supporting references retrieved from specified grounding source. {@link GroundingChunk}. */ | ||
/** | ||
* Optional. Array of supporting references retrieved from specified | ||
* grounding source. {@link GroundingChunk}. | ||
*/ | ||
groundingChunks?: GroundingChunk[]; | ||
@@ -728,20 +763,2 @@ /** Optional. Array of grounding support. {@link GroundingSupport}. */ | ||
* @deprecated | ||
* Grounding attribution. | ||
*/ | ||
export declare interface GroundingAttribution { | ||
/** Optional. Attribution from the web. */ | ||
web?: GroundingAttributionWeb; | ||
/** Optional. Attribution from context retrieved by the retrieval tools. */ | ||
retrievedContext?: GroundingAttributionRetrievedContext; | ||
/** Optional. Segment of the content this attribution belongs to. */ | ||
segment?: GroundingAttributionSegment; | ||
/** | ||
* Optional. Confidence score of the attribution. Ranges from 0 to 1. 1 is | ||
* the most confident. | ||
*/ | ||
confidenceScore?: number; | ||
} | ||
/** | ||
* @deprecated | ||
* Segment of the content this attribution belongs to. | ||
@@ -890,3 +907,6 @@ */ | ||
/** Optional. If set this field, results with vector distance smaller than this threshold will be returned. */ | ||
/** | ||
* Optional. If set this field, results with vector distance smaller than | ||
* this threshold will be returned. | ||
*/ | ||
vectorDistanceThreshold?: number; | ||
@@ -952,11 +972,4 @@ } | ||
*/ | ||
export declare interface GoogleSearchRetrieval { | ||
/** | ||
* @deprecated groundingAttributions field in {@link GroundingMetadata} is also deprecated. | ||
* Optional. Disable using the result from this tool in detecting grounding | ||
* attribution. This does not affect how the result is given to the model for | ||
* generation. | ||
*/ | ||
disableAttribution?: boolean; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export declare interface GoogleSearchRetrieval {} | ||
@@ -981,16 +994,4 @@ /** | ||
*/ | ||
export enum FunctionDeclarationSchemaType { | ||
/** String type. */ | ||
STRING = 'STRING', | ||
/** Number type. */ | ||
NUMBER = 'NUMBER', | ||
/** Integer type. */ | ||
INTEGER = 'INTEGER', | ||
/** Boolean type. */ | ||
BOOLEAN = 'BOOLEAN', | ||
/** Array type. */ | ||
ARRAY = 'ARRAY', | ||
/** Object type. */ | ||
OBJECT = 'OBJECT', | ||
} | ||
export declare type FunctionDeclarationSchemaType = SchemaType; | ||
export const FunctionDeclarationSchemaType = {...SchemaType}; | ||
@@ -1002,3 +1003,3 @@ /** | ||
/** The type of the parameter. */ | ||
type: FunctionDeclarationSchemaType; | ||
type: SchemaType; | ||
/** The format of the parameter. */ | ||
@@ -1013,29 +1014,7 @@ properties: {[k: string]: FunctionDeclarationSchemaProperty}; | ||
/** | ||
* Schema is used to define the format of input/output data. | ||
* Represents a select subset of an OpenAPI 3.0 schema object. | ||
* FunctionDeclarationSchemaProperty is used to define the format of | ||
* input/output data. Represents a select subset of an OpenAPI 3.0 schema object. | ||
* More fields may be added in the future as needed. | ||
*/ | ||
export interface FunctionDeclarationSchemaProperty { | ||
/** | ||
* Optional. The type of the property. {@link | ||
* FunctionDeclarationSchemaType}. | ||
*/ | ||
type?: FunctionDeclarationSchemaType; | ||
/** Optional. The format of the property. */ | ||
format?: string; | ||
/** Optional. The description of the property. */ | ||
description?: string; | ||
/** Optional. Whether the property is nullable. */ | ||
nullable?: boolean; | ||
/** Optional. The items of the property. {@link FunctionDeclarationSchema} */ | ||
items?: FunctionDeclarationSchema; | ||
/** Optional. The enum of the property. */ | ||
enum?: string[]; | ||
/** Optional. Map of {@link FunctionDeclarationSchema}. */ | ||
properties?: {[k: string]: FunctionDeclarationSchema}; | ||
/** Optional. Array of required property. */ | ||
required?: string[]; | ||
/** Optional. The example of the property. */ | ||
example?: unknown; | ||
} | ||
export type FunctionDeclarationSchemaProperty = Schema; | ||
@@ -1054,2 +1033,4 @@ /** | ||
tools?: Tool[]; | ||
/** Optional. This config is shared for all tools provided in the request. */ | ||
toolConfig?: ToolConfig; | ||
/** Optional. The base Vertex AI endpoint to use for the request. */ | ||
@@ -1056,0 +1037,0 @@ apiEndpoint?: string; |
@@ -20,2 +20,4 @@ /** | ||
export * from './errors'; | ||
export * from './tool'; | ||
export * from './common'; | ||
export {GenerateContentResponseHandler} from './generate_content_response_handler'; |
@@ -24,3 +24,3 @@ /** | ||
const USER_AGENT_PRODUCT = 'model-builder'; | ||
const CLIENT_LIBRARY_VERSION = '1.5.0'; // x-release-please-version | ||
const CLIENT_LIBRARY_VERSION = '1.6.0'; // 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}`; |
@@ -126,2 +126,3 @@ /** | ||
tools: modelParams.tools, | ||
toolConfig: modelParams.toolConfig, | ||
requestOptions: requestOptions, | ||
@@ -197,2 +198,3 @@ systemInstruction: modelParams.systemInstruction, | ||
tools: modelParams.tools, | ||
toolConfig: modelParams.toolConfig, | ||
requestOptions: requestOptions, | ||
@@ -199,0 +201,0 @@ systemInstruction: modelParams.systemInstruction, |
@@ -538,5 +538,2 @@ /** | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -561,5 +558,2 @@ `sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -584,5 +578,2 @@ `sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -607,5 +598,2 @@ `sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -688,5 +676,2 @@ `sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -711,5 +696,2 @@ `sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -734,5 +716,2 @@ `sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -757,5 +736,2 @@ `sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -929,5 +905,2 @@ `sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -952,5 +925,2 @@ `sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -974,5 +944,2 @@ `sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -997,5 +964,2 @@ `sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -1204,5 +1168,2 @@ `sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -1227,5 +1188,2 @@ `sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -1249,5 +1207,2 @@ `sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -1272,5 +1227,2 @@ `sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}` | ||
if (groundingMetadata) { | ||
expect(!!groundingMetadata.groundingAttributions).toBeTruthy( | ||
`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}` | ||
); | ||
expect(!!groundingMetadata.webSearchQueries).toBeTruthy( | ||
@@ -1277,0 +1229,0 @@ `sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
173
1190963
22168