Create adem.html
Browse files
adem.html
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>AdamGPT - Mini ChatGPT con Hugging Face</title>
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<h1>AdamGPT - Mini ChatGPT con Hugging Face</h1>
|
8 |
+
<div id="chat-box" style="height: 300px; overflow-y: scroll; border: 1px solid #ccc; padding: 10px; margin-bottom: 10px;"></div>
|
9 |
+
<input type="text" id="user-input" placeholder="Escribe tu mensaje..." style="width: 80%; padding: 5px;">
|
10 |
+
<button onclick="sendMessage()">Enviar</button>
|
11 |
+
|
12 |
+
<script>
|
13 |
+
async function sendMessage() {
|
14 |
+
const userInput = document.getElementById('user-input').value;
|
15 |
+
if (userInput.trim() === '') return;
|
16 |
+
|
17 |
+
appendMessage('Tú: ' + userInput);
|
18 |
+
|
19 |
+
const response = await getChatbotResponse(userInput);
|
20 |
+
appendMessage('AdamGPT: ' + response); // Aquí se cambia 'AdemGPT' por 'AdamGPT'
|
21 |
+
|
22 |
+
document.getElementById('user-input').value = '';
|
23 |
+
}
|
24 |
+
|
25 |
+
async function getChatbotResponse(userInput) {
|
26 |
+
const apiUrl = 'https://api-inference.huggingface.co/models/microsoft/DialoGPT-large'; // Reemplazar con el modelo que elijas
|
27 |
+
const response = await fetch(apiUrl, {
|
28 |
+
method: 'POST',
|
29 |
+
headers: {
|
30 |
+
'Authorization': 'Bearer API_KEY', // Reemplazar 'API_KEY' con tu clave de API de Hugging Face
|
31 |
+
'Content-Type': 'application/json'
|
32 |
+
},
|
33 |
+
body: JSON.stringify({ "inputs": userInput })
|
34 |
+
});
|
35 |
+
const data = await response.json();
|
36 |
+
return data.generated_text || "Lo siento, no entiendo.";
|
37 |
+
}
|
38 |
+
|
39 |
+
function appendMessage(message) {
|
40 |
+
const chatBox = document.getElementById('chat-box');
|
41 |
+
const messageElement = document.createElement('div');
|
42 |
+
messageElement.textContent = message;
|
43 |
+
chatBox.appendChild(messageElement);
|
44 |
+
}
|
45 |
+
</script>
|
46 |
+
</body>
|
47 |
+
</html>
|