""" Self-contained Gradio Chatbot demo. Run: python gradio_chatbot.py Then visit the URL printed in the terminal. """ import gradio as gr import time def slow_echo(message, history): """ Very simple streaming echo bot. You can swap this for an LLM call (OpenAI, transformers, etc.). """ response = f"Echo: {message}" for i in range(len(response)): time.sleep(0.02) # pretend we’re “typing” yield response[: i + 1] demo = gr.ChatInterface( fn=slow_echo, title="Echo Bot 🤖", description="Type anything and watch the bot echo you back, streaming.", examples=["Hello, world!", "Gradio rocks!"], theme="soft", cache_examples=False, ) if __name__ == "__main__": demo.launch()