mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
5b827f5b2c
* remove webcam from video demo * remove blocks_gpt and blocks_neural_instrument_coding demos * only show Try Examples if examples exist * remove if name = main from rendereed code * rename demos that have same name as component * remove references to old demo names from guides * add model3d demo
29 lines
723 B
Python
29 lines
723 B
Python
import random
|
|
|
|
import gradio as gr
|
|
|
|
|
|
def chat(message, history):
|
|
history = history or []
|
|
if message.startswith("How many"):
|
|
response = random.randint(1, 10)
|
|
elif message.startswith("How"):
|
|
response = random.choice(["Great", "Good", "Okay", "Bad"])
|
|
elif message.startswith("Where"):
|
|
response = random.choice(["Here", "There", "Somewhere"])
|
|
else:
|
|
response = "I don't know"
|
|
history.append((message, response))
|
|
return history, history
|
|
|
|
chatbot = gr.Chatbot(color_map=("green", "gray"))
|
|
demo = gr.Interface(
|
|
chat,
|
|
["text", "state"],
|
|
[chatbot, "state"],
|
|
allow_screenshot=False,
|
|
allow_flagging="never",
|
|
)
|
|
if __name__ == "__main__":
|
|
demo.launch()
|