Chats¶
The Chats family contains the widgets that render a chat interface in a view, allowing end users to write a prompt and to read the answer in a conversation. These widgets can be found in the Widgets panel of the stage, under the Chats entry.
The widgets of this family do not talk directly to an LLM. Every message written by the user is sent to a custom backend flow, which computes the answer and returns it to the widget to be displayed in the conversation. The flow can be any Rulex Factory flow containing a task that produces a Conversation structure, as the Generative AI and the Agentic AI tasks do.
The members of this family are:
For a general description of the Reasoning widgets, see this page.
Note
The event triggers available for the Chats widgets are:
onSendPrompt: the event is triggered when the user sends a prompt.
onReceiveAnswer: the event is triggered when the widget receives the answer from the backend.
Note
Chats widgets can be used in slides and dialogs only: they cannot be added to reports.
Chats Behavior¶
The behavior described in this section is common to all the Chats widgets.
Backend connection
Each widget of the Chats family needs to be connected to a custom backend flow, by filling the following options of its Layout options window:
Flow backend: the flow of the custom backend that answers the prompt.
Backend endpoint: the task of the flow to be considered to obtain the answer.
Prompt variable: the flow variable that receives the message written by the user.
If any of these three options is empty, the widget cannot send the message and an error is displayed.
When the user sends a message, the widget computes the selected task of the flow, after having set the flow variables named as in the Prompt variable option to the text of the message. The value is valid only for that computation and it is not saved in the flow. Single quotes contained in the message are automatically escaped.
The flow selected in the Flow backend option can be any flow satisfying the following requirements:
the task selected in the Backend endpoint option must produce a Conversation structure. This is the case, for example, of the Generative AI and of the Agentic AI tasks, whose Conversation output is described in the Outputs section of their pages;
the flow must contain a flow variable whose name matches the one specified in the Prompt variable option. The variable has to be used in the configuration of the task (for example in its Prompt option, by using the parametric mode), so that the message written by the user reaches the model.
Example
A flow made of a single Generative AI task, whose Prompt option is set through the flow variable prompt, can be used as a backend of a Chats widget by setting:
Flow backend: the name of the flow.
Backend endpoint: the name of the Generative AI task.
Prompt variable:
prompt.
If the flow returns an error, the error is displayed to the user and the conversation is not modified.
Warning
If the answer produced by the flow is not encoded in UTF-8, special characters (as for example accented letters) may not be displayed correctly. The widget tries to repair the most common wrong encodings, but the correct solution is to always produce the answer in UTF-8 in the flow.
Conversation
The messages of the conversation are displayed as follows:
The messages of the user are displayed as plain text.
The answers of the backend are displayed as HTML. For security reasons, the HTML is sanitized before being displayed: scripts and unsafe attributes are removed, while inline styles are kept.
While the widget waits for the answer, a loading animation is displayed along with a label randomly chosen among a set of thinking messages. The label changes every 10 seconds. During this time, the send button turns into a stop button that cancels the request.
The completed messages of the conversation are saved in the widget (text only), so that the conversation is preserved when the widget is refreshed, for example after closing its Layout options window. The conversation is cleared when the widget loads a different object or dashboard.
Warning
The conversation is not saved in the backend: it is lost when the view is closed.