Spaces:
Sleeping
Sleeping
# !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) |