epam / ai-dial-chat

A default UI for AI DIAL
https://chat.lab.epam.com
Apache License 2.0
57 stars 24 forks source link

Add Interactive Action Buttons #1764

Open sergesha opened 2 months ago

sergesha commented 2 months ago

Proposal - #1764 Add Interactive Action Buttons

Description

Introduce the possibility to create and manage interactive buttons within the chat user interface. Such buttons would allow users to perform specific actions by clicking them. From an implementation perspective, such an action button would be linked to an arbitrary callback function in the backend. See more thoughts on implementation below.

Inspired by the Chainlit Actions concept.

Use case/motivation

Thoughts on UI

Placement of buttons

There are at least two "levels" of actions:

Our suggestion is to start with message-level actions since the implementation is more clear there. However, we may want to discuss conversation level actions as well so we can choose an initial implementation that is easier to extend later.

Sizing, text overflow

Buttons should expand in size to hold larger text, e.g.:

Action types (out of scope)

A future idea that could easily come on top of this and may inform current implementation: Different types of action buttons to indicate expected behavior, marked by dedicated icons and a meaningful tooltip.

The same look can be implemented without a dedicated feature for this, but standardizing the types would create a more unified user experience across various DIAL apps.

Thoughts on back-end

Chainlit uses WebSockets which facilitates easy back-and-forth sending of actions.
Since DIAL does not use WebSockets, we cannot take inspiration from Chainlit and need a different solution.

We have briefly explored various implementation possibilities and were able to make most of them work.
Before we invest more time, we would like to discuss these possibilities with the DIAL team to ensure alignment with the overall vision.

Sending "Actions" Definitions from DIAL App to DIAL Chat

Option 1: Using custom_content.state and Method set_state

Option 2: Extending Choice (entity from aidial_sdk.chat_completion)

Calling "Actions" from DIAL Chat to DIAL App

Option 1: Using custom_content.state

Option 2: Using custom_fields

Option 3: Extending DIAL SDK

Overall, it seems that for a proper implementation, changes are needed for the DIAL SDK and potentially DIAL CORE as well, as represented by the last option in each category.

Related issues

No response

Confidential information

sergesha commented 1 month ago

Here is a demo application, with actions implemented: https://github.com/WEAIDiscovery/dial-app-actions-demo