eduardmtz commited on
Commit
27a16d2
verified
1 Parent(s): ea910d6

Update test5.html

Browse files
Files changed (1) hide show
  1. 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
- // Hacemos la petici贸n a la API de Hugging Face
114
- //console.log (window.huggingface.variables);
115
-
116
- //const cucu = "YOUR_HUGGING_FACE_API_KEY";
117
- const cucu = window.huggingface.variables["API_KEY_1"];
118
- console.log("key es la : " + cucu)
119
- const response = await fetch(modelUrl, {
120
- method: 'POST',
121
- headers: {
122
- 'Authorization': 'Bearer ' + cucu , // Sustituye por tu API key de Hugging Face
123
- 'Content-Type': 'application/json'
124
- },
125
- body: JSON.stringify(data)
126
- });
127
-
128
- const result = await response.json();
129
- const answer = result?.answer || 'No pude encontrar una respuesta.';
130
- document.getElementById('response').innerHTML = answer;
 
 
 
 
 
 
 
 
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
+