mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-26 01:30:20 +01:00
Fix session saving
This commit is contained in:
parent
619cb4e78b
commit
890b4abdad
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
@ -78,7 +79,7 @@ def create_event_handlers():
|
|||||||
if not shared.args.multi_user:
|
if not shared.args.multi_user:
|
||||||
shared.gradio['save_session'].click(
|
shared.gradio['save_session'].click(
|
||||||
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
|
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
|
||||||
lambda x: json.dumps(x, indent=4), gradio('interface_state'), gradio('temporary_text')).then(
|
save_session, gradio('interface_state'), gradio('temporary_text')).then(
|
||||||
None, gradio('temporary_text'), None, _js=f"(contents) => {{{ui.save_files_js}; saveSession(contents)}}")
|
None, gradio('temporary_text'), None, _js=f"(contents) => {{{ui.save_files_js}; saveSession(contents)}}")
|
||||||
|
|
||||||
shared.gradio['load_session'].upload(
|
shared.gradio['load_session'].upload(
|
||||||
@ -98,3 +99,11 @@ def load_session(file, state):
|
|||||||
|
|
||||||
state.update(data)
|
state.update(data)
|
||||||
return state
|
return state
|
||||||
|
|
||||||
|
|
||||||
|
def save_session(state):
|
||||||
|
output = copy.deepcopy(state)
|
||||||
|
for key in ['prompt_menu-default', 'prompt_menu-notebook']:
|
||||||
|
del output[key]
|
||||||
|
|
||||||
|
return json.dumps(output, indent=4)
|
||||||
|
Loading…
Reference in New Issue
Block a user