Add widget
Browse files
widget.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
```javascript
|
| 3 |
+
async function query(data) {
|
| 4 |
+
const response = await fetch(
|
| 5 |
+
"https://api-inference.huggingface.co/models/latishab/turnsense",
|
| 6 |
+
{
|
| 7 |
+
headers: { Authorization: "Bearer $HUGGINGFACE_TOKEN" },
|
| 8 |
+
method: "POST",
|
| 9 |
+
body: JSON.stringify(data),
|
| 10 |
+
}
|
| 11 |
+
);
|
| 12 |
+
const result = await response.json();
|
| 13 |
+
return result;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
// Example usage
|
| 17 |
+
query({"inputs": "Your text here"}).then((response) => {
|
| 18 |
+
console.log(JSON.stringify(response));
|
| 19 |
+
});
|