Spaces:
Sleeping
Sleeping
File size: 1,103 Bytes
e6868fd |
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 29 30 31 32 33 34 |
import gradio as gr
def converse(message, history, character):
print("User message:", message)
print("Chat history:", history)
print("Selected character:", character)
# Your chatbot logic here
response = f"You said: {message}. You're talking to {character}."
return response
def reset(character):
return [], []
# Gradio app
with gr.Blocks() as demo:
gr.Markdown(f"<h1 style='text-align: center; margin-bottom: 1rem'>{'My Chatbot'}</h1>")
bot = gr.Chatbot(render=False)
dropdown = gr.Dropdown(
["Character 1", "Character 2", "Character 3", "Character 4", "Character 5", "Character 6", "Character 7", "Character 8", "Character 9", "Character 10", "Character 11", "Character 12", "Character 13"],
label="Characters",
info="Select the character that you'd like to speak to",
value="Character 1"
)
chat = gr.ChatInterface(
fn=converse,
chatbot=bot,
additional_inputs=dropdown
)
dropdown.change(fn=reset, inputs=dropdown, outputs=[bot, chat.chatbot_state])
demo.queue()
demo.launch() |