Getting Started with the Kendo UI for Vue Conversational UI
This guide provides essential information about using the Kendo UI for Vue AIPrompt component, part of the Conversational UI package in the Kendo UI for Vue Native suite. In this page you will learn how to:
- Install the Conversational UI package that provides the AIPrompt
- Add the AIPrompt component to your Vue project and apply basic configurations to it.
- Style the component and activate your product license.
After completing this guide, you will be able to reproduce the following example.
Setting Up Your Vue Project
Before you install the Kendo UI for Vue AIPrompt, make sure that you have a running Vue project. The easiest way to set up a Vue project is to use the approach described in the Set up the Vue project section of the First Steps with JavaScript article.
Installing the Conversational UI Package
All Kendo UI for Vue packages are distributed through npm and offer a similar installation experience. To use the AIPrompt component, start with the installation of the Conversational UI npm package and its dependencies.
npm install --save @progress/kendo-vue-conversational-ui @progress/kendo-vue-buttons @progress/kendo-vue-layout @progress/kendo-vue-inputs @progress/kendo-vue-progressbars @progress/kendo-licensing @progress/kendo-drawing @progress/kendo-svg-icons @progress/kendo-vue-intl
Importing the Component
After installing the package, import the AIPrompt component in the Vue App.
In the src/App.vue
file of your Vue project, import the AIPrompt
, AIPromptView
and AIPromptOutputView
components together with the outputViewDefaults
and promptViewDefaults
default configurations from the Conversational UI package.
// ES2015 module syntax
import { AIPrompt, AIPromptOutputView, AIPromptView, outputViewDefaults, promptViewDefaults } from "@progress/kendo-vue-conversational-ui";
// CommonJS format
const { AIPrompt, AIPromptOutputView, AIPromptView, outputViewDefaults, promptViewDefaults } = require('@progress/kendo-vue-conversational-ui');
Using the Component
-
Define the
AIPrompt
,AIPromptView
andAIPromptOutputView
components<AIPrompt> <AIPromptView /> <AIPromptOutputView /> </AIPrompt>
-
Next, define the following:
activeView
property that sets the currently visible view for the component.onActiveViewChange
event triggered when the component's view is changed.onPromptRequest
event which is triggered when the user clicks theGenerate
button in the Prompt view.
Finally pass promptViewDefaults
and outputViewDefaults
to the toolbarItems
prop and define the outputs property in the AIPromptOutputView
component.
<AIPrompt
:activeView="activeView"
@activeviewchange="handleActiveViewChange"
@promptrequest="handleOnRequest"
:toolbarItems="[promptViewDefaults, outputViewDefaults]"
>
<AIPromptView />
<AIPromptOutputView :outputs="outputs" />
</AIPrompt>
-
Add the following data properties and methods:
components: { AIPrompt, AIPromptOutputView, AIPromptView, }, data: function () { return { outputViewDefaults, promptViewDefaults, activeView: promptViewDefaults.name, outputs: [], }; }, methods: { handleOnRequest(prompt, outputItem) { if (!prompt) { return; } this.outputs = [ { id: this.outputs.length + 1, title: "Title", subTitle: `Request ${this.outputs.length + 1}`, responseContent: `Response content for prompt ${ prompt + ". Generation: " + this.outputs.length }`, prompt, }, ...this.outputs, ]; this.activeView = outputViewDefaults.name; }, handleActiveViewChange(viewName) { this.activeView = viewName; }, }
-
To make the AIPrompt look correctly, install and import the Kendo UI Default Theme, which is one of the four beautiful themes for Kendo UI for Vue.
-
Install the Default theme package.
npm install --save @progress/kendo-theme-default
-
Import the Theme package in
src/App.vue
.import '@progress/kendo-theme-default';
-
-
Build, run and test the application by typing the following command in the root folder of your project:
npm run dev
Activating Your License Key
Using any of the UI components in the Kendo UI for Vue Native library requires either a commercial license key or an active trial license key.
Follow the instructions on the My License page to activate your trial or commercial license. You can skip this step if your application already contains a Kendo UI for Vue license file.
Dependencies
The Conversational UI package requires you to install the following peer dependencies in your application:
Package Name | Description |
---|---|
vue 2.6.14 or 3.0.0+ | Contains the functionality necessary to define Vue components. |
@progress/kendo-licensing | Contains the internal infrastructure related to licensing. |
@progress/kendo-vue-buttons | Contains the Kendo UI for Vue Buttons components. |
@progress/kendo-vue-layouts | Contains all layout related components part of the Kendo UI for Vue suite. |
@progress/kendo-vue-inputs | Contains the Inputs available in Kendo UI for Vue. |
@progress/kendo-vue-progressbars | Contains the Kendo UI for Vue components that display progress. |
@progress/kendo-vue-intl | Contains the Kendo UI for Vue Internationalization package that applies the desired cultures by providing services and pipes for the parsing and formatting of dates and numbers. |
@progress/kendo-svg-icons | Contains the Kendo UI for Vue SVG icons. |
Vue 2 is currently in its end-of-support phase till Nov 2024. After our last major release for 2024, Vue 2 will no longer be supported in the new versions of the Kendo UI for Vue components. Please check our Vue 2 End of Support article for more details.
Suggested Links
Learning Resources
- Kendo UI for Vue - First Steps with JavaScript
- Kendo UI for Vue - First Steps with JavaScript + Options API
- Kendo UI for Vue - First Steps with TypeScript
- Kendo UI for Vue - First Steps with TypeScript + Options API
- Virtual Classroom - Kendo UI for Vue with TypeScript(Course Available to Trial and Commercial License Holders)
- Kendo UI Productivity Tools extension for VS Code