Aist1 commited on
Commit
8ca6c35
·
verified ·
1 Parent(s): fb1b8b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -38
app.py CHANGED
@@ -112,7 +112,7 @@ class DeepSelfDiscovery:
112
  **Вопрос для исцеления:** {random.choice(healing_questions)}
113
 
114
  **Техника работы:**
115
- 1. **Визуализация:** Представьте себя в детском возрасте
116
  2. **Диалог:** Спросите, что ему/ей нужно
117
  3. **Поддержка:** Дайте то, чего не хватало
118
  4. **Интеграция:** Обнимите и примите эту часть себя
@@ -269,7 +269,7 @@ def create_interface():
269
  theme=gr.themes.Soft(primary_hue="purple", secondary_hue="pink"),
270
  css="""
271
  .gradio-container {
272
- max-width: 1000px !important;
273
  margin: 0 auto;
274
  }
275
  .practice-card {
@@ -292,8 +292,20 @@ def create_interface():
292
  color: white !important;
293
  border: none !important;
294
  border-radius: 10px !important;
295
- padding: 12px 24px !important;
296
- margin: 5px !important;
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
298
  """
299
  ) as interface:
@@ -313,31 +325,35 @@ def create_interface():
313
  Начните с того, что resonates с вами прямо сейчас.
314
  """)
315
 
 
316
  with gr.Row():
317
  with gr.Column():
318
- values_btn = gr.Button("🎯 Ценности и смыслы", elem_classes="btn-custom")
319
- shadow_btn = gr.Button("🌑 Работа с Тенью", elem_classes="btn-custom")
320
- purpose_btn = gr.Button("🌟 Жизненное предназначение", elem_classes="btn-custom")
321
- child_btn = gr.Button("👶 Исцеление Внутреннего Ребенка", elem_classes="btn-custom")
322
 
323
  with gr.Column():
324
- mindfulness_btn = gr.Button("🧘 Практики осознанности", elem_classes="btn-custom")
325
- strengths_btn = gr.Button("💪 Сильные стороны", elem_classes="btn-custom")
326
- daily_btn = gr.Button("📅 Сегодняшняя практика", elem_classes="btn-custom")
327
- integration_btn_main = gr.Button("🔄 Интеграция открытий", elem_classes="btn-custom")
328
 
329
- personal_map_btn = gr.Button("🗺️ Моя карта самопознания", variant="primary", size="lg")
 
 
 
 
 
 
 
330
 
331
  with gr.Tab("📖 Практика и рефлексия"):
332
  gr.Markdown("### Углубляйте свои открытия через практику")
333
 
334
  with gr.Row():
335
  with gr.Column():
336
- practice_output = gr.Markdown(
337
- label="Практик�� самопознания",
338
- elem_classes="practice-card"
339
- )
340
-
341
  reflection_input = gr.Textbox(
342
  label="Ваши инсайты и размышления",
343
  placeholder="Запишите здесь свои открытия, чувства, осознания...",
@@ -373,48 +389,48 @@ def create_interface():
373
 
374
  quick_output = gr.Markdown(label="Быстрая практика")
375
 
376
- # Обработчики для основных практик - теперь каждая кнопка имеет свой обработчик
377
- values_btn.click(
378
  fn=app.values_clarification,
379
  outputs=practice_output
380
  )
381
 
382
- shadow_btn.click(
383
  fn=app.shadow_work,
384
  outputs=practice_output
385
  )
386
 
387
- purpose_btn.click(
388
  fn=app.life_purpose,
389
  outputs=practice_output
390
  )
391
 
392
- child_btn.click(
393
  fn=app.inner_child_healing,
394
  outputs=practice_output
395
  )
396
 
397
- mindfulness_btn.click(
398
  fn=app.mindfulness_practice,
399
  outputs=practice_output
400
  )
401
 
402
- strengths_btn.click(
403
  fn=app.strengths_identification,
404
  outputs=practice_output
405
  )
406
 
407
- daily_btn.click(
408
  fn=app.daily_practice,
409
  outputs=practice_output
410
  )
411
 
412
- integration_btn_main.click(
413
  fn=app.integration_exercise,
414
  outputs=practice_output
415
  )
416
 
417
- personal_map_btn.click(
418
  fn=app.create_personal_map,
419
  outputs=practice_output
420
  )
@@ -483,7 +499,7 @@ def create_interface():
483
  # Сохранение рефлексий
484
  def save_insight(reflection, user_id="default"):
485
  if not reflection.strip():
486
- return "Введите ваши размышления", practice_output.value
487
 
488
  if user_id not in app.user_data:
489
  app.user_data[user_id] = {"insights": [], "practices": []}
@@ -499,9 +515,12 @@ def create_interface():
499
  # Обновляем отображение инсайтов
500
  insights_text = "## 💫 Ваши инсайты:\n\n"
501
  user_insights = app.user_data[user_id].get("insights", [])
502
- for i, ins in enumerate(reversed(user_insights[-5:]), 1):
503
- date = datetime.fromisoformat(ins['timestamp']).strftime("%d.%m %H:%M")
504
- insights_text += f"**{i}. {date}:** {ins['text'][:100]}...\n\n"
 
 
 
505
 
506
  return "✅ Инсайт сохранен!", insights_text
507
 
@@ -548,12 +567,6 @@ def create_interface():
548
  outputs=progress_output
549
  )
550
 
551
- # Инициализация при загрузке
552
- interface.load(
553
- fn=lambda: "## 🧭 Добро пожаловать в путешествие самопознания!\n\nВыберите практику для начала или воспользуйтесь экспресс-методами для быстрого погружения.",
554
- outputs=practice_output
555
- )
556
-
557
  gr.Markdown("""
558
  ---
559
 
 
112
  **Вопрос для исцеления:** {random.choice(healing_questions)}
