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.
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 RadzenAIPrompt : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender<RadzenAIPrompt Suggestions="@(new[] { "Summarize the text", "Translate to German" })" Context="@text" @bind-Output="@result" />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.
public RadzenAIPrompt()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.
public IEnumerable<AIPromptCommand> Commands { get; set; }
| 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. |
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.
public string Context { get; set; }
| Type | Description |
|---|---|
| string | 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. |
Gets or sets the title of the copy button.
public string CopyTitle { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the title of the copy button. |
Gets or sets whether the component is disabled.
public bool Disabled { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the component is disabled. |
Event callback that is invoked when the request fails. When not set the error message is shown as the output.
public EventCallback<Exception> Error { get; set; }
| Type | Description |
|---|---|
| EventCallback<Exception> | Event callback that is invoked when the request fails. When not set the error message is shown as the output. |
Gets or sets the text of the generate button.
public string GenerateText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the generate button. |
Event callback that is invoked when the model finishes generating.
public EventCallback<AIPromptGeneratedEventArgs> Generated { get; set; }
| Type | Description |
|---|---|
| EventCallback<AIPromptGeneratedEventArgs> | Event callback that is invoked when the model finishes generating. |
Specifies additional custom attributes that will be rendered by the input.
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | Specifies additional custom attributes that will be rendered by the input. |
Gets whether a response is being generated.
public bool IsGenerating { get; }
| Type | Description |
|---|---|
| bool | Gets whether a response is being generated. |
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 name. Falls back to the configured Model.
public string ModelId { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the model name. Falls back to the configured Model. |
Gets or sets the generated output.
public string Output { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the generated output. |
Event callback that is invoked when the output changes, including while it streams.
public EventCallback<string> OutputChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Event callback that is invoked when the output changes, including while it streams. |
Gets or sets a template that renders the output instead of the default Markdown rendering.
public RenderFragment<string> OutputTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment<string> | Gets or sets a template that renders the output instead of the default Markdown rendering. |
Gets or sets the placeholder of the input.
public string Placeholder { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the placeholder of the input. |
Gets or sets the title of the regenerate button.
public string RetryTitle { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the title of the regenerate button. |
Gets or sets whether the output panel is rendered. Set to false to show the output elsewhere via OutputChanged.
public bool ShowOutput { get; set; }
| Type | Description |
|---|---|
| bool | Gets or sets whether the output panel is rendered. Set to false to show the output elsewhere via OutputChanged. |
Gets or sets the text of the stop button shown while generating.
public string StopText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text of the stop button shown while generating. |
Gets or sets the prompts offered as suggestions under the input.
public IEnumerable<string> Suggestions { get; set; }
| Type | Description |
|---|---|
| IEnumerable<string> | Gets or sets the prompts offered as suggestions under the input. |
Gets or sets the system prompt.
public string SystemPrompt { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the system prompt. |
Gets or sets the temperature.
public double? Temperature { get; set; }
| Type | Description |
|---|---|
| double? | Gets or sets the temperature. |
Gets or sets the prompt text.
public string Value { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the prompt text. |
Event callback that is invoked when the prompt text changes.
public EventCallback<string> ValueChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Event callback that is invoked when the prompt text changes. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
Clears the output.
public Task Clear()
| Type | Description |
|---|---|
| Task |
Applies a command to the current output and replaces it with the result.
public Task ExecuteCommand(AIPromptCommand command)
| Type | Name | Description |
|---|---|---|
| AIPromptCommand | command | The command. |
| Type | Description |
|---|---|
| Task |
Sends a prompt to the model and streams the answer into Output.
public Task Generate(string prompt)
| Type | Name | Description |
|---|---|---|
| string | prompt | The prompt. Uses Value when not specified. |
| Type | Description |
|---|---|
| Task |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
Stops the current generation and keeps the output received so far.
public void Stop()