使用 Bot Framework qnamaker CLI 命令部署 QnA Maker 知識庫Deploy QnA Maker knowledge base using the Bot Framework qnamaker CLI commands

適用于: SDK v4APPLIES TO: SDK v4

(CLI) 的 Bot Framework 命令列介面,可讓您自動管理 QnA Maker 知識庫 (KB) 。The Bot Framework Command Line Interface (CLI) lets you automate the management of QnA Maker knowledge base (KB). 它可讓您從命令列或腳本建立、更新和刪除 QnA Maker KB。It lets you create, update, and delete QnA Maker KB from the command line or a script. 本文說明如何在 Azure 中將 QnA Maker KB 部署至 QnA Maker KB。This article explains how to deploy QnA Maker KB to a QnA Maker KB in Azure.

必要條件Prerequisites

使用 qnamaker CLI 命令在您的 bot 中啟用 QnA MakerUsing the qnamaker CLI commands to enable QnA Maker in your bot

本文說明如何使用 Bot Framework CLI 來執行用來部署 QnA Maker KB 的一些常見工作。This article describes how to perform some common tasks used to deploy a QnA Maker KB using the Bot Framework CLI.

一旦建立您的 bot 專案 QnA Maker KB QnA 檔案,您就可以依照本文中所述的步驟來建立您的 QnA Maker KB。Once your bot project's QnA Maker KB .qna files have been created, you are ready to follow the steps outlined in this article to create your QnA Maker KB. 如果您沒有 QnA Maker KB. QnA 檔案的專案,您可以使用 QnAMakerIf you do not have a project with QnA Maker KB .qna files, you can use the QnAMaker. 如需 取得範例的詳細資訊,請參閱範例存放庫的讀我檔案。See the sample repository's readme for information on Getting the samples.

在 Azure 認知服務中建立您的 QnA Maker 資源Create your QnA Maker resource in Azure Cognitive Services

QnA Maker 資源是您使用 Azure 的 [建立認知服務] 頁面所建立的azure 認知服務資源。The QnA Maker resource is an Azure Cognitive Services resource that you create using Azure's Create Cognitive Services page. 這會提供在 Azure 中存取您的 QnA Maker KB 所需的安全性金鑰和端點。This provides the security keys and endpoint needed to access your QnA Maker KB in Azure.

  1. 移至 Azure 建立認知服務 頁面。Go to the Azure Create Cognitive Services page.

  2. 輸入每個欄位的值,然後選取 [ 審核 + 建立 ] 按鈕。Enter values for each of the fields, then select the Review + create button.

    在 Azure 中建立您的 QnA Maker 知識庫

    注意

    輸入 資源群組名稱 時,請記住,您稍後無法變更這些值。When entering the Resource Group and Name, keep in mind that you cannot change these values later. 另請注意,您為 [ 名稱 ] 提供的值將會是 端點 URL 的一部分。Also note that the value you give for Name will be part of your Endpoint URL.

  3. 檢查值以確保其正確無誤,然後選取 [ 建立 ] 按鈕。Review the values to ensure they are correct, then select the Create button.

