RadzenInlineAIPrompt Class

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.

Inheritance

Object

ComponentBase

RadzenComponent

RadzenInlineAIPrompt

Implements

IComponent

IHandleEvent

IHandleAfterRender

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenInlineAIPrompt : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender

Examples

<RadzenTextArea id="description" @bind-Value="description" />
<RadzenInlineAIPrompt @bind-Value="description" TargetId="description" Suggestions="@(new[] { "Fix grammar", "Make it shorter" })" />

Constructors

RadzenInlineAIPromptLink to this section

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.

Declaration
public RadzenInlineAIPrompt()

Properties

AppendTextLink to this section

Gets or sets the text of the button that appends the output to the value. Default is "Append".

Declaration
public string AppendText { get; set; }
Property Value
Type Description
stringGets or sets the text of the button that appends the output to the value. Default is "Append".

AppliedLink to this section

Gets or sets the callback invoked after the output is applied to the value, with the new value.

Declaration
public EventCallback<string> Applied { get; set; }
Property Value
Type Description
EventCallback<string>Gets or sets the callback invoked after the output is applied to the value, with the new value.

ButtonStyleLink to this section

Gets or sets the style of the button. Default is Base.

Declaration
public ButtonStyle ButtonStyle { get; set; }
Property Value
Type Description
ButtonStyleGets or sets the style of the button. Default is Base.

CloseLink to this section

Gets or sets the callback invoked when the popup closes.

Declaration
public EventCallback Close { get; set; }
Property Value
Type Description
EventCallbackGets or sets the callback invoked when the popup closes.

CommandsLink to this section

Gets or sets the commands that refine the output, for example shorter, formal or translate.

Declaration
public IEnumerable<AIPromptCommand> Commands { get; set; }
Property Value
Type Description
IEnumerable<AIPromptCommand>Gets or sets the commands that refine the output, for example shorter, formal or translate.

DisabledLink to this section

Gets or sets whether the button is disabled.

Declaration
public bool Disabled { get; set; }
Property Value
Type Description
boolGets or sets whether the button is disabled.

DiscardTextLink to this section

Gets or sets the text of the button that discards the output. Default is "Discard".

Declaration
public string DiscardText { get; set; }
Property Value
Type Description
stringGets or sets the text of the button that discards the output. Default is "Discard".

ErrorLink to this section

Gets or sets the callback invoked when a request fails.

Declaration
public EventCallback<Exception> Error { get; set; }
Property Value
Type Description
EventCallback<Exception>Gets or sets the callback invoked when a request fails.

GeneratedLink to this section

Gets or sets the callback invoked when the model produces an output.

Declaration
public EventCallback<AIPromptGeneratedEventArgs> Generated { get; set; }
Property Value
Type Description
EventCallback<AIPromptGeneratedEventArgs>Gets or sets the callback invoked when the model produces an output.

IconLink to this section

Gets or sets the icon of the button. Default is auto_awesome.

Declaration
public string Icon { get; set; }
Property Value
Type Description
stringGets or sets the icon of the button. Default is auto_awesome.

IconColorLink to this section

Gets or sets the color of the icon.

Declaration
public string IconColor { get; set; }
Property Value
Type Description
stringGets or sets the color of the icon.

IsOpenLink to this section

Gets whether the popup is open.

Declaration
public bool IsOpen { get; }
Property Value
Type Description
boolGets whether the popup is open.

MaxTokensLink to this section

Gets or sets the maximum number of output tokens.

Declaration
public int? MaxTokens { get; set; }
Property Value
Type Description
int?Gets or sets the maximum number of output tokens.

ModelIdLink to this section

Gets or sets the model. Uses the model of AIChatServiceOptions when not set.

Declaration
public string ModelId { get; set; }
Property Value
Type Description
stringGets or sets the model. Uses the model of AIChatServiceOptions when not set.

OpenLink to this section

Gets or sets the callback invoked when the popup opens.

Declaration
public EventCallback Open { get; set; }
Property Value
Type Description
EventCallbackGets or sets the callback invoked when the popup opens.

OutputLink to this section

Gets the output of the last generation, until it is applied or discarded.

Declaration
public string Output { get; }
Property Value
Type Description
stringGets the output of the last generation, until it is applied or discarded.

OutputTemplateLink to this section

