Skip to content
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
58 changes: 1 addition & 57 deletions src/converters/_caches_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,62 +468,6 @@ export function functionCallingConfigToMldev(
return toObject;
}

export function functionDeclarationToVertex(
fromObject: types.FunctionDeclaration,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromDescription = common.getValueByPath(fromObject, ['description']);
if (fromDescription != null) {
common.setValueByPath(toObject, ['description'], fromDescription);
}

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['name'], fromName);
}

const fromParameters = common.getValueByPath(fromObject, ['parameters']);
if (fromParameters != null) {
common.setValueByPath(toObject, ['parameters'], fromParameters);
}

const fromParametersJsonSchema = common.getValueByPath(fromObject, [
'parametersJsonSchema',
]);
if (fromParametersJsonSchema != null) {
common.setValueByPath(
toObject,
['parametersJsonSchema'],
fromParametersJsonSchema,
);
}

const fromResponse = common.getValueByPath(fromObject, ['response']);
if (fromResponse != null) {
common.setValueByPath(toObject, ['response'], fromResponse);
}

const fromResponseJsonSchema = common.getValueByPath(fromObject, [
'responseJsonSchema',
]);
if (fromResponseJsonSchema != null) {
common.setValueByPath(
toObject,
['responseJsonSchema'],
fromResponseJsonSchema,
);
}

if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
throw new Error(
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
);
}

return toObject;
}

export function getCachedContentParametersToMldev(
apiClient: ApiClient,
fromObject: types.GetCachedContentParameters,
Expand Down Expand Up @@ -1171,7 +1115,7 @@ export function toolToVertex(fromObject: types.Tool): Record<string, unknown> {
let transformedList = fromFunctionDeclarations;
if (Array.isArray(transformedList)) {
transformedList = transformedList.map((item) => {
return functionDeclarationToVertex(item);
return item;
});
}
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);
Expand Down
58 changes: 1 addition & 57 deletions src/converters/_live_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,62 +190,6 @@ export function functionCallToMldev(
return toObject;
}

export function functionDeclarationToVertex(
fromObject: types.FunctionDeclaration,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromDescription = common.getValueByPath(fromObject, ['description']);
if (fromDescription != null) {
common.setValueByPath(toObject, ['description'], fromDescription);
}

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['name'], fromName);
}

const fromParameters = common.getValueByPath(fromObject, ['parameters']);
if (fromParameters != null) {
common.setValueByPath(toObject, ['parameters'], fromParameters);
}

const fromParametersJsonSchema = common.getValueByPath(fromObject, [
'parametersJsonSchema',
]);
if (fromParametersJsonSchema != null) {
common.setValueByPath(
toObject,
['parametersJsonSchema'],
fromParametersJsonSchema,
);
}

const fromResponse = common.getValueByPath(fromObject, ['response']);
if (fromResponse != null) {
common.setValueByPath(toObject, ['response'], fromResponse);
}

const fromResponseJsonSchema = common.getValueByPath(fromObject, [
'responseJsonSchema',
]);
if (fromResponseJsonSchema != null) {
common.setValueByPath(
toObject,
['responseJsonSchema'],
fromResponseJsonSchema,
);
}

if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
throw new Error(
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
);
}

return toObject;
}

export function generationConfigToVertex(
fromObject: types.GenerationConfig,
): Record<string, unknown> {
Expand Down Expand Up @@ -2323,7 +2267,7 @@ export function toolToVertex(fromObject: types.Tool): Record<string, unknown> {
let transformedList = fromFunctionDeclarations;
if (Array.isArray(transformedList)) {
transformedList = transformedList.map((item) => {
return functionDeclarationToVertex(item);
return item;
});
}
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);
Expand Down
61 changes: 2 additions & 59 deletions src/converters/_models_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1413,63 +1413,6 @@ export function functionCallingConfigToMldev(
return toObject;
}

export function functionDeclarationToVertex(
fromObject: types.FunctionDeclaration,
_rootObject?: unknown,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromDescription = common.getValueByPath(fromObject, ['description']);
if (fromDescription != null) {
common.setValueByPath(toObject, ['description'], fromDescription);
}

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['name'], fromName);
}

