Fix author's note token usage

This commit is contained in:
somebody 2022-08-11 18:21:49 -05:00
parent 555ca5fd05
commit a28faa0cb2
1 changed files with 10 additions and 5 deletions

View File

@ -3633,7 +3633,10 @@ def get_message(msg):
broadcast=True broadcast=True
) )
else: else:
if field == "anoteinput":
unencoded = buildauthorsnote(unencoded)
tokens_length = len(tokenizer.encode(unencoded)) tokens_length = len(tokenizer.encode(unencoded))
emit( emit(
'from_server', 'from_server',
{'cmd': 'showfieldbudget', 'data': {"length": tokens_length, "max": max_tokens, "field": field}}, {'cmd': 'showfieldbudget', 'data': {"length": tokens_length, "max": max_tokens, "field": field}},
@ -3969,6 +3972,12 @@ def actionredo():
#==================================================================# #==================================================================#
# #
#==================================================================# #==================================================================#
def buildauthorsnote(authorsnote):
# Build Author's Note if set
if authorsnote == "":
return ""
return ("\n" + vars.authornotetemplate + "\n").replace("<|>", authorsnote)
def calcsubmitbudgetheader(txt, **kwargs): def calcsubmitbudgetheader(txt, **kwargs):
# Scan for WorldInfo matches # Scan for WorldInfo matches
winfo, found_entries = checkworldinfo(txt, **kwargs) winfo, found_entries = checkworldinfo(txt, **kwargs)
@ -3979,11 +3988,7 @@ def calcsubmitbudgetheader(txt, **kwargs):
else: else:
mem = vars.memory mem = vars.memory
# Build Author's Note if set anotetxt = buildauthorsnote(vars.authornote)
if(vars.authornote != ""):
anotetxt = ("\n" + vars.authornotetemplate + "\n").replace("<|>", vars.authornote)
else:
anotetxt = ""
return winfo, mem, anotetxt, found_entries return winfo, mem, anotetxt, found_entries