Spaces:
Runtime error
Runtime error
File size: 1,335 Bytes
7d65e0a 8134690 724fac0 e40e075 7d65e0a e40e075 545d4dd 41b6d08 e40e075 41b6d08 bd1448a e40e075 545d4dd 136485e 545d4dd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import pip
pip.main(['install', 'transformers'])
pip.main(['install', 'torch'])
from transformers import pipeline
model_name_or_path = "dgnk007/crow"
def generate_response(message):
prompt_template=f"### instruct: {message} \n ### Bot:"
generate=pipeline('text-generation',model=model_name_or_path)
response=generate(prompt_template,max_length=1024,return_full_text=False,num_return_sequences=2)
return response[0]['generated_text'], response[1]['generated_text']
with gr.Blocks(theme=gr.themes.Soft()) as block:
with gr.Row():
with gr.Column():
input_box = gr.Textbox(label="Enter your text here:", min_width=600)
prompt = gr.Button("Submit", variant="primary")
with gr.Row():
gr.Examples(['what is google?','what is youtube?'], input_box,)
with gr.Row():
output_block = [
gr.Textbox(label="Response 1", interactive=False),
gr.Textbox(label="Response 2", interactive=False)
]
with gr.Row():
gr.Button(value="Tie")
gr.Button(value="Response 1 Wins",variant='primary')
gr.Button(value="Response 2 Wins",variant='primary')
gr.Button(value="Both are Bad",variant='secondary')
prompt.click(fn=generate_response, inputs=input_box, outputs=output_block)
block.launch() |