Skip to content

Commit

Permalink
Fix broken extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Mar 15, 2023
1 parent c5f14fb commit 348596f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 7 additions & 3 deletions modules/extensions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import gradio as gr

import extensions
import modules.shared as shared

Expand Down Expand Up @@ -40,6 +42,8 @@ def create_extensions_block():
extension.params[param] = shared.settings[_id]

# Creating the extension ui elements
for extension, name in iterator():
if hasattr(extension, "ui"):
extension.ui()
with gr.Box(elem_id="#extensions"):
gr.Markdown("Extensions")
for extension, name in iterator():
if hasattr(extension, "ui"):
extension.ui()
17 changes: 9 additions & 8 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ def create_settings_menus(default_preset):
shared.gradio['chat_generation_attempts'] = gr.Slider(minimum=shared.settings['chat_generation_attempts_min'], maximum=shared.settings['chat_generation_attempts_max'], value=shared.settings['chat_generation_attempts'], step=1, label='Generation attempts (for longer replies)')
shared.gradio['check'] = gr.Checkbox(value=shared.settings[f'stop_at_newline{suffix}'], label='Stop generating at new line character?')

if shared.args.extensions is not None:
extensions_module.create_extensions_block()

with gr.Tab("Chat settings", elem_id="chat-settings"):
shared.gradio['name1'] = gr.Textbox(value=shared.settings[f'name1{suffix}'], lines=1, label='Your name')
shared.gradio['name2'] = gr.Textbox(value=shared.settings[f'name2{suffix}'], lines=1, label='Bot\'s name')
Expand Down Expand Up @@ -278,6 +275,9 @@ def create_settings_menus(default_preset):
with gr.Tab("Settings", elem_id="settings"):
create_settings_menus(default_preset)

if shared.args.extensions is not None:
extensions_module.create_extensions_block()

function_call = 'chat.cai_chatbot_wrapper' if shared.args.cai_chat else 'chat.chatbot_wrapper'
shared.input_params = [shared.gradio[k] for k in ['textbox', 'max_new_tokens', 'do_sample', 'temperature', 'top_p', 'typical_p', 'repetition_penalty', 'encoder_repetition_penalty', 'top_k', 'min_length', 'no_repeat_ngram_size', 'num_beams', 'penalty_alpha', 'length_penalty', 'early_stopping', 'name1', 'name2', 'context', 'check', 'chat_prompt_size_slider', 'chat_generation_attempts']]

Expand Down Expand Up @@ -340,12 +340,12 @@ def create_settings_menus(default_preset):
shared.gradio['max_new_tokens'] = gr.Slider(minimum=shared.settings['max_new_tokens_min'], maximum=shared.settings['max_new_tokens_max'], step=1, label='max_new_tokens', value=shared.settings['max_new_tokens'])

create_model_and_preset_menus()
if shared.args.extensions is not None:
extensions_module.create_extensions_block()

with gr.Tab("Settings", elem_id="settings"):
create_settings_menus(default_preset)

if shared.args.extensions is not None:
extensions_module.create_extensions_block()

shared.input_params = [shared.gradio[k] for k in ['textbox', 'max_new_tokens', 'do_sample', 'temperature', 'top_p', 'typical_p', 'repetition_penalty', 'encoder_repetition_penalty', 'top_k', 'min_length', 'no_repeat_ngram_size', 'num_beams', 'penalty_alpha', 'length_penalty', 'early_stopping']]
output_params = [shared.gradio[k] for k in ['textbox', 'markdown', 'html']]
gen_events.append(shared.gradio['Generate'].click(generate_reply, shared.input_params, output_params, show_progress=shared.args.no_stream, api_name='textgen'))
Expand All @@ -368,8 +368,6 @@ def create_settings_menus(default_preset):
shared.gradio['Stop'] = gr.Button('Stop')

create_model_and_preset_menus()
if shared.args.extensions is not None:
extensions_module.create_extensions_block()

with gr.Column():
with gr.Tab('Raw'):
Expand All @@ -381,6 +379,9 @@ def create_settings_menus(default_preset):
with gr.Tab("Settings", elem_id="settings"):
create_settings_menus(default_preset)

if shared.args.extensions is not None:
extensions_module.create_extensions_block()

shared.input_params = [shared.gradio[k] for k in ['textbox', 'max_new_tokens', 'do_sample', 'temperature', 'top_p', 'typical_p', 'repetition_penalty', 'encoder_repetition_penalty', 'top_k', 'min_length', 'no_repeat_ngram_size', 'num_beams', 'penalty_alpha', 'length_penalty', 'early_stopping']]
output_params = [shared.gradio[k] for k in ['output_textbox', 'markdown', 'html']]
gen_events.append(shared.gradio['Generate'].click(generate_reply, shared.input_params, output_params, show_progress=shared.args.no_stream, api_name='textgen'))
Expand Down

0 comments on commit 348596f

Please sign in to comment.