QnA Maker 資源包含 bot 將用來存取 QnA Maker 知識庫的資訊:The QnA Maker resource includes information your bot will use to access your QnA Maker knowledge base:

  • 索引 Keys. 這些稱為訂用帳戶 金鑰 ,且會自動產生。These are called subscription keys and are auto generated. 參考 QnA Maker 資源以進行任何動作時,您將需要訂用帳戶金鑰,例如在建立或更新您的 QnA Maker KB 時,將在本文中詳細說明。You will need the subscription key when referencing your QnA Maker resource for any action, such as when creating or updating your QnA Maker KB which will be detailed in this article. 您可以在 QnA Maker 資源的 金鑰和端點 分頁中找到金鑰。You can find the keys in the Keys and Endpoint blade in your QnA Maker resource.

  • 端點Endpoint. 這是使用您在建立時所提供的 QnA Maker 資源名稱自動產生的。This is auto-generated using the QnA Maker resource name that you provide when creating it. 它的格式如下: https://<qnamaker-resource-name>.cognitiveservices.azure.com/It has the following format: https://<qnamaker-resource-name>.cognitiveservices.azure.com/. 參考您的 QnA Maker 資源以取得任何動作時,例如建立您的 QnA Maker KB 時,將在本文中詳細說明。When referencing your QnA Maker resource for any action, such as when creating your QnA Maker KB which will be detailed in this article. 您可以在 QnA Maker 資源的 金鑰和端點 分頁中找到金鑰。You can find the key in the Keys and Endpoint blade in your QnA Maker resource.

    提示

    請務必瞭解此 QnA Maker 資源撰寫端點之間的差異,在所有 BF CLI qnamaker 撰寫命令和程式碼設定檔案中所參考的 QnA Maker 知識庫端點金鑰(例如 c # 中的 appsettings.js,或 .env 以 JavaScript 或 Python 撰寫) config.pyIt is important to understand the difference between this QnA Maker resource authoring endpoint which is referenced in all BF CLI qnamaker authoring commands and the QnA Maker Knowledge base endpoint key which is referenced in a source code configuration files such as appsettings.json in C#, or .env in JavaScript or config.py in Python.

  • 位置Location. 這是包含您 QnA Maker KB 的 Azure 區域。This is the Azure region that contains your QnA Maker KB. 當您建立 QnA Maker 資源時,請選取此選擇。You select this when creating the QnA Maker resource.

    Azure 中的金鑰和端點分頁

安裝 Bot Framework CLIInstall the Bot Framework CLI

如果您已經安裝 Bot Framework CLI,您可以直接跳到 建立您的 QnA Maker 模型If you have already installed the Bot Framework CLI you can skip ahead to Create your QnA Maker model.

Bot Framework CLI 需要 Node.jsBot Framework CLI requires Node.js.

  1. 請確定您已安裝最新版的 npm:Make sure you have the latest version of npm installed:

    npm i -g npm
    
  2. 使用 Node.js,從命令列安裝最新版本的 Bot Framework CLI。Using Node.js, install the latest version of Bot Framework CLI from the command line.

    npm i -g @microsoft/botframework-cli
    

如需詳細資訊,請參閱 BOT FRAMEWORK CLI 工具For more information, see Bot Framework CLI tool.

建立您的 QnA Maker 初始化檔Create your QnA Maker initialization file

Bot Framework CLI 提供一種機制,可將所有常用的參數值儲存在初始化檔中。The Bot Framework CLI provides a mechanism to store all commonly used parameter values in an initialization file. 建立此檔案之後, qnamaker 您執行的每個命令都會檢查此檔案是否有必要值(如果命令列未包含這些值)。Once this file is created, every qnamaker command you run will check this file for the required values if they are not included in the command line. 如果您提供該參數的值,它會覆寫 init 檔案中的值。If you do supply that parameter's value, it will override the value in the init file.

您可以使用命令來建立這個 init 檔 qnamaker:initYou create this init file using the qnamaker:init command. 這會建立 JSON 檔案,其中包含執行許多 QnAMaker BF CLI 命令(包括 subscriptionKeykbIdendpointKey主機名稱)時所需的資料。This will create a JSON file containing the data that is required when running many of the QnAMaker BF CLI commands, including subscriptionKey, kbId, endpointKey and hostname.

注意

因為您尚未建立您的 QnA Maker KB,所以系統會提示您提供 KB 識別碼。Since you have not yet created your QnA Maker KB, you will not be able to provide the KB ID when prompted for it. 這樣也會導致 init 檔案遺漏值 kbId hostnameThat will result in an init file that is missing a value for kbId as well hostname. 當您在執行命令時包含選項時,當您建立 QnA Maker KB 時,會自動新增這些值 --saveThese values will be added automatically when you create your QnA Maker KB when you include the --save option when running the command.

用來建立 qnamaker init 檔案的命令:The command to create the qnamaker init file:

bf qnamaker:init

若要建立 QnA Maker CLI init 檔案:To create the QnA Maker CLI init file:

  1. 在您的主控台中,輸入 bf qnamaker:initFrom your console, enter bf qnamaker:init

  2. 系統會提示您提供 Azure 中 QnA Maker 認知服務資源的訂用帳戶金鑰。You will be prompted for the subscription key to your QnA Maker Cognitive Services resource in Azure. 您可以在 [ 金鑰和端點 ] 分頁中找到此選項:You can find this in the Keys and Endpoint blade:

    QnA Maker Azure 中的金鑰和端點

  3. 接下來,系統會提示您輸入知識庫識別碼 (kbId) 。Next you will be prompted for your knowledge base ID (kbId). 由於您尚未建立您的 QnA Maker KB,請輸入 noneSince you have not yet created your QnA Maker KB, enter none.

  4. 系統會將這些值收集並寫出到畫面中,讓您進行驗證。The values are gathered and written out to the screen for you to verify. 如果正確 yes 的類型或只按 enter 鍵。If correct type yes or just press the Enter key.

  5. 接著會建立檔案,並將其儲存至 C:\Users \ <unsername> \AppData\Local @microsoft\botframework-cli\config.jsThe file is then created and saved to C:\Users\<unsername>\AppData\Local@microsoft\botframework-cli\config.json. 因為此檔案包含機密資料,所以它不會儲存在與 bot 專案檔相同的目錄中,以防止在簽入您的原始程式碼時,將其簽入任何可能不安全的位置。Since this file contains sensitive data it is not saved in the same directory as your bot's project files to prevent it from being checked into any potentially unsecured location when checking in your source code.

提示

當您輸入 bf qnamaker CLI 命令時,會自動在此 init 檔中尋找 subscriptionKeykbIdendpointKeyhostname 值,除非您在輸入命令時包含它們,此時輸入的值將會覆寫 init 檔案中的值。When you enter a bf qnamaker CLI command, it will automatically look for the subscriptionKey, kbId, endpointKey and hostname values in this init file unless you include them when entering the command, at which point the values entered will override the values from the init file.

如需使用此命令的詳細資訊,請參閱 bf qnamaker:init BF CLI QnA Maker 讀我檔案中的。For additional information on using this command, see bf qnamaker:init in the BF CLI QnA Maker readme.

重要

本文中說明的命令假設您有 init 檔。The commands explained in this article assume that you have an init file. 如果您沒有 init 檔案,則必須在執行每個命令時包含這些值。If you do not have an init file, you will have to include those values when executing each command.

建立您的 QnA Maker 模型Create your QnA Maker model

為 bot 建立個別的 qna 檔案之後,您可以使用命令將它們轉換成單一 QnA Maker 模型 qnamaker:convertOnce you have created the individual .qna files for your bot, you can convert them into a single QnA Maker model using the qnamaker:convert command. QnA Maker 模型是用來建立 QnA Maker KB 的 JSON 檔案。The QnA Maker model is a JSON file used to create a QnA Maker KB.

若要建立您的 QnA Maker 模型:To create your QnA Maker model:

bf qnamaker:convert -i <input-folder-name> -o <output-folder-name> --name <QnA-KB-Name> -r

例如,此命令 bf qnamaker:convert -i dialogs -o output --name MyQnAMakerBot -r 會以遞迴方式搜尋 對話方塊 _ 目錄和任何子目錄中的所有 qna 檔案,並將它們合併成 輸出 目錄中名為 converted.js 的單一檔案。For example, the command bf qnamaker:convert -i dialogs -o output --name MyQnAMakerBot -r will recursively search for all .qna files in the dialogs _ directory and any subdirectories and merge them into a single file named converted.json in the output directory. 此 JSON 檔案將包含建立 QnA Maker KB 所需的所有資訊,包括名稱 MyQnAMakerBot ,這會是將存在於 Azure 中之 QnA Maker 知識庫的名稱。This JSON file will contain all of the information needed to create a QnA Maker KB, including the name MyQnAMakerBot which will be the name of the QnA Maker knowledge base that will exist in Azure.

如需使用此命令的詳細資訊,請參閱 bf qnamaker:convert BF CLI QnA Maker 讀我檔案中的。For additional information on using this command, see bf qnamaker:convert in the BF CLI QnA Maker readme.

建立您的 QnA Maker 知識庫Create your QnA Maker knowledge base

您 perviously 建立的 QnA Maker 資源 包含兩個訂用帳戶金鑰和端點。The QnA Maker resource you perviously created consists of two subscription keys and an endpoint. 這些是您在建立 QnA Maker KB (QnA Maker KB) 時所需的值。These are values that you need when creating your QnA Maker KB (QnA Maker KB). 您可以有多個與單一 QnA Maker 資源相關聯的 QnA Maker Kb,每個 QnA Maker KB 都會有自己的識別碼,名為 kbIdYou can have multiple QnA Maker KBs associated with a single QnA Maker resource, each QnA Maker KB will have its own ID, named kbId. 此值將會在建立過程中傳回。This value will be returned as a part of the creation process. 當您日後參考此 QnA Maker KB 時,將需要此識別碼。You will need this ID when referring to this QnA Maker KB in the future. 此 QnA Maker KB 會為您的 bot 提供 QnA Maker 所提供的所有功能。This QnA Maker KB provides your bot with all functionality provided by QnA Maker.

若要建立您的 QnA Maker KB:To create your QnA Maker KB:

bf qnamaker:kb:create --in <QnA-Maker-model-JSON-file> --name <QnA-Maker-kb-name>

注意

  • 此命令的輸入檔是 qnamaker:convert 執行上述步驟中所討論的命令所建立的檔案。The input file for this command is the file that is created by running the qnamaker:convert command as discussed in the previous step. 預設會 converted.js開啟 檔案名。The filename is converted.json by default.
  • name 選項是 QNA MAKER KB 的名稱,如果 QnA 模型 JSON 檔案具有 name 屬性的值,則為選擇性,否則將會需要它。The name option is the name of the QnA Maker KB and is optional if the QnA Model JSON file has a value for the name property, otherwise it will be required.

如需使用此命令的詳細資訊,請參閱 bf qnamaker:kb:create BF CLI QnA Maker 讀我檔案中的。For additional information on using this command, see bf qnamaker:kb:create in the BF CLI QnA Maker readme.

測試您的 QnA Maker 知識庫Test your QnA Maker knowledge base

沒有可用於測試 KB 的 BF CLI qnamaker 命令,不過您可以 使用 batch 問題和預期的答案來測試知識庫There are no BF CLI qnamaker commands available to test your KB, however you can Test knowledge base with batch questions and expected answers.

如果您打算建立腳本,從端對端自動執行此程式,這可讓您包含測試。If you plan to create scripts to automate this process from end to end, this will enable you to include testing.

發佈您的 QnA Maker 知識庫Publish your QnA Maker knowledge base

新建立的 QnA Maker Kb 會自動發行至 測試 端點,以便在上線之前進行測試。Newly created QnA Maker KBs are automatically published to the test endpoint where it can be tested prior to it going live. 如需有關測試 KB 的一般資訊,請參閱 QnA Maker 中的測試知識庫For general information about testing your KB, see Test your knowledge base in QnA Maker.

測試完成後,您可以使用將 qnamaker:kb:publish 它發佈至 生產 端點。Once tested you can use the qnamaker:kb:publish to publish it to the production endpoint.

若要發佈您的 QnA Maker 知識庫:To publish your QnA Maker knowledge base:

bf qnamaker:kb:publish

如果您沒有 init 檔案,則發佈您的 QnA Maker KB:To publish your QnA Maker KB if you do not have an init file file:

bf qnamaker:kb:publish --subscriptionKey <Subscription-Key> --kbId <knowledge-base-id>

提示

如果您有多個 QnA Maker KB,而且想要在 init 檔案中指向另一個以外的檔案,您必須使用選項提供 KB 識別碼 --kbIdIf you have multiple QnA Maker KB's and want to publish one other than the one pointed to in the init file, you will need to provide the KB ID using the --kbId option:

bf qnamaker:kb:publish --kbId <knowledge-base-id>

您可以在 [設定] 頁面的 [部署詳細資料] 區段中,找到 QnAMaker中的知識庫識別碼:You can find the knowledge base ID in QnAMaker in the Deployment details section of the SETTINGS page:

QnA Maker 中 [設定] 頁面的 [部署詳細資料] 區段

使用 build 命令建立 QnA Maker 知識庫並將其發行至生產環境Create a QnA Maker knowledge base and publish it to production using the build command

瞭解部署 QnA Maker KB 的程式如何運作,以及完成這篇文章到目前為止,您應該更加瞭解使用 Bot Framework CLI 命令發行至測試或生產端點所需的處理常式。It is helpful to understand how the process of deploying a QnA Maker KB works, and after completing this article up to this point, you should have a better understanding of the processes involved to publish to your test or prod endpoint using the Bot Framework CLI commands.

使用這些命令可讓您在針對特定需求量身打造腳本時提供彈性。Using these commands gives you flexibility when tailoring scripts to your specific needs. 如果不需要這種彈性,還有另一個 BF CLI 命令,可將本文中所討論的大部分命令結合成單一命令,讓您用來建立或更新,然後將 QnA Maker KB 定型和發佈至 生產 端點,這也是 qnamaker:build 命令。If this flexibility is not needed there is another BF CLI command that combines most of the commands discussed in this article into a single command that you can use to create or update, then train and publish a QnA Maker KB to the production endpoint, and that is the qnamaker:build command.

build 命令只會發佈至生產端點。The build command only publishes to the production endpoint. 您可以將它與本文中討論的先前命令分開使用,因為它們主要是在開發過程中用來發行至測試端點,在這種情況下,可能會在發行至生產環境之前進行測試。You can use it separately from the previous commands discussed in this article, as they are primarily used during the development process to publish to the test endpoint, where testing can take place before publishing to production.

QnAMaker build 命令會將下列所有動作合併成單一命令:The QnAMaker build command combines all the following actions into a single command:

  1. 使用您現有的 QnA 檔案,為 每個 找到的地區設定建立一個 QnA Maker 模型。Creates one QnA Maker model for every locale found using your existing .qna files.
  2. 建立新的 QnA Maker KB (如果不存在),否則會覆寫現有的 KB。Creates a new QnA Maker KB if none exists, otherwise it will overwrite the existing KB.
  3. 它會定型您的 QnA Maker KB,然後將其發佈至生產端點。It trains your QnA Maker KB then publishes it to the production endpoint.
  4. 如果您包含選擇性 dialog 參數,則會在 .dialog 使用宣告式方法進行開發時,輸出QnA Maker 辨識器可以使用的定義檔。If you include the optional dialog parameter, it will output the .dialog definition files that can be used by the QnA Maker recognizer when developing using the declarative approach. 對話方塊檔案區段會說明這一點。This is explained in The dialog file section.

如何使用 build 命令How to use the build command

QnAMaker build 命令及其必要參數:The QnAMaker build command with its required parameters:

bf qnamaker:build --in <input-file-or-folder> --subscriptionKey <Subscription-Key> --botName <bot-name>

重要

此命令將會覆寫您先前的 QnA Maker 模型,以及您 QnA Maker KB 中可能存在的任何內容,包括直接在 QnA Maker.ai中建立的任何內容。This command will overwrite your previous QnA Maker model as well any content you might have in your QnA Maker KB, including any content created directly in QnA Maker.ai.

Qnamaker:組建參數The qnamaker:build parameters

  • in:將搜尋 qna 檔案的目錄(包括子目錄)。in: The directory, including sub-directories, that will be searched for .qna files.
  • out:儲存輸出檔案的目錄。out: The directory to save output files to. 這包括所有辨識器檔案以及設定檔案,以及選擇性的對話檔。This includes all the recognizer files as well as the settings file, and optionally the dialog files. 如果您省略此 out 選項,則不會將檔案儲存到磁片,而且只會將撰寫金鑰和端點寫入主控台。If you omit the out option, no files will be saved to disk and only the authoring keys and endpoint will be written to the console.
  • log:布林值,決定是否在此進程期間建立記錄檔。log: A Boolean value that determines if a log is created during this process.
  • botName: Bot 的名稱。botName: The name of your bot. 這會用來產生 QnA Maker KB 的名稱,這會在下面 QnA Maker 的 [ 知識庫中建立 ] 區段中更詳細地說明。This will be used to generate the name of the QnA Maker KB, this is explained in more detail in the QnA Maker Knowledge Bases created section below.
  • subscriptionKey:您的 初始化檔中相同的訂用帳戶金鑰。subscriptionKey: The same subscription key that is in your initialization file.

如需其他參數的詳細資訊,請參閱 BF CLI 讀我檔案中的 bf qnamaker: buildFor information on additional parameters, see bf qnamaker:build in the BF CLI readme.

或者,您可以將這些必要的參數包含在設定檔中,並透過參數提供這些參數 qnaConfigAlternatively, you can include these required parameters in a configuration file and provide them via the qnaConfig parameter.

Qnamaker 設定檔The qnamaker configuration file

Qnamaker 設定檔是 JSON 檔案,可包含任何有效 qnamaker:build 的選項。The qnamaker configuration file is a JSON file that can contain any valid qnamaker:build option.

{
  "in": "<location-of-qna-files>",
  "out": "<location-to-save-output-files>",
  "subscriptionKey": "<Enter-subscription-key-here>",
  "botName": "<Enter-botName-here>"
}

一旦建立之後,您只需要在命令中參考它 qnamaker:build ,例如:Once created all you need to do is reference it in your qnamaker:build command, for example:

bf qnamaker:build --qnaConfig qnaConfig.json

QnA 和多種語言變化QnA and multiple language variations

每個 qna 檔案都可以有多個語言變化,每個支援的語言都有一個。Each .qna file can have multiple language variations, one for each language supported.

使用語言變體時,qna 檔案名的模式如下所示:The pattern for the .qna file name when language variants are used is as follows:

<file-name>.<locale>.qna

例如:For example:

example.en-us.qna
example.fr-fr.qna
example.de-de.qna
etc.

在上述範例中,每個 qna 檔案都會產生一個針對每個語言建立的 QnA Maker KB。In the above example, each one of the .qna files will result in one QnA Maker KB created for each of the languages.

提示

如果無法從檔案名判斷語言,則會使用在 CLI 參數中指定的值 --defaultCultureIf the language cannot be determined from file name, then the value specified in the CLI parameter --defaultCulture will be used. 如果缺少 CLI 參數 --defaultCulture ,則語言會預設為 en-usIf the CLI parameter --defaultCulture is missing, the language will default to en-us.

QnA Maker 建立的知識庫QnA Maker Knowledge Bases created

若要啟用多個人使用 LUIS 模型的案例,而且必須能夠彼此獨立地使用它們,且全都系結至相同的原始檔控制,此 qnamaker:build 命令會使用您證明為參數值的組合 botName ,後面接著您所登入的使用者名稱,然後再接著 QnA,來建立 QnA Maker 知識庫。To enable the scenario where multiple people are working with LUIS models and need to be able to work with them independently from each other while all being tied to the same source control, the qnamaker:build command creates the QnA Maker knowledge base using a combination of the value you proved as the botName parameter followed by the user name you are logged in as, then the locale followed by .qna.

QnA Maker KB 名稱:The QnA Maker KB name:

<botName>(<user-name>).locale.qna

例如,如果您的 botName 是 MyProject ,而且您的使用者名稱是 YuuriTanaka,則您的 kb 名稱會如下所示:For example, if your botName is MyProject and your username is YuuriTanaka, the names of your KBs would be as follows:

MyProject(YuuriTanaka).en-us.qna
MyProject(YuuriTanaka).fr-fr.qna
MyProject(YuuriTanaka).de-de.qna

提示

將使用者名稱包含為 KB 名稱的一部分,可讓多個開發人員獨立工作。Including the username as part of the KB name enables multiple developers to work independently. 此值會自動產生,並使用登入人員的使用者名稱,不過您可以使用選項覆寫此值 --suffixThis value is generated automatically, using the username of the person logged in, however you can override this using the --suffix option.

使用 build 命令產生的設定檔案The settings file generated using the build command

的輸出 qnamaker:build 包含一個設定檔,其中包含所有 QnA Maker 知識庫的對應,包括每個知識庫的 KB 識別碼和主機名稱。The output of qnamaker:build includes one settings file that contains the mapping to all of the QnA Maker knowledge bases, including the KB ID and hostname for each.

QnA Maker KB 設定檔案:The QnA Maker KB settings file:

qnamaker.settings.<app-name>.<website-location>.json

例如,使用者 YuuriTanaka 目的地區域 westus 的設定檔名稱為:For example the settings file for user YuuriTanaka targeting region westus is named:

qnamaker.settings.YuuriTanaka.westus.js開啟qnamaker.settings.YuuriTanaka.westus.json

範例設定檔案:Example settings file:

{
    "qna": {
        "RootDialog_en_us_qna": "<knowledge-base-ID-for-en-us-locale>",
        "RootDialog_fr_fr_qna": "<knowledge-base-ID-for-fr-fr-locale>",
        "hostname": "https://<app-name>.azurewebsites.net/qnamaker"
    }
}

提示

檔案名的 網站位置 部分,以及檔案中檔案名和主機名稱值的 應用程式名稱 部分,都來自于在 Azure 中建立 QnA Maker 資源時所提供的值,在 [ App Service 詳細資料-針對運行 時間] 區段中。The website-location portion of the file name, as well as the app-name portion of the file name and hostname value in the file, both come from the values given when creating the QnA Maker resource in Azure, in the App Service details - for runtime section.

應用程式名稱

對話方塊檔The dialog file

當您使用選擇性 --dialog 選項時,會針對每個 qna 檔案的所有語言變化產生一個對話方塊檔。When you use the optional --dialog option, a dialog file will be generated for all language variations of each of your .qna files.

重要

--schema選項會與選項搭配使用 --dialogThe --schema option is used in conjunction with the --dialog option. 包含 --schema 選項可確保每個建立的對話方塊檔案都有專案根架構檔案的參考。Including the --schema option will ensure that every dialog file created will have a reference to the projects root schema file. 此架構檔案包含您的 bot 所取用之所有元件的架構。This schema file contains the schemas of all the components that are consumed by your bot. 宣告式檔案的每個取用者(包括 [編輯器] [編輯器])都需要架構檔。Every consumer of declarative files, including [Composer][composer], needs a schema file. 如果您的專案沒有架構檔案,您可以使用命令來產生一個 dialog:mergeIf your project does not have a schema file you can generate one using the dialog:merge command. 您必須在執行此命令之前,先執行此命令 luis:buildYou will need to run this command before running the luis:build command. 如需其他資訊,請參閱在 適應性對話方塊中使用宣告式資產的相關文章。For additional information refer to the article on Using declarative assets in adaptive dialogs.

Qnamaker:組建對話方塊和架構參數:The qnamaker:build dialog and schema parameters:

  • 對話方塊dialog. 對話方塊選項有兩個有效的值: multiLanguagecrosstrainedThere are two valid values for the dialog option, multiLanguage and crosstrained.
  • 架構schema. 這會採用指向 bot 架構檔案的相對路徑和檔案名。This takes a relative path and filename pointing to the bot's schema file.

這些檔案會寫入至選項中指定的目錄 outThese files will be written to the directory specified in the out option. 例如:For example:

 ./rootDialog/RootDialog.qna.dialog <-- MultiLanguageRecognizer configured to use all of the languages
 ./rootDialog/RootDialog.en-us.qna.dialog <-- QnARecognizer for en-us locale
 ./rootDialog/RootDialog.fr-fr.qna.dialog <-- QnARecognizer for fr-fr locale

以下是 MultiLanguageRecognizer 檔案的範例:Here is an example of the MultiLanguageRecognizer file:

{
    "$schema": "app.schema",
    "$kind": "Microsoft.MultiLanguageRecognizer",
    "id": "QnA_RootDialog",
    "recognizers": {
        "en-us": "RootDialog.en-us.qna",
        "fr-fr": "RootDialog.fr-fr.qna",
        "": "RootDialog.en-us.qna"
    }
}

如果您使用宣告式方法來開發 bot,您將會使用這些檔案,而且您必須在您的調適型對話方塊檔案中新增此辨識器的參考 .dialogYou will use these files if you are using the declarative approach to developing your bot, and you will need to add a reference to this recognizer in your adaptive dialogs .dialog file. 在下列範例中, "recognizer": "RootDialog.qna" 正在尋找 rootdialog.cs 檔案中所定義的辨識器 。 qnaIn the following example the "recognizer": "RootDialog.qna" is looking for the recognizer that is defined in the file RootDialog.qna.dialog:

如何參考. 對話方塊檔案中的辨識器

如需詳細資訊,請參閱 在適應性對話方塊中使用宣告式資產See Using declarative assets in adaptive dialogs for more information.

其他資訊Additional information