Skip to content

Commit a1a2957

Browse files
xristianstefanovxristianstefanov
authored andcommitted
chore(AiPrompt): fix outdated docs examples
1 parent 74b4e23 commit a1a2957

File tree

2 files changed

+40
-41
lines changed

2 files changed

+40
-41
lines changed

components/aiprompt/events.md

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,7 @@ To define the available output actions, set the `OutputActions` parameter to a l
2626

2727
The event handler receives an argument of type `AIPromptOutputActionClickEventArgs`, 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 [`AIPromptOutputActionClickEventArgs` API reference](slug:Telerik.Blazor.Components.AIPromptOutputActionClickEventArgs).
2828

29-
>caption Handle output action clicks in the AIPrompt
30-
31-
````RAZOR
32-
<TelerikAIPrompt OutputActions="@OutputActions"
33-
OnOutputActionClick="@OnOutputActionClick"
34-
OnPromptRequest="@HandlePromptRequest">
35-
</TelerikAIPrompt>
36-
37-
@code {
38-
private void OnOutputActionClick(AIPromptOutputActionClickEventArgs args)
39-
{
40-
// Handle the output action click event
41-
Console.WriteLine($"Action clicked: {args.Action.Name}");
42-
}
43-
44-
private List<AIPromptOutputActionDescriptor> OutputActions { get; set; } = new List<AIPromptOutputActionDescriptor>()
45-
{
46-
new AIPromptOutputActionDescriptor() { Name = "Copy", Icon = nameof(SvgIcon.Copy) },
47-
new AIPromptOutputActionDescriptor() { Name = "Retry", Icon = nameof(SvgIcon.Share) },
48-
new AIPromptOutputActionDescriptor() { Icon = SvgIcon.ThumbUp, Name = "Thumbs Up" },
49-
new AIPromptOutputActionDescriptor() { Icon = SvgIcon.ThumbDown, Name = "Thumbs Down" }
50-
};
51-
52-
private void HandlePromptRequest(AIPromptPromptRequestEventArgs args)
53-
{
54-
// The example uses dummy data intentionally. Replace the hard-coded string with a call to your AI API.
55-
args.Output = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
56-
}
57-
}
58-
````
29+
See the [example below](#example).
5930

6031
## OnPromptRequest
6132

@@ -108,9 +79,9 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
10879
10980
<TelerikAIPrompt OnPromptRequest="@OnPromptRequestHandler"
11081
OnCommandExecute="@OnCommandExecuteHandler"
111-
OnOutputRate="@OnOutputRateHandler"
82+
OutputActions="@OutputActions"
83+
OnOutputActionClick="@OnOutputActionClick"
11284
PromptChanged="@OnPromptChanged"
113-
ShowOutputRating="true"
11485
Prompt="@Prompt"
11586
Commands="@PromptCommands">
11687
</TelerikAIPrompt>
@@ -133,6 +104,14 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
133104
},
134105
};
135106
107+
private List<AIPromptOutputActionDescriptor> OutputActions { get; set; } = new List<AIPromptOutputActionDescriptor>()
108+
{
109+
new AIPromptOutputActionDescriptor() { Name = "Copy", Icon = nameof(SvgIcon.Copy) },
110+
new AIPromptOutputActionDescriptor() { Name = "Retry", Icon = nameof(SvgIcon.Share) },
111+
new AIPromptOutputActionDescriptor() { Name = "Thumbs Up", Icon = SvgIcon.ThumbUp },
112+
new AIPromptOutputActionDescriptor() { Name = "Thumbs Down", Icon = SvgIcon.ThumbDown }
113+
};
114+
136115
private void OnPromptRequestHandler(AIPromptPromptRequestEventArgs args)
137116
{
138117
// The example uses dummy data intentionally. Replace the hard-coded string with a call to your AI API.
@@ -145,17 +124,19 @@ The `PromptChanged` event fires when the user changes the prompt text. Use the e
145124
args.Output = "Nisl pretium fusce id velit ut tortor pretium. A pellentesque sit amet porttitor eget dolor. Lectus mauris ultrices eros in cursus turpis massa tincidunt.";
146125
}
147126
148-
private void OnOutputRateHandler(AIPromptOutputRateEventArgs args)
127+
private void OnOutputActionClick(AIPromptOutputActionClickEventArgs args)
149128
{
150-
// The example uses dummy data intentionally. Replace the hard-coded string with a call to your AI API.
129+
// Handle the output action click event
130+
Console.WriteLine($"Action clicked: {args.Action.Name}");
151131
}
152132
153133
private void OnPromptChanged(string prompt)
154134
{
155135
Prompt = prompt;
156136
}
157137
}
158-
159138
````
160139

