mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 01:09:22 +01:00
Instruction template: make "Send to default/notebook" work without a tokenizer
This commit is contained in:
parent
f465b7b486
commit
0e1d8d5601
@ -166,11 +166,12 @@ def generate_chat_prompt(user_input, state, **kwargs):
|
|||||||
prompt = remove_extra_bos(prompt)
|
prompt = remove_extra_bos(prompt)
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
# Handle truncation
|
|
||||||
max_length = get_max_prompt_length(state)
|
|
||||||
prompt = make_prompt(messages)
|
prompt = make_prompt(messages)
|
||||||
encoded_length = get_encoded_length(prompt)
|
|
||||||
|
|
||||||
|
# Handle truncation
|
||||||
|
if shared.tokenizer is not None:
|
||||||
|
max_length = get_max_prompt_length(state)
|
||||||
|
encoded_length = get_encoded_length(prompt)
|
||||||
while len(messages) > 0 and encoded_length > max_length:
|
while len(messages) > 0 and encoded_length > max_length:
|
||||||
|
|
||||||
# Remove old message, save system message
|
# Remove old message, save system message
|
||||||
|
@ -109,7 +109,7 @@ def create_chat_settings_ui():
|
|||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Column():
|
with gr.Column():
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
shared.gradio['instruction_template'] = gr.Dropdown(choices=utils.get_available_instruction_templates(), label='Saved instruction templates', value='Select template to load...', elem_classes='slim-dropdown')
|
shared.gradio['instruction_template'] = gr.Dropdown(choices=utils.get_available_instruction_templates(), label='Saved instruction templates', info="After selecting the template, click on \"Load\" to load and apply it.", value='Select template to load...', elem_classes='slim-dropdown')
|
||||||
ui.create_refresh_button(shared.gradio['instruction_template'], lambda: None, lambda: {'choices': utils.get_available_instruction_templates()}, 'refresh-button', interactive=not mu)
|
ui.create_refresh_button(shared.gradio['instruction_template'], lambda: None, lambda: {'choices': utils.get_available_instruction_templates()}, 'refresh-button', interactive=not mu)
|
||||||
shared.gradio['load_template'] = gr.Button("Load", elem_classes='refresh-button')
|
shared.gradio['load_template'] = gr.Button("Load", elem_classes='refresh-button')
|
||||||
shared.gradio['save_template'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu)
|
shared.gradio['save_template'] = gr.Button('💾', elem_classes='refresh-button', interactive=not mu)
|
||||||
|
Loading…
Reference in New Issue
Block a user