113
 
114
  **Техника работы:**
115
+ 1. **Визуализация:** Представьте себя в детском возраста
116
  2. **Диалог:** Спросите, что ему/ей нужно
117
  3. **Поддержка:** Дайте то, чего не хватало
118
  4. **Интеграция:** Обнимите и примите эту часть себя
 
269
  theme=gr.themes.Soft(primary_hue="purple", secondary_hue="pink"),
270
  css="""
271
  .gradio-container {
272
+ max-width: 1200px !important;
273
  margin: 0 auto;
274
  }
275
  .practice-card {
 
292
  color: white !important;
293
  border: none !important;
294
  border-radius: 10px !important;
295
+ padding: 15px 20px !important;
296
+ margin: 8px !important;
297
+ font-size: 14px !important;
298
+ min-width: 200px !important;
299
+ }
300
+ .btn-custom:hover {
301
+ transform: translateY(-2px);
302
+ box-shadow: 0 6px 12px rgba(0,0,0,0.2);
303
+ }
304
+ .practice-grid {
305
+ display: grid;
306
+ grid-template-columns: 1fr 1fr;
307
+ gap: 15px;
308
+ margin: 20px 0;
309
  }
310
  """
311
  ) as interface:
 
325
  Начните с того, что resonates с вами прямо сейчас.
326
  """)
327
 
328
+ # Создаем отдельные кнопки с явными именами
329
  with gr.Row():
330
  with gr.Column():
331
+ btn_values = gr.Button("🎯 Ценности и смыслы", elem_classes="btn-custom")
332
+ btn_shadow = gr.Button("🌑 Работа с Тенью", elem_classes="btn-custom")
333
+ btn_purpose = gr.Button("🌟 Жизненное предназначение", elem_classes="btn-custom")
334
+ btn_child = gr.Button("👶 Исцеление Внутреннего Ребенка", elem_classes="btn-custom")
335
 
336
  with gr.Column():
337
+ btn_mindfulness = gr.Button("🧘 Практики осознанности", elem_classes="btn-custom")
338
+ btn_strengths = gr.Button("💪 Сильные стороны", elem_classes="btn-custom")
339
+ btn_daily = gr.Button("📅 Сегодняшняя практика", elem_classes="btn-custom")
340
+ btn_integration = gr.Button("🔄 Интеграция открытий", elem_classes="btn-custom")
341
 
342
+ btn_map = gr.Button("🗺️ Моя карта самопознания", variant="primary", size="lg", elem_classes="btn-custom")
343
+
344
+ # Область для вывода практики
345
+ practice_output = gr.Markdown(
346
+ value="## 🧭 Выберите практику для начала\n\nНажмите на любую кнопку выше, чтобы начать работу с выбранным методом самопознания.",
347
+ label="Практика самопознания",
348
+ elem_classes="practice-card"
349
+ )
350
 
351
  with gr.Tab("📖 Практика и рефлексия"):
352
  gr.Markdown("### Углубляйте свои открытия через практику")
353
 
354
  with gr.Row():
355
  with gr.Column():
356
+ # Здесь practice_output уже создан, используем его
 
 
 
 
357
  reflection_input = gr.Textbox(
358
  label="Ваши инсайты и размышления",
359
  placeholder="Запишите здесь свои открытия, чувства, осознания...",
 
389
 
390
  quick_output = gr.Markdown(label="Быстрая практика")
391
 
392
+ # Обработчики для основных практик - назначаем на каждую кнопку отдельно
393
+ btn_values.click(
394
  fn=app.values_clarification,
395
  outputs=practice_output
396
  )
397
 
398
+ btn_shadow.click(
399
  fn=app.shadow_work,
400
  outputs=practice_output
401
  )
402
 
403
+ btn_purpose.click(
404
  fn=app.life_purpose,
405
  outputs=practice_output
406
  )
407
 
408
+ btn_child.click(
409
  fn=app.inner_child_healing,
410
  outputs=practice_output
411
  )
412
 
413
+ btn_mindfulness.click(
414
  fn=app.mindfulness_practice,
415
  outputs=practice_output
416
  )
417
 
418
+ btn_strengths.click(
419
  fn=app.strengths_identification,
420
  outputs=practice_output
421
  )
422
 
423
+ btn_daily.click(
424
  fn=app.daily_practice,
425
  outputs=practice_output
426
  )
427
 
428
+ btn_integration.click(
429
  fn=app.integration_exercise,
430
  outputs=practice_output
431
  )
432
 
433
+ btn_map.click(
434
  fn=app.create_personal_map,
435
  outputs=practice_output
436
  )
 
499
  # Сохранение рефлексий
500
  def save_insight(reflection, user_id="default"):
501
  if not reflection.strip():
502
+ return "Введите ваши размышления", insights_display.value
503
 
504
  if user_id not in app.user_data:
505
  app.user_data[user_id] = {"insights": [], "practices": []}
 
515
  # Обновляем отображение инсайтов
516
  insights_text = "## 💫 Ваши инсайты:\n\n"
517
  user_insights = app.user_data[user_id].get("insights", [])
518
+ if user_insights:
519
+ for i, ins in enumerate(reversed(user_insights[-5:]), 1):
520
+ date = datetime.fromisoformat(ins['timestamp']).strftime("%d.%m %H:%M")
521
+ insights_text += f"**{i}. {date}:** {ins['text'][:100]}...\n\n"
522
+ else:
523
+ insights_text += "Пока нет сохраненных инсайтов. Начните записывать свои мысли!"
524
 
525
  return "✅ Инсайт сохранен!", insights_text
526
 
 
567
  outputs=progress_output
568
  )
569
 
 
 
 
 
 
 
570
  gr.Markdown("""
571
  ---
572