An AI assistant for a text field: a button that opens a RadzenAIPrompt in a popup and applies the result to the bound value. Bind Value to the same value as the field; set TargetId to the id of the input or textarea so that a selection inside it becomes the context and only the selection is replaced.
IComponent
IHandleEvent
IHandleAfterRender
RadzenComponent.GetIdAttribute
RadzenComponent.SetParametersAsync
RadzenComponent.OnAfterRenderAsync
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.DefaultUICulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenInlineAIPrompt : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender<RadzenTextArea id="description" @bind-Value="description" />
<RadzenInlineAIPrompt @bind-Value="description" TargetId="description" Suggestions="@(new[] { "Fix grammar", "Make it shorter" })" />An AI assistant for a text field: a button that opens a RadzenAIPrompt in a popup and applies the result to the bound value. Bind Value to the same value as the field; set TargetId to the id of the input or textarea so that a selection inside it becomes the context and only the selection is replaced.
public RadzenInlineAIPrompt()Gets or sets the text of the button that appends the output to the value. Default is "Append".
public string AppendText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the button that appends the output to the value. Default is "Append". |
Gets or sets the callback invoked after the output is applied to the value, with the new value.
public EventCallback<string> Applied { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Gets or sets the callback invoked after the output is applied to the value, with the new value. |
Gets or sets the style of the button. Default is Base.
public ButtonStyle ButtonStyle { get; set; }
| Type | Description |
|---|---|
| ButtonStyle | Gets or sets the style of the button. Default is Base. |
Gets or sets the callback invoked when the popup closes.
public EventCallback Close { get; set; }
| Type | Description |
|---|---|
| EventCallback | Gets or sets the callback invoked when the popup closes. |
Gets or sets the commands that refine the output, for example shorter, formal or translate.
public IEnumerable<AIPromptCommand> Commands { get; set; }
| Type | Description |
|---|---|
| IEnumerable<AIPromptCommand> | Gets or sets the commands that refine the output, for example shorter, formal or translate. |
Gets or sets whether the button is disabled.
public bool Disabled { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the button is disabled. |
Gets or sets the text of the button that discards the output. Default is "Discard".
public string DiscardText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the button that discards the output. Default is "Discard". |
Gets or sets the callback invoked when a request fails.
public EventCallback<Exception> Error { get; set; }
| Type | Description |
|---|---|
| EventCallback<Exception> | Gets or sets the callback invoked when a request fails. |
Gets or sets the callback invoked when the model produces an output.
public EventCallback<AIPromptGeneratedEventArgs> Generated { get; set; }
| Type | Description |
|---|---|
| EventCallback<AIPromptGeneratedEventArgs> | Gets or sets the callback invoked when the model produces an output. |
Gets or sets the icon of the button. Default is auto_awesome.
public string Icon { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the icon of the button. Default is auto_awesome. |
Gets or sets the color of the icon.
public string IconColor { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the color of the icon. |
Gets whether the popup is open.
public bool IsOpen { get; }
| Type | Description |
|---|---|
| bool | Gets whether the popup is open. |
Gets or sets the maximum number of output tokens.
public int? MaxTokens { get; set; }
| Type | Description |
|---|---|
| int? | Gets or sets the maximum number of output tokens. |
Gets or sets the model. Uses the model of AIChatServiceOptions when not set.
public string ModelId { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the model. Uses the model of AIChatServiceOptions when not set. |
Gets or sets the callback invoked when the popup opens.
public EventCallback Open { get; set; }
| Type | Description |
|---|---|
| EventCallback | Gets or sets the callback invoked when the popup opens. |
Gets the output of the last generation, until it is applied or discarded.
public string Output { get; }
| Type | Description |
|---|---|
| string | Gets the output of the last generation, until it is applied or discarded. |
Gets or sets the template that renders the output instead of markdown.
public RenderFragment<string> OutputTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment<string> | Gets or sets the template that renders the output instead of markdown. |
Gets or sets the placeholder of the prompt input.
public string Placeholder { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the placeholder of the prompt input. |
Gets or sets the text of the replace button when a selection is replaced. Default is "Replace selection".
public string ReplaceSelectionText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the replace button when a selection is replaced. Default is "Replace selection". |
Gets or sets the text of the button that replaces the value with the output. Default is "Replace".
public string ReplaceText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the button that replaces the value with the output. Default is "Replace". |
Gets or sets the shade of the button.
public Shade Shade { get; set; }
| Type | Description |
|---|---|
| Shade | Gets or sets the shade of the button. |
Gets or sets whether the button that opens the popup is rendered. Set to false and call ElementReference) to open the popup from your own trigger. Default is true.
public bool ShowButton { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the button that opens the popup is rendered. Set to false and call ElementReference) to open the popup from your own trigger. Default is true. |
Gets or sets the size of the button. Default is Small.
public ButtonSize Size { get; set; }
| Type | Description |
|---|---|
| ButtonSize | Gets or sets the size of the button. Default is Small. |
Gets or sets the prompts offered as buttons, for example "Fix grammar" or "Make it shorter".
public IEnumerable<string> Suggestions { get; set; }
| Type | Description |
|---|---|
| IEnumerable<string> | Gets or sets the prompts offered as buttons, for example "Fix grammar" or "Make it shorter". |
Gets or sets the system prompt. The default asks the model to return only the resulting text without explanations or markdown.
public string SystemPrompt { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the system prompt. The default asks the model to return only the resulting text without explanations or markdown. |
Gets or sets the id of the input or textarea the assistant works on. When set, the text selected in it when the popup opens is used as context and replaced by the result; without a selection, or without a target, the whole Value is used.
public string TargetId { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the id of the input or textarea the assistant works on. When set, the text selected in it when the popup opens is used as context and replaced by the result; without a selection, or without a target, the whole Value is used. |
Gets or sets the sampling temperature.
public double? Temperature { get; set; }
| Type | Description |
|---|---|
| double? | Gets or sets the sampling temperature. |
Gets or sets the text of the button. The button shows only the icon when not set.
public string Text { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the button. The button shows only the icon when not set. |
Gets or sets the title of the button and the accessible name of the popup. Default is "AI assistant".
public string Title { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the title of the button and the accessible name of the popup. Default is "AI assistant". |
Gets or sets the text of the field the assistant works on.
public string Value { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the field the assistant works on. |
Gets or sets the callback invoked when the assistant changes the value.
public EventCallback<string> ValueChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Gets or sets the callback invoked when the assistant changes the value. |
Gets or sets the variant of the button. Default is Text.
public Variant Variant { get; set; }
| Type | Description |
|---|---|
| Variant | Gets or sets the variant of the button. Default is Text. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
Closes the popup.
public Task CloseAsync()
| Type | Description |
|---|---|
| Task |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
Opens the popup anchored to the button, or to the component itself when ShowButton is false.
public Task OpenAsync()
| Type | Description |
|---|---|
| Task |
Opens the popup anchored to the button, or to the component itself when ShowButton is false.
public Task OpenAsync(ElementReference anchor)
| Type | Name | Description |
|---|---|---|
| ElementReference | anchor |
| Type | Description |
|---|---|
| Task |