Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

[4.4] Dispatch updates for actions and slots #1159

Merged
merged 6 commits into from
Apr 25, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class SkillRouter
/// <returns>Whether the intent matches a Skill.</returns>
public static SkillManifest IsSkill(List<SkillManifest> skillConfiguration, string dispatchIntent)
{
return skillConfiguration.SingleOrDefault(s => s.Id == dispatchIntent.ToString());
return skillConfiguration.SingleOrDefault(s => s.Actions.Any(a => a.Id == dispatchIntent.ToString()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version Condition=" '$(PackageVersion)' == '' ">4.0.0-local</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,73 +84,74 @@ if (-not $manifest) {
}

Write-Host "> Getting intents for dispatch ..."
$dictionary = @{ }
foreach ($action in $manifest.actions) {
if ($action.definition.triggers.utteranceSources) {
foreach ($source in $action.definition.triggers.utteranceSources) {
foreach ($luisStr in $source.source) {
$luis = $luisStr -Split '#'
if ($dictionary.ContainsKey($luis[0])) {
$intents = $dictionary[$luis[0]]
$intents += $luis[1]
$dictionary[$luis[0]] = $intents
}
else {
$dictionary.Add($luis[0], @($luis[1]))
}
}
}
}
}

Write-Host "> Adding skill to dispatch ..."
try {
$intentName = $manifest.Id
foreach ($luisApp in $dictionary.Keys) {
$intents = $dictionary[$luisApp]
$luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile

if (-not $luFile) {
$luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile

if ($luFile) {
$luisFolder = $(Join-Path $luisFolder $langCode)
}
else {
Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed
Write-Host "! Checked the following locations:" -ForegroundColor DarkRed
Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed
Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed
Throw
}
foreach ($action in $manifest.actions) {
if ($action.definition.triggers.utteranceSources) {
$sources = @{}
foreach ($source in ($action.definition.triggers.utteranceSources | Where-Object {$_.locale -eq $langCode})) {
foreach ($luisStr in $source.source) {
$luis = $luisStr -Split '#'
if ($sources.ContainsKey($luis[0])) {
$intents = $sources[$luis[0]]
$intents += $luis[1]
$sources[$luis[0]] = $intents
}
else {
$sources.Add($luis[0], @($luis[1]))
}
}
}

Write-Host "> Adding $($action.id) action to dispatch ..."
foreach ($luisApp in $sources.Keys) {
$intents = $sources[$luisApp]
$luFile = Get-ChildItem -Path $(Join-Path $luisFolder "$($luisApp).lu") ` 2>> $logFile

if (-not $luFile) {
$luFile = Get-ChildItem -Path $(Join-Path $luisFolder $langCode "$($luisApp).lu") ` 2>> $logFile

if ($luFile) {
$luisFolder = $(Join-Path $luisFolder $langCode)
}
else {
Write-Host "! Could not find $($manifest.Name) LU file. Please provide the -luisFolder parameter." -ForegroundColor DarkRed
Write-Host "! Checked the following locations:" -ForegroundColor DarkRed
Write-Host " $(Join-Path $luisFolder "$($luisApp).lu")" -ForegroundColor DarkRed
Write-Host " $(Join-Path $luisFolder $langCode "$($luisApp).lu")" -ForegroundColor DarkRed
Throw
}
}

# Parse LU file
ludown parse toluis `
--in $luFile `
--luis_culture $language `
--out_folder $luisFolder `
--out "$($luisApp).luis"

$luisFile = Get-ChildItem `
-Path $luisFolder `
-Filter "$($luisApp).luis" `
-Recurse `
-Force 2>> $logFile

if ($luisFile) {
(dispatch add `
--type file `
--filePath $luisFile `
--name $action.id `
--intentName $action.id `
--includedIntents $intents `
--dataFolder $dispatchFolder `
--dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null
}
else {
Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed
Break
}
}
}

# Parse LU file
ludown parse toluis `
--in $luFile `
--luis_culture $language `
--out_folder $luisFolder `
--out "$($luisApp).luis"

$luisFile = Get-ChildItem `
-Path $luisFolder `
-Filter "$($luisApp).luis" `
-Recurse `
-Force 2>> $logFile

if ($luisFile) {
(dispatch add `
--type file `
--filePath $luisFile `
--intentName $intentName `
--dataFolder $dispatchFolder `
--dispatch $(Join-Path $dispatchFolder "$($dispatchName).dispatch")) 2>> $logFile | Out-Null
}
else {
Write-Host "! Could not find LUIS file: $(Join-Path $luisFolder "$($luisApp).luis")" -ForegroundColor DarkRed
Break
}
}
}
}
catch {
Break
Expand Down Expand Up @@ -284,10 +285,12 @@ if ($manifest.authenticationConnections) {
}
}

Write-Host "> Done."

if ($manualScopesRequired) {
Write-Host "+ Could not configure scopes automatically. You must configure the following scopes in the Azure Portal to use this skill: $($newScopes -Join ', ')" -ForegroundColor Magenta
}

if ($manualAuthRequired) {
Write-Host "+ Could not configure authentication connection automatically. You must configure one of the following connection types manually in the Azure Portal: $($manifest.authenticationConnections.serviceProviderId -Join ', ')" -ForegroundColor Magenta
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,6 @@ $settings | Add-Member -Type NoteProperty -Force -Name 'contentModerator' -Value
$settings | ConvertTo-Json -depth 100 | Out-File $(Join-Path $outFolder appsettings.json)

# Deploy cognitive models
Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)"
Invoke-Expression "$(Join-Path $PSScriptRoot 'deploy_cognitive_models.ps1') -name $($name) -luisAuthoringRegion $($luisAuthoringRegion) -luisAuthoringKey $($luisAuthoringKey) -qnaSubscriptionKey $($outputs.qnaMaker.value.key) -outFolder $($outFolder)"

Write-Host "> Done."
Original file line number Diff line number Diff line change
Expand Up @@ -67,48 +67,17 @@ if (-not $manifest) {
Break
}

Write-Host "> Getting intents for dispatch ..."
$dictionary = @{ }
foreach ($action in $manifest.actions) {
if ($action.definition.triggers.utteranceSources) {
foreach ($source in $action.definition.triggers.utteranceSources) {
foreach ($luisStr in $source.source) {
$luis = $luisStr -Split '#'
if ($dictionary.ContainsKey($luis[0])) {
$intents = $dictionary[$luis[0]]
$intents += $luis[1]
$dictionary[$luis[0]] = $intents
}
else {
$dictionary.Add($luis[0], @($luis[1]))
}
}
}
}
}

Write-Host "> Removing skill from dispatch ..."
try {
$intentName = $manifest.Id
$dispatch = Get-Content $dispatchPath | ConvertFrom-Json

if ($dispatch.services) {
foreach ($luisApp in $dictionary.Keys) {
$intents = $dictionary[$luisApp]
$toRemove = $dispatch.services | Where-Object { $_.name -eq $luisApp }
$dispatch.services = $dispatch.services | Where-Object -FilterScript { $_.name -ne $luisApp }
$dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ }
}

$dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath
}
else {
Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed
Break
}
$dispatch = Get-Content $dispatchPath | ConvertFrom-Json
if ($dispatch.services) {
$toRemove = $dispatch.services | Where-Object { $manifest.actions.id -contains $_.name }
$dispatch.services = $dispatch.services | Where-Object -FilterScript { $manifest.actions.id -notcontains $_.name }
$dispatch.serviceIds = $dispatch.serviceIds | Where-Object -FilterScript { $toRemove.id -notcontains $_ }

$dispatch | ConvertTo-Json -depth 100 | Out-File $dispatchPath
}
catch {
Break
else {
Write-Host "! No services found in file: $($dispatchPath)" -ForegroundColor DarkRed
}

Write-Host "> Running dispatch refresh ..."
Expand Down Expand Up @@ -143,4 +112,6 @@ if (Test-Path $skillsFile) {
}
else {
Write-Host "! Could not find file: $($skillFile)" -ForegroundColor Cyan
}
}

Write-Host "> Done."
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected override async Task<InterruptionAction> OnInterruptDialogAsync(DialogC
{
// We have identiifed a skill so initialize the skill connection with the target skill
// the dispatch intent is the Action ID of the Skill enabling us to resolve the specific action and identify slots
await dc.BeginDialogAsync(identifiedSkill.Id, intent);
await dc.BeginDialogAsync(identifiedSkill.Id, intent.ToString());

// Pass the activity we have
var result = await dc.ContinueDialogAsync();
Expand Down
Loading