import random import gradio as gr def response(message, history): if "吗?" in message: response_text_tmp = message.replace("吗?", "!") if "我" in response_text_tmp: response_text = response_text_tmp.replace("我", "你") else: response_text=response_text_tmp else: responses = ["I'm not sure.", "Interesting.", "Tell me more!"] response_text = random.choice(responses) return response_text demo = gr.ChatInterface( response, title="Please Ask Me", description="Only the Yes-no question with 吗?, can I give u certain answer!", ) demo.launch()