Skip to content

Commit 82f4830

Browse files
Updated the image and context
1 parent 8625938 commit 82f4830

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed
105 Bytes
Loading

MAUI/AIAssistView/items.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ The `SfAIAssistView` control includes a built-in event called [CardTapped](https
430430

431431
## Show error response
432432

433-
The `SfAIAssistView` allows to display error responses by setting the text to the `ErrorMessage`, ensuring clear notification when an error occurs during AI interactions.
433+
The `SfAIAssistView` allows to display error responses by setting the error text to the `AssistItem.ErrorMessage` property, ensuring clear notification when an error occurs during AI interactions.
434434

435435
{% tabs %}
436-
{% highlight c# tabtitle="ViewModel.cs" hl_lines="24" %}
436+
{% highlight c# tabtitle="ViewModel.cs" hl_lines="36" %}
437437

438438
public class ViewModel : INotifyPropertyChanged
439439
{
@@ -453,17 +453,28 @@ public class ViewModel : INotifyPropertyChanged
453453
await GetResult(requestItem);
454454
}
455455
456-
private async Task GetResult(AssistItem requestItem)
456+
private async Task GetResultAsync(AssistItem requestItem)
457457
{
458-
await Task.Delay(1000).ConfigureAwait(true);
459-
460-
AssistItem responseItem = new AssistItem()
458+
try
459+
{
460+
await Task.Delay(1000);
461+
// If successful, add the normal response
462+
AssistItem responseItem = new AssistItem()
463+
{
464+
Text = "Active Listening – Fully focusing and responding to the speaker with attention and empathy. Passive Listening – Hearing without reacting or engaging with the speaker. Empathetic Listening – Understanding the speaker’s emotions and feelings deeply.",
465+
IsRequested = false,
466+
};
467+
this.AssistItems.Add(responseItem);
468+
}
469+
catch (Exception ex)
461470
{
462-
ErrorMessage = "An error occured. Either the engine you requested does not exist or there was another issue processing your request.",
463-
IsRequested = false,
464-
};
465-
466-
this.AssistItems.Add(responseItem);
471+
AssistItem errorItem = new AssistItem()
472+
{
473+
ErrorMessage = "An error occurred. Either the engine you requested does not exist or there was another issue processing your request.",
474+
IsRequested = false,
475+
};
476+
this.AssistItems.Add(errorItem);
477+
}
467478
}
468479
}
469480

0 commit comments

Comments
 (0)