mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-01-11 13:00:34 +01:00
Update character log logic (#977)
* When logs are cleared, save the cleared log over the old log files * Generate a log file when a character is loaded the first time
This commit is contained in:
parent
57f768eaad
commit
625d81f495
@ -285,6 +285,9 @@ def clear_chat_log(name1, name2, greeting, mode):
|
||||
shared.history['internal'] += [['<|BEGIN-VISIBLE-CHAT|>', greeting]]
|
||||
shared.history['visible'] += [['', apply_extensions(greeting, "output")]]
|
||||
|
||||
# Save cleared logs
|
||||
save_history(timestamp=False)
|
||||
|
||||
return chat_html_wrapper(shared.history['visible'], name1, name2, mode)
|
||||
|
||||
|
||||
@ -434,10 +437,15 @@ def load_character(character, name1, name2, mode):
|
||||
|
||||
if Path(f'logs/{shared.character}_persistent.json').exists():
|
||||
load_history(open(Path(f'logs/{shared.character}_persistent.json'), 'rb').read(), name1, name2)
|
||||
elif greeting != "":
|
||||
else:
|
||||
# Insert greeting if it exists
|
||||
if greeting != "":
|
||||
shared.history['internal'] += [['<|BEGIN-VISIBLE-CHAT|>', greeting]]
|
||||
shared.history['visible'] += [['', apply_extensions(greeting, "output")]]
|
||||
|
||||
# Create .json log files since they don't already exist
|
||||
save_history(timestamp=False)
|
||||
|
||||
return name1, name2, picture, greeting, context, end_of_turn, chat_html_wrapper(shared.history['visible'], name1, name2, mode, reset_cache=True)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user