mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-27 02:35:50 +03:00
feat(skill/mbti): main logic backbone
This commit is contained in:
parent
6ed88a5946
commit
33109a4c8b
@ -299,8 +299,11 @@ class Nlu {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case there is no next action to prepare anymore
|
/**
|
||||||
if (!processedData.action.next_action) {
|
* In case there is no next action to prepare anymore
|
||||||
|
* and there is an explicit stop of the loop from the skill
|
||||||
|
*/
|
||||||
|
if (!processedData.action.next_action && processedData.core?.isInActionLoop === false) {
|
||||||
this.conv.cleanActiveContext()
|
this.conv.cleanActiveContext()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
"actions": {
|
"actions": {
|
||||||
"setup": {
|
"setup": {
|
||||||
"type": "dialog",
|
"type": "logic",
|
||||||
"utterance_samples": [
|
"utterance_samples": [
|
||||||
"I want to know my MBTI personality type",
|
"I want to know my MBTI personality type",
|
||||||
"Start a personality type [quiz|questionnaire|test]"
|
"Start a personality type [quiz|questionnaire|test]"
|
||||||
],
|
],
|
||||||
"answers": [
|
|
||||||
"Alright, let's go!<br><br>1/20<br>At a party do you:<ul><li>a. Interact with many, including strangers</li><li>b. Interact with a few, known to you</li></ul>"
|
|
||||||
],
|
|
||||||
"next_action": "quiz"
|
"next_action": "quiz"
|
||||||
},
|
},
|
||||||
"quiz": {
|
"quiz": {
|
||||||
@ -56,6 +53,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"answers": {
|
"answers": {
|
||||||
|
"1": ["%question%/20<br>At a party do you:<ul><li>a. Interact with many, including strangers</li><li>b. Interact with a few, known to you</li></ul>"],
|
||||||
"2": ["%question%/20<br>Is it worse to:<ul><li>a. Have your \"head in the clouds\"</li><li>b. Be \"in a rut\"</li></ul>"],
|
"2": ["%question%/20<br>Is it worse to:<ul><li>a. Have your \"head in the clouds\"</li><li>b. Be \"in a rut\"</li></ul>"],
|
||||||
"3": ["%question%/20<br>Is it worse to:<ul><li>a. Have your \"head in the clouds\"</li><li>b. Be \"in a rut\"</li></ul>"]
|
"3": ["%question%/20<br>Is it worse to:<ul><li>a. Have your \"head in the clouds\"</li><li>b. Be \"in a rut\"</li></ul>"]
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,24 @@ import utils
|
|||||||
from ..lib import db
|
from ..lib import db
|
||||||
|
|
||||||
def quiz(params):
|
def quiz(params):
|
||||||
"""TODO"""
|
"""Loop over the questions and track choices"""
|
||||||
|
|
||||||
resolvers = params['resolvers']
|
resolvers = params['resolvers']
|
||||||
|
|
||||||
for resolver in resolvers:
|
for resolver in resolvers:
|
||||||
if resolver['name'] == 'mbti_quiz':
|
if resolver['name'] == 'form':
|
||||||
answer = resolver['value']
|
choice = resolver['value']
|
||||||
|
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
|
current_question = session['current_question'] + 1
|
||||||
current_question = 1
|
|
||||||
if session != None:
|
|
||||||
current_question = session['current_question']
|
|
||||||
|
|
||||||
db.upsert_session(current_question)
|
db.upsert_session(current_question)
|
||||||
|
|
||||||
current_question += 1
|
|
||||||
|
|
||||||
if current_question == 20:
|
if current_question == 20:
|
||||||
# TODO
|
# TODO
|
||||||
return utils.output('end', 'Your personality type is...', { 'isInActionLoop': False })
|
return utils.output('end', 'Your personality type is...', { 'isInActionLoop': False })
|
||||||
|
|
||||||
return utils.output('end', { 'key': current_question, 'data': { 'question': current_question }})
|
return utils.output('end', { 'key': str(current_question),
|
||||||
|
'data': {
|
||||||
|
'question': str(current_question)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
19
skills/social_communication/mbti/src/actions/setup.py
Normal file
19
skills/social_communication/mbti/src/actions/setup.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
|
import utils
|
||||||
|
from ..lib import db
|
||||||
|
|
||||||
|
def setup(params):
|
||||||
|
"""Initialize session"""
|
||||||
|
|
||||||
|
session = db.get_session()
|
||||||
|
|
||||||
|
current_question = 1
|
||||||
|
db.upsert_session(current_question)
|
||||||
|
|
||||||
|
return utils.output('end', { 'key': str(current_question),
|
||||||
|
'data': {
|
||||||
|
'question': str(current_question)
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user