Pradyumna Das
Tera Expert

Hi Experts,

In this article, I have added the code to get the NLU Prediction result based on our model and utterance. 

 

Execute the below code in the background script to test :

 

try {
    var modelId='<<Add you model sysID>>';//NLU Model sys_id
    var utterance='coffee with prady';// add the utterance
    if (modelId && utterance) {
        var result = global.NLUStudioPredictor.testUtterance(modelId, utterance);
        //gs.info(JSON.stringify(result));//print the result
        if(result.status=='success'){
            gs.info(result.message.intents[0].intentName);//Print the predicted Intent Name
            gs.info(parseInt(result.message.intents[0].score)*100);//print the accuracy score in % wrt utterance
        }
    } else {
        gs.info("Invalid input data provided");
    }
} catch (e) {
    gs.info('Error+++++++++ '+e);
}

 

 

Please mark this helpful if this helps you in any manner.

 

Thanks,

Pradyumna Das

Version history
Last update:
‎10-10-2023 11:20 AM
Updated by:
Contributors