mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-11-05 00:17:25 +00:00
[GH-ISSUE #193] [FEATURE REQUEST] Allow pairing of Lora/Lycoris with Trigger Words #136
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
low priority
low priority
pull-request
question
waiting for feedback
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
DominikDoom/a1111-sd-webui-tagcomplete#136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @createchange on GitHub (Jul 3, 2023).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/193
Originally assigned to: @DominikDoom on GitHub.
Hi,
I have extra networks that I use which require trigger words. I would like to be able to autocomplete both the (in my case) Lycoris with the triggerword(s).
I explored this extension which offers some sort of functionality to this end, but it is not user friendly. For instance, you cannot include multiple extra networks in a prompt.
I have considered that I can just create pairings in the
extra fileconfig, and disregard auto-complete for the networks, but that means I lose some of the auto-discovery functionality which is not desirable. Alternatively, I can use both autocomplete and extra file in tandem - one to load up the network, and the other to pull in desired tags. This works, but is not super ideal, either.Any thoughts on potentially incorporating some sort of system to this end?
@DominikDoom commented on GitHub (Jul 3, 2023):
The extension you mentioned seems to use a pre-configured list with known keywords and an option to manually add more.
It would be out of scope for me to maintain my own list for stuff like this or scour civitai for keywords, but I could give it a try to use their existing list if both extensions are installed.
Main difficulty here is that their system is hash-based, hash calculation can take a bit and isn't a good fit for real time completion. They use the old method where hash is built from the first x bytes of the file instead of a proper full hash, but it is still a delay. And I probably can't use the list as-is without mirroring their hash system. But at least the manual way would definitely be an option.
Another question would be where to insert them, since text position matters. Probably an option to choose between start or end would be best.
@DominikDoom commented on GitHub (Jul 8, 2023):
I finally made some progress on this. It does in fact use the model-keyword extension list, so a lot of stuff will work out of the box.
Once it is installed, model-keyword can also be disabled, since we only care about the default keyword list they provide (which is updated quite often, probably automatically).
Custom mappings will also work, they can be set through the model-keyword UI and are saved in a lora-keyword-user.txt file.
I calculate the hashes in the same format for all local lora/lycos and cache them until they are modified, so they can be compared with the model-keyword lists later without needing to recalculate at every start (although the method is quite fast anyway since it only looks at the first few bytes like older webui versions). However, this can also lead to hash collisions which will override the previous keywords with the last loaded ones, but hopefully this will be rare enough to be ignorable. model-keyword has the same issues there.
The main problem is that model-keyword has no support for Lycos at this moment, and their built-in list also doesn't contain any keywords for lycos at the moment, from what I've seen. You can also only select models from the Lora folder in the UI to add custom mappings, so it's a bit of a hassle to add Lycos. One option would be to move the lycos into a temporary Lora subfolder, add them in the UI, then move them back. The other option would be to visit the respective Civitai page and copy the "AUTOV1" hash from there (which can be accessed by cycling through the hash field with the arrow next to it), and then write that hash and the keywords to the lora-keyword-user.txt file manually.
Another issue is undoability, currently if you don't want the keywords you need to disable the option for it beforehand. Since they are added programmatically, CTRL-Z to undo them will not work (there are some methods, but all deprecated or requiring a custom history implementation). Before this is merged, I want to try to add the latter (or at least a one-time undo) so they can be removed fast if they were added by mistake.
But you can check out the https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/tree/feature-trigger-word-completion branch to try it out, feedback would be appreciated. You need to enable it in the settings:

For now, it also always adds the keywords to the beginning of the prompt for simplicity.
@createchange commented on GitHub (Jul 13, 2023):
That was quite a quick turnaround! My response took longer than the work you put in.
Unfortunately, that branch appears to be broken at present. When installing it, autocompletion fails outright. Additionally, I receive an error when trying to
Refresh TAC temp files.Is my experience expected? I recognize that the branch could be in a different state from when you responded.
@DominikDoom commented on GitHub (Jul 13, 2023):
No, that would definitely be unexpected. The main branch is only one commit ahead, and that is a non-critical small fix.
For me, completion and refreshing the files still works without problems on the feature branch, and I didn't change anything there since my original answer.
It will also just print "Tag Autocomplete: Could not locate model-keyword extension, LORA/LYCO trigger word completion will be unavailable." in the console if it can't find the necessary mapping files, so I don't think it's related to that.
Can you give me some more details on the errors you are getting? Both the webui terminal and the browser console are relevant.
Since the refresh fails, it seems path related, so maybe I overlooked something that isn't properly getting set up for you.
@a-krum-of-bread-learns commented on GitHub (Jul 18, 2023):
I like this idea and want it even if I need to manually input the trigger words for each LORA/LYCO I use. how close is it to that kind of state.
@DominikDoom commented on GitHub (Jul 19, 2023):
@a-krum-of-bread Well, you can try out the branch right now. It does work both with the preset and custom added trigger words specified in the model-keyword extension already.
The only thing missing before I will add it to the main branch is what I mentioned above, an easy way to remove the keywords if you don't want them that time, along with some minor stuff like more settings. Which I hope to finish this week.
@DominikDoom commented on GitHub (Jul 22, 2023):
I was able to mostly finish it up today and merge it, hopefully it works for you now without issues.
For more info on how it works, see the accompanying README section.
For now it always inserts at the beginning of the prompt, but I think that will be sufficient for most use cases.
@createchange commented on GitHub (Jul 26, 2023):
Sorry for not checking back in on this til now. I have limited time for SD. However, I tested out the extension updates, and it works great! Thanks for putting in the work to make using LORAs that much easier.