Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +4 -3
static/script.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
const textGenForm = document.querySelector('.text-gen-form');
|
| 2 |
|
| 3 |
-
const translateText = async (text) => {
|
| 4 |
-
const inferResponse = await fetch(`
|
| 5 |
const inferJson = await inferResponse.json();
|
| 6 |
|
| 7 |
return inferJson.output;
|
|
@@ -11,10 +11,11 @@ textGenForm.addEventListener('submit', async (event) => {
|
|
| 11 |
event.preventDefault();
|
| 12 |
|
| 13 |
const textGenInput = document.getElementById('text-gen-input');
|
|
|
|
| 14 |
const textGenParagraph = document.querySelector('.text-gen-output');
|
| 15 |
|
| 16 |
try {
|
| 17 |
-
textGenParagraph.textContent = await translateText(textGenInput.value);
|
| 18 |
} catch (err) {
|
| 19 |
console.error(err);
|
| 20 |
}
|
|
|
|
| 1 |
const textGenForm = document.querySelector('.text-gen-form');
|
| 2 |
|
| 3 |
+
const translateText = async (text, rating) => {
|
| 4 |
+
const inferResponse = await fetch(`predict?text=${text}&rating=${rating}`);
|
| 5 |
const inferJson = await inferResponse.json();
|
| 6 |
|
| 7 |
return inferJson.output;
|
|
|
|
| 11 |
event.preventDefault();
|
| 12 |
|
| 13 |
const textGenInput = document.getElementById('text-gen-input');
|
| 14 |
+
const rating = document.getElementById('rating-input');
|
| 15 |
const textGenParagraph = document.querySelector('.text-gen-output');
|
| 16 |
|
| 17 |
try {
|
| 18 |
+
textGenParagraph.textContent = await translateText(textGenInput.value, rating.value);
|
| 19 |
} catch (err) {
|
| 20 |
console.error(err);
|
| 21 |
}
|