AI service that generates and refines component configurations.
Definition
Namespace:Telerik.Blazor.Components.DatAInsightsComposer
Assembly:Telerik.Blazor.DatAInsightsComposer.dll
Syntax:
public class DatAInsightsComposerAIService : IDatAInsightsComposerAIService
Inheritance: objectDatAInsightsComposerAIService
Implements:
Constructors
public DatAInsightsComposerAIService(DatAInsightsComposerAIServiceDependencies dependencies)
Properties
ArcGaugeConfigChatOptions
ChatOptions
protected ChatOptions ArcGaugeConfigChatOptions { get; set; }
ChartConfigChatOptions
ChatOptions
protected ChatOptions ChartConfigChatOptions { get; set; }
ChatClient
IChatClient
protected IChatClient? ChatClient { get; set; }
CircularGaugeConfigChatOptions
ChatOptions
protected ChatOptions CircularGaugeConfigChatOptions { get; set; }
DatasetAndComponentSelectionChatOptions
ChatOptions
protected ChatOptions DatasetAndComponentSelectionChatOptions { get; set; }
GridConfigChatOptions
ChatOptions
protected ChatOptions GridConfigChatOptions { get; set; }
LinearGaugeConfigChatOptions
ChatOptions
protected ChatOptions LinearGaugeConfigChatOptions { get; set; }
RadialGaugeConfigChatOptions
ChatOptions
protected ChatOptions RadialGaugeConfigChatOptions { get; set; }
Methods
Selects the dataset AND the component in a single LLM call, then generates the component configuration(s) for each selection.
public virtual Task<ComponentConfigAIResponse> GenerateComponentsAsync(GenerateComponentsRequest request, CancellationToken ct = default)
Implements:
Builds the ChatOptions used for ArcGauge configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetArcGaugeConfigChatOptions()
ChatOptions
Builds the ChatOptions used for Chart configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetChartConfigChatOptions()
ChatOptions
Builds the ChatOptions used for CircularGauge configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetCircularGaugeConfigChatOptions()
ChatOptions
The shared Grid/Chart/Gauge classification heuristics (signal keywords, disambiguation rules, and worked examples) used when selecting a dataset+component pair (GetSelectDatasetAndComponentPrompt(List<DatasetDescriptor>)) and in follow-up routing. Kept in one place so the prompts can't drift apart on how they interpret the same wording.
Returns the same per-component-type opt-in rules used by BuildConfigPrompt(string, ComponentType, ComponentConfig), so the merged multi-component pipeline gets identical guidance about which properties to omit unless the user explicitly asks for them. Without this, the model has no instruction to leave feature flags null and tends to set them all to enabled. Split into one virtual method per component type so consumers can override just one type's rules instead of this whole switch.
protected virtual string GetComponentTypeRules(ComponentType componentType)
Builds the ChatOptions used for the multi-dataset-to-component mapping step. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetDatasetAndComponentSelectionOptions()
ChatOptions
The dataset config prompt rules.
Builds the ChatOptions used for Grid configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetGridConfigChatOptions()
ChatOptions
Builds the ChatOptions used for LinearGauge configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetLinearGaugeConfigChatOptions()
ChatOptions
Builds the ChatOptions used for RadialGauge configuration generation. Override to customize the schema or add provider-specific ChatOptions settings.
protected virtual ChatOptions GetRadialGaugeConfigChatOptions()
ChatOptions
protected virtual string GetRefineFollowUpRoutingPrompt(List<DatasetDescriptor> datasets, ComponentConfig currentConfig, string restrictions)
protected virtual string GetSelectDatasetAndComponentPrompt(List<DatasetDescriptor> datasets)
Routes a single current visualization using its context and the eligible dataset catalog, then refines on the same dataset or generates fresh configuration on a different dataset. Successful single-visualization follow-ups use two model calls. Multiple current visualizations retain their existing dataset/type selections and configuration pipeline. Caller-owned configurations are not modified.
public virtual Task<ComponentConfigAIResponse> RefineComponentsAsync(RefineComponentsRequest request, CancellationToken ct = default)
Implements:
The main extension point for calling an LLM: override this to route the request to your own
backend (which then calls the LLM on your behalf). If you don't override it, the base
implementation falls back to the IChatClient registered via
ChatClient (e.g. through Microsoft.Extensions.AI); if neither is available, it
throws an InvalidOperationException that explains what to implement.
protected virtual Task<ChatResponse> SendChatRequestAsync(IList<ChatMessage> messages, ChatOptions options, CancellationToken ct)
Task<ChatResponse>
The IChatClient path's generate-flow seam: gives a consuming service the real
list and ChatOptions the base pipeline built (e.g. to
log schema size or timing) before forwarding to . Only
reached when nothing overrides SendGenerateComponentsRequestAsync(GenerateComponentsAIRequest, CancellationToken) above it.
protected virtual Task<ChatResponse> SendGenerateComponentsChatRequestAsync(GenerateComponentsAIRequest request, IList<ChatMessage> messages, ChatOptions options, CancellationToken ct)
Task<ChatResponse>
Sends one AI request that is part of the generate flow (GenerateComponentsAsync(GenerateComponentsRequest, CancellationToken)),
with no dependency on ChatOptions/ChatMessage — this is the seam a service that
doesn't use an in-process IChatClient at all should override: request
already carries everything needed (operation, prompts, schema) to package
for an external backend, and GenerateComponentsAIResponse is all it needs to
return (just the raw text answer and whether the model refused). Default implementation
rebuilds the messages/options an in-process IChatClient call needs and forwards to
.
protected virtual Task<GenerateComponentsAIResponse> SendGenerateComponentsRequestAsync(GenerateComponentsAIRequest request, CancellationToken ct)
Refine-flow counterpart of .
protected virtual Task<ChatResponse> SendRefineComponentsChatRequestAsync(RefineComponentsAIRequest request, IList<ChatMessage> messages, ChatOptions options, CancellationToken ct)
Task<ChatResponse>
Refine-flow counterpart of SendGenerateComponentsRequestAsync(GenerateComponentsAIRequest, CancellationToken) — same "no
ChatOptions dependency" seam, driven by RefineComponentsAIRequest/
RefineComponentsAIResponse instead.
protected virtual Task<RefineComponentsAIResponse> SendRefineComponentsRequestAsync(RefineComponentsAIRequest request, CancellationToken ct)
The IChatClient path's dataset+component-selection seam: gives a consuming service the
real list and ChatOptions the base pipeline built before
forwarding to . Only reached when nothing overrides
above it.
protected virtual Task<ChatResponse> SendSelectDatasetAndComponentChatRequestAsync(SelectDatasetAndComponentAIRequest request, IList<ChatMessage> messages, ChatOptions options, CancellationToken ct)
Task<ChatResponse>
The seam a service that doesn't use an in-process IChatClient should override for the
dataset+component selection step, including contextual single-visualization follow-up routing —
mirrors SendGenerateComponentsRequestAsync(GenerateComponentsAIRequest, CancellationToken). Integrations must honor the supplied
system prompt and schema rather than hardcoding initial selection behavior.
Default implementation rebuilds the messages/options an in-process IChatClient call
needs and forwards to .
protected virtual Task<SelectDatasetAndComponentAIResponse> SendSelectDatasetAndComponentRequestAsync(SelectDatasetAndComponentAIRequest request, CancellationToken ct)