pull/180/head
AIrjen 2024-04-05 10:17:23 +02:00
parent 9f714d2723
commit b3d9899534
4 changed files with 45 additions and 11 deletions

View File

@ -4808,16 +4808,17 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s
# check if its matching all words from the override: # check if its matching all words from the override:
possible_words_to_check = override_subject.lower().split() + override_outfit.lower().split() possible_words_to_check = override_subject.lower().split() + override_outfit.lower().split()
# print(possible_words_to_check) #print(possible_words_to_check)
words_to_check = [] words_to_check = []
words_to_remove = ['subject', 'solo', '1girl', '1boy'] words_to_remove = ['subject', 'solo', '1girl', '1boy']
for word in possible_words_to_check: for word in possible_words_to_check:
word = word.translate(translation_table_remove_stuff) word = word.translate(translation_table_remove_stuff)
#print(word)
if word not in words_to_remove: if word not in words_to_remove:
if not word.startswith("-") and not word.endswith("-"): if (not word.startswith("-") and not word.endswith("-")) and (not word.startswith("_") and not word.endswith("_")) :
words_to_check.append(word) words_to_check.append(word)
#print(words_to_check)
if chosensubject not in ("humanoid","firstname","job","fictional","non fictional","human"): if chosensubject not in ("humanoid","firstname","job","fictional","non fictional","human"):
gender = "" gender = ""
if(superpromptstyle == "" or superpromptstyle == "all"): if(superpromptstyle == "" or superpromptstyle == "all"):
@ -4866,7 +4867,6 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s
question += "Expand the following " + gender + " " + subject_to_generate + " prompt to make it more " + superpromptstyle question += "Expand the following " + gender + " " + subject_to_generate + " prompt to make it more " + superpromptstyle
else: else:
question += "Expand the following " + gender + " " + subject_to_generate + " prompt to add more detail: " question += "Expand the following " + gender + " " + subject_to_generate + " prompt to add more detail: "
# question = "Expand the following fantasy character prompt to describe a portrait: "
@ -4936,11 +4936,12 @@ def one_button_superprompt(insanitylevel = 5, prompt = "", seed = -1, override_s
return superpromptresult return superpromptresult
def replace_user_wildcards(completeprompt): def replace_user_wildcards(completeprompt):
user_wildcards_list = re.findall(r'-[\w_]*-', completeprompt) for i in range(0,10):
for user_wildcard in user_wildcards_list: user_wildcards_list = re.findall(r'-[\w_]*-', completeprompt)
user_wildcard_clean = user_wildcard.strip("-") for user_wildcard in user_wildcards_list:
wordlist = csv_to_list(csvfilename=user_wildcard_clean, directory="./userfiles/") user_wildcard_clean = user_wildcard.strip("-")
if(wordlist): wordlist = csv_to_list(csvfilename=user_wildcard_clean, directory="./userfiles/wildcards/")
completeprompt = completeprompt.replace(user_wildcard, random.choice(wordlist),1) if(wordlist):
completeprompt = completeprompt.replace(user_wildcard, random.choice(wordlist),1)
return completeprompt return completeprompt

View File

@ -31,6 +31,7 @@ def csv_to_list(csvfilename, antilist=[], directory="./csvfiles/", lowerandstrip
full_path = os.path.join(script_dir, directory ) full_path = os.path.join(script_dir, directory )
userfilesfolder = os.path.join(script_dir, userfilesdirectory ) userfilesfolder = os.path.join(script_dir, userfilesdirectory )
directoryfilesfolder = os.path.join(script_dir, directory ) directoryfilesfolder = os.path.join(script_dir, directory )
# check if there is a replace file # check if there is a replace file
if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/" or directory=="./csvfiles/templates/"): if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/" or directory=="./csvfiles/templates/"):
for filename in os.listdir(userfilesfolder): for filename in os.listdir(userfilesfolder):
@ -81,6 +82,26 @@ def csv_to_list(csvfilename, antilist=[], directory="./csvfiles/", lowerandstrip
csvlist.append(row[0].lower().strip()) csvlist.append(row[0].lower().strip())
else: else:
csvlist.append(row[0]) csvlist.append(row[0])
# dirty hack for possible .txt files
if(os.path.isfile(full_path + csvfilename + ".txt")):
with open(full_path + csvfilename + ".txt", "r", newline="",encoding="utf8") as file:
reader = csv.reader(file, delimiter=delimiter)
if(skipheader==True):
next(reader)
if(listoflistmode==True):
csvlist = list(reader)
else:
for row in reader:
value = row[0]
if(
gender != "all" and (row[1] == gender or row[1] == "genderless" or row[1] == "both")
or gender == "all"
):
if(value.lower().strip() not in antilist):
if(lowerandstrip == 1):
csvlist.append(row[0].lower().strip())
else:
csvlist.append(row[0])
# do the add ons! # do the add ons!
if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/"): if(directory=="./csvfiles/" or directory=="./csvfiles/special_lists/"):

View File

@ -0,0 +1,6 @@
Add wildcard files here, if you can't make use of Dynamic Prompts.
Files can be called as "sample_wildcard.csv" and are then usable in One Button Prompt with -sample_wildcard- as the wildcard.
.txt files are also supported here.
It is not possible to call build-in wildcards from the custom wildcards.
It is possible to nest custom wildcards with other custom wildcards (up to 10 deep). To do this, use the -wildcard- notation inside a wildcard.

View File

@ -0,0 +1,6 @@
Cool banana wearing sunglasses
Cute Norwegian forest cat
Sock puppet version of Ed Sheeran
An evil wizard casting a spell
The demon queen of hell laughing manically
person wearing a cool hat
1 Cool banana wearing sunglasses
2 Cute Norwegian forest cat
3 Sock puppet version of Ed Sheeran
4 An evil wizard casting a spell
5 The demon queen of hell laughing manically
6 person wearing a cool hat