forked from hansonrobotics/ChatScript-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIa.css
More file actions
142 lines (126 loc) · 4.48 KB
/
Ia.css
File metadata and controls
142 lines (126 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IA de Lealtad y Amistad</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
color: #333;
padding: 20px;
}
.chat-container {
max-width: 600px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.chat-box {
max-height: 400px;
overflow-y: auto;
margin-bottom: 20px;
}
.message {
padding: 10px;
border-radius: 10px;
margin-bottom: 10px;
}
.user-message {
background-color: #e0f7fa;
text-align: right;
}
.bot-message {
background-color: #f1f8e9;
text-align: left;
}
#inputMessage {
width: 100%;
padding: 10px;
border-radius: 10px;
border: 1px solid #ccc;
margin-top: 10px;
}
.send-btn {
background-color: #00796b;
color: #fff;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
margin-top: 10px;
}
.send-btn:hover {
background-color: #004d40;
}
.header {
text-align: center;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="header">
<h2>IA de Lealtad y Amistad</h2>
<p>Hola, soy tu IA amigable. ¡Estoy aquí para ayudarte! 😊</p>
</div>
<div class="chat-box" id="chatBox">
<!-- Mensajes aparecerán aquí -->
</div>
<input type="text" id="inputMessage" placeholder="Escribe tu mensaje aquí..." />
<button class="send-btn" onclick="enviarMensaje()">Enviar</button>
</div>
<script>
// Saludo inicial de la IA
const botInitialMessage = "¡Hola! ¿Cómo te llamas? Estoy aquí para ayudarte con todo lo que necesites.";
// Función para agregar mensaje al chat
function agregarMensaje(message, sender) {
const chatBox = document.getElementById("chatBox");
const messageDiv = document.createElement("div");
messageDiv.classList.add("message", sender);
const textNode = document.createTextNode(message);
messageDiv.appendChild(textNode);
chatBox.appendChild(messageDiv);
chatBox.scrollTop = chatBox.scrollHeight; // Desplaza hacia abajo para ver el último mensaje
}
// Función para manejar el mensaje del usuario
function enviarMensaje() {
const inputMessage = document.getElementById("inputMessage").value;
if (inputMessage.trim() === "") return;
// Muestra el mensaje del usuario
agregarMensaje(inputMessage, "user-message");
// Limpia el campo de texto
document.getElementById("inputMessage").value = "";
// Respuesta de la IA
setTimeout(function() {
responderIA(inputMessage);
}, 1000);
}
// Función para responder la IA
function responderIA(userMessage) {
let response = "";
// Aquí puedes personalizar la lógica de la IA para responder
if (userMessage.toLowerCase().includes("hola")) {
response = "¡Hola! ¿Cómo te encuentras hoy? 😊";
} else if (userMessage.toLowerCase().includes("cómo estás")) {
response = "Estoy bien, gracias por preguntar. ¡Aquí para ayudarte siempre!";
} else if (userMessage.toLowerCase().includes("adiós")) {
response = "¡Hasta luego! ¡Siempre estaré aquí para ti!";
} else {
response = "¡Vaya! No entendí eso, pero siempre estoy dispuesto a aprender. ¿Cómo puedo ayudarte?";
}
// Muestra la respuesta de la IA
agregarMensaje(response, "bot-message");
}
// Saludo inicial cuando la página carga
window.onload = function() {
agregarMensaje(botInitialMessage, "bot-message");
};
</script>
</body>
</html>