This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetchPrediction(TEXT = "give me a flight from baltimore to newark"){ | |
TEXT = encodeURI("tokens=BOS "+TEXT+" EOS"); | |
console.log(TEXT); | |
//You need to replace this temporary URL | |
var url = "https://e769db6e.ngrok.io/predict"; | |
var options = { | |
"method" : "POST", | |
"contentType" : "application/x-www-form-urlencoded", | |
"payload" : TEXT, | |
'muteHttpExceptions': true | |
}; | |
var response = UrlFetchApp.fetch(url, options); | |
var json = response.getContentText(); | |
console.log(json); | |
prediction = JSON.parse(json); | |
//console.log(prediction); | |
console.log(prediction["intent_predictions"]); | |
console.log(prediction["slots_predictions"].join("_")); | |
//return [prediction["intent_predictions"], JSON.stringify(prediction["slots_predictions"])]; | |
return [prediction["intent_predictions"], prediction["slots_predictions"].join("_")]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment