Spaces:
Running
Running
Update test5.html
Browse files- test5.html +27 -19
test5.html
CHANGED
|
@@ -5,7 +5,6 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Preguntas sobre Documentos</title>
|
| 7 |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
|
| 8 |
-
<!-- Incluir pdf.js -->
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.10.377/pdf.min.js"></script>
|
| 10 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.2/mammoth.browser.min.js"></script>
|
| 11 |
</head>
|
|
@@ -110,26 +109,35 @@
|
|
| 110 |
}
|
| 111 |
};
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
</script>
|
| 133 |
</body>
|
| 134 |
</html>
|
| 135 |
|
|
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Preguntas sobre Documentos</title>
|
| 7 |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
|
|
|
|
| 8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.10.377/pdf.min.js"></script>
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.2/mammoth.browser.min.js"></script>
|
| 10 |
</head>
|
|
|
|
| 109 |
}
|
| 110 |
};
|
| 111 |
|
| 112 |
+
console.log("Enviando datos: ", data); // Verificaci贸n de los datos enviados
|
| 113 |
+
const cucu = window.hugginface.variable["API_KEY_1"];
|
| 114 |
+
console.log("key : " + cucu);
|
| 115 |
+
try {
|
| 116 |
+
// Hacemos la petici贸n a la API de Hugging Face
|
| 117 |
+
const response = await fetch(modelUrl, {
|
| 118 |
+
method: 'POST',
|
| 119 |
+
headers: {
|
| 120 |
+
'Authorization': 'Bearer ' + cucu, // Sustituye por tu API key de Hugging Face
|
| 121 |
+
'Content-Type': 'application/json'
|
| 122 |
+
},
|
| 123 |
+
body: JSON.stringify(data)
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
if (!response.ok) {
|
| 127 |
+
throw new Error(`Error: ${response.statusText} - ${await response.text()}`);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
const result = await response.json();
|
| 131 |
+
const answer = result?.answer || 'No pude encontrar una respuesta.';
|
| 132 |
+
document.getElementById('response').innerHTML = answer;
|
| 133 |
+
|
| 134 |
+
} catch (error) {
|
| 135 |
+
console.error('Error al hacer la consulta:', error);
|
| 136 |
+
alert('Hubo un error al procesar la solicitud: ' + error.message);
|
| 137 |
+
}
|
| 138 |
}
|
| 139 |
</script>
|
| 140 |
</body>
|
| 141 |
</html>
|
| 142 |
|
| 143 |
+
|