Skip to content

Commit f25ccbb

Browse files
authored
Add additional Vertex types (#8131)
1 parent acef5e3 commit f25ccbb

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed

packages/vertexai/src/types/enums.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ export enum HarmBlockThreshold {
5656
BLOCK_NONE = 'BLOCK_NONE'
5757
}
5858

59+
/**
60+
* @public
61+
*/
62+
export enum HarmBlockMethod {
63+
// The harm block method is unspecified.
64+
HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED',
65+
// The harm block method uses both probability and severity scores.
66+
SEVERITY = 'SEVERITY',
67+
// The harm block method uses the probability score.
68+
PROBABILITY = 'PROBABILITY'
69+
}
70+
5971
/**
6072
* Probability that a prompt or candidate matches a harm category.
6173
* @public
@@ -73,6 +85,23 @@ export enum HarmProbability {
7385
HIGH = 'HIGH'
7486
}
7587

88+
/**
89+
* Harm severity levels.
90+
* @public
91+
*/
92+
export enum HarmSeverity {
93+
// Harm severity unspecified.
94+
HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED',
95+
// Negligible level of harm severity.
96+
HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE',
97+
// Low level of harm severity.
98+
HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW',
99+
// Medium level of harm severity.
100+
HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM',
101+
// High level of harm severity.
102+
HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH'
103+
}
104+
76105
/**
77106
* Reason that a prompt was blocked.
78107
* @public

packages/vertexai/src/types/requests.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { Content } from './content';
19-
import { HarmBlockThreshold, HarmCategory } from './enums';
19+
import { HarmBlockMethod, HarmBlockThreshold, HarmCategory } from './enums';
2020

2121
/**
2222
* Base parameters for a number of methods.
@@ -52,6 +52,7 @@ export interface GenerateContentRequest extends BaseParams {
5252
export interface SafetySetting {
5353
category: HarmCategory;
5454
threshold: HarmBlockThreshold;
55+
method: HarmBlockMethod;
5556
}
5657

5758
/**
@@ -65,6 +66,8 @@ export interface GenerationConfig {
6566
temperature?: number;
6667
topP?: number;
6768
topK?: number;
69+
presencePenalty?: number;
70+
frequencyPenalty?: number;
6871
}
6972

7073
/**

packages/vertexai/src/types/responses.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
BlockReason,
2121
FinishReason,
2222
HarmCategory,
23-
HarmProbability
23+
HarmProbability,
24+
HarmSeverity
2425
} from './enums';
2526

2627
/**
@@ -101,6 +102,7 @@ export interface GenerateContentCandidate {
101102
finishMessage?: string;
102103
safetyRatings?: SafetyRating[];
103104
citationMetadata?: CitationMetadata;
105+
groundingMetadata?: GroundingMetadata;
104106
}
105107

106108
/**
@@ -124,6 +126,51 @@ export interface Citation {
124126
publicationDate?: Date;
125127
}
126128

129+
/**
130+
* Metadata returned to client when grounding is enabled.
131+
* @public
132+
*/
133+
export interface GroundingMetadata {
134+
webSearchQueries?: string[];
135+
retrievalQueries?: string[];
136+
groundingAttributions: GroundingAttribution[];
137+
}
138+
139+
/**
140+
* @public
141+
*/
142+
export interface GroundingAttribution {
143+
segment: Segment;
144+
confidenceScore?: number;
145+
web?: WebAttribution;
146+
retrievedContext?: RetrievedContextAttribution;
147+
}
148+
149+
/**
150+
* @public
151+
*/
152+
export interface Segment {
153+
partIndex: number;
154+
startIndex: number;
155+
endIndex: number;
156+
}
157+
158+
/**
159+
* @public
160+
*/
161+
export interface WebAttribution {
162+
uri: string;
163+
title: string;
164+
}
165+
166+
/**
167+
* @public
168+
*/
169+
export interface RetrievedContextAttribution {
170+
uri: string;
171+
title: string;
172+
}
173+
127174
/**
128175
* Protobuf google.type.Date
129176
* @public
@@ -141,12 +188,24 @@ export interface Date {
141188
export interface SafetyRating {
142189
category: HarmCategory;
143190
probability: HarmProbability;
191+
severity: HarmSeverity;
192+
probabilityScore: number;
193+
severityScore: number;
194+
blocked: boolean;
144195
}
145196

146197
/**
147198
* Response from calling {@link GenerativeModel.countTokens}.
148199
* @public
149200
*/
150201
export interface CountTokensResponse {
202+
/**
203+
* The total number of tokens counted across all instances from the request.
204+
*/
151205
totalTokens: number;
206+
/**
207+
* The total number of billable characters counted across all instances
208+
* from the request.
209+
*/
210+
totalBillableCharacters?: number;
152211
}

0 commit comments

Comments
 (0)