RadzenAIPrompt Class

A prompt box for one-shot AI tasks: the user types or picks a prompt, the model's answer streams into an output panel and commands such as "Shorter" or "Translate" refine it. Set Context to run the prompts against a piece of text, for example the content of an editor. Uses the IChatClient configured for IAIChatService.

Inheritance

Object

ComponentBase

RadzenComponent

RadzenAIPrompt

Implements

IComponent

IHandleEvent

IHandleAfterRender

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenAIPrompt : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender

Examples

<RadzenAIPrompt Suggestions="@(new[] { "Summarize the text", "Translate to German" })" Context="@text" @bind-Output="@result" />

Constructors

RadzenAIPromptLink to this section

A prompt box for one-shot AI tasks: the user types or picks a prompt, the model's answer streams into an output panel and commands such as "Shorter" or "Translate" refine it. Set Context to run the prompts against a piece of text, for example the content of an editor. Uses the IChatClient configured for IAIChatService.

Declaration
public RadzenAIPrompt()

Properties

CommandsLink to this section

Gets or sets the commands shown under the output. A command sends the current output together with its Prompt and replaces the output with the result.

Declaration
public IEnumerable<AIPromptCommand> Commands { get; set; }
Property Value
Type Description
IEnumerable<AIPromptCommand>Gets or sets the commands shown under the output. A command sends the current output together with its Prompt and replaces the output with the result.

ContextLink to this section

Gets or sets the text the prompts apply to, for example the content of an editor or the selected text. When set, the model receives it together with the prompt.

Declaration
public string Context { get; set; }
Property Value
Type Description
stringGets or sets the text the prompts apply to, for example the content of an editor or the selected text. When set, the model receives it together with the prompt.

CopyTitleLink to this section

Gets or sets the title of the copy button.

Declaration
public string CopyTitle { get; set; }
Property Value
Type Description
stringGets or sets the title of the copy button.

DisabledLink to this section

Gets or sets whether the component is disabled.

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

ErrorLink to this section

Event callback that is invoked when the request fails. When not set the error message is shown as the output.

Declaration
public EventCallback<Exception> Error { get; set; }
Property Value
Type Description
EventCallback<Exception>Event callback that is invoked when the request fails. When not set the error message is shown as the output.

GenerateTextLink to this section

Gets or sets the text of the generate button.

Declaration
public string GenerateText { get; set; }
Property Value
Type Description
stringGets or sets the text of the generate button.

GeneratedLink to this section

Event callback that is invoked when the model finishes generating.

Declaration
public EventCallback<AIPromptGeneratedEventArgs> Generated { get; set; }
Property Value
Type Description
EventCallback<AIPromptGeneratedEventArgs>Event callback that is invoked when the model finishes generating.

InputAttributesLink to this section

Specifies additional custom attributes that will be rendered by the input.

Declaration
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }
Property Value
Type Description
IReadOnlyDictionary<string, object>Specifies additional custom attributes that will be rendered by the input.

IsGeneratingLink to this section

Gets whether a response is being generated.

Declaration
public bool IsGenerating { get; }
Property Value
Type Description
boolGets whether a response is being generated.

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 name. Falls back to the configured Model.

Declaration
public string ModelId { get; set; }
Property Value
Type Description
stringGets or sets the model name. Falls back to the configured Model.

OutputLink to this section

Gets or sets the generated output.

Declaration
public string Output { get; set; }
Property Value
Type Description
stringGets or sets the generated output.

OutputChangedLink to this section

Event callback that is invoked when the output changes, including while it streams.

Declaration
public EventCallback<string> OutputChanged { get; set; }
Property Value
Type Description
EventCallback<string>Event callback that is invoked when the output changes, including while it streams.

OutputTemplateLink to this section

Gets or sets a template that renders the output instead of the default Markdown rendering.

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

PlaceholderLink to this section

Gets or sets the placeholder of the input.

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

RetryTitleLink to this section

Gets or sets the title of the regenerate button.

Declaration
public string RetryTitle { get; set; }
Property Value
Type Description
stringGets or sets the title of the regenerate button.

ShowOutputLink to this section

Gets or sets whether the output panel is rendered. Set to false to show the output elsewhere via OutputChanged.

Declaration
public bool ShowOutput { get; set; }
Property Value
Type Description
boolGets or sets whether the output panel is rendered. Set to false to show the output elsewhere via OutputChanged.

StopTextLink to this section

Gets or sets the text of the stop button shown while generating.

Declaration
public string StopText { get; set; }
Property Value
Type Description
stringGets or sets the text of the stop button shown while generating.

SuggestionsLink to this section

Gets or sets the prompts offered as suggestions under the input.

Declaration
public IEnumerable<string> Suggestions { get; set; }
Property Value
Type Description
IEnumerable<string>Gets or sets the prompts offered as suggestions under the input.

SystemPromptLink to this section

Gets or sets the system prompt.

Declaration
public string SystemPrompt { get; set; }
Property Value
Type Description
stringGets or sets the system prompt.

TemperatureLink to this section

Gets or sets the temperature.

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

ValueLink to this section

Gets or sets the prompt text.

Declaration
public string Value { get; set; }
Property Value
Type Description
stringGets or sets the prompt text.

ValueChangedLink to this section

Event callback that is invoked when the prompt text changes.

Declaration
public EventCallback<string> ValueChanged { get; set; }
Property Value
Type Description
EventCallback<string>Event callback that is invoked when the prompt text changes.

Methods

BuildRenderTreeLink to this section

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

ClearLink to this section

Clears the output.

Declaration
public Task Clear()
Returns
Type Description
Task

DisposeLink to this section

Declaration
public override void Dispose()

ExecuteCommandLink to this section

Applies a command to the current output and replaces it with the result.

Declaration
public Task ExecuteCommand(AIPromptCommand command)
Parameters
Type Name Description
AIPromptCommand command The command.
Returns
Type Description
Task

GenerateLink to this section

Sends a prompt to the model and streams the answer into Output.

Declaration
public Task Generate(string prompt)
Parameters
Type Name Description
string prompt The prompt. Uses Value when not specified.
Returns
Type Description
Task

GetComponentCssClassLink to this section

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

StopLink to this section

Stops the current generation and keeps the output received so far.

Declaration
public void Stop()
An error has occurred. This app may no longer respond until reloaded. Reload 🗙