RECORD MY SPECH - Initial Deployment
Browse files- README.md +7 -5
- index.html +385 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: k
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,385 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ChatGPT Clone</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| 10 |
+
<style>
|
| 11 |
+
body {
|
| 12 |
+
font-family: 'Montserrat', sans-serif;
|
| 13 |
+
}
|
| 14 |
+
/* Custom scrollbar */
|
| 15 |
+
::-webkit-scrollbar {
|
| 16 |
+
width: 6px;
|
| 17 |
+
}
|
| 18 |
+
::-webkit-scrollbar-track {
|
| 19 |
+
background: #f1f1f1;
|
| 20 |
+
}
|
| 21 |
+
::-webkit-scrollbar-thumb {
|
| 22 |
+
background: #888;
|
| 23 |
+
border-radius: 3px;
|
| 24 |
+
}
|
| 25 |
+
::-webkit-scrollbar-thumb:hover {
|
| 26 |
+
background: #555;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/* Typing indicator animation */
|
| 30 |
+
@keyframes typing {
|
| 31 |
+
0% { opacity: 0.5; }
|
| 32 |
+
50% { opacity: 1; }
|
| 33 |
+
100% { opacity: 0.5; }
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.typing-indicator span {
|
| 37 |
+
animation: typing 1.5s infinite;
|
| 38 |
+
}
|
| 39 |
+
.typing-indicator span:nth-child(2) {
|
| 40 |
+
animation-delay: 0.2s;
|
| 41 |
+
}
|
| 42 |
+
.typing-indicator span:nth-child(3) {
|
| 43 |
+
animation-delay: 0.4s;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* Message fade-in animation */
|
| 47 |
+
@keyframes fadeIn {
|
| 48 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 49 |
+
to { opacity: 1; transform: translateY(0); }
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.message {
|
| 53 |
+
animation: fadeIn 0.3s ease-out;
|
| 54 |
+
}
|
| 55 |
+
</style>
|
| 56 |
+
</head>
|
| 57 |
+
<body class="bg-gray-50 h-screen flex flex-col">
|
| 58 |
+
<!-- Header -->
|
| 59 |
+
<header class="bg-white border-b border-gray-200 py-3 px-4 flex items-center justify-between">
|
| 60 |
+
<div class="flex items-center">
|
| 61 |
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center text-white font-bold mr-2">AI</div>
|
| 62 |
+
<h1 class="text-lg font-semibold">ChatGPT</h1>
|
| 63 |
+
</div>
|
| 64 |
+
<div class="flex space-x-3">
|
| 65 |
+
<button class="text-gray-500 hover:text-gray-700">
|
| 66 |
+
<i class="fas fa-sun"></i>
|
| 67 |
+
</button>
|
| 68 |
+
<button class="text-gray-500 hover:text-gray-700">
|
| 69 |
+
<i class="fas fa-cog"></i>
|
| 70 |
+
</button>
|
| 71 |
+
</div>
|
| 72 |
+
</header>
|
| 73 |
+
|
| 74 |
+
<!-- Chat container -->
|
| 75 |
+
<div class="flex-1 overflow-y-auto p-4 space-y-6" id="chat-container">
|
| 76 |
+
<!-- Welcome message -->
|
| 77 |
+
<div class="message max-w-3xl mx-auto bg-white rounded-lg p-4 shadow-sm">
|
| 78 |
+
<div class="flex items-start space-x-3">
|
| 79 |
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center text-white font-bold flex-shrink-0">AI</div>
|
| 80 |
+
<div>
|
| 81 |
+
<h3 class="font-semibold">ChatGPT</h3>
|
| 82 |
+
<p class="text-gray-700 mt-1">Hello! I'm ChatGPT, an AI assistant. How can I help you today?</p>
|
| 83 |
+
<div class="mt-3 grid grid-cols-1 md:grid-cols-2 gap-2">
|
| 84 |
+
<button class="suggestion-btn bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-3 rounded-md text-sm text-left transition">
|
| 85 |
+
"Explain quantum computing in simple terms"
|
| 86 |
+
</button>
|
| 87 |
+
<button class="suggestion-btn bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-3 rounded-md text-sm text-left transition">
|
| 88 |
+
"Give me creative ideas for a 10-year-old's birthday"
|
| 89 |
+
</button>
|
| 90 |
+
<button class="suggestion-btn bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-3 rounded-md text-sm text-left transition">
|
| 91 |
+
"How do I make an HTTP request in JavaScript?"
|
| 92 |
+
</button>
|
| 93 |
+
<button class="suggestion-btn bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-3 rounded-md text-sm text-left transition">
|
| 94 |
+
"Write a poem about artificial intelligence"
|
| 95 |
+
</button>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
|
| 102 |
+
<!-- Recording overlay -->
|
| 103 |
+
<div id="recording-overlay" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
|
| 104 |
+
<div class="bg-white rounded-lg p-6 max-w-sm w-full text-center">
|
| 105 |
+
<div class="flex justify-center mb-4">
|
| 106 |
+
<div class="w-16 h-16 rounded-full bg-red-500 flex items-center justify-center animate-pulse">
|
| 107 |
+
<i class="fas fa-microphone text-white text-2xl"></i>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
<h3 class="text-lg font-semibold mb-2">Recording...</h3>
|
| 111 |
+
<p class="text-gray-600 mb-4">Speak now. Click stop when finished.</p>
|
| 112 |
+
<button id="stop-recording" class="bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-md">
|
| 113 |
+
Stop Recording
|
| 114 |
+
</button>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<!-- Mic button area -->
|
| 119 |
+
<div class="bg-white border-t border-gray-200 p-6 flex flex-col items-center">
|
| 120 |
+
<button id="mic-button" class="w-16 h-16 rounded-full bg-green-500 hover:bg-green-600 text-white flex items-center justify-center transition-all transform hover:scale-105">
|
| 121 |
+
<i class="fas fa-microphone text-2xl"></i>
|
| 122 |
+
</button>
|
| 123 |
+
<p id="recording-status" class="text-sm text-gray-500 mt-2 hidden">Listening...</p>
|
| 124 |
+
</div>
|
| 125 |
+
|
| 126 |
+
<script>
|
| 127 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 128 |
+
const chatForm = document.getElementById('chat-form');
|
| 129 |
+
const messageInput = document.getElementById('message-input');
|
| 130 |
+
const chatContainer = document.getElementById('chat-container');
|
| 131 |
+
const sendButton = document.getElementById('send-button');
|
| 132 |
+
const micButton = document.getElementById('mic-button');
|
| 133 |
+
const recordingOverlay = document.getElementById('recording-overlay');
|
| 134 |
+
const stopRecordingBtn = document.getElementById('stop-recording');
|
| 135 |
+
|
| 136 |
+
let isRecording = false;
|
| 137 |
+
|
| 138 |
+
// Speech recognition setup
|
| 139 |
+
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 140 |
+
const recognition = new SpeechRecognition();
|
| 141 |
+
recognition.continuous = false;
|
| 142 |
+
recognition.interimResults = false;
|
| 143 |
+
recognition.lang = 'en-US';
|
| 144 |
+
|
| 145 |
+
// Handle mic button click
|
| 146 |
+
micButton.addEventListener('click', toggleSpeechRecognition);
|
| 147 |
+
|
| 148 |
+
function toggleSpeechRecognition() {
|
| 149 |
+
if (isRecording) {
|
| 150 |
+
stopSpeechRecognition();
|
| 151 |
+
} else {
|
| 152 |
+
startSpeechRecognition();
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function startSpeechRecognition() {
|
| 157 |
+
try {
|
| 158 |
+
recognition.start();
|
| 159 |
+
isRecording = true;
|
| 160 |
+
document.getElementById('recording-status').classList.remove('hidden');
|
| 161 |
+
recordingOverlay.classList.remove('hidden');
|
| 162 |
+
micButton.classList.add('animate-pulse', 'bg-red-500', 'hover:bg-red-600');
|
| 163 |
+
micButton.classList.remove('bg-green-500', 'hover:bg-green-600');
|
| 164 |
+
|
| 165 |
+
// Show visual feedback
|
| 166 |
+
micButton.innerHTML = '<i class="fas fa-stop text-2xl"></i>';
|
| 167 |
+
} catch (err) {
|
| 168 |
+
console.error('Speech recognition error:', err);
|
| 169 |
+
addMessageToChat('ai', "Couldn't access microphone. Please check permissions and try again.");
|
| 170 |
+
resetMicButton();
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
function stopSpeechRecognition() {
|
| 175 |
+
try {
|
| 176 |
+
recognition.stop();
|
| 177 |
+
} catch (e) {
|
| 178 |
+
console.log('Recognition already stopped');
|
| 179 |
+
}
|
| 180 |
+
resetMicButton();
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
function resetMicButton() {
|
| 184 |
+
isRecording = false;
|
| 185 |
+
document.getElementById('recording-status').classList.add('hidden');
|
| 186 |
+
recordingOverlay.classList.add('hidden');
|
| 187 |
+
micButton.classList.remove('animate-pulse', 'bg-red-500', 'hover:bg-red-600');
|
| 188 |
+
micButton.classList.add('bg-green-500', 'hover:bg-green-600');
|
| 189 |
+
micButton.innerHTML = '<i class="fas fa-microphone text-2xl"></i>';
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
recognition.onresult = async (event) => {
|
| 193 |
+
const transcript = event.results[0][0].transcript;
|
| 194 |
+
stopSpeechRecognition();
|
| 195 |
+
|
| 196 |
+
// Show processing indicator
|
| 197 |
+
showTypingIndicator();
|
| 198 |
+
|
| 199 |
+
// Add user message to chat
|
| 200 |
+
addMessageToChat('user', transcript);
|
| 201 |
+
|
| 202 |
+
// Generate and play response using the API
|
| 203 |
+
await generateAndPlayResponse(transcript);
|
| 204 |
+
};
|
| 205 |
+
|
| 206 |
+
recognition.onerror = (event) => {
|
| 207 |
+
console.error('Speech recognition error:', event.error);
|
| 208 |
+
let errorMessage = "Sorry, I couldn't understand your speech. Please try again.";
|
| 209 |
+
|
| 210 |
+
switch(event.error) {
|
| 211 |
+
case 'no-speech':
|
| 212 |
+
errorMessage = "No speech detected. Please try speaking louder or closer to the microphone.";
|
| 213 |
+
break;
|
| 214 |
+
case 'audio-capture':
|
| 215 |
+
errorMessage = "Couldn't access microphone. Please check your microphone settings.";
|
| 216 |
+
break;
|
| 217 |
+
case 'not-allowed':
|
| 218 |
+
errorMessage = "Microphone access was denied. Please enable microphone permissions.";
|
| 219 |
+
break;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
resetMicButton();
|
| 223 |
+
addMessageToChat('ai', errorMessage);
|
| 224 |
+
};
|
| 225 |
+
|
| 226 |
+
recognition.onend = () => {
|
| 227 |
+
if (isRecording) {
|
| 228 |
+
stopSpeechRecognition();
|
| 229 |
+
}
|
| 230 |
+
};
|
| 231 |
+
|
| 232 |
+
stopRecordingBtn.addEventListener('click', function() {
|
| 233 |
+
if (mediaRecorder && isRecording) {
|
| 234 |
+
mediaRecorder.stop();
|
| 235 |
+
isRecording = false;
|
| 236 |
+
}
|
| 237 |
+
});
|
| 238 |
+
|
| 239 |
+
// Handle suggestion buttons
|
| 240 |
+
document.querySelectorAll('.suggestion-btn').forEach(button => {
|
| 241 |
+
button.addEventListener('click', function() {
|
| 242 |
+
messageInput.value = this.textContent.trim();
|
| 243 |
+
messageInput.focus();
|
| 244 |
+
messageInput.dispatchEvent(new Event('input'));
|
| 245 |
+
});
|
| 246 |
+
});
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
async function generateAndPlayResponse(message) {
|
| 250 |
+
try {
|
| 251 |
+
// Generate response
|
| 252 |
+
const response = generateResponse(message);
|
| 253 |
+
|
| 254 |
+
// Remove typing indicator
|
| 255 |
+
removeTypingIndicator();
|
| 256 |
+
|
| 257 |
+
// Add AI response to chat
|
| 258 |
+
addMessageToChat('ai', response);
|
| 259 |
+
|
| 260 |
+
// Call the text-to-speech API
|
| 261 |
+
const response = await fetch('https://nihalgazi-text-to-speech-unlimited.hf.space/gradio_api/call/text_to_speech_app', {
|
| 262 |
+
method: 'POST',
|
| 263 |
+
headers: {
|
| 264 |
+
'Content-Type': 'application/json'
|
| 265 |
+
},
|
| 266 |
+
body: JSON.stringify({
|
| 267 |
+
data: [
|
| 268 |
+
response, // Text to speak
|
| 269 |
+
"alloy", // Voice model
|
| 270 |
+
"", // Empty string (not sure what this is for)
|
| 271 |
+
true, // Streaming
|
| 272 |
+
3 // Quality level
|
| 273 |
+
]
|
| 274 |
+
})
|
| 275 |
+
});
|
| 276 |
+
|
| 277 |
+
const data = await response.json();
|
| 278 |
+
const eventId = data.data[0];
|
| 279 |
+
|
| 280 |
+
// Stream the audio response
|
| 281 |
+
const audioStream = await fetch(`https://nihalgazi-text-to-speech-unlimited.hf.space/gradio_api/call/text_to_speech_app/${eventId}`);
|
| 282 |
+
const audioBlob = await audioStream.blob();
|
| 283 |
+
const audioUrl = URL.createObjectURL(audioBlob);
|
| 284 |
+
const audio = new Audio(audioUrl);
|
| 285 |
+
audio.play();
|
| 286 |
+
|
| 287 |
+
// Scroll to bottom
|
| 288 |
+
scrollToBottom();
|
| 289 |
+
} catch (error) {
|
| 290 |
+
console.error('Error generating response:', error);
|
| 291 |
+
removeTypingIndicator();
|
| 292 |
+
addMessageToChat('ai', "Sorry, I encountered an error processing your request.");
|
| 293 |
+
scrollToBottom();
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
function addMessageToChat(sender, message) {
|
| 298 |
+
const messageDiv = document.createElement('div');
|
| 299 |
+
messageDiv.className = 'message max-w-3xl mx-auto bg-white rounded-lg p-4 shadow-sm';
|
| 300 |
+
|
| 301 |
+
if (sender === 'user') {
|
| 302 |
+
messageDiv.innerHTML = `
|
| 303 |
+
<div class="flex items-start space-x-3 justify-end">
|
| 304 |
+
<div class="text-right">
|
| 305 |
+
<p class="text-gray-700">${message}</p>
|
| 306 |
+
</div>
|
| 307 |
+
<div class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white font-bold flex-shrink-0">Y</div>
|
| 308 |
+
</div>
|
| 309 |
+
`;
|
| 310 |
+
} else {
|
| 311 |
+
messageDiv.innerHTML = `
|
| 312 |
+
<div class="flex items-start space-x-3">
|
| 313 |
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center text-white font-bold flex-shrink-0">AI</div>
|
| 314 |
+
<div>
|
| 315 |
+
<h3 class="font-semibold">ChatGPT</h3>
|
| 316 |
+
<p class="text-gray-700 mt-1">${message}</p>
|
| 317 |
+
</div>
|
| 318 |
+
</div>
|
| 319 |
+
`;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
chatContainer.appendChild(messageDiv);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
function showTypingIndicator() {
|
| 326 |
+
const typingDiv = document.createElement('div');
|
| 327 |
+
typingDiv.className = 'message max-w-3xl mx-auto';
|
| 328 |
+
typingDiv.id = 'typing-indicator';
|
| 329 |
+
typingDiv.innerHTML = `
|
| 330 |
+
<div class="flex items-start space-x-3">
|
| 331 |
+
<div class="w-8 h-8 rounded-full bg-green-500 flex items-center justify-center text-white font-bold flex-shrink-0">AI</div>
|
| 332 |
+
<div class="typing-indicator bg-white rounded-lg p-4 shadow-sm">
|
| 333 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full mx-0.5"></span>
|
| 334 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full mx-0.5"></span>
|
| 335 |
+
<span class="inline-block w-2 h-2 bg-gray-400 rounded-full mx-0.5"></span>
|
| 336 |
+
</div>
|
| 337 |
+
</div>
|
| 338 |
+
`;
|
| 339 |
+
|
| 340 |
+
chatContainer.appendChild(typingDiv);
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
function removeTypingIndicator() {
|
| 344 |
+
const typingIndicator = document.getElementById('typing-indicator');
|
| 345 |
+
if (typingIndicator) {
|
| 346 |
+
typingIndicator.remove();
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
function scrollToBottom() {
|
| 351 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
function generateResponse(message) {
|
| 355 |
+
// Simple response generation - in a real app, this would call an API
|
| 356 |
+
const responses = [
|
| 357 |
+
"I understand you're asking about: " + message + ". Here's what I can tell you about that topic...",
|
| 358 |
+
"That's an interesting question! " + message + " is something that can be explored from multiple perspectives...",
|
| 359 |
+
"Regarding " + message + ", I'd be happy to help. The key points to consider are...",
|
| 360 |
+
"I've analyzed your query about " + message + " and here's my response...",
|
| 361 |
+
message + " is a fascinating subject. Let me break it down for you..."
|
| 362 |
+
];
|
| 363 |
+
|
| 364 |
+
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
|
| 365 |
+
|
| 366 |
+
// Sometimes add a follow-up question
|
| 367 |
+
if (Math.random() > 0.5) {
|
| 368 |
+
const followUps = [
|
| 369 |
+
" Would you like me to go into more detail about any specific aspect?",
|
| 370 |
+
" Did that answer your question or would you like more information?",
|
| 371 |
+
" I can provide examples if that would be helpful. Would you like some?",
|
| 372 |
+
" Is there anything else related to this you'd like to know?"
|
| 373 |
+
];
|
| 374 |
+
return randomResponse + followUps[Math.floor(Math.random() * followUps.length)];
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
return randomResponse;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
// Focus input on page load
|
| 381 |
+
messageInput.focus();
|
| 382 |
+
});
|
| 383 |
+
</script>
|
| 384 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Kamocodes/k" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 385 |
+
</html>
|