Hi Guys, i am Currently working on Designing my Custom Chat bot, i am trying to create customizable ‘settings’ that change the prompts in the backend. I designed the widgets ‘Chat’, ‘Entscheidungszeitraum’ and ‘Zuständigkeitsbereich’ and i want the send button to only be displayed and active when i am using the widget ‘Chat’. Does anybody know how I can interactively display the send button dependant on the currently active widget?
Code
chat_bot = pn.chat.ChatInterface(callback=get_single_response, avatar=user_avatar,
widgets=[pn.chat.ChatAreaInput(placeholder="Was möchten Sie wissen?", name='Chat'),
date_range_slider, county_selection ], user=user_name,
show_rerun=False, show_undo=False, show_clear=False)
Screenshot
def toggle_send(active):
if active == 0:
return True
else:
return False
chat_bot = pn.chat.ChatInterface(callback=get_single_response, avatar=user_avatar,
widgets=[pn.chat.ChatAreaInput(placeholder="Was möchten Sie wissen?", name='Chat'),
date_range_slider, county_selection ], user=user_name,
show_rerun=False, show_undo=False, show_clear=False)
chat_bot.show_send = pn.bind(toggle_send, chat_bot.param.active)
Hi Andrew,
thank you for your response, sadly I could not get your code chunk to work, but based on your idea i solved my problem using the following code:
def toggle_send(event):
active = event.obj.active
if active == 0:
chat_bot.show_send = True
else:
chat_bot.show_send = False
chat_bot = pn.chat.ChatInterface(avatar=user_avatar,callback=get_single_response ,widgets=[
pn.chat.ChatAreaInput(placeholder="Was möchten Sie wissen?", name='Chat'), date_range_slider, county_selection
], user=user_name, show_rerun=False, show_undo=False, show_clear=False, show_send=True)
chat_bot._input_layout.param.watch(toggle_send, ['active'], onlychanged=False)
temp.main.append(chat_bot)
temp.servable()
pn.serve(temp)