161-
* [Live Demo: AIPrompt Overview](https://demos.telerik.com/blazor-ui/aiprompt/overview)
140+
## See Also
141+
142+
* [Live Demo: AIPrompt](https://demos.telerik.com/blazor-ui/aiprompt/overview)

components/aiprompt/views/output.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ position: 20
1212

1313
The Output view shows the responses generated by the underlying AI service. Each response renders in its dedicated output card and provides two options to the user—to copy the content of the response or to retry the request. The Output view is activated through interaction—once the user fills out a prompt within the Prompt view and requests a response, the Output view will become active.
1414

15-
If the `ShowOutputRating` is enabled on the component level, the output card will also feature two additional options-to upvote or downvote the response. To handle this interaction, you can use the `OnOutputRate` event. For more information on how to handle the event, refer to the [AIPrompt events](slug:aiprompt-events) article.
15+
If `OutputActions` are configured at the component level, the output card also features two additional options to upvote and downvote the response. To handle this interaction, you can use the `OnOutputActionClick` event. For more information on how to handle the event, refer to the [AIPrompt events](slug:aiprompt-events) article.
1616

1717
By default, the Output view is rendered and is part of the predefined views. However, if you provide a render fragment of type `AIPromptViews` to the `TelerikAIPrompt` tag, you override the default rendering, meaning you must explicitly add `AIPromptOutputView` tag within it.
1818

@@ -31,10 +31,13 @@ By default, the Output view is rendered and is part of the predefined views. How
3131
}
3232
````
3333

34-
>caption Use the `ShowOutputRating` to include visuals related to upvoting or downvoting a specific output.
34+
>caption Use `OutputActions` to include visuals related to upvoting or downvoting a specific output.
3535
3636
````RAZOR
37-
<TelerikAIPrompt @bind-Prompt="@Prompt" ShowOutputRating="true" OnOutputRate="@OnOutputRateHandler">
37+
<TelerikAIPrompt @bind-Prompt="@Prompt"
38+
OnPromptRequest="@OnPromptRequestHandler"
39+
OutputActions="@OutputActions"
40+
OnOutputActionClick="@OnOutputActionClick">
3841
<AIPromptViews>
3942
<AIPromptPromptView ButtonText="Prompt View" ButtonIcon="@SvgIcon.Sparkles" />
4043
<AIPromptOutputView ButtonText="Output View" ButtonIcon="@SvgIcon.Comment" />
@@ -44,10 +47,25 @@ By default, the Output view is rendered and is part of the predefined views. How
4447
@code {
4548
private string Prompt { get; set; }
4649
47-
private void OnOutputRateHandler(AIPromptOutputRateEventArgs args)
50+
private void OnOutputActionClick(AIPromptOutputActionClickEventArgs args)
4851
{
49-
// Handle the output rate event here
52+
// Handle the output action click event
53+
Console.WriteLine($"Action clicked: {args.Action.Name}");
5054
}
55+
56+
private void OnPromptRequestHandler(AIPromptPromptRequestEventArgs args)
57+
{
58+
// The example uses dummy data intentionally. Replace the hard-coded string with a call to your AI API.
59+
args.Output = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vel pretium lectus quam id leo in.";
60+
}
61+
62+
private List<AIPromptOutputActionDescriptor> OutputActions { get; set; } = new List<AIPromptOutputActionDescriptor>()
63+
{
64+
new AIPromptOutputActionDescriptor() { Name = "Copy", Icon = nameof(SvgIcon.Copy) },
65+
new AIPromptOutputActionDescriptor() { Name = "Retry", Icon = nameof(SvgIcon.Share) },
66+
new AIPromptOutputActionDescriptor() { Name = "Thumbs Up", Icon = SvgIcon.ThumbUp },
67+
new AIPromptOutputActionDescriptor() { Name = "Thumbs Down", Icon = SvgIcon.ThumbDown }
68+
};
5169
}
5270
````
5371

0 commit comments

Comments
 (0)