类似形状的 Javascript sdk 用于 - LUISA 认证 客户端
这个包中包含一个LUISAuthoring Client的同构SDK.
| 软件包版本 | LUIS 写入 API 版本 |
|---|---|
| 3.0.0 (单位:千美元) | /luis/api/v2.0 (英语) |
| 4.0.0审查 | /luis/作者/v3.0-审查 |
目前得到支持的环境
- 节点.js 6.x.x 或更高版本
- 浏览器 JavaScript
如何安装
npm install @azure/cognitiveservices-luis-authoring
如何使用
nodejs - 认证,客户端创建和列表PhraseLists的特性,作为TypeScript所写的示例.
安装@azure/ ms-rest-azure-js
npm install @azure/ms-rest-azure-js
样本代码
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
import { LUISAuthoringClient } from "@azure/cognitiveservices-luis-authoring";
let authoringKey = process.env["luis-authoring-key"];
const creds = new CognitiveServicesCredentials(authoringKey);
// check the following link to find your region
// https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-reference-regions
const region = "<your-region>";
const client = new LUISAuthoringClient(
creds,
"https://" + region + ".api.cognitive.microsoft.com/"
);
const appId = "<your-app-id>"; // replace this with your appId.
const versionId = "0.1"; // replace with version of your luis application. Initial value will be 0.1
const skip = 1;
const take = 1;
client.features
.listPhraseLists(appId, versionId, { skip, take })
.then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
console.error(err);
});
浏览器 - 认证,客户端创建和列表PhraseLists功能,作为用JavaScript写作的示例.
样本代码
- 索引.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>@azure/cognitiveservices-luis-authoring sample</title>
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
<script src="node_modules/@azure/cognitiveservices-luis-authoring/dist/cognitiveservices-luis-authoring.js"></script>
<script type="text/javascript">
let authoringKey = process.env["luis-authoring-key"];
const creds = new msRest.ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': authoringKey } });
const region = "<your-region>";
const client = new Azure.CognitiveservicesLuisAuthoring.LUISAuthoringClient(
creds,
"https://" + region + ".api.cognitive.microsoft.com/"
);
const appId = "<your-app-id>"; // replace this with your appId.
const versionId = "0.1"; // replace with version of your luis application. Initial value will be 0.1
const skip = 1;
const take = 1;
client.features
.listPhraseLists(appId, versionId, { skip, take })
.then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
console.log("An error occurred:");
console.error(err);
});
</script>
</head>
<body></body>
</html>
相关项目
