Skip to content

Commit

Permalink
feat(server): prepare the next action on non-slot-filled skills
Browse files Browse the repository at this point in the history
  • Loading branch information
louistiti committed May 22, 2022
1 parent ffe0c8d commit 0acb31a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions server/src/core/nlu.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,34 @@ class Nlu {
this.nluResultObj.entities = this.conv.activeContext.entities

try {
// TODO: next action based on next_action
const data = await this.brain.execute(this.nluResultObj, { mute: opts.mute })
const processedData = await this.brain.execute(this.nluResultObj, { mute: opts.mute })

// Prepare next action if there is one queuing
if (processedData.nextAction) {
this.conv.cleanActiveContext()
this.conv.activeContext = {
lang: this.brain.lang,
slots: { },
isInActionLoop: !!processedData.nextAction.loop,
originalUtterance: processedData.utterance,
nluDataFilePath: processedData.nluDataFilePath,
actionName: processedData.action.next_action,
domain: processedData.classification.domain,
intent: `${processedData.classification.skill}.${processedData.action.next_action}`,
entities: []
}
}

console.log('data', data)
console.log('final this.conv.activeContext', this.conv.activeContext)

const processingTimeEnd = Date.now()
const processingTime = processingTimeEnd - processingTimeStart

return resolve({
processingTime, // In ms, total time
...data,
...processedData,
nluProcessingTime:
processingTime - data?.executionTime // In ms, NLU processing time only
processingTime - processedData?.executionTime // In ms, NLU processing time only
})
} catch (e) /* istanbul ignore next */ {
log[e.type](e.obj.message)
Expand Down

0 comments on commit 0acb31a

Please sign in to comment.