Streaming AI Responses with InlineAIPrompt
The ASP.NET MVC InlineAIPrompt component enables streaming responses, allowing users to view AI-generated content in real time as it's being created. This capability significantly improves the user experience by offering instant feedback and a more dynamic interaction.
Streaming proves especially beneficial in scenarios such as:
- Handling lengthy AI outputs that require several seconds to complete.
- Building inline editing tools where users anticipate immediate updates.
- Connecting with AI platforms that deliver responses in chunks.
- Boosting engagement in contextual AI support environments.
Configuration
To enable streaming in the InlineAIPrompt component, follow these steps:
-
Enable the
IsStreaming
property of the InlineAIPrompt. This property controls whether the component displays the Stop Generation button and indicates that a response is being streamed.Razor@(Html.Kendo().InlineAIPrompt() .Name("inlineAi") .IsStreaming(true) ...... //Additional configuration )
-
To initiate streaming in the ASP.NET MVC InlineAIPrompt component, you need to handle the
PromptRequest
event. This event is triggered when the user either clicks the Send button or presses Enter.Razor@(Html.Kendo().InlineAIPrompt() .Name("inlineaiprompt") .Events(ev => ev.PromptRequest("onPromptRequest")) ... //Additional configuration )