Skip to content

Enhanced ComfyUI Prompt Detection & Copy Functionality#27

Open
jakedev796 wants to merge 1 commit intoPanicTitan:mainfrom
jakedev796:main
Open

Enhanced ComfyUI Prompt Detection & Copy Functionality#27
jakedev796 wants to merge 1 commit intoPanicTitan:mainfrom
jakedev796:main

Conversation

@jakedev796
Copy link

@jakedev796 jakedev796 commented Jun 29, 2025

I saw you've been doing some thinking on how to best handle the prompt detection, as it gets really complicated with the advanced workflows. So hopefully this helps you towards that. It was working consistently on my end with this new setup, but I definitely don't have the craziest workflows that exist.

It's worth noting that I've had hit or miss detection when using multiple positive prompt nodes, but I didn't really account for this in the code. Likely a simple enough fix if this gets merged. The current way it will handle it is it will likely just take one of the prompt nodes instead of both, but I didn't do extensive testing on this.

Fixes

  • Fixed bug where negative prompts weren't being detected due to logic error in node array parsing
  • Fixed click-to-copy functionality with proper error handling and browser fallbacks

Enhancements

  • Multi-strategy prompt extraction:
    • Title-based detection (most reliable)
    • Node type recognition with heuristics
    • Basic workflow structure parsing
    • Keyword-based classification
  • Configurable system via prompt_config.py for easy extension

Technical Changes

  • Enhanced metadata_extractor.py with ComfyUIPromptParser class
  • Added structured prompt output with extraction method tracking
  • Improved frontend metadata parsing with fallback support
  • Moved quite a bit of logic for metadata parsing from frontend to backend. SoC.

Impact

  • Dramatically improved negative prompt detection across workflow types
  • Easy extensibility for new ComfyUI node types

Testing

  • Tested on basic and advanced workflows
  • Confirmed backward compatibility with existing data

Directly resolves both #13 and (I think) #16

@PanicTitan
Copy link
Owner

I tested your pull request but found that it produced "worse" results on my image set compared to the previous version, such as missing some information that was previously present or swapping prompts. After reviewing your code, I was inspired to take a different approach and ended up completely rewriting the parser. The new implementation gave better results in my tests and is designed to be relatively easier to extend, supporting more complex or unique workflows by simply creating a new class.

Thank you for your contribution! You can try out the updated parser in version v2.5.0 and see how it performs with your images.

@jakedev796
Copy link
Author

Fantastic! I look forward to trying it out then! 😁 I figured mine wouldn't be a one size fits all solution, but very happy it gave you the inspiration to find a better solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants