Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vertex GA] Miscellaneous breaking changes for Vertex GA #8514

Merged
merged 8 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions common/api-review/vertexai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export interface BaseParams {

// @public
export enum BlockReason {
// (undocumented)
BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED",
// (undocumented)
OTHER = "OTHER",
// (undocumented)
Expand Down Expand Up @@ -145,8 +143,6 @@ export interface FileDataPart {

// @public
export enum FinishReason {
// (undocumented)
FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED",
// (undocumented)
MAX_TOKENS = "MAX_TOKENS",
// (undocumented)
Expand Down Expand Up @@ -182,8 +178,6 @@ export enum FunctionCallingMode {
// (undocumented)
AUTO = "AUTO",
// (undocumented)
MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
// (undocumented)
NONE = "NONE"
}

Expand All @@ -201,7 +195,7 @@ export interface FunctionCallPart {

// @public
export interface FunctionDeclaration {
description?: string;
description: string;
name: string;
parameters?: FunctionDeclarationSchema;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -589,7 +573,7 @@ export type Tool = FunctionDeclarationsTool;
// @public
export interface ToolConfig {
// (undocumented)
functionCallingConfig: FunctionCallingConfig;
functionCallingConfig?: FunctionCallingConfig;
}

// @public
Expand Down
2 changes: 1 addition & 1 deletion packages/vertexai/src/requests/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('request methods', () => {
false,
'',
{
timeout: 0
timeout: 180000
}
);
} catch (e) {
Expand Down
10 changes: 6 additions & 4 deletions packages/vertexai/src/requests/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
15 changes: 0 additions & 15 deletions packages/vertexai/src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions packages/vertexai/src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -247,7 +247,7 @@ export interface FunctionDeclarationSchemaProperty {
* @public
*/
export interface ToolConfig {
functionCallingConfig: FunctionCallingConfig;
functionCallingConfig?: FunctionCallingConfig;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vertexai/src/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface UsageMetadata {
* @public
*/
export interface PromptFeedback {
blockReason: BlockReason;
blockReason?: BlockReason;
safetyRatings: SafetyRating[];
blockReasonMessage?: string;
}
Expand Down
Loading