Skip to content

Commit 460e3b1

Browse files
fix(Google Gemini Node): Don't pass hardcoded value for durationSeconds when generating a video (#17793)
Co-authored-by: Shireen Missi <[email protected]>
1 parent 1d31e6a commit 460e3b1

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/GoogleGemini.node.test.ts

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import * as helpers from '@utils/helpers';
12
import { mockDeep } from 'jest-mock-extended';
23
import type { IExecuteFunctions, IBinaryData, INode } from 'n8n-workflow';
34
import { NodeOperationError } from 'n8n-workflow';
45

5-
import * as helpers from '@utils/helpers';
6-
76
import * as audio from './actions/audio';
87
import * as file from './actions/file';
98
import * as image from './actions/image';
@@ -1008,6 +1007,72 @@ describe('GoogleGemini Node', () => {
10081007
});
10091008
});
10101009

1010+
it('should not pass durationSeconds if not provided', async () => {
1011+
executeFunctionsMock.getNodeParameter.mockImplementation((parameter: string) => {
1012+
switch (parameter) {
1013+
case 'modelId':
1014+
return 'models/veo-3.0-generate-002';
1015+
case 'prompt':
1016+
return 'Panning wide shot of a calico kitten sleeping in the sunshine';
1017+
case 'options':
1018+
return {
1019+
aspectRatio: '16:9',
1020+
personGeneration: 'dont_allow',
1021+
sampleCount: 1,
1022+
};
1023+
case 'returnAs':
1024+
return 'url';
1025+
default:
1026+
return undefined;
1027+
}
1028+
});
1029+
executeFunctionsMock.getCredentials.mockResolvedValue({ apiKey: 'test-api-key' });
1030+
apiRequestMock.mockResolvedValue({
1031+
name: 'operations/123',
1032+
done: true,
1033+
response: {
1034+
generateVideoResponse: {
1035+
generatedSamples: [
1036+
{
1037+
video: {
1038+
uri: 'https://example.com/video.mp4',
1039+
},
1040+
},
1041+
],
1042+
},
1043+
},
1044+
});
1045+
1046+
const result = await video.generate.execute.call(executeFunctionsMock, 0);
1047+
1048+
expect(result).toEqual([
1049+
{
1050+
json: {
1051+
url: 'https://example.com/video.mp4',
1052+
},
1053+
pairedItem: { item: 0 },
1054+
},
1055+
]);
1056+
expect(apiRequestMock).toHaveBeenCalledWith(
1057+
'POST',
1058+
'/v1beta/models/veo-3.0-generate-002:predictLongRunning',
1059+
{
1060+
body: {
1061+
instances: [
1062+
{
1063+
prompt: 'Panning wide shot of a calico kitten sleeping in the sunshine',
1064+
},
1065+
],
1066+
parameters: {
1067+
aspectRatio: '16:9',
1068+
personGeneration: 'dont_allow',
1069+
sampleCount: 1,
1070+
},
1071+
},
1072+
},
1073+
);
1074+
});
1075+
10111076
it('should handle errors from video generation', async () => {
10121077
executeFunctionsMock.getNodeParameter.mockImplementation((parameter: string) => {
10131078
switch (parameter) {

packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/video/generate.operation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const properties: INodeProperties[] = [
6060
name: 'durationSeconds',
6161
type: 'number',
6262
default: 8,
63-
description: 'Length of the generated video in seconds',
63+
description: 'Length of the generated video in seconds. Supported only by certain models.',
6464
typeOptions: {
6565
minValue: 5,
6666
maxValue: 8,
@@ -159,7 +159,7 @@ export async function execute(this: IExecuteFunctions, i: number): Promise<INode
159159
aspectRatio: options.aspectRatio,
160160
personGeneration: options.personGeneration,
161161
sampleCount: options.sampleCount ?? 1,
162-
durationSeconds: options.durationSeconds ?? 8,
162+
durationSeconds: options.durationSeconds,
163163
},
164164
};
165165
let response = (await apiRequest.call(this, 'POST', `/v1beta/${model}:predictLongRunning`, {

0 commit comments

Comments
 (0)