mirror of
https://github.com/leon-ai/leon.git
synced 2024-11-30 19:07:39 +03:00
feat(server): pickup questions for slot filling
This commit is contained in:
parent
6aa60bfbd8
commit
3bbc2f8a25
@ -2,7 +2,6 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
from sys import argv
|
||||
from pathlib import Path
|
||||
import spacy
|
||||
import geonamescache
|
||||
|
||||
|
@ -83,10 +83,13 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
* NER before processing NLU (cf. line 210 in nlu.js)
|
||||
* 2. [OK] Grab intents with slots
|
||||
* 3. [OK] .addSlot() as per the slots config
|
||||
* 4. Handle random questions picking
|
||||
* 5. Train resolvers (affirm_deny: boolean value)
|
||||
* 6. Map resolvers to skill actions
|
||||
* 7. Utterance source type to get raw input from utterance
|
||||
* 4. [OK] Handle random questions picking
|
||||
* srcAnswer has the array, need to activate context now?
|
||||
* to detect we should pick .srcAnswer
|
||||
* 5. Activiate context and return slot data to skills
|
||||
* 6. Train resolvers (affirm_deny: boolean value)
|
||||
* 7. Map resolvers to skill actions
|
||||
* 8. Utterance source type to get raw input from utterance
|
||||
*/
|
||||
if (slots) {
|
||||
for (let l = 0; l < slots.length; l += 1) {
|
||||
|
@ -112,9 +112,8 @@ class Nlu {
|
||||
}
|
||||
|
||||
const result = await this.nlp.process(utterance)
|
||||
|
||||
const {
|
||||
locale, domain, intent, score, answers
|
||||
locale, domain, intent, score, answers, slotFill, srcAnswer
|
||||
} = result
|
||||
const [skillName, actionName] = intent.split('.')
|
||||
let obj = {
|
||||
@ -224,6 +223,16 @@ class Nlu {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: slot filling
|
||||
console.log('result', result)
|
||||
if (slotFill && srcAnswer) {
|
||||
const answer = srcAnswer[Math.floor(Math.random() * srcAnswer.length)]
|
||||
|
||||
this.brain.talk(answer)
|
||||
this.brain.socket.emit('is-typing', false)
|
||||
return resolve()
|
||||
}
|
||||
|
||||
try {
|
||||
// Inject action entities with the others if there is
|
||||
const data = await this.brain.execute(obj, { mute: opts.mute })
|
||||
|
@ -16,7 +16,8 @@
|
||||
"name": "number"
|
||||
},
|
||||
"questions": [
|
||||
"How many players should I set?"
|
||||
"How many players should I set?",
|
||||
"Sure, how many players should I prepare?"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user