6 Commits

Author SHA1 Message Date
oobabooga
776b7914bf Delete Open Assistant.txt 2023-04-04 12:55:55 -03:00
oobabooga
2944c6d204 Delete Alpaca.txt 2023-04-04 12:55:47 -03:00
oobabooga
cbaa231a0a Delete dummy.txt 2023-04-04 12:55:22 -03:00
oobabooga
065383ec67 Add files via upload 2023-04-04 12:55:05 -03:00
oobabooga
214dd6307e Create dummy.txt 2023-04-04 12:54:37 -03:00
oobabooga
a500061b08 Create script.py 2023-04-04 12:54:04 -03:00
4 changed files with 53 additions and 3 deletions

View File

@@ -0,0 +1,51 @@
from pathlib import Path
import gradio as gr
from modules import shared
from modules import ui as _ui
params = {
'template': '%input%'
}
def get_available_templates():
return ['None'] + sorted(set((k.stem for k in Path('extensions/prompt_template/templates').glob('*.txt'))), key=str.lower)
def load_template(fname):
if fname in ['None', '']:
return '%input%'
else:
with open(Path(f'extensions/prompt_template/templates/{fname}.txt'), 'r', encoding='utf-8') as f:
text = f.read()
if text[-1] == '\n':
text = text[:-1]
return text
def input_modifier(string):
"""
This function is applied to your text inputs before
they are fed into the model.
"""
return params['template'].replace('%input%', string)
def output_modifier(string):
return f'\n{string}'
def setup():
shared.args.verbose = True
def ui():
# Gradio elements
with gr.Row():
with gr.Column():
template = gr.Textbox(value=params['template'], info="%input% will be replaced with your user input.", label='Template')
with gr.Column():
with gr.Row():
template_menu = gr.Dropdown(choices=get_available_templates(), value='None', label='Available templates')
_ui.create_refresh_button(shared.gradio['model_menu'], lambda : None, lambda : {'choices': get_available_templates()}, 'refresh-button')
template_menu.change(load_template, template_menu, template)
template.change(lambda x: params.update({"template": x}), template, None)

View File

@@ -1,6 +1,5 @@
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Write a poem about the transformers Python library.
Mention the word "large language models" in that poem.
%input%
### Response:

View File

@@ -0,0 +1 @@
<|prompter|>%input%<|endoftext|><|assistant|>

View File

@@ -1 +0,0 @@
<|prompter|>Write a story about future of AI development<|endoftext|><|assistant|>