Gets or sets the template that renders the output instead of markdown.

Declaration
public RenderFragment<string> OutputTemplate { get; set; }
Property Value
Type Description
RenderFragment<string>Gets or sets the template that renders the output instead of markdown.

PlaceholderLink to this section

Gets or sets the placeholder of the prompt input.

Declaration
public string Placeholder { get; set; }
Property Value
Type Description
stringGets or sets the placeholder of the prompt input.

ReplaceSelectionTextLink to this section

Gets or sets the text of the replace button when a selection is replaced. Default is "Replace selection".

Declaration
public string ReplaceSelectionText { get; set; }
Property Value
Type Description
stringGets or sets the text of the replace button when a selection is replaced. Default is "Replace selection".

ReplaceTextLink to this section

Gets or sets the text of the button that replaces the value with the output. Default is "Replace".

Declaration
public string ReplaceText { get; set; }
Property Value
Type Description
stringGets or sets the text of the button that replaces the value with the output. Default is "Replace".

ShadeLink to this section

Gets or sets the shade of the button.

Declaration
public Shade Shade { get; set; }
Property Value
Type Description
ShadeGets or sets the shade of the button.

ShowButtonLink to this section

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.

Declaration
public bool ShowButton { get; set; }
Property Value
Type Description
boolGets 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.

SizeLink to this section

Gets or sets the size of the button. Default is Small.

Declaration
public ButtonSize Size { get; set; }
Property Value
Type Description
ButtonSizeGets or sets the size of the button. Default is Small.

SuggestionsLink to this section

Gets or sets the prompts offered as buttons, for example "Fix grammar" or "Make it shorter".

Declaration
public IEnumerable<string> Suggestions { get; set; }
Property Value
Type Description
IEnumerable<string>Gets or sets the prompts offered as buttons, for example "Fix grammar" or "Make it shorter".

SystemPromptLink to this section

Gets or sets the system prompt. The default asks the model to return only the resulting text without explanations or markdown.

Declaration
public string SystemPrompt { get; set; }
Property Value
Type Description
stringGets or sets the system prompt. The default asks the model to return only the resulting text without explanations or markdown.

TargetIdLink to this section

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.

Declaration
public string TargetId { get; set; }
Property Value
Type Description
stringGets 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.

TemperatureLink to this section

Gets or sets the sampling temperature.

Declaration
public double? Temperature { get; set; }
Property Value
Type Description
double?Gets or sets the sampling temperature.

TextLink to this section

Gets or sets the text of the button. The button shows only the icon when not set.

Declaration
public string Text { get; set; }
Property Value
Type Description
stringGets or sets the text of the button. The button shows only the icon when not set.

TitleLink to this section

Gets or sets the title of the button and the accessible name of the popup. Default is "AI assistant".

Declaration
public string Title { get; set; }
Property Value
Type Description
stringGets or sets the title of the button and the accessible name of the popup. Default is "AI assistant".

ValueLink to this section

Gets or sets the text of the field the assistant works on.

Declaration
public string Value { get; set; }
Property Value
Type Description
stringGets or sets the text of the field the assistant works on.

ValueChangedLink to this section

Gets or sets the callback invoked when the assistant changes the value.

Declaration
public EventCallback<string> ValueChanged { get; set; }
Property Value
Type Description
EventCallback<string>Gets or sets the callback invoked when the assistant changes the value.

VariantLink to this section

Gets or sets the variant of the button. Default is Text.

Declaration
public Variant Variant { get; set; }
Property Value
Type Description
VariantGets or sets the variant of the button. Default is Text.

Methods

BuildRenderTreeLink to this section

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder __builder

CloseAsyncLink to this section

Closes the popup.

Declaration
public Task CloseAsync()
Returns
Type Description
Task

GetComponentCssClassLink to this section

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

OpenAsyncLink to this section

Opens the popup anchored to the button, or to the component itself when ShowButton is false.

Declaration
public Task OpenAsync()
Returns
Type Description
Task

OpenAsyncLink to this section

Opens the popup anchored to the button, or to the component itself when ShowButton is false.

Declaration
public Task OpenAsync(ElementReference anchor)
Parameters
Type Name Description
ElementReference anchor
Returns
Type Description
Task
An error has occurred. This app may no longer respond until reloaded. Reload 🗙