Skip to content

Commit 83a739a

Browse files
chore(InlineAiPrompt): address all comments
1 parent cc8de8b commit 83a739a

File tree

3 files changed

+59
-92
lines changed

3 files changed

+59
-92
lines changed

components/inlineaiprompt/events.md

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ position: 10
1010

1111
# InlineAIPrompt Events
1212

13-
This article explains the events available in the Telerik InlineAIPrompt for Blazor:
13+
This article describes the events of the Telerik InlineAIPrompt for Blazor:
1414

1515
* [`OnOutputActionClick`](#onoutputactionclick)
1616
* [`OnPromptRequest`](#onpromptrequest)
@@ -20,49 +20,31 @@ This article explains the events available in the Telerik InlineAIPrompt for Bla
2020

2121
## OnOutputActionClick
2222

23-
The `OnOutputActionClick` event fires when the user clicks an output action button in the output view of the AIPrompt component. Use this event to handle custom actions such as copying, retrying, or providing feedback on the generated output.
23+
The `OnOutputActionClick` event fires when the user clicks an output action button in the output view of the InlineAIPrompt component. Use this event to handle custom actions such as copying, retrying, or providing feedback on the generated output.
2424

2525
To define the available output actions, set the `OutputActions` parameter to a list of [`InlineAIPromptOutputActionDescriptor`](slug:Telerik.Blazor.Components.InlineAIPromptOutputActionDescriptor) objects. Each action descriptor configures the appearance and behavior of an action button.
2626

27-
The event handler receives an argument of type `InlineAIPromptOutputActionClickEventArgs`, which provides details about the clicked action, the prompt, the output, and the related command (if any). For a full list of available properties, refer to the [`InlineAIPromptOutputActionClickEventArgs` API reference](slug:Telerik.Blazor.Components.InlineAIPromptOutputActionClickEventArgs).
27+
The event handler receives an argument of type [`InlineAIPromptOutputActionClickEventArgs` API reference](slug:Telerik.Blazor.Components.InlineAIPromptOutputActionClickEventArgs), which provides details about the clicked action, the prompt, the output, and the related command (if any).
2828

2929
## OnPromptRequest
3030

3131
The `OnPromptRequest` event fires when the user clicks on the **Generate** button within the Prompt view or retries a prompt from the Output view.
3232

33-
The event handler receives an argument of type [`InlineAIPromptPromptRequestEventArgs`](slug:Telerik.Blazor.Components.InlineAIPromptPromptRequestEventArgs). See the [example below](#example).
34-
35-
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
36-
37-
| Property | Type | Description |
38-
| --- | --- | --- |
39-
| `Prompt` | `string` | The prompt text of the request. |
40-
| `Output` | `string` | The output of the request. The output is based on the prompt text. |
41-
| `IsCancelled` | `bool` | Whether the event is cancelled and the built-in action is prevented. |
42-
| `OutputItem` | `InlineAIPromptOutputItemDescriptor` | The output item. This property will be populated only when the user retries an existing output. See [`InlineAIPromptOutputItemDescriptor`](slug:Telerik.Blazor.Components.InlineAIPromptOutputItemDescriptor). |
33+
The event handler receives an argument of type [`InlineAIPromptPromptRequestEventArgs` API reference](slug:Telerik.Blazor.Components.InlineAIPromptPromptRequestEventArgs). See the [example below](#example).
4334

4435
> Do not use the `OnPromptRequest` event when [integrating the InlineAIPrompt component with `Microsoft.Extensions.AI`](slug:common-features-microsoft-extensions-ai-integration). The `OnPromptRequest` event disables such integration.
4536
4637
## OnPromptRequestStop
4738

4839
The `OnPromptRequestStop` event fires when the user stops a prompt request by clicking the stop floating action button in the output view. This event allows you to handle the cancellation of an ongoing prompt request.
4940

50-
The event handler receives an `EventCallback` with no arguments.
41+
The event handler receives no arguments.
5142

5243
## OnCommandExecute
5344

5445
The `OnCommandExecute` event fires when the user clicks on a command within the Commands view.
5546

56-
The event handler receives an argument of type [`InlineAIPromptCommandExecuteEventArgs`](slug:Telerik.Blazor.Components.InlineAIPromptCommandExecuteEventArgs). See the [example below](#example).
57-
58-
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
59-
60-
| Property | Type | Description |
61-
| --- | --- | --- |
62-
| `Command` | `AIPromptCommandDescriptor` | The executed command. |
63-
| `Output` | `string` | The output based on the executed command. |
64-
| `IsCancelled` | `bool` | Whether the event is cancelled and the built-in action is prevented. |
65-
| `OutputItem` | `InlineAIPromptOutputItemDescriptor` | The output item. This property will be populated only when the user retries an existing output. See [`InlineAIPromptOutputItemDescriptor`](slug:Telerik.Blazor.Components.InlineAIPromptOutputItemDescriptor). |
47+
The event handler receives an argument of type [`InlineAIPromptCommandExecuteEventArgs` API reference](slug:Telerik.Blazor.Components.InlineAIPromptCommandExecuteEventArgs). See the [example below](#example).
6648

6749
## PromptChanged
6850

@@ -76,11 +58,10 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
7658
<div class="genres-container">
7759
@foreach (var genre in MovieGenres)
7860
{
79-
<div class="genre-card"
80-
@onclick="@((MouseEventArgs e) => OnGenreContextMenuAsync(e, genre))"
81-
@onclick:preventDefault="true">
61+
<TelerikButton Class="genre-card"
62+
OnClick="@((MouseEventArgs e) => OnGenreContextMenuAsync(e, genre))">
8263
@genre
83-
</div>
64+
</TelerikButton>
8465
}
8566
</div>
8667
@@ -103,9 +84,9 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
10384
@code {
10485
private int PromptRequestsCount { get; set; } = 0;
10586
private string EventsLog { get; set; } = string.Empty;
106-
private string UserPrompt { get; set; }
107-
private string PromptContext { get; set; }
108-
private TelerikInlineAIPrompt InlinePromptRef { get; set; }
87+
private string UserPrompt { get; set; } = string.Empty;
88+
private string PromptContext { get; set; } = string.Empty;
89+
private TelerikInlineAIPrompt? InlinePromptRef { get; set; }
10990
11091
private List<InlineAIPromptCommandDescriptor> Commands { get; set; } = new()
11192
{
@@ -176,19 +157,19 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
176157
private async Task OnGenreContextMenuAsync(MouseEventArgs e, string genre)
177158
{
178159
PromptContext = genre;
179-
await InlinePromptRef.ShowAsync(e.ClientX, e.ClientY);
160+
await InlinePromptRef!.ShowAsync(e.ClientX, e.ClientY);
180161
}
181162
182163
private async Task OnPromptRequest(InlineAIPromptPromptRequestEventArgs args)
183164
{
184-
await Task.Delay(1000);
165+
await Task.Delay(200);
185166
args.Output = $"AI suggestion for prompt #{PromptRequestsCount++} in {PromptContext}";
186167
EventsLog += $"OnPromptRequest fired <br />";
187168
}
188169
189170
private async Task OnCommandExecute(InlineAIPromptCommandExecuteEventArgs args)
190171
{
191-
await Task.Delay(1000);
172+
await Task.Delay(200);
192173
args.Output = $"AI executed: {args.Command.Title} for {PromptContext}";
193174
EventsLog += $"OnCommandExecute fired <br />";
194175
}

components/inlineaiprompt/overview.md

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,26 @@ position: 0
1010

1111
# Blazor InlineAIPrompt Overview
1212

13-
The UI for Blazor InlineAIPrompt is a popup-based component that lets you interact with AI language models right inside your content.
13+
The Telerik InlineAIPrompt for Blazor is a popup-based component that lets you interact with AI language models right inside your content.
1414

15-
It provides a simple and focused way to send prompts and get responses from AI without interrupting the user’s flow. The InlineAIPrompt is great for adding contextual AI help exactly where users need it.
15+
The InlineAIPrompt provides a simple and focused way to send prompts and get responses from AI without interrupting the user’s flow. The InlineAIPrompt is great for adding contextual AI help exactly where users need it.
1616

1717
## Creating Blazor InlineAIPrompt
1818

1919
1. Add the `<TelerikInlineAIPrompt>` tag.
2020
2. Subscribe to the `OnPromptRequest` event that will fire whenever the user sends a prompt request. The handler expects an argument of type `InlineAIPromptPromptRequestEventArgs`.
2121
3. Set the `Prompt` parameter
22-
4. (optional) Set the `PromptContext` parameter
2322

2423
>caption Telerik Blazor InlineAIPrompt
2524
2625
````Razor
2726
<div class="products-container">
2827
@foreach (var product in Products)
2928
{
30-
<div class="product-card"
31-
@onclick="@((MouseEventArgs e) => ShowPromptAsync(e, product))"
32-
@onclick:preventDefault="true">
29+
<TelerikButton Class="product-card"
30+
OnClick="@((MouseEventArgs e) => ShowPromptAsync(e, product))">
3331
@product
34-
</div>
32+
</TelerikButton>
3533
}
3634
</div>
3735
@@ -42,9 +40,9 @@ It provides a simple and focused way to send prompts and get responses from AI w
4240
</TelerikInlineAIPrompt>
4341
4442
@code {
45-
private string UserPrompt { get; set; }
46-
private string PromptContext { get; set; }
47-
private TelerikInlineAIPrompt InlinePromptRef { get; set; }
43+
private string UserPrompt { get; set; } = string.Empty;
44+
private string PromptContext { get; set; } = string.Empty;
45+
private TelerikInlineAIPrompt? InlinePromptRef { get; set; }
4846
4947
private List<string> Products { get; set; } = new()
5048
{
@@ -56,12 +54,12 @@ It provides a simple and focused way to send prompts and get responses from AI w
5654
private async Task ShowPromptAsync(MouseEventArgs e, string product)
5755
{
5856
PromptContext = product;
59-
await InlinePromptRef.ShowAsync(e.ClientX, e.ClientY);
57+
await InlinePromptRef!.ShowAsync(e.ClientX, e.ClientY);
6058
}
6159
6260
private void OnPromptRequest(InlineAIPromptPromptRequestEventArgs args)
6361
{
64-
args.Output = $"AI assistance for: {PromptContext}";
62+
args.Output = $"AI response for: {PromptContext}";
6563
}
6664
}
6765
@@ -87,44 +85,30 @@ It provides a simple and focused way to send prompts and get responses from AI w
8785

8886
## Streaming
8987

90-
The InlineAIPrompt component supports streaming responses, letting users view AI-generated content in real time as it’s created. [Read more about the Blazor InlineAIPrompt streaming...](slug:inlineaiprompt-streaming)
88+
The InlineAIPrompt component supports streaming responses, which lets users view AI-generated content in real time as it’s created. [Read more about the Blazor InlineAIPrompt streaming...](slug:inlineaiprompt-streaming)
9189

9290
## Events
9391

94-
The InlineAIPrompt component offers several events that allow developers to handle user interactions and processes effectively. [Read more about the Blazor InlineAIPrompt events...](slug:inlineaiprompt-events)
92+
The InlineAIPrompt component offers several events that allow developers to handle user interactions effectively. [Read more about the Blazor InlineAIPrompt events...](slug:inlineaiprompt-events)
9593

96-
## InlineAIPrompt Parameters
94+
## InlineAIPrompt API
9795

98-
The following table lists the InlineAIPrompt parameters. Also check the [InlineAIPrompt API Reference](slug:Telerik.Blazor.Components.TelerikInlineAIPrompt) for a full list of all properties, methods and events.
99-
100-
@[template](/_contentTemplates/common/parameters-table-styles.md#table-layout)
101-
102-
| Parameter | Type and Default&nbsp;Value | Description |
103-
| --- | --- | --- |
104-
| `Class` | `string` | `The class that is rendered on the .k-prompt element.` |
105-
| `Commands` | `List<AIPromptCommandDescriptor>` | `Configures predefined commands for the component.` |
106-
| `EnableSpeechToText` | `bool` | `Specifies whether to enable speech to text functionality.` |
107-
| `OutputActions` | `List<AIPromptOutputActionDescriptor>` | `Defines the output actions.` |
108-
| `Placeholder` | `string` | `Placeholder text for the input field.` |
109-
| `Prompt` | `string` | `The value of the text field and the prompt that is sent to the AI service.` |
110-
| `PromptContext` | `string` | `Defines the additional context that is passed with the input/command prompt and system prompt.` |
111-
| `SystemPrompt` | `string` | `Defines the system prompt that is used when the component is integrated with MEAI.` |
96+
Get familiar with all InlineAIPrompt parameters, methods, events, and nested tags in the [InlineAIPrompt API Reference](slug:Telerik.Blazor.Components.TelerikInlineAIPrompt).
11297

11398
### Settings and Commands
11499

115-
The InlineAIPrompt exposes settings for itself and its speech to text button. To configure the options, declare a `<InlineAIPromptPopupSettings>` or `InlineAIPromptSpeechToTextButtonSettings` tag inside a `<InlineAIPromptSettings>` tag.
100+
The InlineAIPrompt exposes settings for its popup and its embedded [Speech to Text Button](slug:speechtotextbutton-overview). To configure the options, declare a `<InlineAIPromptPopupSettings>` or `<InlineAIPromptSpeechToTextButtonSettings>` tag inside `<InlineAIPromptSettings>`.
116101

117-
The InlineAIPrompt component also exposes an option to set predefined commands. To configure the actions, use the `Commands` parameter and subscribe to the `OnCommandExecute` event that will fire whenever the user executes a command. The handler expects an argument of type `InlineAIPromptCommandExecuteEventArgs`.
102+
The InlineAIPrompt component also exposes an option to set predefined commands, which is a predefined prompt that is processed immediately. To configure the actions, use the `Commands` parameter and subscribe to the `OnCommandExecute` event that will fire whenever the user executes a command. The handler expects an argument of type `InlineAIPromptCommandExecuteEventArgs`.
118103

119104
````Razor
120105
<div class="destinations-container">
121106
@foreach (var destination in TravelDestinations)
122107
{
123-
<div class="destination-card"
124-
@onclick="@((MouseEventArgs e) => ShowPromptAsync(e, destination))"
125-
@onclick:preventDefault="true">
108+
<TelerikButton Class="destination-card"
109+
OnClick="@((MouseEventArgs e) => ShowPromptAsync(e, destination))">
126110
@destination
127-
</div>
111+
</TelerikButton>
128112
}
129113
</div>
130114
@@ -153,9 +137,9 @@ The InlineAIPrompt component also exposes an option to set predefined commands.
153137
</TelerikInlineAIPrompt>
154138
155139
@code {
156-
private string UserPrompt { get; set; }
157-
private string PromptContext { get; set; }
158-
private TelerikInlineAIPrompt InlinePromptRef { get; set; }
140+
private string UserPrompt { get; set; } = string.Empty;
141+
private string PromptContext { get; set; } = string.Empty;
142+
private TelerikInlineAIPrompt? InlinePromptRef { get; set; }
159143
160144
private List<InlineAIPromptCommandDescriptor> Commands { get; set; } = new()
161145
{
@@ -207,7 +191,7 @@ The InlineAIPrompt component also exposes an option to set predefined commands.
207191
private async Task ShowPromptAsync(MouseEventArgs e, string destination)
208192
{
209193
PromptContext = destination;
210-
await InlinePromptRef.ShowAsync(e.ClientX, e.ClientY);
194+
await InlinePromptRef!.ShowAsync(e.ClientX, e.ClientY);
211195
}
212196
213197
private void OnPromptRequest(InlineAIPromptPromptRequestEventArgs args)
@@ -239,10 +223,10 @@ The InlineAIPrompt component also exposes an option to set predefined commands.
239223
cursor: pointer;
240224
}
241225
242-
.destination-card:hover {
243-
transform: translateY(-5px);
244-
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
245-
}
226+
.destination-card:hover {
227+
transform: translateY(-5px);
228+
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
229+
}
246230
</style>
247231
````
248232

@@ -254,7 +238,7 @@ Use the component reference to execute the following methods.
254238
|-------------|-------------|
255239
| `Refresh` | Re-renders the component. |
256240
| `ShowAsync` | Shows the inline prompt at defined coordinates. Accepts two parameters: X and Y coordinates to position the popup. |
257-
| `HideAsync` | Hides the inline prompt. |
241+
| `HideAsync` | Hides the Inline AI Prompt. |
258242

259243
## See Also
260244

components/inlineaiprompt/streaming.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ position: 5
1010

1111
# Streaming AI Responses with InlineAIPrompt
1212

13-
The UI for Blazor InlineAIPrompt component supports streaming responses, allowing users to see AI-generated content as it is being produced. This feature improves the user experience by providing immediate feedback and a more interactive interface.
13+
The Blazor InlineAIPrompt component supports streaming responses, allowing users to see AI-generated content as it is being produced. This feature improves the user experience by providing immediate feedback and a more interactive interface.
1414

1515
Streaming is particularly useful when:
1616

17-
* Working with long-form AI responses that take several seconds to generate.
17+
* Working with long-form AI responses that take more time to generate.
1818
* Creating inline editing interfaces where users expect real-time feedback.
1919
* Integrating with AI services that support chunked responses.
2020
* Enhancing user engagement in contextual AI assistance scenarios.
@@ -30,7 +30,7 @@ This event is fired when the user clicks the Stop Generation button. You can use
3030
When implementing real AI model streaming logic:
3131

3232
* Replace the sample `OutputChunks` loop with your actual AI model streaming code.
33-
* Each time a new piece of text arrives from the AI model, call `AppendOutput` to update the InlineAIPrompt output area.
33+
* Each time a new piece of response arrives from the AI model, call `AppendOutput` to update the InlineAIPrompt output area.
3434
* If the user clicks the Stop Generation button, cancel the AI request in `OnPromptRequestStop`.
3535

3636
## Example
@@ -43,11 +43,10 @@ When implementing real AI model streaming logic:
4343
<div class="destinations-container">
4444
@foreach (var destination in TravelDestinations)
4545
{
46-
<div class="destination-card"
47-
@onclick="@((MouseEventArgs e) => OnDestinationContextMenuAsync(e, destination))"
48-
@onclick:preventDefault="true">
46+
<TelerikButton Class="destination-card"
47+
OnClick="@((MouseEventArgs e) => OnDestinationContextMenuAsync(e, destination))">
4948
@destination
50-
</div>
49+
</TelerikButton>
5150
}
5251
</div>
5352
@@ -56,17 +55,20 @@ When implementing real AI model streaming logic:
5655
OnPromptRequest="@OnPromptRequestAsync"
5756
OnPromptRequestStop="@OnPromptRequestStopAsync"
5857
PromptContext="@PromptContext">
58+
<InlineAIPromptSettings>
59+
<InlineAIPromptPopupSettings Width="400px" />
60+
</InlineAIPromptSettings>
5961
</TelerikInlineAIPrompt>
6062
6163
@code {
62-
private string UserPrompt { get; set; }
63-
private string PromptContext { get; set; }
64-
private TelerikInlineAIPrompt InlinePromptRef { get; set; }
65-
private CancellationTokenSource CancellationTokenSource { get; set; }
64+
private string UserPrompt { get; set; } = string.Empty;
65+
private string PromptContext { get; set; } = string.Empty;
66+
private TelerikInlineAIPrompt? InlinePromptRef { get; set; }
67+
private CancellationTokenSource? CancellationTokenSource { get; set; }
6668
6769
private async Task OnPromptRequestStopAsync()
6870
{
69-
await CancellationTokenSource.CancelAsync();
71+
await CancellationTokenSource!.CancelAsync();
7072
}
7173
7274
private List<string> TravelDestinations { get; set; } = new()
@@ -86,15 +88,15 @@ When implementing real AI model streaming logic:
8688
private async Task OnDestinationContextMenuAsync(MouseEventArgs e, string destination)
8789
{
8890
PromptContext = destination;
89-
await InlinePromptRef.ShowAsync(e.ClientX, e.ClientY);
91+
await InlinePromptRef!.ShowAsync(e.ClientX, e.ClientY);
9092
}
9193
9294
private async Task OnPromptRequestAsync(InlineAIPromptPromptRequestEventArgs args)
9395
{
9496
CancellationTokenSource = new CancellationTokenSource();
9597
foreach (var chunk in OutputChunks)
9698
{
97-
InlinePromptRef.AppendOutput(chunk);
99+
InlinePromptRef!.AppendOutput(chunk);
98100
await Task.Delay(1000, CancellationTokenSource.Token);
99101
}
100102
}

0 commit comments

Comments
 (0)