InvokeAI icon indicating copy to clipboard operation
InvokeAI copied to clipboard

feat(prompts): hotkey controlled prompt weighting

Open joshistoast opened this issue 1 month ago • 2 comments

Summary

Adds the ability to use keyboard controls to adjust prompt weightings using ctrl + up / down.

Related Issues / Discussions

https://discord.com/channels/1020123559063990373/1407078244531965963

QA Instructions

Merge Plan

Checklist

  • [x] The PR has a short but descriptive title, suitable for a changelog
  • [x] Tests added / updated (if applicable)
  • [ ] ❗Changes to a redux slice have a corresponding migration
  • [ ] Documentation added / updated (if applicable)
  • [ ] Updated What's New copy (if doing a release after this PR)

joshistoast avatar Oct 30 '25 08:10 joshistoast

I had a quick look at this, but couldn't figure out the UI for adjusting the prompt weightings. I guess the prompt weight code isn't wired up to the UI yet?

What is the intended interface? Does the user select a word or phrase in the prompt textbox and then presses ctrl-up/down in order to increase or decrease the weighting?

lstein avatar Nov 02 '25 19:11 lstein

I had a quick look at this, but couldn't figure out the UI for adjusting the prompt weightings. I guess the prompt weight code isn't wired up to the UI yet?

What is the intended interface? Does the user select a word or phrase in the prompt textbox and then presses ctrl-up/down in order to increase or decrease the weighting?

Yeah I've got a local implementation but it's not solid enough to commit yet. But yes that's the current way to use it (ctrl + up/down). There is a long list of rules to make sure it automagically makes intelligent selections to modify, some of those are in the discord forum on this topic.

joshistoast avatar Nov 02 '25 19:11 joshistoast

@joshistoast Just checking in to see if you're still working on this?

lstein avatar Nov 16 '25 14:11 lstein

@joshistoast Just checking in to see if you're still working on this?

@lstein Apologies for my tardiness on this, it's sitting on my PC at home mostly done but I'm out of state ATM. Will try to have this done within the month god willing.

joshistoast avatar Nov 20 '25 08:11 joshistoast

Including this here:

Behavior Rules:

ATTENTION SYNTAX:

  • Words support +/- attention: word+, word-, word++, word--, etc.
  • Groups support both +/- and numeric: (words)+, (words)1.2, (words)0.8
  • word++ is roughly equivalent to (word)1.2 in effect
  • Mixed attention like word+- or numeric on words word1.2 is invalid

ADJUSTMENT RULES:

  • word++ down → word+
  • word+ down → word (attention removed)
  • word down → word-
  • word- down → word--
  • (content)1.2 down → (content)1.1
  • (content)1.1 down → content (group unwrapped)
  • content content down → (content content)0.9 (new group created)

SELECTION BEHAVIOR:

  • Cursor/selection within a word → expand to full word, adjust word attention
  • Cursor touching group boundary (parens or weight) → adjust group attention
  • Selection entirely within a group → adjust that group's attention
  • Selection spans multiple content nodes → create new group with initial attention
  • Whitespace and punctuation are ignored for content selection

joshistoast avatar Nov 28 '25 20:11 joshistoast

Ctrl + Mouse Wheel would be great. It needs to get around the default zooming function somehow though.

ufuksarp avatar Dec 02 '25 08:12 ufuksarp

Yippee test succeeded

joshistoast avatar Dec 03 '25 05:12 joshistoast

You are still getting lint:prettier errors. I was able to fix this on my local copy using pnpm prettier --write invokeai/frontend. However, I don't have permission to push to your branch. Once all the tests pass, I'll merge your PR.

lstein avatar Dec 08 '25 22:12 lstein

You are still getting lint:prettier errors. I was able to fix this on my local copy using pnpm prettier --write invokeai/frontend. However, I don't have permission to push to your branch. Once all the tests pass, I'll merge your PR.

Fixed the lint issue. Also, I have Allow edits by maintainers checked, so I'm not sure why it's not letting you push to it.

joshistoast avatar Dec 08 '25 23:12 joshistoast