jeanmarcocruz207 commited on
Commit
2560a3d
·
verified ·
1 Parent(s): 74cd672

Upload 29 files

Browse files
Files changed (1) hide show
  1. app.py +29 -20
app.py CHANGED
@@ -246,27 +246,36 @@ def build_ui() -> gr.Blocks:
246
  user_in.submit(main_chat, inputs=chat_inputs, outputs=chat_outputs)
247
 
248
  # --- Helper JS to hide welcome message on first interaction ---
249
- demo.js("""
250
- function() {
251
- const userInput = document.getElementById('prompt-input').querySelector('textarea');
252
- const welcomeCard = document.getElementById('welcome-card');
253
- const chatCanvas = document.getElementById('chat-canvas');
254
-
255
- function handleFirstInteraction() {
256
- if (welcomeCard.style.display !== 'none') {
257
- welcomeCard.style.display = 'none';
258
- chatCanvas.style.display = 'flex';
 
259
  }
260
- }
261
-
262
- userInput.addEventListener('focus', handleFirstInteraction);
263
- userInput.addEventListener('keyup', (e) => {
264
- if (e.target.value.length > 0) {
265
- handleFirstInteraction();
266
  }
267
- });
268
- }
269
- """)
 
 
 
 
 
 
 
 
270
 
271
  # Verify Ollama status on load
272
  demo.load(verify, outputs=[], every=60)
@@ -287,4 +296,4 @@ if __name__ == "__main__":
287
  server_name="0.0.0.0",
288
  server_port=7860,
289
  share=False
290
- )
 
246
  user_in.submit(main_chat, inputs=chat_inputs, outputs=chat_outputs)
247
 
248
  # --- Helper JS to hide welcome message on first interaction ---
249
+ gr.HTML(
250
+ """
251
+ <script>
252
+ (function attachWelcomeListeners() {
253
+ const inputContainer = document.querySelector('#prompt-input textarea');
254
+ const welcomeCard = document.getElementById('welcome-card');
255
+ const chatCanvas = document.getElementById('chat-canvas');
256
+
257
+ if (!inputContainer || !welcomeCard || !chatCanvas) {
258
+ requestAnimationFrame(attachWelcomeListeners);
259
+ return;
260
  }
261
+
262
+ function handleFirstInteraction() {
263
+ if (welcomeCard.style.display !== 'none') {
264
+ welcomeCard.style.display = 'none';
265
+ chatCanvas.style.display = 'flex';
266
+ }
267
  }
268
+
269
+ inputContainer.addEventListener('focus', handleFirstInteraction, { once: true });
270
+ inputContainer.addEventListener('input', (event) => {
271
+ if (event.target.value.length > 0) {
272
+ handleFirstInteraction();
273
+ }
274
+ });
275
+ })();
276
+ </script>
277
+ """
278
+ )
279
 
280
  # Verify Ollama status on load
281
  demo.load(verify, outputs=[], every=60)
 
296
  server_name="0.0.0.0",
297
  server_port=7860,
298
  share=False
299
+ )