Spaces:
Sleeping
Sleeping
File size: 810 Bytes
83eaee2 0b48655 83eaee2 |
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 |
# !pip install gradio
import gradio as gr
from typing import List, Tuple
import numpy as np
def reset() -> List:
return []
def interact(chatbot: List[Tuple[str, str]], user_input: str) -> List[Tuple[str, str]]:
responses = ["You are right", "HaHa", "I don't know"]
response = np.random.choice(responses, 1)[0]
chatbot.append((user_input, response))
return chatbot
with gr.Blocks() as demo:
gr.Markdown(f"# Gradio Tutorial")
chatbot = gr.Chatbot()
input_textbox = gr.Textbox(label="Input", value = "")
with gr.Row():
sent_button = gr.Button(value="Send")
reset_button = gr.Button(value="Reset")
sent_button.click(interact, inputs=[chatbot, input_textbox], outputs=[chatbot])
reset_button.click(reset, outputs=[chatbot])
demo.launch(debug = True) |