mirror of
https://github.com/leon-ai/leon.git
synced 2024-11-27 08:06:03 +03:00
chore: tmp
This commit is contained in:
parent
fa4bd6a8a1
commit
6c59f17207
@ -17,7 +17,7 @@
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/games/guess_the_number/decide",
|
||||
"route": "/api/action/games/guess_the_number/replay",
|
||||
"params": []
|
||||
},
|
||||
{
|
||||
|
@ -133,11 +133,34 @@ class Nlu {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: make difference between context that needs slots and the ones who does not
|
||||
// TODO: this case is only for slots context
|
||||
// TODO: an action requiring slots must always have a next_action
|
||||
console.log('THIS.CONV', this.conv.activeContext)
|
||||
if (this.conv.hasActiveContext()) {
|
||||
const processedData = await this.slotFill(utterance, opts)
|
||||
if (processedData) {
|
||||
return resolve(processedData)
|
||||
console.log('processedData (slot filled over)', processedData)
|
||||
|
||||
if (processedData && Object.keys(processedData).length > 0) {
|
||||
processedData.nextAction = 'guess'
|
||||
// Set new context with the next action if there is one
|
||||
if (processedData.nextAction) {
|
||||
this.conv.activeContext = {
|
||||
lang: this.brain.lang,
|
||||
slots: { },
|
||||
originalUtterance: processedData.utterance,
|
||||
nluDataFilePath: processedData.nluDataFilePath,
|
||||
actionName: processedData.nextAction,
|
||||
domain: processedData.classification.domain,
|
||||
intent: `${processedData.classification.skill}.${processedData.nextAction}`,
|
||||
entities: []
|
||||
}
|
||||
|
||||
console.log('NEW ACTIVE CONTEXT', this.conv.activeContext)
|
||||
}
|
||||
}
|
||||
|
||||
return resolve(processedData)
|
||||
}
|
||||
|
||||
const result = await this.nlp.process(utterance)
|
||||
@ -315,16 +338,32 @@ class Nlu {
|
||||
// TODO: next action based on next_action
|
||||
const data = await this.brain.execute(this.nluResultObj, { mute: opts.mute })
|
||||
|
||||
if (this.conv.activeContext.name === 'setup_game') {
|
||||
// If it is a loop action
|
||||
// TODO: remove this
|
||||
data.loop = true
|
||||
console.log('data', data)
|
||||
// TODO: if there is a nextAction, then don't empty active context for next round?
|
||||
// TODO: or name "nextAction" by something else such as "nextContext"?
|
||||
// TODO: make difference between next action that needs to be immediately triggered
|
||||
// TODO: and the one that just need to set the context
|
||||
|
||||
if (data.loop) {
|
||||
this.conv.activeContext.nextAction = 'guess'
|
||||
// TODO: remove the next if
|
||||
if (data.classification.skill === 'guess_the_number') {
|
||||
data.nextAction = 'guess'
|
||||
// Set new context with the next action if there is one
|
||||
if (data.nextAction) {
|
||||
this.conv.activeContext = {
|
||||
lang: this.brain.lang,
|
||||
slots: { },
|
||||
originalUtterance: data.utterance,
|
||||
nluDataFilePath: data.nluDataFilePath,
|
||||
actionName: data.nextAction,
|
||||
domain: data.domain,
|
||||
intent: `${data.classification.skill}.${data.nextAction}`,
|
||||
entities: []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('this.conv.activeContext', this.conv.activeContext)
|
||||
|
||||
const processingTimeEnd = Date.now()
|
||||
const processingTime = processingTimeEnd - processingTimeStart
|
||||
|
||||
@ -427,6 +466,9 @@ class Nlu {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('this.conv.activeContext just before execute', this.conv.activeContext)
|
||||
console.log('this.nluResultObj just before execute', this.nluResultObj)
|
||||
|
||||
this.conv.cleanActiveContext()
|
||||
|
||||
return this.brain.execute(this.nluResultObj, { mute: opts.mute })
|
||||
|
@ -34,13 +34,12 @@
|
||||
"next_action": "setup"
|
||||
},
|
||||
"setup": {
|
||||
"type": "logic",
|
||||
"next_action": "guess"
|
||||
"type": "logic"
|
||||
},
|
||||
"guess": {
|
||||
"type": "logic"
|
||||
},
|
||||
"decide": {
|
||||
"replay": {
|
||||
"type": "dialog",
|
||||
"slots": [
|
||||
{
|
||||
|
@ -13,9 +13,7 @@ def setup(params):
|
||||
|
||||
# TODO: save these values in DB
|
||||
|
||||
# if "not init" phase: check nb + increment counter
|
||||
|
||||
# TODO: "loop" option to return to the core
|
||||
# TODO: add output_context
|
||||
return utils.output('end', 'ready', utils.translate('ready', {
|
||||
'players_nb': slots['players_nb']['value']['sourceText'],
|
||||
'email_test': slots['email_test']['value']['sourceText']
|
||||
|
Loading…
Reference in New Issue
Block a user