Spaces:
Running
Running
Update index.html
Browse files- index.html +30 -42
index.html
CHANGED
|
@@ -8,61 +8,53 @@
|
|
| 8 |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
| 9 |
<script>
|
| 10 |
function sendQuestion() {
|
| 11 |
-
|
| 12 |
-
|
| 13 |
// https://baf8-34-87-104-241.ngrok-free.app/generate
|
| 14 |
// var myHeaders = new Headers();
|
| 15 |
// myHeaders.append("Content-Type", "application/json");
|
| 16 |
-
|
| 17 |
// var q_text = document.getElementById('question').value
|
| 18 |
-
|
| 19 |
// var raw = JSON.stringify({
|
| 20 |
// "prompt": '<s>[INST] {q_text} [/INST]',
|
| 21 |
// "max_tokens": 256,
|
| 22 |
// "temperature": 0.1
|
| 23 |
// });
|
| 24 |
-
|
| 25 |
// var requestOptions = {
|
| 26 |
// method: 'POST',
|
| 27 |
// headers: myHeaders,
|
| 28 |
// body: raw,
|
| 29 |
// redirect: 'follow'
|
| 30 |
// };
|
| 31 |
-
|
| 32 |
// fetch("https://baf8-34-87-104-241.ngrok-free.app/generate", requestOptions)
|
| 33 |
// .then(response => response.text())
|
| 34 |
// .then(result => console.log(result))
|
| 35 |
// .catch(error => console.log('error', error));
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
console.log(error);
|
| 63 |
-
});
|
| 64 |
-
|
| 65 |
-
|
| 66 |
// let continuation = 'The best things in life are';
|
| 67 |
// let prompt = `<s>[INST] ${continuation} [/INST]`;
|
| 68 |
// let counter = 0;
|
|
@@ -85,7 +77,6 @@
|
|
| 85 |
// break;
|
| 86 |
// }
|
| 87 |
// }
|
| 88 |
-
|
| 89 |
// fetch(
|
| 90 |
// 'https://baf8-34-87-104-241.ngrok-free.app/generate' +
|
| 91 |
// encodeURIComponent(document.getElementById('question').value)
|
|
@@ -102,8 +93,7 @@
|
|
| 102 |
// document.getElementById("answer").textContent = "Error: Unable to fetch data";
|
| 103 |
// document.getElementById("answer").classList.remove("hidden");
|
| 104 |
// });
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
</script>
|
| 108 |
<style>
|
| 109 |
@keyframes spin {
|
|
@@ -111,11 +101,9 @@
|
|
| 111 |
transform: rotate(360deg);
|
| 112 |
}
|
| 113 |
}
|
| 114 |
-
|
| 115 |
.animate-spin {
|
| 116 |
animation: spin 1s linear infinite;
|
| 117 |
}
|
| 118 |
-
|
| 119 |
</style>
|
| 120 |
</head>
|
| 121 |
<body class="bg-gray-100 min-h-screen">
|
|
@@ -142,4 +130,4 @@
|
|
| 142 |
</div>
|
| 143 |
</div>
|
| 144 |
</body>
|
| 145 |
-
</html>
|
|
|
|
| 8 |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
| 9 |
<script>
|
| 10 |
function sendQuestion() {
|
| 11 |
+
document.getElementById("loading").classList.remove("hidden");
|
| 12 |
+
document.getElementById("answer").classList.add("hidden");
|
| 13 |
// https://baf8-34-87-104-241.ngrok-free.app/generate
|
| 14 |
// var myHeaders = new Headers();
|
| 15 |
// myHeaders.append("Content-Type", "application/json");
|
|
|
|
| 16 |
// var q_text = document.getElementById('question').value
|
|
|
|
| 17 |
// var raw = JSON.stringify({
|
| 18 |
// "prompt": '<s>[INST] {q_text} [/INST]',
|
| 19 |
// "max_tokens": 256,
|
| 20 |
// "temperature": 0.1
|
| 21 |
// });
|
|
|
|
| 22 |
// var requestOptions = {
|
| 23 |
// method: 'POST',
|
| 24 |
// headers: myHeaders,
|
| 25 |
// body: raw,
|
| 26 |
// redirect: 'follow'
|
| 27 |
// };
|
|
|
|
| 28 |
// fetch("https://baf8-34-87-104-241.ngrok-free.app/generate", requestOptions)
|
| 29 |
// .then(response => response.text())
|
| 30 |
// .then(result => console.log(result))
|
| 31 |
// .catch(error => console.log('error', error));
|
| 32 |
+
let data = JSON.stringify({
|
| 33 |
+
"prompt": "<s>[INST] ତୁମେ କିଏ? [/INST] ",
|
| 34 |
+
"max_tokens": 25,
|
| 35 |
+
"temperature": 0.1
|
| 36 |
+
});
|
| 37 |
+
let config = {
|
| 38 |
+
method: 'post',
|
| 39 |
+
maxBodyLength: Infinity,
|
| 40 |
+
url: 'https://7e2d-34-136-146-180.ngrok-free.app/generate',
|
| 41 |
+
headers: {
|
| 42 |
+
'Content-Type': 'application/json',
|
| 43 |
+
// "Access-Control-Allow-Origin": "*",
|
| 44 |
+
"ngrok-skip-browser-warning": true
|
| 45 |
+
},
|
| 46 |
+
data: data
|
| 47 |
+
};
|
| 48 |
+
axios.request(config)
|
| 49 |
+
.then((response) => {
|
| 50 |
+
console.log(JSON.stringify(response.data));
|
| 51 |
+
document.getElementById("answer").textContent = response.data;
|
| 52 |
+
document.getElementById("loading").classList.add("hidden");
|
| 53 |
+
document.getElementById("answer").classList.remove("hidden");
|
| 54 |
+
})
|
| 55 |
+
.catch((error) => {
|
| 56 |
+
console.log(error);
|
| 57 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
// let continuation = 'The best things in life are';
|
| 59 |
// let prompt = `<s>[INST] ${continuation} [/INST]`;
|
| 60 |
// let counter = 0;
|
|
|
|
| 77 |
// break;
|
| 78 |
// }
|
| 79 |
// }
|
|
|
|
| 80 |
// fetch(
|
| 81 |
// 'https://baf8-34-87-104-241.ngrok-free.app/generate' +
|
| 82 |
// encodeURIComponent(document.getElementById('question').value)
|
|
|
|
| 93 |
// document.getElementById("answer").textContent = "Error: Unable to fetch data";
|
| 94 |
// document.getElementById("answer").classList.remove("hidden");
|
| 95 |
// });
|
| 96 |
+
};
|
|
|
|
| 97 |
</script>
|
| 98 |
<style>
|
| 99 |
@keyframes spin {
|
|
|
|
| 101 |
transform: rotate(360deg);
|
| 102 |
}
|
| 103 |
}
|
|
|
|
| 104 |
.animate-spin {
|
| 105 |
animation: spin 1s linear infinite;
|
| 106 |
}
|
|
|
|
| 107 |
</style>
|
| 108 |
</head>
|
| 109 |
<body class="bg-gray-100 min-h-screen">
|
|
|
|
| 130 |
</div>
|
| 131 |
</div>
|
| 132 |
</body>
|
| 133 |
+
</html>
|