h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.98k stars 327 forks source link

feat: Add stop button to ui.chatbot #2011 #2018

Closed marek-mihok closed 1 year ago

marek-mihok commented 1 year ago

This change improves the ui.chatbot component by allowing user to stop the generation of bot's response with a Stop generating button. This button is visible only if a new generating prop is set to True and the stop event is triggered only if it is registered within events prop first, please see the updated API:

/** Create a chatbot card to allow getting prompts from users and providing them with LLM generated answers. */
export interface Chatbot {
  /** An identifying name for this component. */
  name: Id
  /** Chat messages data. Requires cyclic buffer. */
  data: Rec[]
  /** Chat input box placeholder. Use for prompt examples. */
  placeholder?: S
  /** The events to capture on this chatbot. One of 'stop'. */
  events?: S[]
  /** True to show a button to stop the text generation. Defaults to False. */
  generating?: B
}

chatbot_events_stop

Closes #2011

marek-mihok commented 1 year ago

@mturoci good point! It's added. Also I've updated our tour examples with a new chatbot_events_stop.py example. It uses a map buffer for now, but we can update it once the new list buffer is merged.