Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple user confirm template #267

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions languages/thingtalk/dialogue_acts/recommendation.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ function makeRecommendationReply(ctx, proposal) {
if (action || hasLearnMore)
options.end = false;
if (action === null) {
// we don't want 'confirm' to loop sys_recommend_one states
if (ctx.state.dialogueAct === 'confirm')
return null;
return makeAgentReply(ctx, makeSimpleState(ctx, 'sys_recommend_one', null), proposal, null, options);
} else {
const chainParam = findChainParam(topResult, action);
Expand Down Expand Up @@ -222,9 +225,19 @@ function positiveRecommendationReply(ctx, acceptedAction, name) {
// A: how about the ... ?
// U: sure I like that
//
// this doesn't make much sense, so we don't want this flow
if (actionProposal === null)
return null;
// This falls into the simple "confirm" state category,
// where the agent will propose an action the following turn.
if (actionProposal === null) {
const clone = ctx.clone();

// make sure user is talking about the correct entity
if (!name)
return null;
if (name[0].value !== ctx.aux.topResult.value.id.value)
return null;

return makeSimpleState(clone, 'confirm', null);
}

acceptedAction = actionProposal;
}
Expand Down
5 changes: 5 additions & 0 deletions languages/thingtalk/en/dialogue.genie
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ context
ctx_incomplete_action_after_search,
ctx_learn_more,
ctx_display_nonlist_result,
ctx_confirm,

// agent states (used to continue the conversation with more user utterances)
// these more or less map to the agent dialogue acts, except we don't distinguish
Expand Down Expand Up @@ -212,6 +213,10 @@ $agent = {
// learn more
ctx:ctx_learn_more system_learn_more
=> S.makeAgentReply(ctx, S.makeSimpleState(ctx, 'sys_learn_more_what', null));

// answer simple confirm state with recommendation
ctx:ctx_confirm proposal:system_confirmed_recommendation
=> D.makeRecommendationReply(ctx, proposal);
}

$user = {
Expand Down
6 changes: 6 additions & 0 deletions languages/thingtalk/en/dlg/recommendation.genie
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ system_recommendation = {
};
}

// recommendations following a user confirm state
system_confirmed_recommendation = {
ctx:ctx_confirm ('would you like to' | 'would you like me to') action:contextual_action_phrase [weight=0.1]
=> D.makeActionRecommendation(ctx, action);
}

recommendation_accept_phrase_with_action = {
accept_phrase generic_preamble_for_action action:coref_action_command => action;
}
Expand Down
3 changes: 3 additions & 0 deletions languages/thingtalk/state_manip.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ function tagContextForAgent(ctx) {
assert(ctx.results);
return ['ctx_learn_more'];

case 'confirm':
return ['ctx_confirm'];

case 'execute':
case 'ask_recommend':
if (ctx.nextInfo !== null) {
Expand Down