Code
import random
import gradio as gr
def random_response(message, history):
return random.choice(["Yes", "No"])
demo = gr.ChatInterface(random_response, type="messages", autofocus=False)
demo.launch()Runnable examples for the frozen Gradio Lite 5.45.0 browser runtime.
This coding playground returns a random yes or no response through gr.ChatInterface. Click Run, send a message, and inspect the two-value response function.
import random
import gradio as gr
def random_response(message, history):
return random.choice(["Yes", "No"])
demo = gr.ChatInterface(random_response, type="messages", autofocus=False)
demo.launch()