Skip to content
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

Support for Passing Dynamic Prompts via Command-Line Arguments #39

Open
Gerkinfeltser opened this issue Feb 11, 2024 · 1 comment
Open

Comments

@Gerkinfeltser
Copy link

Hello! Thanks so much for your work on this!

I'm working with a script generated by the comfyui_to_python.py and am trying to modify the outputted script's functionality to accept dynamic prompts through command-line arguments. The goal is to make the script more flexible by allowing users to specify prompts at runtime, instead of having them hardcoded or predefined within the script (Actually trying to get it to work with LLM agent workflows).

Currently, the script either uses the hard coded prompt or (I assume) requires modification in the source code to change the prompt used in its operations.

Ideally, I would like the ability to pass a prompt directly when executing the script, something like this:
python script_name.py "Custom prompt text here"

This would set the script to use the provided text as the prompt for its execution cycle.

Questions:

  • Is there existing functionality within the script or project that supports this, and I might have overlooked it?
  • If not, could you guide me on how best to implement this feature? Are there any considerations or best practices I should follow to maintain compatibility with the rest of the project?

Attempts:
I've tried modifying the script to parse command-line arguments using the sys.argv list, setting the first argument as the prompt variable. Here's a snippet of my current unsuccessful approach:

...
import sys
# Check for command-line arguments for the prompt
if len(sys.argv) > 1:
    prompt = sys.argv[1]
else:
    prompt = "beautiful scenery nature glass bottle yada yada yada"
...
        cliptextencode = cliptextencode.encode(
            text=prompt,
            clip=get_value_at_index(checkpointloadersimple_4, 1),
        )

I appreciate any guidance or suggestions you can provide. Thank you for your time and assistance.

@atmaranto
Copy link

I have created a system that dynamically generates command-line arguments based on the inputs that are not fulfilled for any node in the ComfyUI workflow (i.e., any input [including widget inputs converted to piped inputs] that is required but not connected to a node will be interpreted as a command-line input).

Unfortunately, this repo has not been active in some time. My fork is here which implements this system.

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

No branches or pull requests

2 participants