import random | |
import gradio as gr | |
import time | |
def random_response(message, history=[]): | |
for i in range(len(message)): | |
time.sleep(0.3) | |
yield "You typed: " + message[:i+1] | |
def yes_man(message, history=[]): | |
if message.endswith("?"): | |
return random.choice(["Yes", "No"]) | |
else: | |
return "Ask me anything!" | |
gr.ChatInterface( | |
yes_man, | |
chatbot = gr.Chatbot(height=300, placeholder = "<strong>Your Personal Y/N Bot</strong><br>Ask Me Anything"), | |
textbox = gr.Textbox(placeholder = "Ask me a yes or no question", container = False, scale = 7), | |
title = "Y/N Bot", | |
description = "Ask Yes Man any question", | |
theme = "soft", | |
examples = ["Hello", "Am I cool?", "Are tomatoes vegetables?"], | |
cache_examples = True, | |
retry_btn = None, | |
undo_btn = "Delete Previous", | |
clear_btn = "Clear", | |
).launch(share = True) | |