Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2020 05:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
function fetchPrediction(TEXT = "give me a flight from baltimore to newark"){
TEXT = encodeURI("tokens=BOS "+TEXT+" EOS");
//You need to replace this temporary URL
var url = "";
var options = {
"method" : "POST",
"contentType" : "application/x-www-form-urlencoded",
"payload" : TEXT,
'muteHttpExceptions': true
var response = UrlFetchApp.fetch(url, options);
var json = response.getContentText();
prediction = JSON.parse(json);
//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