AI scenarios
Options & theming
Bit.BlazorUI.AI Scripted transportOne region of the page with its own options, design system, scheme, density and direction - the options through BitAiOptionsProvider, everything visual through the same theme as the rest of bit BlazorUI.
Live demo
Change the controls beside the chat: they re-skin and reconfigure only the region the chat is in.
A themed, configured region
Answer 1. The cost is dominated by rendering, not by parsing. Coalescing updates removes most of it, and virtualization removes the rest.
Here is the shape of it:
var budget = TimeSpan.FromMilliseconds(18);
scheduler.Request();The interval is the only dial that matters.
- Render modes 94%
- Circuit lifetime 81%
Two passages matched, and they say the same thing.
Options
BitAiOptionsProvider cascades a BitAiUiOptions to every AI component inside it, so a
page or a region of one sets its preferences once rather than on every component: the string table
(Strings, a BitAiStrings subclass for another language or another tone), what a
message shows (ShowUsage, ShowModelName, ShowTimestamps,
ShowMessageActions, ShowLineNumbers, ...), the render interval, the virtualization
threshold, the image policy. It renders no element of its own, and an inner provider overrides an outer one
for its own content.
The other two places options come from: ai.ConfigureUi(...) sets the defaults of the whole app,
and the UiOptions of one BitAiChat configures that chat alone.
The chat opens on a six-message conversation built in code, so there is something to restyle; what you send
goes to the transport registered for the site, which echoes it. Each option toggle (strings and the Show ones) builds a new
BitAiUiOptions record (BitAiUiOptions.Default with { ... }): the options are
immutable, and a new instance is what tells the provider to hand the change down.
Theming
Scheme, accent, density and direction are not options of the AI components: they are styled with the global
--bit-* tokens like every other component of the library, so they follow the theme there is.
- A design system and scheme for a region come from a scoped preset,
bit-theme="material-dark"on any element - the Fluent 2, Material and Cupertino presets ship withBit.BlazorUI.Extras, whose bundles the host page links. - Density is the
--bit-layout-density-scalemultiplier, set in CSS as here or throughBitTheme.Layout.DensityScaleof aBitThemeProvider. - Direction is a
diron an ancestor, or theDirparameter of one component. - The accent is the site's: change it with the swatches in the header (AccentColorSwitcher), and the chat follows.
Each component also has its own --bit-Ai<Name>-* variables and its Classes /
Styles for what one component should look like differently - see its page, and
Theming for the whole system.
Components used
BitAiOptionsProvider- the options of everything inside it.BitAiChat- the chat they reach, and every component it renders.
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.