Salt40404 commited on
Commit
a93861b
·
verified ·
1 Parent(s): a57d75e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -62
app.py CHANGED
@@ -27,11 +27,38 @@ Keep a simple, approachable, and friendly tone otherwise."""
27
  fade_js = """
28
  <script>
29
  document.addEventListener("DOMContentLoaded", () => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  // Observer for chat messages
31
  const observer = new MutationObserver(mutations => {
32
  mutations.forEach(m => {
33
  m.addedNodes.forEach(node => {
34
  if (node.classList && node.classList.contains('chat-message')) {
 
 
 
 
 
 
 
 
 
 
35
  // Enhanced message animation
36
  node.style.opacity = 0;
37
  node.style.transform = 'translateY(20px) scale(0.95)';
@@ -57,23 +84,6 @@ document.addEventListener("DOMContentLoaded", () => {
57
  // Enhanced typing animation for textarea
58
  const txt = document.querySelector("textarea");
59
  if (txt) {
60
- // Add smooth text appearance
61
- txt.addEventListener("input", function() {
62
- // Store current cursor position
63
- const cursorPosition = this.selectionStart;
64
-
65
- // Add smooth text effect
66
- this.style.transition = "all 0.2s ease";
67
- this.style.backgroundColor = "#222";
68
-
69
- setTimeout(() => {
70
- this.style.backgroundColor = "#1a1a1a";
71
-
72
- // Restore cursor position
73
- this.setSelectionRange(cursorPosition, cursorPosition);
74
- }, 200);
75
- });
76
-
77
  txt.addEventListener("focus", () => {
78
  txt.style.transition = "all 0.3s ease";
79
  txt.style.transform = "translateY(-2px)";
@@ -190,36 +200,6 @@ document.addEventListener("DOMContentLoaded", () => {
190
  }, 50);
191
  }, 3000);
192
  }
193
-
194
- // Add smooth text appearance effect
195
- const addSmoothTextEffect = () => {
196
- const textareas = document.querySelectorAll("textarea");
197
- textareas.forEach(textarea => {
198
- if (textarea.hasAttribute("data-smooth-added")) return;
199
-
200
- textarea.setAttribute("data-smooth-added", "true");
201
-
202
- textarea.addEventListener("input", function() {
203
- // Add smooth transition for text color
204
- this.style.transition = "color 0.2s ease";
205
-
206
- // Briefly change color for smooth appearance
207
- const originalColor = this.style.color;
208
- this.style.color = "#aaa";
209
-
210
- setTimeout(() => {
211
- this.style.color = originalColor || "#fff";
212
- }, 50);
213
- });
214
- });
215
- };
216
-
217
- // Add smooth text effect
218
- addSmoothTextEffect();
219
-
220
- // Observe for new textareas
221
- const textareaObserver = new MutationObserver(addSmoothTextEffect);
222
- textareaObserver.observe(document.body, { childList: true, subtree: true });
223
  });
224
  </script>
225
  """
@@ -264,6 +244,47 @@ body {
264
  border-bottom-left-radius: 5px;
265
  margin-right: 40px;
266
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  textarea {
268
  border: none;
269
  outline: none;
@@ -278,7 +299,7 @@ textarea {
278
  min-height: 56px; /* Prevent resizing */
279
  box-sizing: border-box;
280
  resize: none;
281
- transition: all 0.3s ease, color 0.2s ease;
282
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
283
  width: 100%;
284
  }
@@ -327,6 +348,7 @@ textarea {
327
  background: #1a1a1a;
328
  padding: 15px;
329
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
 
330
  }
331
  .gr-box {
332
  border-radius: 15px;
@@ -361,20 +383,6 @@ textarea {
361
  .bounce {
362
  animation: bounce 0.8s;
363
  }
364
- /* Smooth text animation */
365
- @keyframes textAppear {
366
- from {
367
- opacity: 0.5;
368
- transform: translateY(2px);
369
- }
370
- to {
371
- opacity: 1;
372
- transform: translateY(0);
373
- }
374
- }
375
- .smooth-text {
376
- animation: textAppear 0.2s ease;
377
- }
378
  /* Scrollbar styling */
379
  ::-webkit-scrollbar {
380
  width: 8px;
 
27
  fade_js = """
28
  <script>
29
  document.addEventListener("DOMContentLoaded", () => {
30
+ // Add startup message
31
+ setTimeout(() => {
32
+ const chatContainer = document.querySelector(".chat-interface");
33
+ if (chatContainer && chatContainer.children.length === 0) {
34
+ const startupMsg = document.createElement("div");
35
+ startupMsg.className = "startup-message";
36
+ startupMsg.innerHTML = '<div class="startup-content"><div class="startup-icon">🤖</div><div class="startup-text"><div class="startup-title">BitAI</div><div class="startup-subtitle">How was your day? Good morning!</div><div class="startup-note">Entirely made by AI</div></div></div>';
37
+ chatContainer.appendChild(startupMsg);
38
+
39
+ // Animate in
40
+ setTimeout(() => {
41
+ startupMsg.style.opacity = "1";
42
+ startupMsg.style.transform = "translateY(0)";
43
+ }, 100);
44
+ }
45
+ }, 500);
46
+
47
  // Observer for chat messages
48
  const observer = new MutationObserver(mutations => {
49
  mutations.forEach(m => {
50
  m.addedNodes.forEach(node => {
51
  if (node.classList && node.classList.contains('chat-message')) {
52
+ // Remove startup message when first real message appears
53
+ const startupMsg = document.querySelector(".startup-message");
54
+ if (startupMsg) {
55
+ startupMsg.style.opacity = "0";
56
+ startupMsg.style.transform = "translateY(20px)";
57
+ setTimeout(() => {
58
+ startupMsg.remove();
59
+ }, 300);
60
+ }
61
+
62
  // Enhanced message animation
63
  node.style.opacity = 0;
64
  node.style.transform = 'translateY(20px) scale(0.95)';
 
84
  // Enhanced typing animation for textarea
85
  const txt = document.querySelector("textarea");
86
  if (txt) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  txt.addEventListener("focus", () => {
88
  txt.style.transition = "all 0.3s ease";
89
  txt.style.transform = "translateY(-2px)";
 
200
  }, 50);
201
  }, 3000);
202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  });
204
  </script>
205
  """
 
244
  border-bottom-left-radius: 5px;
245
  margin-right: 40px;
246
  }
247
+ /* Startup message */
248
+ .startup-message {
249
+ opacity: 0;
250
+ transform: translateY(20px);
251
+ transition: opacity 0.5s ease, transform 0.5s ease;
252
+ margin: 20px 0;
253
+ display: flex;
254
+ justify-content: center;
255
+ }
256
+ .startup-content {
257
+ display: flex;
258
+ align-items: center;
259
+ background: linear-gradient(145deg, #2e2e2e, #252525);
260
+ padding: 20px;
261
+ border-radius: 20px;
262
+ box-shadow: 0 4px 15px rgba(0,0,0,0.2);
263
+ max-width: 80%;
264
+ }
265
+ .startup-icon {
266
+ font-size: 32px;
267
+ margin-right: 15px;
268
+ }
269
+ .startup-text {
270
+ text-align: left;
271
+ }
272
+ .startup-title {
273
+ font-weight: bold;
274
+ font-size: 18px;
275
+ margin-bottom: 5px;
276
+ color: #fff;
277
+ }
278
+ .startup-subtitle {
279
+ font-size: 16px;
280
+ margin-bottom: 3px;
281
+ color: #eee;
282
+ }
283
+ .startup-note {
284
+ font-size: 12px;
285
+ color: #aaa;
286
+ font-style: italic;
287
+ }
288
  textarea {
289
  border: none;
290
  outline: none;
 
299
  min-height: 56px; /* Prevent resizing */
300
  box-sizing: border-box;
301
  resize: none;
302
+ transition: all 0.3s ease;
303
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
304
  width: 100%;
305
  }
 
348
  background: #1a1a1a;
349
  padding: 15px;
350
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
351
+ min-height: 400px;
352
  }
353
  .gr-box {
354
  border-radius: 15px;
 
383
  .bounce {
384
  animation: bounce 0.8s;
385
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  /* Scrollbar styling */
387
  ::-webkit-scrollbar {
388
  width: 8px;