-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassify.js
More file actions
34 lines (25 loc) · 780 Bytes
/
classify.js
File metadata and controls
34 lines (25 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const axios = require('axios');
// This is the function where the call to the API is made.
async function classifyText(text) {
// INSERT CODE SNIPPET FROM POSTMAN BELOW
let data = JSON.stringify({ "inputs": text });
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api-inference.huggingface.co/models/SamLowe/roberta-base-go_emotions',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer '+ process.env['ACCESS_TOKEN']
},
data : data
};
try {
const response = await axios.request(config);
return response.data;
}
catch (error) {
console.log(error);
}
}
// Allows for summarizeText() to be called outside of this file
module.exports = classifyText;