- Adding custom views
- Setting active view
Contact Support
Custom views in ASP.NET CORE AI AssistView control
20 Sep 20248 minutes to read
Adding custom views
By using the e-aiassistview-view
tag helper you can define the collection of different assist view models in the AI AssistView. You can customize the default and the custom views added.
Setting view type
You can set the type of view by using the type property. It accepts two values such as Assist, and Custom.
@using Syncfusion.EJ2.InteractiveChat;
<div class="aiassist-container" style="height: 350px; width: 650px;">
<ejs-aiassistview id="aiAssistView" promptRequest="onPromptRequest" created="onCreated">
<e-aiassistview-views>
<e-aiassistview-view type="Assist"></e-aiassistview-view>
<e-aiassistview-view type="Custom" name="Response" viewTemplate="<div class='view-container'><h5>Response view content</h5></div>"></e-aiassistview-view>
</e-aiassistview-views>
</ejs-aiassistview>
</div>
<script>
var assistObj;
function onCreated() {
assistObj = this;
}
function onPromptRequest(args) {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AI AssistView control to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
assistObj.addPromptResponse(defaultResponse);
}, 2000);
}
</script>
Setting name
You can use the name
property to specifies the header name of the Assist
or Custom
views in the AI AssistView.
@using Syncfusion.EJ2.InteractiveChat;
<div class="aiassist-container" style="height: 350px; width: 650px;">
<ejs-aiassistview id="aiAssistView" promptRequest="onPromptRequest" created="onCreated">
<e-aiassistview-views>
<e-aiassistview-view type="Assist" name="Prompt"></e-aiassistview-view>
<e-aiassistview-view type="Custom" name="Response" viewTemplate="<div class='view-container'><h5>Response view content</h5></div>"></e-aiassistview-view>
</e-aiassistview-views>
</ejs-aiassistview>
</div>
<script>
var assistObj;
function onCreated() {
assistObj = this;
}
function onPromptRequest(args) {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AI AssistView control to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
assistObj.addPromptResponse(defaultResponse);
}, 2000);
}
</script>
Setting iconCss
You can customize the view icons by using the iconCss
property. By default the e-assistview-icon
class is added as built-in header icon for the AI AssistView.
@using Syncfusion.EJ2.InteractiveChat;
<div class="aiassist-container" style="height: 350px; width: 650px;">
<ejs-aiassistview id="aiAssistView" promptRequest="onPromptRequest" created="onCreated">
<e-aiassistview-views>
<e-aiassistview-view type="Assist"></e-aiassistview-view>
<e-aiassistview-view type="Custom" name="Response" IconCss="e-comment-show" viewTemplate="<div class='view-container'><h5>Response view content</h5></div>"></e-aiassistview-view>
</e-aiassistview-views>
</ejs-aiassistview>
</div>
<script>
var assistObj;
function onCreated() {
assistObj = this;
}
function onPromptRequest(args) {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AI AssistView control to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
assistObj.addPromptResponse(defaultResponse);
}, 2000);
}
</script>
Setting view template
You can use the viewTemplate
property to add the view content of the multiple views added in the AI AssistView.
@using Syncfusion.EJ2.InteractiveChat;
<div class="aiassist-container" style="width: max(50%, 500px); margin: 30px auto;">
<ejs-aiassistview id="aiAssistView">
<e-aiassistview-views>
<e-aiassistview-view type="Assist" name="Prompt" viewTemplate="<div class='view-container'><h5>Prompt view content</h5></div>"></e-aiassistview-view>
<e-aiassistview-view type="Custom" name="Response" iconCss="e-icons e-comment-show" viewTemplate="<div class='view-container'><h5>Response view content</h5></div>"></e-aiassistview-view>
</e-aiassistview-views>
</ejs-aiassistview>
</div>
<style>
.view-container {
margin: 20px auto;
width: 80%;
}
</style>
Setting active view
You can use the activeView
property to set the active view in the AI AssistView. By default, the value is 0
.
@using Syncfusion.EJ2.InteractiveChat;
<div class="aiassist-container" style="height: 350px; width: 650px;">
<ejs-aiassistview id="aiAssistView" activeView="1" promptRequest="onPromptRequest" created="onCreated">
<e-aiassistview-views>
<e-aiassistview-view type="Assist"></e-aiassistview-view>
<e-aiassistview-view type="Custom" name="Response" iconCss="e-icons e-comment-show" viewTemplate="<div class='view-container'><h5>Response view content</h5></div>"></e-aiassistview-view>
</e-aiassistview-views>
</ejs-aiassistview>
</div>
<script>
var assistObj;
function onCreated() {
assistObj = this;
}
function onPromptRequest(args) {
setTimeout(() => {
let defaultResponse = 'For real-time prompt processing, connect the AI AssistView control to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
assistObj.addPromptResponse(defaultResponse);
}, 2000);
}
</script>
<style>
.view-container {
height: inherit;
display: flex;
align-items: center;
justify-content: center;
}
</style>