Skip to content

Commit 6ed3698

Browse files
yinghsienwucopybara-github
authored andcommitted
feat: support Blocking FunctionCall in Live API in AgentPlatform (Vertex)
PiperOrigin-RevId: 912037899
1 parent 4383bad commit 6ed3698

5 files changed

Lines changed: 8 additions & 177 deletions

File tree

src/converters/_caches_converters.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -468,62 +468,6 @@ export function functionCallingConfigToMldev(
468468
return toObject;
469469
}
470470

471-
export function functionDeclarationToVertex(
472-
fromObject: types.FunctionDeclaration,
473-
): Record<string, unknown> {
474-
const toObject: Record<string, unknown> = {};
475-
476-
const fromDescription = common.getValueByPath(fromObject, ['description']);
477-
if (fromDescription != null) {
478-
common.setValueByPath(toObject, ['description'], fromDescription);
479-
}
480-
481-
const fromName = common.getValueByPath(fromObject, ['name']);
482-
if (fromName != null) {
483-
common.setValueByPath(toObject, ['name'], fromName);
484-
}
485-
486-
const fromParameters = common.getValueByPath(fromObject, ['parameters']);
487-
if (fromParameters != null) {
488-
common.setValueByPath(toObject, ['parameters'], fromParameters);
489-
}
490-
491-
const fromParametersJsonSchema = common.getValueByPath(fromObject, [
492-
'parametersJsonSchema',
493-
]);
494-
if (fromParametersJsonSchema != null) {
495-
common.setValueByPath(
496-
toObject,
497-
['parametersJsonSchema'],
498-
fromParametersJsonSchema,
499-
);
500-
}
501-
502-
const fromResponse = common.getValueByPath(fromObject, ['response']);
503-
if (fromResponse != null) {
504-
common.setValueByPath(toObject, ['response'], fromResponse);
505-
}
506-
507-
const fromResponseJsonSchema = common.getValueByPath(fromObject, [
508-
'responseJsonSchema',
509-
]);
510-
if (fromResponseJsonSchema != null) {
511-
common.setValueByPath(
512-
toObject,
513-
['responseJsonSchema'],
514-
fromResponseJsonSchema,
515-
);
516-
}
517-
518-
if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
519-
throw new Error(
520-
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
521-
);
522-
}
523-
524-
return toObject;
525-
}
526-
527471
export function getCachedContentParametersToMldev(
528472
apiClient: ApiClient,
529473
fromObject: types.GetCachedContentParameters,
@@ -1171,7 +1115,7 @@ export function toolToVertex(fromObject: types.Tool): Record<string, unknown> {
11711115
let transformedList = fromFunctionDeclarations;
11721116
if (Array.isArray(transformedList)) {
11731117
transformedList = transformedList.map((item) => {
1174-
return functionDeclarationToVertex(item);
1118+
return item;
11751119
});
11761120
}
11771121
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);

src/converters/_live_converters.ts

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -190,62 +190,6 @@ export function functionCallToMldev(
190190
return toObject;
191191
}
192192

193-
export function functionDeclarationToVertex(
194-
fromObject: types.FunctionDeclaration,
195-
): Record<string, unknown> {
196-
const toObject: Record<string, unknown> = {};
197-
198-
const fromDescription = common.getValueByPath(fromObject, ['description']);
199-
if (fromDescription != null) {
200-
common.setValueByPath(toObject, ['description'], fromDescription);
201-
}
202-
203-
const fromName = common.getValueByPath(fromObject, ['name']);
204-
if (fromName != null) {
205-
common.setValueByPath(toObject, ['name'], fromName);
206-
}
207-
208-
const fromParameters = common.getValueByPath(fromObject, ['parameters']);
209-
if (fromParameters != null) {
210-
common.setValueByPath(toObject, ['parameters'], fromParameters);
211-
}
212-
213-
const fromParametersJsonSchema = common.getValueByPath(fromObject, [
214-
'parametersJsonSchema',
215-
]);
216-
if (fromParametersJsonSchema != null) {
217-
common.setValueByPath(
218-
toObject,
219-
['parametersJsonSchema'],
220-
fromParametersJsonSchema,
221-
);
222-
}
223-
224-
const fromResponse = common.getValueByPath(fromObject, ['response']);
225-
if (fromResponse != null) {
226-
common.setValueByPath(toObject, ['response'], fromResponse);
227-
}
228-
229-
const fromResponseJsonSchema = common.getValueByPath(fromObject, [
230-
'responseJsonSchema',
231-
]);
232-
if (fromResponseJsonSchema != null) {
233-
common.setValueByPath(
234-
toObject,
235-
['responseJsonSchema'],
236-
fromResponseJsonSchema,
237-
);
238-
}
239-
240-
if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
241-
throw new Error(
242-
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
243-
);
244-
}
245-
246-
return toObject;
247-
}
248-
249193
export function generationConfigToVertex(
250194
fromObject: types.GenerationConfig,
251195
): Record<string, unknown> {
@@ -2323,7 +2267,7 @@ export function toolToVertex(fromObject: types.Tool): Record<string, unknown> {
23232267
let transformedList = fromFunctionDeclarations;
23242268
if (Array.isArray(transformedList)) {
23252269
transformedList = transformedList.map((item) => {
2326-
return functionDeclarationToVertex(item);
2270+
return item;
23272271
});
23282272
}
23292273
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);

src/converters/_models_converters.ts

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,63 +1413,6 @@ export function functionCallingConfigToMldev(
14131413
return toObject;
14141414
}
14151415

1416-
export function functionDeclarationToVertex(
1417-
fromObject: types.FunctionDeclaration,
1418-
_rootObject?: unknown,
1419-
): Record<string, unknown> {
1420-
const toObject: Record<string, unknown> = {};
1421-
1422-
const fromDescription = common.getValueByPath(fromObject, ['description']);
1423-
if (fromDescription != null) {
1424-
common.setValueByPath(toObject, ['description'], fromDescription);
1425-
}
1426-
1427-
const fromName = common.getValueByPath(fromObject, ['name']);
1428-
if (fromName != null) {
1429-
common.setValueByPath(toObject, ['name'], fromName);
1430-
}
1431-
1432-
const fromParameters = common.getValueByPath(fromObject, ['parameters']);
1433-
if (fromParameters != null) {
1434-
common.setValueByPath(toObject, ['parameters'], fromParameters);
1435-
}
1436-
1437-
const fromParametersJsonSchema = common.getValueByPath(fromObject, [
1438-
'parametersJsonSchema',
1439-
]);
1440-
if (fromParametersJsonSchema != null) {
1441-
common.setValueByPath(
1442-
toObject,
1443-
['parametersJsonSchema'],
1444-
fromParametersJsonSchema,
1445-
);
1446-
}
1447-
1448-
const fromResponse = common.getValueByPath(fromObject, ['response']);
1449-
if (fromResponse != null) {
1450-
common.setValueByPath(toObject, ['response'], fromResponse);
1451-
}
1452-
1453-
const fromResponseJsonSchema = common.getValueByPath(fromObject, [
1454-
'responseJsonSchema',
1455-
]);
1456-
if (fromResponseJsonSchema != null) {
1457-
common.setValueByPath(
1458-
toObject,
1459-
['responseJsonSchema'],
1460-
fromResponseJsonSchema,
1461-
);
1462-
}
1463-
1464-
if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
1465-
throw new Error(
1466-
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
1467-
);
1468-
}
1469-
1470-
return toObject;
1471-
}
1472-
14731416
export function generateContentConfigToMldev(
14741417
apiClient: ApiClient,
14751418
fromObject: types.GenerateContentConfig,
@@ -5220,7 +5163,7 @@ export function toolToMldev(
52205163

52215164
export function toolToVertex(
52225165
fromObject: types.Tool,
5223-
rootObject?: unknown,
5166+
_rootObject?: unknown,
52245167
): Record<string, unknown> {
52255168
const toObject: Record<string, unknown> = {};
52265169

@@ -5275,7 +5218,7 @@ export function toolToVertex(
52755218
let transformedList = fromFunctionDeclarations;
52765219
if (Array.isArray(transformedList)) {
52775220
transformedList = transformedList.map((item) => {
5278-
return functionDeclarationToVertex(item, rootObject);
5221+
return item;
52795222
});
52805223
}
52815224
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ export enum PhishBlockThreshold {
216216
BLOCK_ONLY_EXTREMELY_HIGH = 'BLOCK_ONLY_EXTREMELY_HIGH',
217217
}
218218

219-
/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
219+
/** Specifies the function Behavior. Currently only non-blocking functions are supported. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method. */
220220
export enum Behavior {
221221
/**
222-
* This value is unused.
222+
* This value is unspecified.
223223
*/
224224
UNSPECIFIED = 'UNSPECIFIED',
225225
/**
@@ -2388,7 +2388,7 @@ export declare interface FunctionDeclaration {
23882388
response?: Schema;
23892389
/** Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`. */
23902390
responseJsonSchema?: unknown;
2391-
/** Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This field is not supported in Vertex AI. */
2391+
/** Optional. Specifies the function Behavior. Currently only non-blocking functions are supported. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method. */
23922392
behavior?: Behavior;
23932393
}
23942394

test/system/node/live_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ async function make_session_with_queue(
140140
return session;
141141
}
142142

143-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000; // 10 seconds
143+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20 * 1000; // 20 seconds
144144

145145
describe('live', () => {
146146
let testName: string = '';

0 commit comments

Comments
 (0)