-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (36 loc) · 1.07 KB
/
app.js
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
35
36
37
38
new Vue({
el: '#app',
data: {
userInput: '',
responseData: "Output will be updated when the computation is done.. ",
ACCESS_TOKEN: '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'
},
methods: {
async fetchData() {
const data = { "inputs": this.userInput };
try {
const response = await fetch(
"https://api-inference.huggingface.co/models/tomaarsen/span-marker-mbert-base-multinerd",
{
headers: { Authorization: `Bearer ${this.ACCESS_TOKEN}` },
method: "POST",
body: JSON.stringify(data),
}
);
const result = await response.json();
this.responseData = result;
} catch (error) {
console.error("Error fetching data:", error);
}
},
},
computed: {
formattedResponseData() {
if (Array.isArray(this.responseData)) {
return this.responseData.map(item => `(entity_group:${item.entity_group} word: ${item.word})`).join('<br>');
} else {
return "Output will be updated when the computation is done.. ";
}
}
}
});