Example of generative UI in ASP.NET MVC AI AssistView Control
This sample demonstrates how to render interactive generative UI tools directly within AI responses using user prompts in the AI AssistView control. By configuring an appropriate system prompt, the AI can generate well-structured prompts that automatically invoke the registered tools, enabling seamless integration of dynamic and interactive UI elements within responses.
DEMO
SOURCE
In this example, the AI AssistView is configured with the UI tools:
- The
addPromptResponsemethod adds AI responses to the AIAssistView by accepting a blocks array that defines content structure. Tools are registered usingregisterToolUI(), which defines a template and handler function for rendering. - Tool registration - Three registered tools deliver rich content:
weather-cardfor forecast displays,chart-toolfor GDP growth visualization, andsales-gridfor regional performance data. - bannerTemplate - Customizes the initial banner content with icon and heading.
- promptSuggestions - Provides predefined prompts for weather forecasts, sales analysis, and economic trend data.
- promptRequest - Handles prompt execution and dynamically renders custom tools.
- enableStreaming - Enables real-time response streaming with simulated delay.