Skip to content

Instantly share code, notes, and snippets.

@rajshah4
Last active November 16, 2022 01:33
Show Gist options
  • Save rajshah4/6cde451b7f126aeaa67d89503cba5b93 to your computer and use it in GitHub Desktop.
Save rajshah4/6cde451b7f126aeaa67d89503cba5b93 to your computer and use it in GitHub Desktop.
to_formal formula to call Hugging Inference Endpoints
function to_formal(input="That was funny LOL") {
const endpointUrl = "https://qw2w1h.us-east-1.aws.endpoints.huggingface.cloud";
const options = {
"method" : "POST",
"contentType" : "application/json",
"payload" : JSON.stringify({"inputs": input}),
"headers" : {
"Authorization" : "Bearer api_org_TOKEN"
}
};
const response = UrlFetchApp.fetch(endpointUrl, options);
const data = JSON.parse(response.getContentText());
const result = data[0]['generated_text']
console.log(result)
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment