menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfAIAssistView - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfAIAssistView

    Inheritance
    System.Object
    SfBaseComponent
    SfAIAssistView
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.GetEffectivePlatform()
    SfBaseComponent.GetMainComponentPlatform()
    SfBaseComponent.IsMainLicenseComponent()
    SfBaseComponent.LicenseContext
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    SfBaseComponent.ValidateLicense()
    Namespace: Syncfusion.Blazor.InteractiveChat
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfAIAssistView : SfBaseComponent
    Examples
     
    <SfAIAssistView>
        <ChildContent>
            <AssistViews>
                <AssistView Header="AI Generation"></AssistView>
                <CustomView Header="NoteBook"></CustomView>
            </AssistViews>
        </ChildContent>
    </SfAIAssistView>

    Constructors

    SfAIAssistView()

    Declaration
    public SfAIAssistView()

    Properties

    ActiveView

    Gets or sets the index of the active view in the SfAIAssistView component.

    Declaration
    public int ActiveView { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer representing the index of the active view. The default value is 0.

    Remarks

    This property determines which view is currently active and visible in the SfAIAssistView component.

    ActiveViewChanged

    Declaration
    public EventCallback<int> ActiveViewChanged { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.Int32>

    AttachmentRemoved

    Event triggered when an attachment is removed from the upload list in the SfAIAssistView component.

    Declaration
    public EventCallback<RemovingEventArgs> AttachmentRemoved { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<RemovingEventArgs>
    Remarks

    This event allows for actions to be performed following an attachment's removal, such as updating the user interface or notifying other application components.

    Examples

    Handling the attachment removed event:

    <SfAIAssistView AttachmentRemoved="OnAttachmentRemoved">
        <!-- Configuration -->
    </SfAIAssistView>
    
    @code {
        private Task OnAttachmentRemoved(RemovingEventArgs args)
        {
            Console.WriteLine($"Attachment removed: {args.FileName}");
            return Task.CompletedTask;
        }
    }

    AttachmentSettings

    Gets or sets the configuration settings for attachments in the SfAIAssistView component.

    Declaration
    public AssistViewAttachmentSettings AttachmentSettings { get; set; }
    Property Value
    Type Description
    AssistViewAttachmentSettings

    An instance of AssistViewAttachmentSettings containing the configuration settings for attachments.

    Remarks

    This property provides settings for handling attachments, such as the save URL, remove URL, allowed file types, and maximum file size attributes.

    AttachmentUploadChange

    Gets or sets the event callback that will be invoked when the attached files are uploaded in the SfAIAssistView component.

    Declaration
    public EventCallback<UploadChangeEventArgs> AttachmentUploadChange { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<UploadChangeEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that handles attachment upload events. The default value is an empty event callback.

    Remarks

    This event is triggered when users upload file attachments within the AI AssistView component. Unlike traditional file upload scenarios, this event enables client-side file processing without requiring a server endpoint, making it ideal for AI-powered applications that need to process attachments locally or send them directly to AI services.

    The event provides access to uploaded file information through the UploadChangeEventArgs parameter, allowing developers to read file contents using the OpenReadStream() method of the Microsoft.AspNetCore.Components.Forms.IBrowserFile interface. This is particularly useful for AI AssistView scenarios where file content needs to be analyzed, processed, or included in AI prompts.

    Examples

    The following example demonstrates how to handle attachment uploads in an AI AssistView component:

    <SfAIAssistView AttachmentUploadChange="OnChange">
        <!-- Configuration -->
    </SfAIAssistView>
    
    @code{
        private async Task OnChange(UploadChangeEventArgs args)
        {
            try
            {
                foreach (var file in args.Files)
                {
                    var path = @"D:\" + file.FileInfo.Name;
                    FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
                    await file.File.OpenReadStream(long.MaxValue).CopyToAsync(filestream);
                    filestream.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
      }

    AttachmentUploadFailed

    Event raised when the attachment upload fails in the SfAIAssistView component.

    Declaration
    public EventCallback<FailureEventArgs> AttachmentUploadFailed { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<FailureEventArgs>
    Remarks

    This event occurs when a file upload does not complete successfully. It enables the handling of upload failure scenarios via error handling logic.

    Examples

    Handling an upload failure event:

    <SfAIAssistView AttachmentUploadFailed="OnUploadFailed">
        <!-- Configuration -->
    </SfAIAssistView>
    
    @code {
        private Task OnUploadFailed(FailureEventArgs args)
        {
            Console.WriteLine($"Upload failed for file: {args.FileName}, Reason: {args.Reason}");
            return Task.CompletedTask;
        }
    }

    AttachmentUploadStart

    Event triggered before the attachment upload begins in the SfAIAssistView component.

    Declaration
    public EventCallback<UploadingEventArgs> AttachmentUploadStart { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<UploadingEventArgs>
    Remarks

    This event allows customization and validation before the upload process starts. It provides access to the event arguments required for custom handling.

    Examples

    Handling the attachment upload start event:

    <SfAIAssistView AttachmentUploadstart="OnStartUploading">
        <!-- Configuration -->
    </SfAIAssistView>
    
    @code {
        private Task OnStartUploading(UploadingEventArgs args)
        {
            Console.WriteLine($"Starting upload for file: {args.FileName}");
            return Task.CompletedTask;
        }
    }

    AttachmentUploadSuccess

    Event raised when the attachment upload is successful in the SfAIAssistView component.

    Declaration
    public EventCallback<SuccessEventArgs> AttachmentUploadSuccess { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<SuccessEventArgs>
    Remarks

    This event is triggered after a file has been successfully uploaded. It allows handling subsequent actions, like updating UI elements or logging success messages.

    Examples

    Handling the successful upload event:

    <SfAIAssistView AttachmentUploadSuccess="OnUploadSuccess">
        <!-- Configuration -->
    </SfAIAssistView>
    
    @code {
        private Task OnUploadSuccess(SuccessEventArgs args)
        {
            Console.WriteLine($"File uploaded successfully: {args.FileName}");
            return Task.CompletedTask;
        }
    }

    ChildContent

    Gets or sets a value that indicates the child content for the AIAssist.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment

    Created

    Event raised when the SfAIAssistView is created.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.Object>
    Remarks

    This event is triggered when the SfAIAssistView component is created.

    CssClass

    Gets or sets custom CSS classes for the SfAIAssistView component.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    A string containing CSS class names to customize the appearance. The default is String.Empty.

    Remarks

    This property allows adding custom CSS classes for styling the SfAIAssistView component.

    EnableRtl

    Gets or sets whether the right to left direction is enabled for SfAIAssistView component.

    Declaration
    public bool EnableRtl { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, if the right to left direction is enabled for SfAIAssistView component. The default value is false.

    Height

    Gets or sets the height of the SfAIAssistView component.

    Declaration
    public string Height { get; set; }
    Property Value
    Type Description
    System.String

    The height of the SfAIAssistView component. The default is "100%".

    Remarks

    This property specifies the height of the SfAIAssistView component.

    ID

    Sets id attribute for the AI Prompt.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    Accepts the string value.

    Prompt

    Gets or sets the prompt text in the SfAIAssistView component. Supports two-way binding.

    Declaration
    public string Prompt { get; set; }
    Property Value
    Type Description
    System.String

    The text to be used as the prompt. The default is String.Empty.

    Remarks

    This property represents the text input prompt for the SfAIAssistView component. Define @bind-Prompt to use two-way binding.

    PromptChanged

    Event raised when the prompt text is changed in the SfAIAssistView.

    Declaration
    public EventCallback<string> PromptChanged { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.String>
    Remarks

    This event is triggered when the prompt text is changed in the SfAIAssistView component.

    PromptIconCss

    Gets or sets the CSS class for the prompter avatar in the SfAIAssistView component.

    Declaration
    public string PromptIconCss { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the CSS class for styling the avatar of each prompt. The default value is an empty string.

    Remarks

    Use this property to apply custom styles to the prompt avatar in the SfAIAssistView component.

    PromptPlaceholder

    Gets or sets the placeholder text for the prompt input text area in the SfAIAssistView component.

    Declaration
    public string PromptPlaceholder { get; set; }
    Property Value
    Type Description
    System.String

    The placeholder text displayed in the prompt input text area field. The default is "Type prompt for assistance...".

    Remarks

    This property provides placeholder text to guide users on what to input in the prompt text area field in the SfAIAssistView component.

    PromptRequested

    Event raised when a prompt request is made in the SfAIAssistView.

    Declaration
    public EventCallback<AssistViewPromptRequestedEventArgs> PromptRequested { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<AssistViewPromptRequestedEventArgs>
    Remarks

    This event is triggered when a prompt request is made in the SfAIAssistView component.

    Prompts

    Gets or sets the collection of prompts and their responses in the SfAIAssistView component.

    Declaration
    public List<AssistViewPrompt> Prompts { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<AssistViewPrompt>

    A list of AssistViewPrompt representing the prompts. The default is an empty list.

    Remarks

    This property holds the collection of provided prompts and their responses for the SfAIAssistView component.

    PromptSuggestions

    Gets or sets the list of prompt suggestions in the SfAIAssistView component.

    Declaration
    public List<string> PromptSuggestions { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.String>

    A list of strings representing the prompt suggestions. The default is an empty list.

    Remarks

    This property contains the suggestions that can be used as prompts in the SfAIAssistView component.

    PromptSuggestionsHeader

    Gets or sets the header text for the prompt suggestions in the SfAIAssistView component.

    Declaration
    public string PromptSuggestionsHeader { get; set; }
    Property Value
    Type Description
    System.String

    The header text displayed above the prompt suggestions list. The default is String.Empty.

    Remarks

    This property provides a header for the list of prompt suggestions in the SfAIAssistView component.

    ResponseIconCss

    Gets or sets the CSS class for the responder avatar in the SfAIAssistView component.

    Declaration
    public string ResponseIconCss { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the CSS class for styling the avatar of each response. The default value is an empty string.

    Remarks

    Use this property to apply custom styles to the responder avatar in the SfAIAssistView component.

    ResponseStopped

    Event triggered when the "Stop Responding" button is clicked during an ongoing prompt response.

    Declaration
    public EventCallback<ResponseStoppedEventArgs> ResponseStopped { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<ResponseStoppedEventArgs>
    Remarks
    • The event is raised when a user explicitly clicks "Stop Responding."
    • Use this event to stop AI processing and handle UI updates, ensuring a smooth user experience.
    • The event provides ResponseStoppedEventArgs to access details such as the associated prompt and its index.

    ShowHeader

    Gets or sets a value indicating whether the header is displayed in the SfAIAssistView component.

    Declaration
    public bool ShowHeader { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the header is displayed; otherwise, false. The default is true.

    Remarks

    This property controls the visibility of the header in the SfAIAssistView component.

    Width

    Gets or sets the width of the SfAIAssistView component.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    The width of the SfAIAssistView component. The default is "100%".

    Remarks

    This property specifies the width of the SfAIAssistView component.

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    ExecutePromptAsync(String)

    Executes the prompts at dynamically to generate the respective output.

    Declaration
    public Task ExecutePromptAsync(string Prompt)
    Parameters
    Type Name Description
    System.String Prompt
    Returns
    Type Description
    System.Threading.Tasks.Task

    System.Threading.Tasks.Task.

    OnAfterRenderAsync(Boolean)

    Method invoked after each time the component has been rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    Set to true for the first time component rendering; otherwise gets false.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Overrides
    SfBaseComponent.OnAfterRenderAsync(Boolean)

    OnInitializedAsync()

    Method invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Overrides
    SfBaseComponent.OnInitializedAsync()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    ScrollToBottomAsync()

    Scrolls the SfAIAssistView component to the bottom asynchronously.

    Declaration
    public Task ScrollToBottomAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous scrolling operation.

    Remarks

    Ensures the latest content is visible by programmatically scrolling to the bottom of the view.

    UpdateResponseAsync(String)

    Asynchronously updates the streaming response of a prompt by appending the latest chunk and rendering it in real-time within the SfAIAssistView component.

    Declaration
    public Task UpdateResponseAsync(string response)
    Parameters
    Type Name Description
    System.String response

    The full accumulated response, including all previously received chunks. Each chunk is appended externally (before calling this method), ensuring a progressive update of the response in the UI.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation. This method executes in a non-blocking manner, ensuring that UI updates occur smoothly without freezing the main thread.

    Remarks
    • This method is designed to handle AI-generated streaming responses efficiently.
    • It enables real-time response rendering by progressively updating the SfAIAssistView component as new chunks arrive.
    • Asynchronous execution ensures a smooth UI experience, allowing updates without blocking user interactions.
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved