This package has been deprecated

Author message:

The QnA Maker service is being retired on the 31st of March, 2025. A newer version of the question and answering capability is now available as part of Azure Cognitive Service for Language. For information on migrating existing QnA Maker knowledge bases to question answering, consult the migration guide: https://learn.microsoft.com/azure/cognitive-services/language-service/question-answering/how-to/migrate-qnamaker

@azure/cognitiveservices-qnamaker
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

An isomorphic javascript sdk for - QnAMakerClient

This package contains an isomorphic SDK for editing and creating Knowledge Bases, its endpoints and keys. For interacting with QnAMaker such as training and asking questions please see @azure/cognitiveservices-qnamaker-runtime.

Currently supported environments

  • Node.js version 6.x.x or higher
  • Browser JavaScript

How to Install

npm install @azure/cognitiveservices-qnamaker

How to use

nodejs - Authentication, client creation and getSettings endpointSettings as an example written in TypeScript.

Install @azure/ms-rest-azure-js
npm install @azure/ms-rest-azure-js
Sample code
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");  
const { QnAMakerClient } = require("@azure/cognitiveservices-qnamaker");

async function main() {
  const QNAMAKER_KEY = process.env["QNAMAKER_KEY"] || "<QNAMAKER_KEY>";
  const QNAMAKER_ENDPOINT = process.env["QNAMAKER_ENDPOINT"] || "<QNAMAKER_ENDPOINT>";

  const cognitiveServicesCredentials = new CognitiveServicesCredentials(QNAMAKER_KEY);
  const client = new QnAMakerClient(cognitiveServicesCredentials, QNAMAKER_ENDPOINT);

  const settings = await client.endpointSettings.getSettings();

  console.log(`The result is: ${JSON.stringify(settings)}`);
}

main();

browser - Authentication, client creation and getSettings endpointSettings as an example written in JavaScript.

Install @azure/ms-rest-browserauth
npm install @azure/ms-rest-browserauth
Sample code

See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

  • index.html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>@azure/cognitiveservices-qnamaker sample</title>
    <script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
    <script src="node_modules/@azure/cognitiveservices-qnamaker/dist/cognitiveservices-qnamaker.js"></script>
    <script type="text/javascript">
      async function main() {
        const QNAMAKER_KEY = "<QNAMAKER_KEY>";
        const QNAMAKER_ENDPOINT = "<QNAMAKER_ENDPOINT>";
        const cognitiveServiceCredentials = new msRest.ApiKeyCredentials({
          inHeader: {
            "Ocp-Apim-Subscription-Key": QNAMAKER_KEY
          }
        });

        const client = new Azure.CognitiveservicesQnamaker.QnAMakerClient(
          cognitiveServiceCredentials,
          QNAMAKER_ENDPOINT
        );

        const settings = client.endpointSettings.getSettings();
        console.log(`The result is: ${settings}`);
      }

      main();
    </script>
  </head>
  <body></body>
</html>

Related projects

Impressions

Package Sidebar

Install

npm i @azure/cognitiveservices-qnamaker

Weekly Downloads

213

Version

3.2.0

License

MIT

Unpacked Size

580 kB

Total Files

89

Last publish

Collaborators

  • microsoft1es
  • amarzavery
  • vladbarosan
  • veronicagg
  • azure-sdk