Skip to content

Commit 9b83df2

Browse files
committed
misc changes for Vertex GA
1 parent 7194d9c commit 9b83df2

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

packages/vertexai/src/requests/request.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ describe('request methods', () => {
243243
false,
244244
'',
245245
{
246-
timeout: 0
246+
timeout: 180000
247247
}
248248
);
249249
} catch (e) {

packages/vertexai/src/requests/request.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ export async function makeRequest(
186186
*/
187187
function buildFetchOptions(requestOptions?: RequestOptions): RequestInit {
188188
const fetchOptions = {} as RequestInit;
189+
let timeoutMillis = 180 * 1000; // default: 180 s
189190
if (requestOptions?.timeout && requestOptions?.timeout >= 0) {
190-
const abortController = new AbortController();
191-
const signal = abortController.signal;
192-
setTimeout(() => abortController.abort(), requestOptions.timeout);
193-
fetchOptions.signal = signal;
191+
timeoutMillis = requestOptions.timeout;
194192
}
193+
const abortController = new AbortController();
194+
const signal = abortController.signal;
195+
setTimeout(() => abortController.abort(), timeoutMillis);
196+
fetchOptions.signal = signal;
195197
return fetchOptions;
196198
}

packages/vertexai/src/types/enums.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const POSSIBLE_ROLES = ['user', 'model', 'function', 'system'] as const;
3232
* @public
3333
*/
3434
export enum HarmCategory {
35-
HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED',
3635
HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH',
3736
HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
3837
HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT',
@@ -44,8 +43,6 @@ export enum HarmCategory {
4443
* @public
4544
*/
4645
export enum HarmBlockThreshold {
47-
// Threshold is unspecified.
48-
HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
4946
// Content with NEGLIGIBLE will be allowed.
5047
BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE',
5148
// Content with NEGLIGIBLE and LOW will be allowed.
@@ -60,8 +57,6 @@ export enum HarmBlockThreshold {
6057
* @public
6158
*/
6259
export enum HarmBlockMethod {
63-
// The harm block method is unspecified.
64-
HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED',
6560
// The harm block method uses both probability and severity scores.
6661
SEVERITY = 'SEVERITY',
6762
// The harm block method uses the probability score.
@@ -73,8 +68,6 @@ export enum HarmBlockMethod {
7368
* @public
7469
*/
7570
export enum HarmProbability {
76-
// Probability is unspecified.
77-
HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED',
7871
// Content has a negligible chance of being unsafe.
7972
NEGLIGIBLE = 'NEGLIGIBLE',
8073
// Content has a low chance of being unsafe.
@@ -90,8 +83,6 @@ export enum HarmProbability {
9083
* @public
9184
*/
9285
export enum HarmSeverity {
93-
// Harm severity unspecified.
94-
HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED',
9586
// Negligible level of harm severity.
9687
HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE',
9788
// Low level of harm severity.
@@ -107,8 +98,6 @@ export enum HarmSeverity {
10798
* @public
10899
*/
109100
export enum BlockReason {
110-
// A blocked reason was not specified.
111-
BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED',
112101
// Content was blocked by safety settings.
113102
SAFETY = 'SAFETY',
114103
// Content was blocked, but the reason is uncategorized.
@@ -120,8 +109,6 @@ export enum BlockReason {
120109
* @public
121110
*/
122111
export enum FinishReason {
123-
// Default value. This value is unused.
124-
FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED',
125112
// Natural stop point of the model or provided stop sequence.
126113
STOP = 'STOP',
127114
// The maximum number of tokens as specified in the request was reached.
@@ -138,8 +125,6 @@ export enum FinishReason {
138125
* @public
139126
*/
140127
export enum FunctionCallingMode {
141-
// Unspecified function calling mode. This value should not be used.
142-
MODE_UNSPECIFIED = 'MODE_UNSPECIFIED',
143128
// Default model behavior, model decides to predict either a function call
144129
// or a natural language response.
145130
AUTO = 'AUTO',

packages/vertexai/src/types/requests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export interface CountTokensRequest {
113113
*/
114114
export interface RequestOptions {
115115
/**
116-
* Request timeout in milliseconds.
116+
* Request timeout in milliseconds. Defaults to 180 seconds (180000ms).
117117
*/
118118
timeout?: number;
119119
/**

packages/vertexai/src/types/responses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export interface UsageMetadata {
9191
* @public
9292
*/
9393
export interface PromptFeedback {
94-
blockReason: BlockReason;
94+
blockReason?: BlockReason;
9595
safetyRatings: SafetyRating[];
9696
blockReasonMessage?: string;
9797
}

0 commit comments

Comments
 (0)