const fromParameters = common.getValueByPath(fromObject, ['parameters']);
if (fromParameters != null) {
common.setValueByPath(toObject, ['parameters'], fromParameters);
}

const fromParametersJsonSchema = common.getValueByPath(fromObject, [
'parametersJsonSchema',
]);
if (fromParametersJsonSchema != null) {
common.setValueByPath(
toObject,
['parametersJsonSchema'],
fromParametersJsonSchema,
);
}

const fromResponse = common.getValueByPath(fromObject, ['response']);
if (fromResponse != null) {
common.setValueByPath(toObject, ['response'], fromResponse);
}

const fromResponseJsonSchema = common.getValueByPath(fromObject, [
'responseJsonSchema',
]);
if (fromResponseJsonSchema != null) {
common.setValueByPath(
toObject,
['responseJsonSchema'],
fromResponseJsonSchema,
);
}

if (common.getValueByPath(fromObject, ['behavior']) !== undefined) {
throw new Error(
'behavior parameter is not supported in Gemini Enterprise Agent Platform (previously known as Vertex AI).',
);
}

return toObject;
}

export function generateContentConfigToMldev(
apiClient: ApiClient,
fromObject: types.GenerateContentConfig,
Expand Down Expand Up @@ -5220,7 +5163,7 @@ export function toolToMldev(

export function toolToVertex(
fromObject: types.Tool,
rootObject?: unknown,
_rootObject?: unknown,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

Expand Down Expand Up @@ -5275,7 +5218,7 @@ export function toolToVertex(
let transformedList = fromFunctionDeclarations;
if (Array.isArray(transformedList)) {
transformedList = transformedList.map((item) => {
return functionDeclarationToVertex(item, rootObject);
return item;
});
}
common.setValueByPath(toObject, ['functionDeclarations'], transformedList);
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ export enum PhishBlockThreshold {
BLOCK_ONLY_EXTREMELY_HIGH = 'BLOCK_ONLY_EXTREMELY_HIGH',
}

/** Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This enum is not supported in Vertex AI. */
/** 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. */
export enum Behavior {
/**
* This value is unused.
* This value is unspecified.
*/
UNSPECIFIED = 'UNSPECIFIED',
/**
Expand Down Expand Up @@ -2388,7 +2388,7 @@ export declare interface FunctionDeclaration {
response?: Schema;
/** 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`. */
responseJsonSchema?: unknown;
/** Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This field is not supported in Vertex AI. */
/** 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. */
behavior?: Behavior;
}

Expand Down
2 changes: 1 addition & 1 deletion test/system/node/live_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function make_session_with_queue(
return session;
}

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10 * 1000; // 10 seconds
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20 * 1000; // 20 seconds

describe('live', () => {
let testName: string = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
>515 {"setup":{"model":"projects/REDACTED/locations/REDACTED/publishers/google/models/gemini-2.0-flash-live-preview-04-09","generationConfig":{"responseModalities":["AUDIO"]},"tools":[{"functionDeclarations":[{"description":"Get the current weather in a given location","name":"get_current_weather","parameters":{"type":"OBJECT","properties":{"location":{"type":"STRING","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"STRING","enum":["celsius","fahrenheit"]}},"required":["location"]}}]}]}}
>515 {"setup":{"model":"projects/REDACTED/locations/REDACTED/publishers/google/models/gemini-2.0-flash-live-preview-04-09","generationConfig":{"responseModalities":["AUDIO"]},"tools":[{"functionDeclarations":[{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"OBJECT","properties":{"location":{"type":"STRING","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"STRING","enum":["celsius","fahrenheit"]}},"required":["location"]}}]}]}}
>129 {"clientContent":{"turns":[{"parts":[{"text":"what is the weather in Redmond Washington"}],"role":"user"}],"turnComplete":true}}
<86 {
"setupComplete": {
Expand Down
Loading