|
| 1 | +@page "/" |
| 2 | + |
| 3 | +<div style="height: 350px; width: 650px;"> |
| 4 | + <SfAIAssistView PromptSuggestions="@TaskSuggestions" PromptRequested="@HandlePromptRequest"></SfAIAssistView> |
| 5 | +</div> |
| 6 | + |
| 7 | +@code { |
| 8 | + |
| 9 | + List<string> TaskSuggestions = new List<string> |
| 10 | + { |
| 11 | + "How do I prioritize my tasks?", |
| 12 | + "How can I improve my time management skills?" |
| 13 | + }; |
| 14 | + |
| 15 | + public class ChatResponseModel |
| 16 | + { |
| 17 | + public string? UserPrompt { get; set; } |
| 18 | + public string? BotResponse { get; set; } |
| 19 | + } |
| 20 | + |
| 21 | + private List<ChatResponseModel> ResponseData = new List<ChatResponseModel>() |
| 22 | + { |
| 23 | + new ChatResponseModel() |
| 24 | + { |
| 25 | + UserPrompt = "How do I prioritize my tasks?", |
| 26 | + BotResponse = @"Prioritize tasks by urgency and impact: tackle high-impact tasks first, |
| 27 | + delegate when possible, and break large tasks into smaller steps. For more assistance, |
| 28 | + feel free to ask—I’m here to help!" |
| 29 | + }, |
| 30 | + new ChatResponseModel() |
| 31 | + { |
| 32 | + UserPrompt = "How can I improve my time management skills?", |
| 33 | + BotResponse = @"To improve time management skills, try setting clear goals, using a planner |
| 34 | + or digital tools, prioritizing tasks, breaking tasks into smaller steps, and minimizing |
| 35 | + distractions. Regularly review and adjust your approach for better efficiency." |
| 36 | + } |
| 37 | + }; |
| 38 | + |
| 39 | + private async Task HandlePromptRequest(AssistViewPromptRequestedEventArgs args) |
| 40 | + { |
| 41 | + await Task.Delay(3000); |
| 42 | + var isUserPromptFound = ResponseData.Any(data => data.UserPrompt == args.Prompt); |
| 43 | + var matchedData = ResponseData.FirstOrDefault(data => data.UserPrompt == args.Prompt); |
| 44 | + var fallbackResponse = @"For real-time prompt processing, connect the AI AssistView component |
| 45 | + to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain |
| 46 | + the necessary API credentials to authenticate and enable seamless integration."; |
| 47 | + args.Response = isUserPromptFound ? matchedData?.BotResponse : fallbackResponse; |
| 48 | + } |
| 49 | +} |
0 commit comments