Chatbot

Runnable examples for the frozen Gradio Lite 5.45.0 browser runtime.

Build a minimal synchronous Gradio ChatInterface.

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.

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()
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()