Skip to content

Commit b228479

Browse files
Refactor error handling and update options (#77)
1 parent 2b19fa8 commit b228479

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

nodes/VlmRun/VlmRun.node.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
INodePropertyOptions,
1010
INodeTypeDescription,
1111
} from 'n8n-workflow';
12+
1213
import { FileRequest, ChatMessage, ResponseFormat } from './types';
1314
import { ApiService } from './ApiService';
1415
import { processFile, processImageRequest } from './utils';
@@ -68,25 +69,25 @@ export class VlmRun implements INodeType {
6869
description: 'Extract insights or transcribe content from video files',
6970
action: 'Analyze video',
7071
},
72+
{
73+
name: 'Chat Completion',
74+
value: 'chatCompletion',
75+
description: 'Generate chat completions using OpenAI-compatible API',
76+
action: 'Chat completion',
77+
},
7178
{
7279
name: 'Execute Agent',
7380
value: 'executeAgent',
7481
description: 'Execute an agent',
7582
action: 'Execute agent',
7683
},
77-
{
78-
name: 'Manage Files',
79-
value: 'file',
80-
description: 'List uploaded files or upload new files to VLM Run',
81-
action: 'Manage files',
82-
},
83-
{
84-
name: 'Chat Completion',
85-
value: 'chatCompletion',
86-
description: 'Generate chat completions using OpenAI-compatible API',
87-
action: 'Chat completion',
88-
},
89-
],
84+
{
85+
name: 'Manage Files',
86+
value: 'file',
87+
description: 'List uploaded files or upload new files to VLM Run',
88+
action: 'Manage files',
89+
},
90+
],
9091
default: 'document',
9192
},
9293
// File field for document, image, audio, video operations
@@ -893,7 +894,10 @@ export class VlmRun implements INodeType {
893894

894895
// Validate that if type is json_schema, schema must be provided
895896
if (userDefinedResponseFormat.type === 'json_schema' && !userDefinedResponseFormat.schema) {
896-
throw new Error('Schema is required when type is "json_schema"');
897+
throw new NodeOperationError(
898+
this.getNode(),
899+
'Schema is required when type is "json_schema"',
900+
);
897901
}
898902

899903
// For structured outputs (json_schema), ensure strict is set to true if not provided
@@ -904,7 +908,10 @@ export class VlmRun implements INodeType {
904908
}
905909
// If it's an empty object or doesn't have type/schema, treat as undefined (ignore it)
906910
} else if (parsed !== undefined) {
907-
throw new Error('Response format must be an object');
911+
throw new NodeOperationError(
912+
this.getNode(),
913+
'Response format must be an object',
914+
);
908915
}
909916
} catch (error) {
910917
throw new NodeOperationError(

0 commit comments

Comments
 (0)