diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index ff33d56f269..3a126c2bfb4 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -19,8 +19,6 @@ export interface BaseParams { // @public export enum BlockReason { - // (undocumented) - BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED", // (undocumented) OTHER = "OTHER", // (undocumented) @@ -145,8 +143,6 @@ export interface FileDataPart { // @public export enum FinishReason { - // (undocumented) - FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", // (undocumented) MAX_TOKENS = "MAX_TOKENS", // (undocumented) @@ -182,8 +178,6 @@ export enum FunctionCallingMode { // (undocumented) AUTO = "AUTO", // (undocumented) - MODE_UNSPECIFIED = "MODE_UNSPECIFIED", - // (undocumented) NONE = "NONE" } @@ -201,7 +195,7 @@ export interface FunctionCallPart { // @public export interface FunctionDeclaration { - description?: string; + description: string; name: string; parameters?: FunctionDeclarationSchema; } @@ -401,8 +395,6 @@ export interface GroundingMetadata { // @public (undocumented) export enum HarmBlockMethod { - // (undocumented) - HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED", // (undocumented) PROBABILITY = "PROBABILITY", // (undocumented) @@ -418,9 +410,7 @@ export enum HarmBlockThreshold { // (undocumented) BLOCK_NONE = "BLOCK_NONE", // (undocumented) - BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH", - // (undocumented) - HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED" + BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH" } // @public @@ -432,15 +422,11 @@ export enum HarmCategory { // (undocumented) HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH", // (undocumented) - HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT", - // (undocumented) - HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED" + HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT" } // @public export enum HarmProbability { - // (undocumented) - HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED", // (undocumented) HIGH = "HIGH", // (undocumented) @@ -460,9 +446,7 @@ export enum HarmSeverity { // (undocumented) HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM", // (undocumented) - HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE", - // (undocumented) - HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED" + HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE" } // @public @@ -499,7 +483,7 @@ export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]; // @public export interface PromptFeedback { // (undocumented) - blockReason: BlockReason; + blockReason?: BlockReason; // (undocumented) blockReasonMessage?: string; // (undocumented) @@ -589,7 +573,7 @@ export type Tool = FunctionDeclarationsTool; // @public export interface ToolConfig { // (undocumented) - functionCallingConfig: FunctionCallingConfig; + functionCallingConfig?: FunctionCallingConfig; } // @public diff --git a/packages/vertexai/src/requests/request.test.ts b/packages/vertexai/src/requests/request.test.ts index 16a1ece2c7e..63308b32f7e 100644 --- a/packages/vertexai/src/requests/request.test.ts +++ b/packages/vertexai/src/requests/request.test.ts @@ -243,7 +243,7 @@ describe('request methods', () => { false, '', { - timeout: 0 + timeout: 180000 } ); } catch (e) { diff --git a/packages/vertexai/src/requests/request.ts b/packages/vertexai/src/requests/request.ts index eac99a23038..618516dc8b4 100644 --- a/packages/vertexai/src/requests/request.ts +++ b/packages/vertexai/src/requests/request.ts @@ -186,11 +186,13 @@ export async function makeRequest( */ function buildFetchOptions(requestOptions?: RequestOptions): RequestInit { const fetchOptions = {} as RequestInit; + let timeoutMillis = 180 * 1000; // default: 180 s if (requestOptions?.timeout && requestOptions?.timeout >= 0) { - const abortController = new AbortController(); - const signal = abortController.signal; - setTimeout(() => abortController.abort(), requestOptions.timeout); - fetchOptions.signal = signal; + timeoutMillis = requestOptions.timeout; } + const abortController = new AbortController(); + const signal = abortController.signal; + setTimeout(() => abortController.abort(), timeoutMillis); + fetchOptions.signal = signal; return fetchOptions; } diff --git a/packages/vertexai/src/types/enums.ts b/packages/vertexai/src/types/enums.ts index fd901241250..3e66bacc612 100644 --- a/packages/vertexai/src/types/enums.ts +++ b/packages/vertexai/src/types/enums.ts @@ -32,7 +32,6 @@ export const POSSIBLE_ROLES = ['user', 'model', 'function', 'system'] as const; * @public */ export enum HarmCategory { - HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED', HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH', HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT', HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT', @@ -44,8 +43,6 @@ export enum HarmCategory { * @public */ export enum HarmBlockThreshold { - // Threshold is unspecified. - HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED', // Content with NEGLIGIBLE will be allowed. BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE', // Content with NEGLIGIBLE and LOW will be allowed. @@ -60,8 +57,6 @@ export enum HarmBlockThreshold { * @public */ export enum HarmBlockMethod { - // The harm block method is unspecified. - HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED', // The harm block method uses both probability and severity scores. SEVERITY = 'SEVERITY', // The harm block method uses the probability score. @@ -73,8 +68,6 @@ export enum HarmBlockMethod { * @public */ export enum HarmProbability { - // Probability is unspecified. - HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED', // Content has a negligible chance of being unsafe. NEGLIGIBLE = 'NEGLIGIBLE', // Content has a low chance of being unsafe. @@ -90,8 +83,6 @@ export enum HarmProbability { * @public */ export enum HarmSeverity { - // Harm severity unspecified. - HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED', // Negligible level of harm severity. HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE', // Low level of harm severity. @@ -107,8 +98,6 @@ export enum HarmSeverity { * @public */ export enum BlockReason { - // A blocked reason was not specified. - BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED', // Content was blocked by safety settings. SAFETY = 'SAFETY', // Content was blocked, but the reason is uncategorized. @@ -120,8 +109,6 @@ export enum BlockReason { * @public */ export enum FinishReason { - // Default value. This value is unused. - FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED', // Natural stop point of the model or provided stop sequence. STOP = 'STOP', // The maximum number of tokens as specified in the request was reached. @@ -138,8 +125,6 @@ export enum FinishReason { * @public */ export enum FunctionCallingMode { - // Unspecified function calling mode. This value should not be used. - MODE_UNSPECIFIED = 'MODE_UNSPECIFIED', // Default model behavior, model decides to predict either a function call // or a natural language response. AUTO = 'AUTO', diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts index 1e976b386b6..d4606e64861 100644 --- a/packages/vertexai/src/types/requests.ts +++ b/packages/vertexai/src/types/requests.ts @@ -113,7 +113,7 @@ export interface CountTokensRequest { */ export interface RequestOptions { /** - * Request timeout in milliseconds. + * Request timeout in milliseconds. Defaults to 180 seconds (180000ms). */ timeout?: number; /** @@ -145,10 +145,10 @@ export declare interface FunctionDeclaration { */ name: string; /** - * Optional. Description and purpose of the function. Model uses it to decide + * Description and purpose of the function. Model uses it to decide * how and whether to call the function. */ - description?: string; + description: string; /** * Optional. Describes the parameters to this function in JSON Schema Object * format. Reflects the Open API 3.03 Parameter Object. Parameter names are @@ -247,7 +247,7 @@ export interface FunctionDeclarationSchemaProperty { * @public */ export interface ToolConfig { - functionCallingConfig: FunctionCallingConfig; + functionCallingConfig?: FunctionCallingConfig; } /** diff --git a/packages/vertexai/src/types/responses.ts b/packages/vertexai/src/types/responses.ts index 0a4557fb055..026002a851d 100644 --- a/packages/vertexai/src/types/responses.ts +++ b/packages/vertexai/src/types/responses.ts @@ -91,7 +91,7 @@ export interface UsageMetadata { * @public */ export interface PromptFeedback { - blockReason: BlockReason; + blockReason?: BlockReason; safetyRatings: SafetyRating[]; blockReasonMessage?: string; }