Skip to content

Commit 254d4f8

Browse files
Merge pull request #3561 from syncfusion-content/Chat_ErrorResponse
977149: Added UG topic for Support to show error response UI in SfAIAssistView
2 parents 980c5f7 + 82f4830 commit 254d4f8

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
17.8 KB
Loading

MAUI/AIAssistView/items.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,58 @@ The `SfAIAssistView` control includes a built-in event called [CardTapped](https
427427

428428
{% endhighlight %}
429429
{% endtabs %}
430+
431+
## Show error response
432+
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.
434+
435+
{% tabs %}
436+
{% highlight c# tabtitle="ViewModel.cs" hl_lines="36" %}
437+
438+
public class ViewModel : INotifyPropertyChanged
439+
{
440+
441+
...
442+
443+
private void GenerateAssistItems()
444+
{
445+
AssistItem requestItem = new AssistItem()
446+
{
447+
Text = "Types of listening",
448+
IsRequested = true
449+
};
450+
451+
this.AssistItems.Add(requestItem);
452+
453+
await GetResult(requestItem);
454+
}
455+
456+
private async Task GetResultAsync(AssistItem requestItem)
457+
{
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)
470+
{
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+
}
478+
}
479+
}
480+
481+
{% endhighlight %}
482+
{% endtabs %}
483+
484+
![Error message in .NET MAUI AI AssistView](images/maui-aiassistview-error-message.png)

0 commit comments

Comments
 (0)