Spaces:
Runtime error
Runtime error
nanthaaxim
commited on
Commit
·
545d4dd
1
Parent(s):
5cbb6c9
gradio update
Browse files
app.py
CHANGED
@@ -6,12 +6,29 @@ from transformers import pipeline
|
|
6 |
|
7 |
model_name_or_path = "dgnk007/crow"
|
8 |
|
9 |
-
|
10 |
-
def chatbot(message):
|
11 |
prompt_template=f'### instruct: {message} \n### Bot: '
|
12 |
generate=pipeline('text-generation',model=model_name_or_path)
|
13 |
response=generate(prompt_template,max_length=128,return_full_text=False,num_return_sequences=2)
|
14 |
return response[0]['generated_text'], response[1]['generated_text']
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
model_name_or_path = "dgnk007/crow"
|
8 |
|
9 |
+
def generate_response(message):
|
|
|
10 |
prompt_template=f'### instruct: {message} \n### Bot: '
|
11 |
generate=pipeline('text-generation',model=model_name_or_path)
|
12 |
response=generate(prompt_template,max_length=128,return_full_text=False,num_return_sequences=2)
|
13 |
return response[0]['generated_text'], response[1]['generated_text']
|
14 |
|
15 |
+
with gr.Blocks(theme=gr.themes.Soft()) as block:
|
16 |
+
with gr.Row():
|
17 |
+
with gr.Column():
|
18 |
+
input_box = gr.Textbox(lines=5, label="Enter your text here:", min_width=600)
|
19 |
+
prompt = gr.Button("Submit", variant="primary")
|
20 |
+
with gr.Row():
|
21 |
+
gr.Examples(['what is google?','what is youtube?'], input_box,)
|
22 |
+
with gr.Row():
|
23 |
+
output_block = [
|
24 |
+
gr.Textbox(label="Response 1", interactive=False),
|
25 |
+
gr.Textbox(label="Response 2", interactive=False)
|
26 |
+
]
|
27 |
+
with gr.Row():
|
28 |
+
gr.Button(value="Tie")
|
29 |
+
gr.Button(value="Response 1 Wins",variant='primary')
|
30 |
+
gr.Button(value="Response 2 Wins",variant='primary')
|
31 |
+
gr.Button(value="Both are Bad",variant='secondary')
|
32 |
+
prompt.click(fn=generate_response, inputs=input_box, outputs=output_block)
|
33 |
+
|
34 |
+
block.launch()
|