Back to Devexpress

MemoSmartAutoComplete.SuggestionReceived Event

blazor-devexpress-dot-aiintegration-dot-blazor-dot-editors-dot-memosmartautocomplete.md

latest3.5 KB
Original Source

MemoSmartAutoComplete.SuggestionReceived Event

Fires when the Memo receives a suggestion from an AI service.

Namespace : DevExpress.AIIntegration.Blazor.Editors

Assembly : DevExpress.AIIntegration.Blazor.Editors.v25.2.dll

NuGet Package : DevExpress.AIIntegration.Blazor.Editors

Declaration

csharp
[Parameter]
public EventCallback<MemoSmartAutoCompleteSuggestionReceivedEventArgs> SuggestionReceived { get; set; }

Parameters

TypeDescription
MemoSmartAutoCompleteSuggestionReceivedEventArgs

An object that contains data for this event.

|

Remarks

Use the SuggestionReceived event to handle AI-generated text suggestions. The event argument’s SuggestionText and ResponseStatus properties allow you to obtain suggestion text and a status of the AI service response.

Common use cases:

  • Process and validate AI-generated text suggestions before they are applied.
  • Check an AI service response status.
  • Log or analyze suggestion patterns.
  • Customize or filter suggestions based on business rules.
razor
<label for="memoSmartAutoComplete" class="demo-text cw-480 mb-1">
    To see autocomplete suggestions, move the caret to the end and start typing.
</label>
<DxMemo @bind-Text=@TextValue
        Rows="5"
        CssClass="cw-480"
        InputId="memoSmartAutoComplete">
    <Extensions>
        <MemoSmartAutoComplete InputDelay="1000" SuggestionReceived="@OnSuggestionReceived" />
    </Extensions>
</DxMemo>
<div class="demo-text cw-480 mt-2">
    <p class="mb-0">Request count: <b>@_requestCount</b></p>
    <p>Current suggestion: <b>@GetSuggestionText()</b></p>
    <p>Current response status: <b>@_lastResponseStatus</b></p>
</div>

@code {
    string _lastSuggestionText { get; set; }
    string _lastResponseStatus { get; set; } = "None";
    int _requestCount { get; set; }
    string GetSuggestionText() {
        if(string.IsNullOrWhiteSpace(_lastSuggestionText))
            return "Empty string";
        return _lastSuggestionText;
    }
    void OnSuggestionReceived(MemoSmartAutoCompleteSuggestionReceivedEventArgs e) {
        _requestCount++;
        _lastResponseStatus = e.ResponseStatus;
        _lastSuggestionText = e.SuggestionText;
    }
    string TextValue { get; set; } =
    "Taylor continues to have problems managing expectations. " +
    "She is too optimistic and refuses to be realistic about the workload involved. " +
    "I recommend";
}

Run Demo

For information on the AI-powered Smart Autocomplete extension setup, refer to the following class description: MemoSmartAutoComplete.

See Also

MemoSmartAutoComplete Class

MemoSmartAutoComplete Members

DevExpress.AIIntegration.Blazor.Editors Namespace