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

[4.4] Fixes skill template build errors #1209

Merged
merged 3 commits into from
May 1, 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 @@ -6,17 +6,16 @@

namespace SkillSample.Controllers
{
[ApiController]
public class BotController : SkillController
{
public BotController(
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
SkillHttpAdapter skillHttpAdapter,
SkillWebSocketAdapter skillWebSocketAdapter,
IBot bot,
BotSettingsBase botSettings)
: base(botFrameworkHttpAdapter, skillHttpAdapter, skillWebSocketAdapter, bot, botSettings)
{
}
}
[ApiController]
public class BotController : SkillController
{
public BotController(
IBot bot,
BotSettingsBase botSettings,
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
SkillWebSocketAdapter skillWebSocketAdapter)
: base(bot, botSettings, botFrameworkHttpAdapter, skillWebSocketAdapter)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ if (-not $luisAuthoringKey) {
}
}

# Get languages
$languageArr = $languages -split ","

# Initialize settings obj
$settings = @{ cognitiveModels = New-Object PSObject }
$settings = @{ defaultLocale = $languageArr[0]; cognitiveModels = New-Object PSObject }

# Deploy localized resources
Write-Host "Deploying cognitive models ..."
foreach ($language in $languages -split ",")
Write-Host "> Deploying cognitive models ..."
foreach ($language in $languageArr)
{
$langCode = ($language -split "-")[0]

Expand All @@ -73,7 +76,7 @@ foreach ($language in $languages -split ",")
foreach ($lu in $luisFiles)
{
# Deploy LUIS model
$luisApp = DeployLUIS -name $name -lu_file $lu -region $location -luisAuthoringKey $luisAuthoringKey -language $language -log $logFile
$luisApp = DeployLUIS -name $name -lu_file $lu -region $luisAuthoringRegion -luisAuthoringKey $luisAuthoringKey -language $language -log $logFile

if ($luisApp) {
# Add to config
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#Requires -Version 6

Param(
[string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'),
[switch] $RemoteToLocal,
[string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'),
[string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'),
[string] $qnaFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'QnA'),
[string] $lgOutFolder = $(Join-Path (Get-Location) 'Services'),
[string] $logFile = $(Join-Path $PSScriptRoot .. "update_cognitive_models_log.txt")
)

. $PSScriptRoot\luis_functions.ps1
. $PSScriptRoot\qna_functions.ps1

# Reset log file
if (Test-Path $logFile) {
Clear-Content $logFile -Force | Out-Null
}
else {
New-Item -Path $logFile | Out-Null
}

Write-Host "> Getting config file ..."
$languageMap = @{}
$config = Get-Content -Raw -Path $configFile | ConvertFrom-Json
$config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value }

foreach ($langCode in $languageMap.Keys) {
$models = $languageMap[$langCode]

if($RemoteToLocal)
{
# Update local LU files based on hosted models
foreach ($luisApp in $models.languageModels)
{
Write-Host "> Updating local $($luisApp.id).lu file ..."
luis export version `
--appId $luisApp.appid `
--versionId $luisApp.version `
--authoringKey $luisApp.authoringKey | ludown refresh `
--stdin `
-n "$($luisApp.id).lu" `
-o $(Join-Path $luisFolder $langCode)
}

# Update local LU files based on hosted QnA KBs
foreach ($kb in $models.knowledgebases)
{
Write-Host "> Updating local $($kb.id).lu file ..."
qnamaker export kb `
--environment Prod `
--kbId $kb.kbId `
--subscriptionKey $kb.subscriptionKey | ludown refresh `
--stdin `
-n "$($kb.id).lu" `
-o $(Join-Path $qnaFolder $langCode)
}
}
else
{
# Update each luis model based on local LU files
foreach ($luisApp in $models.languageModels) {
Write-Host "> Updating hosted $($luisApp.id) app..."
$lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu")
UpdateLUIS `
-lu_file $lu `
-appId $luisApp.appid `
-version $luisApp.version `
-authoringKey $luisApp.authoringKey `
-subscriptionKey $app.subscriptionKey
}

# Update each knowledgebase based on local LU files
foreach ($kb in $models.knowledgebases) {
Write-Host "> Updating hosted $($kb.id) kb..."
$lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu")
UpdateKB `
-lu_file $lu `
-kbId $kb.kbId `
-qnaSubscriptionKey $kb.subscriptionKey
}
}
}

# Update dispatch model
Write-Host "> Updating dispatch model ..."
$dispatch = $models.dispatchModel
dispatch refresh `
--dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") `
--dataFolder $dispatchFolder 2>> $logFile | Out-Null

# Update dispatch.cs file
Write-Host "> Running LuisGen ..."
luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null

Write-Host "> Done."
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.4.0-preview44" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview44" />
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.4.0-preview48" />
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.4.0-preview48" />
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.3.1" />
<PackageReference Include="Microsoft.Bot.Connector" Version="4.3.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"microsoftAppId": "",
"microsoftAppPassword": "",
"oauthConnections": [
{
"name": "",
"provider": ""
}
],
"oauthConnections": [],
"appInsights": {
"appId": "",
"instrumentationKey": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@
"en": {
"languageModels": [
{
"id": "general",
"name": "",
"appid": "",
"version": "0.1",
"region": "",
"name": "",
"authoringkey": "",
"id": "general",
"subscriptionkey": ""
},
{
"id": "skill",
"name": "",
"appid": "",
"version": "0.1",
"region": "",
"name": "",
"authoringkey": "",
"id": "skill",
"subscriptionkey": ""
}
]
}
}
},
"defaultLocale": "en-us"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
namespace $safeprojectname$.Controllers
{
[ApiController]
public class BotController : SkillController
{
public BotController(
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
SkillHttpAdapter skillHttpAdapter,
SkillWebSocketAdapter skillWebSocketAdapter,
IBot bot,
BotSettingsBase botSettings)
: base(botFrameworkHttpAdapter, skillHttpAdapter, skillWebSocketAdapter, bot, botSettings)
{
}
public class BotController : SkillController
{
public BotController(
IBot bot,
BotSettingsBase botSettings,
IBotFrameworkHttpAdapter botFrameworkHttpAdapter,
SkillWebSocketAdapter skillWebSocketAdapter)
: base(bot, botSettings, botFrameworkHttpAdapter, skillWebSocketAdapter)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ if (-not $luisAuthoringKey) {
}
}

# Get languages
$languageArr = $languages -split ","

# Initialize settings obj
$settings = @{ cognitiveModels = New-Object PSObject }
$settings = @{ defaultLocale = $languageArr[0]; cognitiveModels = New-Object PSObject }

# Deploy localized resources
Write-Host "Deploying cognitive models ..."
foreach ($language in $languages -split ",")
Write-Host "> Deploying cognitive models ..."
foreach ($language in $languageArr)
{
$langCode = ($language -split "-")[0]

Expand All @@ -73,18 +76,18 @@ foreach ($language in $languages -split ",")
foreach ($lu in $luisFiles)
{
# Deploy LUIS model
$luisApp = DeployLUIS -name $name -lu_file $lu -region $location -luisAuthoringKey $luisAuthoringKey -language $language -log $logFile
$luisApp = DeployLUIS -name $name -lu_file $lu -region $luisAuthoringRegion -luisAuthoringKey $luisAuthoringKey -language $language -log $logFile

if ($luisApp) {
# Add to config
$config.languageModels += @{
id = $lu.BaseName
name = $luisApp.name
appid = $luisApp.id
authoringkey = $luisauthoringkey
subscriptionkey = $luisauthoringkey
authoringkey = $luisAuthoringKey
subscriptionkey = $luisAuthoringKey
version = $luisApp.activeVersion
region = $location
region = $luisAuthoringRegion
}

RunLuisGen $lu "$($lu.BaseName)" $(Join-Path $outFolder Services)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#Requires -Version 6

Param(
[string] $configFile = $(Join-Path (Get-Location) 'cognitivemodels.json'),
[switch] $RemoteToLocal,
[string] $dispatchFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'Dispatch'),
[string] $luisFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'LU'),
[string] $qnaFolder = $(Join-Path $PSScriptRoot '..' 'Resources' 'QnA'),
[string] $lgOutFolder = $(Join-Path (Get-Location) 'Services'),
[string] $logFile = $(Join-Path $PSScriptRoot .. "update_cognitive_models_log.txt")
)

. $PSScriptRoot\luis_functions.ps1
. $PSScriptRoot\qna_functions.ps1

# Reset log file
if (Test-Path $logFile) {
Clear-Content $logFile -Force | Out-Null
}
else {
New-Item -Path $logFile | Out-Null
}

Write-Host "> Getting config file ..."
$languageMap = @{}
$config = Get-Content -Raw -Path $configFile | ConvertFrom-Json
$config.cognitiveModels.PSObject.Properties | Foreach-Object { $languageMap[$_.Name] = $_.Value }

foreach ($langCode in $languageMap.Keys) {
$models = $languageMap[$langCode]

if($RemoteToLocal)
{
# Update local LU files based on hosted models
foreach ($luisApp in $models.languageModels)
{
Write-Host "> Updating local $($luisApp.id).lu file ..."
luis export version `
--appId $luisApp.appid `
--versionId $luisApp.version `
--authoringKey $luisApp.authoringKey | ludown refresh `
--stdin `
-n "$($luisApp.id).lu" `
-o $(Join-Path $luisFolder $langCode)
}

# Update local LU files based on hosted QnA KBs
foreach ($kb in $models.knowledgebases)
{
Write-Host "> Updating local $($kb.id).lu file ..."
qnamaker export kb `
--environment Prod `
--kbId $kb.kbId `
--subscriptionKey $kb.subscriptionKey | ludown refresh `
--stdin `
-n "$($kb.id).lu" `
-o $(Join-Path $qnaFolder $langCode)
}
}
else
{
# Update each luis model based on local LU files
foreach ($luisApp in $models.languageModels) {
Write-Host "> Updating hosted $($luisApp.id) app..."
$lu = Get-Item -Path $(Join-Path $luisFolder $langCode "$($luisApp.id).lu")
UpdateLUIS `
-lu_file $lu `
-appId $luisApp.appid `
-version $luisApp.version `
-authoringKey $luisApp.authoringKey `
-subscriptionKey $app.subscriptionKey
}

# Update each knowledgebase based on local LU files
foreach ($kb in $models.knowledgebases) {
Write-Host "> Updating hosted $($kb.id) kb..."
$lu = Get-Item -Path $(Join-Path $qnaFolder $langCode "$($kb.id).lu")
UpdateKB `
-lu_file $lu `
-kbId $kb.kbId `
-qnaSubscriptionKey $kb.subscriptionKey
}
}
}

# Update dispatch model
Write-Host "> Updating dispatch model ..."
$dispatch = $models.dispatchModel
dispatch refresh `
--dispatch $(Join-Path $dispatchFolder $langCode "$($dispatch.name).dispatch") `
--dataFolder $dispatchFolder 2>> $logFile | Out-Null

# Update dispatch.cs file
Write-Host "> Running LuisGen ..."
luisgen $(Join-Path $dispatchFolder $langCode "$($dispatch.name).json") -cs "DispatchLuis" -o $lgOutFolder 2>> $logFile | Out-Null

Write-Host "> Done."
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ProjectItem ReplaceParameters="false" TargetFileName="deploy.ps1">deploy.ps1</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="deploy_cognitive_models.ps1">deploy_cognitive_models.ps1</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="luis_functions.ps1">luis_functions.ps1</ProjectItem>
<ProjectItem ReplaceParameters="false" TargetFileName="update_cognitive_models.ps1">update_cognitive_models.ps1</ProjectItem>
</Folder>
</Folder>
<Folder Name="Dialogs" TargetFolderName="Dialogs">
Expand Down
Loading