Spaces:
Sleeping
Sleeping
File size: 870 Bytes
2656fac 8c4fdc3 2656fac | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import gradio as gr
import random
def prefill_chatbot(choice):
if choice == "Greeting":
return [
{"role": "user", "content": "Hi there!"},
{"role": "assistant", "content": "Hello! How can I assist you today?"}
]
elif choice == "Complaint":
return [
{"role": "user", "content": "I'm not happy with the service."},
{"role": "assistant", "content": "I'm sorry to hear that. Can you please tell me more about the issue?"}
]
else:
return []
def random_response(message, history):
return random.choice(["Yes", "No"])
with gr.Blocks() as demo:
radio = gr.Radio(["Greeting", "Complaint", "Blank"])
chat = gr.ChatInterface(random_response, api_name="chat")
radio.change(prefill_chatbot, radio, chat.chatbot_value)
if __name__ == "__main__":
demo.launch()
|