-
Notifications
You must be signed in to change notification settings - Fork 7
fix: linting issue #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { | |
| INodePropertyOptions, | ||
| INodeTypeDescription, | ||
| } from 'n8n-workflow'; | ||
|
|
||
| import { FileRequest, ChatMessage, ResponseFormat } from './types'; | ||
| import { ApiService } from './ApiService'; | ||
| import { processFile, processImageRequest } from './utils'; | ||
|
|
@@ -68,25 +69,25 @@ export class VlmRun implements INodeType { | |
| description: 'Extract insights or transcribe content from video files', | ||
| action: 'Analyze video', | ||
| }, | ||
| { | ||
| name: 'Chat Completion', | ||
| value: 'chatCompletion', | ||
| description: 'Generate chat completions using OpenAI-compatible API', | ||
| action: 'Chat completion', | ||
| }, | ||
| { | ||
| name: 'Execute Agent', | ||
| value: 'executeAgent', | ||
| description: 'Execute an agent', | ||
| action: 'Execute agent', | ||
| }, | ||
| { | ||
| name: 'Manage Files', | ||
| value: 'file', | ||
| description: 'List uploaded files or upload new files to VLM Run', | ||
| action: 'Manage files', | ||
| }, | ||
| { | ||
| name: 'Chat Completion', | ||
| value: 'chatCompletion', | ||
| description: 'Generate chat completions using OpenAI-compatible API', | ||
| action: 'Chat completion', | ||
| }, | ||
| ], | ||
| { | ||
| name: 'Manage Files', | ||
| value: 'file', | ||
| description: 'List uploaded files or upload new files to VLM Run', | ||
| action: 'Manage files', | ||
| }, | ||
| ], | ||
| default: 'document', | ||
| }, | ||
| // File field for document, image, audio, video operations | ||
|
|
@@ -893,7 +894,10 @@ export class VlmRun implements INodeType { | |
|
|
||
| // Validate that if type is json_schema, schema must be provided | ||
| if (userDefinedResponseFormat.type === 'json_schema' && !userDefinedResponseFormat.schema) { | ||
| throw new Error('Schema is required when type is "json_schema"'); | ||
| throw new NodeOperationError( | ||
| this.getNode(), | ||
| 'Schema is required when type is "json_schema"', | ||
| ); | ||
| } | ||
|
|
||
| // For structured outputs (json_schema), ensure strict is set to true if not provided | ||
|
|
@@ -904,7 +908,10 @@ export class VlmRun implements INodeType { | |
| } | ||
| // If it's an empty object or doesn't have type/schema, treat as undefined (ignore it) | ||
| } else if (parsed !== undefined) { | ||
| throw new Error('Response format must be an object'); | ||
| throw new NodeOperationError( | ||
| this.getNode(), | ||
| 'Response format must be an object', | ||
| ); | ||
|
Comment on lines
+911
to
+914
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my other comment, while using throw new Error('Response format must be an object'); |
||
| } | ||
| } catch (error) { | ||
| throw new NodeOperationError( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While using
NodeOperationErroris generally best practice in n8n nodes, in this specific context it leads to a less clear error message for the user. Thecatchblock on line 916 wraps this error into anotherNodeOperationError, prefixing the message withInvalid JSON format for response_format: .... This makes the specific validation error (Schema is required when type is "json_schema") appear as a generic JSON format error.To provide a clearer error, it would be better to either keep throwing a standard
Errorwhich thecatchblock seems designed to handle, or refactor thecatchblock to re-throwNodeOperationErrorinstances directly. Given the scope of this PR, reverting tonew Error(...)seems more appropriate.