h2oai / wave

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

feat: Add support for feedback events on chatbot responses #2165 #2178

Closed marek-mihok closed 7 months ago

marek-mihok commented 8 months ago

The PR fulfills these requirements: (check all the apply)


Usage example:

https://github.com/h2oai/wave/assets/23740173/1ff4870e-73f5-4d82-b053-384a0cb4ab0f

This PR also features an API change - added a feedback event:

/** 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 list or cyclic buffer. */
  data: Rec
  /** Chat input box placeholder. Use for prompt examples. */
  placeholder?: S
  /** The events to capture on this chatbot. One of 'stop' | 'scroll_up' | 'feedback'. */
  events?: S[]
  /** True to show a button to stop the text generation. Defaults to False. */
  generating?: B
  /** The previous messages to show as the user scrolls up. */
  prev_items?: ChatbotMessage[]
}

Closes #2165