Skip to content

Commit

Permalink
feat(server): handle case when all slots have been filled in one utte…
Browse files Browse the repository at this point in the history
…rance
  • Loading branch information
louistiti committed Mar 31, 2022
1 parent 8746175 commit 22e9234
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/src/core/nlu.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ class Nlu {
return resolve({ })
}

// In case all slots have been filled in the first utterance
if (this.conv.hasActiveContext()) {
const processedData = await this.slotFill(utterance, opts)
if (processedData) {
return resolve(processedData)
}
}

try {
// Inject action entities with the others if there is
const data = await this.brain.execute(this.nluResultObj, { mute: opts.mute })
Expand Down Expand Up @@ -307,7 +315,7 @@ class Nlu {

// Continue to loop for questions if a slot has been filled correctly
let notFilledSlot = this.conv.getNotFilledSlot()
if (entities.length > 0) {
if (notFilledSlot && entities.length > 0) {
const hasMatch = entities.some(({ entity }) => entity === notFilledSlot.expectedEntity)

if (hasMatch) {
Expand Down Expand Up @@ -338,7 +346,7 @@ class Nlu {
* 5.1 [OK] In Conversation, need to chain output/input contexts to each other
* to understand what action should be next
* 5.2 [OK] Execute next action (based on input_context?)
* 5.3 [Ready] Need to handle the case if a context is filled in one shot
* 5.3 [OK] Need to handle the case if a context is filled in one shot
* e.g. I wanna play with 2 players and louis.grenard@gmail.com
* Need to refactor now (nluResultObj method to build it, etc.)
* 6. What's next once the next action has been executed?
Expand Down Expand Up @@ -395,10 +403,6 @@ class Nlu {

return true
}
// In case all slots have been filled in the first utterance
if (this.conv.hasActiveContext() && !notFilledSlot) {
// TODO: call method that execute brain with slot (need refactoring first)
}

return false
}
Expand Down

0 comments on commit 22e9234

Please sign in to comment.