AI
AiMessageActions
BitAiMessageActions is the row under a finished assistant message: copy, read aloud (with a BitAiReadAloud), regenerate (with a session, for the newest reply) and thumbs up or down feedback, plus extra buttons of the app's own, and the metadata the BitAiUiOptions in force choose to show - the model, the token usage, the time. The actions are revealed while the message is hovered or holds the focus; the metadata is always shown. BitAiChatMessage renders one under every reply.
Notes
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Pinned
Feedback
Regenerate
Extra actions
Options
Disabled
Cascading parameters
Read aloud
Style & Class
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle it - and any instance nested inside it, which inherits the value too; a parameter changes one alone,
as does the real CSS property on the instance's Style / Styles when that property does not inherit (opacity: 1 keeps
one disabled instance undimmed without undimming a disabled one inside it), while an inherited one such as color or
font-family also reaches the nested instances that do not set it themselves. Leave a variable unset and the component
falls back to the theme token beside it.
BitAiMessageActions CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-AiMessageActions-gap | spacing(1.5) | Room between the group of actions and each piece of metadata. |
| --bit-AiMessageActions-actions-gap | spacing(0.5) | Room between two action buttons. |
| --bit-AiMessageActions-color | var(--bit-clr-fg-ter) | Text of the metadata: the model, the usage and the time. |
| --bit-AiMessageActions-font-size | var(--bit-tpg-fs-xs) | Size of the metadata. |
| --bit-AiMessageActions-error-color | var(--bit-clr-err-fg) | Text saying that reading the reply aloud failed. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitAiMessageActions parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| CanRegenerate | bool | true | Offers regeneration of the message, when a Session is given. Only the newest assistant message should offer it, since regenerating an older one discards everything after it; a BitAiChatMessage sets it from its IsLatest. |
| Classes | BitAiMessageActionsClassStyles? | null | Custom CSS classes for different parts of the message actions. |
| ExtraActionsTemplate | RenderFragment? | null | The extra buttons appended to the row of actions, after the feedback buttons. They are revealed and hidden with the built-in ones, and left out with them when the ShowMessageActions of the options in force is off. |
| Message | BitAiMessage | The message these actions belong to (required): what copy copies, what feedback is recorded on, and where the model, the usage and the time are read from. | |
| OnFeedback | EventCallback<BitAiFeedbackKind> | The callback for when the user records feedback, so a host can persist it: Positive or Negative, or None when the user pressed the chosen one again to withdraw it. The message's Feedback is already updated when it is raised. A BitAiChatMessage (and the BitAiMessageList and BitAiChat around it) reports the same choice through its own OnFeedback as a BitAiMessageFeedback, which pairs it with the message (see the BitAiChatMessage page). | |
| Pinned | bool | false | Keeps the actions visible rather than revealing them while the message is hovered or holds the focus. |
| ReadAloud | BitAiReadAloud? | null | What reads the message aloud, which offers the "Read aloud" action. When null, the one cascaded by an ancestor - a BitAiChat with AllowReadAloud on - is used, and with none the action is not offered. |
| Session | BitAiChatSession? | null | The session driving the conversation of the message, which enables regeneration. |
| ShowFeedback | bool | true | Shows the thumbs up and thumbs down buttons. |
| Styles | BitAiMessageActionsClassStyles? | null | Custom CSS styles for different parts of the message actions. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. An attribute written on the component wins over an entry of the same name. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitAiMessageActionsClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitAiMessageActions. |
| Actions | string? | null | Custom CSS classes/styles for the group of action buttons of the BitAiMessageActions. |
| ReadAloudButton | BitButtonClassStyles? | null | Custom CSS classes/styles for the read aloud button of the BitAiMessageActions. |
| ReadAloudStatus | string? | null | Custom CSS classes/styles for the status of the BitAiMessageActions saying that reading the message aloud failed. |
| RegenerateButton | BitButtonClassStyles? | null | Custom CSS classes/styles for the regenerate button of the BitAiMessageActions. |
| FeedbackButton | BitButtonClassStyles? | null | Custom CSS classes/styles for the two feedback buttons of the BitAiMessageActions. |
| Model | string? | null | Custom CSS classes/styles for the model name of the BitAiMessageActions. |
| Time | string? | null | Custom CSS classes/styles for the time of the BitAiMessageActions. |
BitAiReadAloud properties
Reads replies aloud through the app's own text-to-speech: made with an IBitAiTextToSpeech, or a synthesizer delegate (the reply and a token in, a BitAiSpeechAudio - FromStream, FromBytes or FromUrl - out), it plays the speech in the browser. One instance drives the action of every reply of a chat; a BitAiChat with AllowReadAloud makes one and cascades it. One reading plays at a time on a page, nothing is read while a dictation records, and a dictation starting silences what plays.
| Name | Type | Default value | Description |
|---|---|---|---|
| KeepReading | bool | false | Whether a reading goes on with each reply that finishes after the one it was started on (ReadNextAsync), until it is stopped. Read as a reading starts. |
| Language | string? | null | The language handed to the IBitAiTextToSpeech service, as a BCP 47 language tag; null leaves it to the service. |
| PlaybackRate | double | 1 | The speed the speech plays at, 1 being as synthesized; the browser keeps its pitch. |
| Message | BitAiMessage? | null | The reply being read - loading, playing, waiting to finish arriving, or, while keep reading follows the conversation, the last one it read. |
| IsLoading | bool | false | Whether the speech of the reply is being synthesized. |
| IsPlaying | bool | false | Whether speech is playing. |
| IsFollowing | bool | false | Whether keep reading follows the conversation. |
| FailedMessage | BitAiMessage? | null | The reply whose reading failed last, until another reading starts or the reading is stopped - for its button to say so. |
| Error | string? | null | What failed in the reading of the FailedMessage: synthesis-failed or playback-failed. |
| IsReading(message) | bool | Whether the reply is the one being read, which its button stops rather than starts. | |
| HasFailed(message) | bool | Whether the reading of the reply is the one that failed last. | |
| PrepareAsync() | Task | Has the browser wake the player inside every click of an element carrying data-bit-ai-read-aloud, so the speech may play on Blazor Server, where the press reaches .NET only once the gesture is over. The actions of a reply carry the attribute and call it; a button of the app's own does the same. | |
| ReadAsync(message) | Task | Reads a reply, in place of whatever is being read. A reply still arriving is read once it has finished. | |
| ToggleAsync(message) | Task | Stops the reading of the reply when it is the one being read, and reads it otherwise - what the action's button does. | |
| ReadNextAsync(reply) | Task | Tells the reader a reply has finished: it is read when a reading waits for it, or when keep reading follows the conversation - only a reply that finished normally, never one stopped or failed half way. BitAiChat calls it as each turn ends (BitAiChatSession.TurnCompleted); a chat assembled by hand calls it itself. | |
| StopAsync() | Task | Stops the reading, keep reading with it. | |
| Changed | event Action | Raised whenever what is read, or whether it is loading or playing, changes. | |
| Failed | event Action<string> | Raised when a reading fails: synthesis-failed (the synthesizer threw) or playback-failed (the browser could not play the audio). The reading is stopped, and the actions of the reply show and announce the failure. |
BitAiFeedbackKind enum
| Name | Value | Description |
|---|---|---|
| None | 0 | No feedback given, or the feedback was withdrawn. |
| Positive | 1 | The response was helpful (thumbs up). |
| Negative | 2 | The response was not helpful (thumbs down). |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.