Spaces:
Running
Running
it's not working
Browse files- README.md +9 -5
- index.html +324 -18
README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: undefined
|
| 3 |
+
colorFrom: pink
|
| 4 |
+
colorTo: purple
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
| 14 |
+
|
index.html
CHANGED
|
@@ -1,19 +1,325 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 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>Gemini Buddy</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
| 11 |
+
<script>
|
| 12 |
+
tailwind.config = {
|
| 13 |
+
theme: {
|
| 14 |
+
extend: {
|
| 15 |
+
colors: {
|
| 16 |
+
primary: {
|
| 17 |
+
500: '#4285F4',
|
| 18 |
+
600: '#3367D6'
|
| 19 |
+
},
|
| 20 |
+
secondary: {
|
| 21 |
+
500: '#34A853',
|
| 22 |
+
600: '#2D9249'
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
</script>
|
| 29 |
+
<style>
|
| 30 |
+
.chat-message.user {
|
| 31 |
+
background-color: #E8F0FE;
|
| 32 |
+
border-radius: 18px 18px 4px 18px;
|
| 33 |
+
}
|
| 34 |
+
.chat-message.bot {
|
| 35 |
+
background-color: #F1F3F4;
|
| 36 |
+
border-radius: 18px 18px 18px 4px;
|
| 37 |
+
}
|
| 38 |
+
#vanta-bg {
|
| 39 |
+
position: fixed;
|
| 40 |
+
top: 0;
|
| 41 |
+
left: 0;
|
| 42 |
+
width: 100%;
|
| 43 |
+
height: 100%;
|
| 44 |
+
z-index: -1;
|
| 45 |
+
opacity: 0.3;
|
| 46 |
+
}
|
| 47 |
+
.typing-indicator span {
|
| 48 |
+
display: inline-block;
|
| 49 |
+
width: 8px;
|
| 50 |
+
height: 8px;
|
| 51 |
+
background-color: #5F6368;
|
| 52 |
+
border-radius: 50%;
|
| 53 |
+
margin-right: 4px;
|
| 54 |
+
animation: bounce 1.4s infinite ease-in-out both;
|
| 55 |
+
}
|
| 56 |
+
.typing-indicator span:nth-child(1) {
|
| 57 |
+
animation-delay: 0s;
|
| 58 |
+
}
|
| 59 |
+
.typing-indicator span:nth-child(2) {
|
| 60 |
+
animation-delay: 0.2s;
|
| 61 |
+
}
|
| 62 |
+
.typing-indicator span:nth-child(3) {
|
| 63 |
+
animation-delay: 0.4s;
|
| 64 |
+
margin-right: 0;
|
| 65 |
+
}
|
| 66 |
+
@keyframes bounce {
|
| 67 |
+
0%, 80%, 100% { transform: scale(0); }
|
| 68 |
+
40% { transform: scale(1); }
|
| 69 |
+
}
|
| 70 |
+
</style>
|
| 71 |
+
</head>
|
| 72 |
+
<body class="bg-gray-50 min-h-screen flex flex-col">
|
| 73 |
+
<div id="vanta-bg"></div>
|
| 74 |
+
|
| 75 |
+
<header class="bg-white shadow-sm py-4 px-6 sticky top-0 z-10">
|
| 76 |
+
<div class="max-w-4xl mx-auto flex items-center justify-between">
|
| 77 |
+
<div class="flex items-center space-x-2">
|
| 78 |
+
<div class="w-10 h-10 rounded-full bg-gradient-to-r from-primary-500 to-secondary-500 flex items-center justify-center">
|
| 79 |
+
<i data-feather="message-square" class="text-white"></i>
|
| 80 |
+
</div>
|
| 81 |
+
<h1 class="text-xl font-bold text-gray-800">Gemini Buddy</h1>
|
| 82 |
+
</div>
|
| 83 |
+
<button id="clear-chat" class="text-gray-500 hover:text-primary-500 transition-colors">
|
| 84 |
+
<i data-feather="trash-2" class="w-5 h-5"></i>
|
| 85 |
+
</button>
|
| 86 |
+
</div>
|
| 87 |
+
</header>
|
| 88 |
+
|
| 89 |
+
<main class="flex-1 max-w-4xl w-full mx-auto px-4 py-6 overflow-y-auto">
|
| 90 |
+
<div id="chat-container" class="space-y-4">
|
| 91 |
+
<div class="chat-message bot max-w-[85%] p-4">
|
| 92 |
+
<div class="flex items-start space-x-2">
|
| 93 |
+
<div class="w-8 h-8 rounded-full bg-secondary-500 flex items-center justify-center flex-shrink-0">
|
| 94 |
+
<i data-feather="cpu" class="text-white w-4 h-4"></i>
|
| 95 |
+
</div>
|
| 96 |
+
<div class="flex-1">
|
| 97 |
+
<p class="text-gray-800">Hello! I'm Gemini, your AI assistant. How can I help you today?</p>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</main>
|
| 103 |
+
|
| 104 |
+
<footer class="bg-white border-t py-4 px-6 sticky bottom-0">
|
| 105 |
+
<div class="max-w-4xl mx-auto">
|
| 106 |
+
<form id="chat-form" class="flex space-x-2">
|
| 107 |
+
<input
|
| 108 |
+
id="user-input"
|
| 109 |
+
type="text"
|
| 110 |
+
placeholder="Ask me anything..."
|
| 111 |
+
class="flex-1 border border-gray-300 rounded-full px-4 py-2 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
| 112 |
+
autocomplete="off"
|
| 113 |
+
>
|
| 114 |
+
<button
|
| 115 |
+
type="submit"
|
| 116 |
+
class="w-12 h-12 rounded-full bg-primary-500 text-white flex items-center justify-center hover:bg-primary-600 transition-colors"
|
| 117 |
+
>
|
| 118 |
+
<i data-feather="send" class="w-5 h-5"></i>
|
| 119 |
+
</button>
|
| 120 |
+
</form>
|
| 121 |
+
</div>
|
| 122 |
+
</footer>
|
| 123 |
+
|
| 124 |
+
<script>
|
| 125 |
+
const gemini = {
|
| 126 |
+
getNewCookie: async function () {
|
| 127 |
+
const r = await fetch("https://gemini.google.com/_/BardChatUi/data/batchexecute?rpcids=maGuAc&source-path=%2F&bl=boq_assistant-bard-web-server_20250814.06_p1&f.sid=-7816331052118000090&hl=en-US&_reqid=173780&rt=c", {
|
| 128 |
+
"headers": {
|
| 129 |
+
"content-type": "application/x-www-form-urlencoded;charset=UTF-8",
|
| 130 |
+
},
|
| 131 |
+
"body": "f.req=%5B%5B%5B%22maGuAc%22%2C%22%5B0%5D%22%2Cnull%2C%22generic%22%5D%5D%5D&",
|
| 132 |
+
"method": "POST"
|
| 133 |
+
});
|
| 134 |
+
console.log('get new cookie')
|
| 135 |
+
return r.headers.getSetCookie()[0].split("; ")[0]
|
| 136 |
+
},
|
| 137 |
+
ask: async function (prompt, previousId = null) {
|
| 138 |
+
try {
|
| 139 |
+
if (typeof (prompt) !== "string" || !prompt?.trim()?.length) {
|
| 140 |
+
throw new Error(`Prompt cannot be empty`);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
const response = await fetch('/api/chat', {
|
| 144 |
+
method: 'POST',
|
| 145 |
+
headers: {
|
| 146 |
+
'Content-Type': 'application/json',
|
| 147 |
+
},
|
| 148 |
+
body: JSON.stringify({
|
| 149 |
+
prompt: prompt,
|
| 150 |
+
conversationId: previousId
|
| 151 |
+
})
|
| 152 |
+
});
|
| 153 |
+
|
| 154 |
+
if (!response.ok) {
|
| 155 |
+
const errorData = await response.json();
|
| 156 |
+
throw new Error(errorData.message || 'Failed to get response');
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
const data = await response.json();
|
| 160 |
+
return {
|
| 161 |
+
text: data.response,
|
| 162 |
+
id: data.conversationId
|
| 163 |
+
};
|
| 164 |
+
} catch (error) {
|
| 165 |
+
console.error('Error in ask function:', error);
|
| 166 |
+
throw error;
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
// Initialize Vanta.js background
|
| 171 |
+
if (window.VANTA) {
|
| 172 |
+
VANTA.NET({
|
| 173 |
+
el: "#vanta-bg",
|
| 174 |
+
mouseControls: true,
|
| 175 |
+
touchControls: true,
|
| 176 |
+
gyroControls: false,
|
| 177 |
+
minHeight: 200.00,
|
| 178 |
+
minWidth: 200.00,
|
| 179 |
+
scale: 1.00,
|
| 180 |
+
scaleMobile: 1.00,
|
| 181 |
+
color: 0x4285f4,
|
| 182 |
+
backgroundColor: 0xf8fafc,
|
| 183 |
+
points: 10.00,
|
| 184 |
+
maxDistance: 20.00,
|
| 185 |
+
spacing: 15.00
|
| 186 |
+
});
|
| 187 |
+
} else {
|
| 188 |
+
console.warn('VANTA library not loaded');
|
| 189 |
+
document.getElementById('vanta-bg').style.backgroundColor = '#f8fafc';
|
| 190 |
+
}
|
| 191 |
+
// Initialize chat functionality
|
| 192 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 193 |
+
feather.replace();
|
| 194 |
+
|
| 195 |
+
const chatContainer = document.getElementById('chat-container');
|
| 196 |
+
const chatForm = document.getElementById('chat-form');
|
| 197 |
+
const userInput = document.getElementById('user-input');
|
| 198 |
+
const clearChatBtn = document.getElementById('clear-chat');
|
| 199 |
+
|
| 200 |
+
let conversationId = null;
|
| 201 |
+
|
| 202 |
+
// Add user message to chat
|
| 203 |
+
function addUserMessage(message) {
|
| 204 |
+
const messageDiv = document.createElement('div');
|
| 205 |
+
messageDiv.className = 'chat-message user max-w-[85%] ml-auto p-4';
|
| 206 |
+
messageDiv.innerHTML = `
|
| 207 |
+
<div class="flex items-start space-x-2 justify-end">
|
| 208 |
+
<div class="flex-1 text-right">
|
| 209 |
+
<p class="text-gray-800">${message}</p>
|
| 210 |
+
</div>
|
| 211 |
+
<div class="w-8 h-8 rounded-full bg-primary-500 flex items-center justify-center flex-shrink-0">
|
| 212 |
+
<i data-feather="user" class="text-white w-4 h-4"></i>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
`;
|
| 216 |
+
chatContainer.appendChild(messageDiv);
|
| 217 |
+
scrollToBottom();
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
// Add bot message to chat
|
| 221 |
+
function addBotMessage(message, isTyping = false) {
|
| 222 |
+
const messageDiv = document.createElement('div');
|
| 223 |
+
messageDiv.className = 'chat-message bot max-w-[85%] p-4';
|
| 224 |
+
|
| 225 |
+
if (isTyping) {
|
| 226 |
+
messageDiv.innerHTML = `
|
| 227 |
+
<div class="flex items-start space-x-2">
|
| 228 |
+
<div class="w-8 h-8 rounded-full bg-secondary-500 flex items-center justify-center flex-shrink-0">
|
| 229 |
+
<i data-feather="cpu" class="text-white w-4 h-4"></i>
|
| 230 |
+
</div>
|
| 231 |
+
<div class="typing-indicator flex space-x-1 items-center">
|
| 232 |
+
<span></span>
|
| 233 |
+
<span></span>
|
| 234 |
+
<span></span>
|
| 235 |
+
</div>
|
| 236 |
+
</div>
|
| 237 |
+
`;
|
| 238 |
+
} else {
|
| 239 |
+
messageDiv.innerHTML = `
|
| 240 |
+
<div class="flex items-start space-x-2">
|
| 241 |
+
<div class="w-8 h-8 rounded-full bg-secondary-500 flex items-center justify-center flex-shrink-0">
|
| 242 |
+
<i data-feather="cpu" class="text-white w-4 h-4"></i>
|
| 243 |
+
</div>
|
| 244 |
+
<div class="flex-1">
|
| 245 |
+
<p class="text-gray-800">${message}</p>
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
`;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
chatContainer.appendChild(messageDiv);
|
| 252 |
+
scrollToBottom();
|
| 253 |
+
feather.replace();
|
| 254 |
+
return messageDiv;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
// Scroll chat to bottom
|
| 258 |
+
function scrollToBottom() {
|
| 259 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// Handle form submission
|
| 263 |
+
chatForm.addEventListener('submit', async (e) => {
|
| 264 |
+
e.preventDefault();
|
| 265 |
+
|
| 266 |
+
const message = userInput.value.trim();
|
| 267 |
+
if (!message) return;
|
| 268 |
+
|
| 269 |
+
// Add user message
|
| 270 |
+
addUserMessage(message);
|
| 271 |
+
userInput.value = '';
|
| 272 |
+
|
| 273 |
+
// Add typing indicator
|
| 274 |
+
const typingElement = addBotMessage('', true);
|
| 275 |
+
|
| 276 |
+
try {
|
| 277 |
+
try {
|
| 278 |
+
// Get response from Gemini
|
| 279 |
+
const response = await gemini.ask(message, conversationId);
|
| 280 |
+
|
| 281 |
+
// Remove typing indicator
|
| 282 |
+
chatContainer.removeChild(typingElement);
|
| 283 |
+
|
| 284 |
+
// Add bot response with markdown support
|
| 285 |
+
const formattedText = response.text
|
| 286 |
+
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
| 287 |
+
.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
| 288 |
+
.replace(/```([\s\S]+?)```/g, '<pre><code>$1</code></pre>');
|
| 289 |
+
addBotMessage(formattedText);
|
| 290 |
+
|
| 291 |
+
// Update conversation ID for context
|
| 292 |
+
conversationId = response.id;
|
| 293 |
+
} catch (error) {
|
| 294 |
+
// Remove typing indicator
|
| 295 |
+
chatContainer.removeChild(typingElement);
|
| 296 |
+
|
| 297 |
+
// Show user-friendly error message
|
| 298 |
+
addBotMessage("I'm having trouble connecting right now. Please try again later.");
|
| 299 |
+
console.error('Chat error:', error);
|
| 300 |
+
}
|
| 301 |
+
} catch (error) {
|
| 302 |
+
// Remove typing indicator
|
| 303 |
+
chatContainer.removeChild(typingElement);
|
| 304 |
+
|
| 305 |
+
// Show error message
|
| 306 |
+
addBotMessage(`Sorry, I encountered an error: ${error.message}`);
|
| 307 |
+
console.error(error);
|
| 308 |
+
}
|
| 309 |
+
});
|
| 310 |
+
|
| 311 |
+
// Clear chat history
|
| 312 |
+
clearChatBtn.addEventListener('click', () => {
|
| 313 |
+
// Keep only the initial bot message
|
| 314 |
+
while (chatContainer.children.length > 1) {
|
| 315 |
+
chatContainer.removeChild(chatContainer.lastChild);
|
| 316 |
+
}
|
| 317 |
+
conversationId = null;
|
| 318 |
+
});
|
| 319 |
+
|
| 320 |
+
// Focus input on page load
|
| 321 |
+
userInput.focus();
|
| 322 |
+
});
|
| 323 |
+
</script>
|
| 324 |
+
</body>
|
| 325 |
</html>
|