fix: remove enum tutorial for the moment

This commit is contained in:
Lars Liden 2019-04-03 13:29:42 -07:00
Родитель b18064dd4e
Коммит fd08f2efb6
3 изменённых файлов: 6 добавлений и 157 удалений

12
.vscode/launch.json поставляемый
Просмотреть файл

@ -55,18 +55,6 @@
"--preserve-symlinks"
]
},
{
"type": "node",
"request": "launch",
"name": "tutorialEnums",
"program": "${workspaceFolder}/lib/demos/tutorialEnums.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
],
"runtimeArgs": [
"--preserve-symlinks"
]
},
{
"type": "node",
"request": "launch",

12
package-lock.json сгенерированный
Просмотреть файл

@ -518,7 +518,7 @@
},
"async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
"resolved": "http://registry.npmjs.org/async/-/async-1.5.2.tgz",
"integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
},
"async-each": {
@ -3185,7 +3185,7 @@
},
"http-proxy-middleware": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.18.0.tgz",
"resolved": "http://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.18.0.tgz",
"integrity": "sha512-Fs25KVMPAIIcgjMZkVHJoKg9VcXcC1C8yb9JUgeDvVXY0S/zgVIhMb+qVswDIgtJe2DfckMSY2d6TuTEutlk6Q==",
"requires": {
"http-proxy": "^1.16.2",
@ -6065,7 +6065,7 @@
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"resolved": "http://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"resolve": {
@ -6629,7 +6629,7 @@
},
"superagent": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/superagent/-/superagent-2.3.0.tgz",
"resolved": "http://registry.npmjs.org/superagent/-/superagent-2.3.0.tgz",
"integrity": "sha1-cDUpoHFOV+EjlZ3e+84ZOy5Q0RU=",
"requires": {
"component-emitter": "^1.2.0",
@ -6646,7 +6646,7 @@
"dependencies": {
"form-data": {
"version": "1.0.0-rc4",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.0-rc4.tgz",
"resolved": "http://registry.npmjs.org/form-data/-/form-data-1.0.0-rc4.tgz",
"integrity": "sha1-BaxrwiIntD5EYfSIFhVUaZ1Pi14=",
"requires": {
"async": "^1.5.2",
@ -6700,7 +6700,7 @@
},
"swagger-client": {
"version": "2.2.21",
"resolved": "https://registry.npmjs.org/swagger-client/-/swagger-client-2.2.21.tgz",
"resolved": "http://registry.npmjs.org/swagger-client/-/swagger-client-2.2.21.tgz",
"integrity": "sha1-WWa+I0dyRm5EcW9l4yAIFm2u66Q=",
"requires": {
"btoa": "^1.1.2",

Просмотреть файл

@ -1,139 +0,0 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import * as path from 'path'
import * as express from 'express'
import { ConversationLearner, ClientMemoryManager, FileStorage, ReadOnlyClientMemoryManager, uiRouter } from '@conversationlearner/sdk'
import chalk from 'chalk'
import config from '../config'
import * as BB from 'botbuilder'
import getDolRouter from '../dol'
//===================
// Create Bot server
//===================
const server = express()
const isDevelopment = process.env.NODE_ENV === 'development'
if (isDevelopment) {
console.log(chalk.yellowBright(`Adding /directline routes`))
server.use(getDolRouter(config.botPort))
console.log(chalk.greenBright(`Adding /ui routes`))
server.use(uiRouter)
}
server.listen(config.botPort, () => {
console.log(`Server listening to port: ${config.botPort}`)
})
const { bfAppId, bfAppPassword, modelId, ...clOptions } = config
//==================
// Create Adapter
//==================
const adapter = new BB.BotFrameworkAdapter({ appId: bfAppId, appPassword: bfAppPassword });
//==================================
// Storage
//==================================
// Initialize ConversationLearner using file storage.
// Recommended only for development
// See "storageDemo.ts" for other storage options
let fileStorage = new FileStorage(path.join(__dirname, 'storage'))
//==================================
// Initialize Conversation Learner
//==================================
const sdkRouter = ConversationLearner.Init(clOptions, fileStorage)
if (isDevelopment) {
console.log(chalk.cyanBright(`Adding /sdk routes`))
server.use('/sdk', sdkRouter)
}
let cl = new ConversationLearner(modelId);
//=================================
// Add Entity Logic
//=================================
/**
* Processes messages received from the user. Called by the dialog system.
* @param {string} text Last user input to the Bot
* @param {ClientMemoryManager} memoryManager Allows for viewing and manipulating Bot's memory
* @returns {Promise<void>}
*/
cl.EntityDetectionCallback(async (text: string, memoryManager: ClientMemoryManager): Promise<void> => {
// No entity processing in this example
})
//=================================
// Sample API Callbacks
//=================================
cl.AddCallback({
name: "SetSpa",
logic: async (memoryManager: ClientMemoryManager, value: string) => {
memoryManager.Set("Spa", value);
}
})
cl.AddCallback({
name: "SetChampagne",
logic: async (memoryManager: ClientMemoryManager, value: string) => {
memoryManager.Set("Champagne", value);
}
})
cl.AddCallback({
name: "SetBed",
logic: async (memoryManager: ClientMemoryManager, value: string) => {
memoryManager.Set("Bed", value);
}
})
cl.AddCallback({
name: "ShowRoom",
render: async (logicResult: any, memoryManager: ReadOnlyClientMemoryManager) => {
let response = [bedType(memoryManager)]
const spa = memoryManager.Get("Spa", ClientMemoryManager.AS_BOOLEAN)
if (spa) {
response.push("We have added a moring Spa package.")
}
const champagne = memoryManager.Get("Champagne", ClientMemoryManager.AS_BOOLEAN)
if (champagne) {
response.push("Champagne will be brought to your room after dinner.")
}
return response.join(',')
}
})
function bedType(memoryManager: ReadOnlyClientMemoryManager): string {
const bedValue = memoryManager.Get("Bed", ClientMemoryManager.AS_STRING)
switch (bedValue) {
case "KING":
return "You selected a king size bed."
case "QUEEN":
return "You selected a queen size bed."
case "MULTI":
return "You room with have two twin beds."
default:
return "You have not selected a room type."
}
}
//=================================
// Handle Incoming Messages
//=================================
server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async context => {
let result = await cl.recognize(context)
if (result) {
return cl.SendResult(result);
}
})
})