-
Notifications
You must be signed in to change notification settings - Fork 448
fix: loading api-format workflow that contains "parameters" string #7411
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
429d242
767f141
d18a9c7
2c76be9
2546bcc
4c83edc
d562423
8eb36fb
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 |
|---|---|---|
|
|
@@ -1468,7 +1468,21 @@ export class ComfyApp { | |
| } | ||
| } | ||
|
|
||
| // Use parameters as fallback when no workflow exists | ||
| if (prompt) { | ||
| try { | ||
| const promptObj = | ||
| typeof prompt === 'string' ? JSON.parse(prompt) : prompt | ||
| if (this.isApiJson(promptObj)) { | ||
| this.loadApiJson(promptObj, fileName) | ||
| return | ||
| } | ||
| } catch (err) { | ||
| console.error('Failed to parse prompt:', err) | ||
| } | ||
| // Fall through to parameters as a last resort | ||
| } | ||
|
|
||
| // Use parameters strictly as the final fallback | ||
| if (parameters) { | ||
| // Note: Not putting this in `importA1111` as it is mostly not used | ||
| // by external callers, and `importA1111` has no access to `app`. | ||
|
|
@@ -1481,18 +1495,25 @@ export class ComfyApp { | |
| return | ||
| } | ||
|
|
||
| if (prompt) { | ||
| const promptObj = typeof prompt === 'string' ? JSON.parse(prompt) : prompt | ||
| this.loadApiJson(promptObj, fileName) | ||
| return | ||
| } | ||
|
|
||
| this.showErrorOnFileLoad(file) | ||
| } | ||
|
|
||
| // @deprecated | ||
| isApiJson(data: unknown) { | ||
| return _.isObject(data) && Object.values(data).every((v) => v.class_type) | ||
| isApiJson(data: unknown): data is ComfyApiWorkflow { | ||
|
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. 🧹 Nitpick | 🔵 Trivial Remove The method is marked as deprecated but is actively used in the new prompt-handling code (line 1475). Either remove the deprecation tag if the method is still needed, or provide an alternative and update the calling code. 🤖 Prompt for AI Agents |
||
| if (!_.isObject(data) || Array.isArray(data)) { | ||
| return false | ||
| } | ||
| if (Object.keys(data).length === 0) return false | ||
|
|
||
| return Object.values(data).every((node) => { | ||
| if (!node || typeof node !== 'object' || Array.isArray(node)) { | ||
| return false | ||
| } | ||
|
|
||
| const { class_type: classType, inputs } = node as Record<string, unknown> | ||
| const inputsIsRecord = _.isObject(inputs) && !Array.isArray(inputs) | ||
| return typeof classType === 'string' && inputsIsRecord | ||
| }) | ||
| } | ||
|
Comment on lines
1501
to
1517
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. 🧹 Nitpick | 🔵 Trivial Clarify The 🤖 Prompt for AI Agents |
||
|
|
||
| loadApiJson(apiData: ComfyApiWorkflow, fileName: string) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
What is this, an image for ants?