Add a grammar editor to the UI (#4061)

This commit is contained in:
oobabooga 2023-09-24 18:05:24 -03:00 committed by GitHub
parent 08c4fb12ae
commit 08cf150c0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 75 additions and 62 deletions

View file

@ -73,3 +73,15 @@ def create_event_handlers():
lambda x: f'{x}.yaml', gradio('preset_menu'), gradio('delete_filename')).then(
lambda: 'presets/', None, gradio('delete_root')).then(
lambda: gr.update(visible=True), None, gradio('file_deleter'))
shared.gradio['save_grammar'].click(
ui.gather_interface_values, gradio(shared.input_elements), gradio('interface_state')).then(
lambda x: x, gradio('grammar_string'), gradio('save_contents')).then(
lambda: 'grammars/', None, gradio('save_root')).then(
lambda: 'My Fancy Grammar.gbnf', None, gradio('save_filename')).then(
lambda: gr.update(visible=True), None, gradio('file_saver'))
shared.gradio['delete_grammar'].click(
lambda x: x, gradio('grammar_file'), gradio('delete_filename')).then(
lambda: 'grammars/', None, gradio('delete_root')).then(
lambda: gr.update(visible=True), None, gradio('file_deleter'))