Spaces:
Running
Running
Updated
Browse files- index.html +39 -11
index.html
CHANGED
|
@@ -17,12 +17,12 @@
|
|
| 17 |
<h2>Feedback</h2>
|
| 18 |
|
| 19 |
<textarea id="feedback" name="feedback" rows="5" cols="50"
|
| 20 |
-
placeholder="
|
| 21 |
|
| 22 |
<div class="button-group">
|
| 23 |
-
<button type="
|
| 24 |
<button type="button" class="btn save" disabled>Submit</button>
|
| 25 |
-
<button type="
|
| 26 |
</div>
|
| 27 |
</form>
|
| 28 |
</div>
|
|
@@ -218,11 +218,12 @@
|
|
| 218 |
|
| 219 |
<script type="module">
|
| 220 |
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
|
| 221 |
-
async function callGradioAPI(userInput) {
|
| 222 |
// 1. Connect to the app (use your Space name or URL)
|
| 223 |
const app = await Client.connect('https://rr19tech-my-proxy.hf.space');
|
| 224 |
// 2. Call the endpoint with user input passed as an array
|
| 225 |
-
const result = await app.predict("/call_private_api", [userInput]);
|
|
|
|
| 226 |
// 3. Access the returned data
|
| 227 |
console.log("Result:", result.data);
|
| 228 |
return result.data;
|
|
@@ -331,13 +332,17 @@
|
|
| 331 |
}
|
| 332 |
postAdv();//posting it one time
|
| 333 |
const intervalId = setInterval(postAdv, 300000);
|
| 334 |
-
function get_api_results(result, container){
|
| 335 |
-
callGradioAPI(result)
|
| 336 |
.then(data => {
|
| 337 |
if (data) {
|
| 338 |
console.log('Received data:', data);
|
| 339 |
-
|
| 340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
return data;
|
| 342 |
}
|
| 343 |
else{
|
|
@@ -354,7 +359,7 @@
|
|
| 354 |
//get the entered value
|
| 355 |
let command = consoleArea.value;
|
| 356 |
//call_api(command);
|
| 357 |
-
let result = get_api_results(command, consoleArea);
|
| 358 |
//console.log("data is: " + result);
|
| 359 |
consoleArea.value = "";//null the value
|
| 360 |
}
|
|
@@ -364,7 +369,30 @@
|
|
| 364 |
console.log("am i double clicked!!");
|
| 365 |
consoleArea.value = ""; //clearning for next question
|
| 366 |
});
|
| 367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
</script>
|
| 369 |
<div class="disclaimer"><span >Disclaimer: </span><p>All information presented is sourced from the respective business owners and is intended for informational purposes only.</p></div>
|
| 370 |
</body>
|
|
|
|
| 17 |
<h2>Feedback</h2>
|
| 18 |
|
| 19 |
<textarea id="feedback" name="feedback" rows="5" cols="50"
|
| 20 |
+
placeholder="Testing feedback, Example: Hello, I am Tester, increase the font size ..." ></textarea>
|
| 21 |
|
| 22 |
<div class="button-group">
|
| 23 |
+
<button type="button" class="btn send" id="structure">Create Feedback</button>
|
| 24 |
<button type="button" class="btn save" disabled>Submit</button>
|
| 25 |
+
<button type="button" class="btn clear" id="feedbackClr" >Clear</button>
|
| 26 |
</div>
|
| 27 |
</form>
|
| 28 |
</div>
|
|
|
|
| 218 |
|
| 219 |
<script type="module">
|
| 220 |
import { Client } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
|
| 221 |
+
async function callGradioAPI(userInput, api_method) {
|
| 222 |
// 1. Connect to the app (use your Space name or URL)
|
| 223 |
const app = await Client.connect('https://rr19tech-my-proxy.hf.space');
|
| 224 |
// 2. Call the endpoint with user input passed as an array
|
| 225 |
+
//const result = await app.predict("/call_private_api", [userInput]);
|
| 226 |
+
const result = await app.predict(api_method, [userInput]);
|
| 227 |
// 3. Access the returned data
|
| 228 |
console.log("Result:", result.data);
|
| 229 |
return result.data;
|
|
|
|
| 332 |
}
|
| 333 |
postAdv();//posting it one time
|
| 334 |
const intervalId = setInterval(postAdv, 300000);
|
| 335 |
+
function get_api_results(result, container, api_method){
|
| 336 |
+
callGradioAPI(result, api_method)
|
| 337 |
.then(data => {
|
| 338 |
if (data) {
|
| 339 |
console.log('Received data:', data);
|
| 340 |
+
|
| 341 |
+
//if (api_method == "/call_private_api") {
|
| 342 |
+
container.value = data;
|
| 343 |
+
container.textContent = data;
|
| 344 |
+
//}
|
| 345 |
+
|
| 346 |
return data;
|
| 347 |
}
|
| 348 |
else{
|
|
|
|
| 359 |
//get the entered value
|
| 360 |
let command = consoleArea.value;
|
| 361 |
//call_api(command);
|
| 362 |
+
let result = get_api_results(command, consoleArea, "/call_private_api");
|
| 363 |
//console.log("data is: " + result);
|
| 364 |
consoleArea.value = "";//null the value
|
| 365 |
}
|
|
|
|
| 369 |
console.log("am i double clicked!!");
|
| 370 |
consoleArea.value = ""; //clearning for next question
|
| 371 |
});
|
| 372 |
+
|
| 373 |
+
//code for getting structured llm
|
| 374 |
+
const userFeedback = document.getElementById('feedback');
|
| 375 |
+
const structBtn = document.getElementById('structure');
|
| 376 |
+
structBtn.addEventListener('click', () => {
|
| 377 |
+
//caputre the value ented in the text area
|
| 378 |
+
let feedback = userFeedback.value;
|
| 379 |
+
console.log("Get structure button clicekd! " + feedback);
|
| 380 |
+
userFeedback.value = ""; //clear the content
|
| 381 |
+
let result = get_api_results(feedback, userFeedback, "/user_feedback");
|
| 382 |
+
|
| 383 |
+
});
|
| 384 |
+
|
| 385 |
+
//adding a double click event to clear the contents for next question
|
| 386 |
+
userFeedback.addEventListener('dblclick', function(event) {
|
| 387 |
+
console.log("userFeedback double clicked!!");
|
| 388 |
+
userFeedback.value = ""; //clearning for next question
|
| 389 |
+
});
|
| 390 |
+
|
| 391 |
+
const clearFeedback = document.getElementById('feedbackClr');
|
| 392 |
+
clearFeedback.addEventListener('click', function(event) {
|
| 393 |
+
console.log("Clearing feedback!!");
|
| 394 |
+
userFeedback.value = ""; //clearning for next question
|
| 395 |
+
});
|
| 396 |
</script>
|
| 397 |
<div class="disclaimer"><span >Disclaimer: </span><p>All information presented is sourced from the respective business owners and is intended for informational purposes only.</p></div>
|
| 398 |
</body>
|