conversational-language-understanding
Version:
Conversational language understanding is part of Azure Language Studio and It can be used to create NLP application.
49 lines (48 loc) • 1.72 kB
JavaScript
var axios = require('axios');
class CustomCLU {
constructor(endpoint, subscriptionKey, projectName, deploymentName) {
this.endpoint = endpoint
this.subscriptionKey = subscriptionKey
this.projectName = projectName
this.deploymentName = deploymentName
}
CluRecognizer(context) {
var data = JSON.stringify({
"kind": "Conversation",
"analysisInput": {
"conversationItem": {
"id": "PARTICIPANT_ID_HERE",
"text": context.activity.text,
"modality": "text",
"language": "en",
"participantId": "PARTICIPANT_ID_HERE"
}
},
"parameters": {
"projectName": this.projectName,
"verbose": true,
"deploymentName": this.deploymentName,
"stringIndexType": "TextElement_V8"
}
});
var config = {
method: 'post',
url: `${this.endpoint}/language/:analyze-conversations?api-version=2022-10-01-preview`,
headers: {
'Ocp-Apim-Subscription-Key': this.subscriptionKey,
'Content-Type': 'application/json'
},
data: data
};
try {
return new Promise(async(resolve) => {
let response = await axios(config)
console.log('response', response.data.result)
resolve(response.data.result)
})
} catch (error) {
console.log(error)
}
}
}
module.exports.CustomCLU = CustomCLU