Rong6693 commited on
Commit
c0cc997
·
verified ·
1 Parent(s): bef6f3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +167 -534
app.py CHANGED
@@ -2,683 +2,316 @@ import streamlit as st
2
  import random
3
  from datetime import datetime
4
 
5
- # 頁面配置
6
-
7
  st.set_page_config(
8
  page_title=“SoulCompass - Find Your Inner North Star”,
9
  page_icon=“🧭”,
10
  layout=“wide”
11
  )
12
 
13
- # 語言配置
14
-
15
- LANGUAGES = {
16
- “English”: “en”,
17
- “中文”: “zh”,
18
- “Español”: “es”,
19
- “Français”: “fr”
20
- }
21
-
22
- # 多語言文本
23
-
24
- TEXTS = {
25
- “en”: {
26
- “title”: “SoulCompass”,
27
- “subtitle”: “Find Your Inner North Star”,
28
- “features”: “Tarot Reading | Numerology | Soul Journal | AI Therapist”,
29
- “tarot_tab”: “Tarot Reading”,
30
- “numerology_tab”: “Numerology”,
31
- “journal_tab”: “Soul Journal”,
32
- “ai_tab”: “AI Therapist”,
33
- “question_label”: “Please describe your question in detail”,
34
- “question_placeholder”: “Example: I’m facing difficulties at work and don’t know which path to choose next…”,
35
- “start_reading”: “Start Tarot Reading”,
36
- “quota_text”: “Daily Free Readings”,
37
- “quota_exceeded”: “Daily free quota exceeded! Come back tomorrow”,
38
- “reading_complete”: “Your tarot reading is complete!”,
39
- “mood_score”: “Today’s mood score”,
40
- “energy_level”: “Energy level”,
41
- “save_journal”: “Save Today’s Journal”,
42
- “journal_saved”: “Journal saved! Another precious record added to your growth journey”
43
- },
44
- “zh”: {
45
- “title”: “SoulCompass 心靈羅盤”,
46
- “subtitle”: “找到內心的北極星”,
47
- “features”: “塔羅占卜 | 數字占卜 | 心靈日記 | AI療癒師”,
48
- “tarot_tab”: “塔羅占卜”,
49
- “numerology_tab”: “數字占卜”,
50
- “journal_tab”: “心靈日記”,
51
- “ai_tab”: “AI療癒師”,
52
- “question_label”: “請詳細描述您想要占卜的問題”,
53
- “question_placeholder”: “例如:我最近在工作上遇到困難,不知道該如何選擇下一步…”,
54
- “start_reading”: “開始塔羅占卜”,
55
- “quota_text”: “每日免費占卜次數”,
56
- “quota_exceeded”: “今日免費額度已用完!明天再來”,
57
- “reading_complete”: “您的塔羅占卜已完成!”,
58
- “mood_score”: “今日心情指數”,
59
- “energy_level”: “能量水平”,
60
- “save_journal”: “保存今日日記”,
61
- “journal_saved”: “日記已保存!您的成長軌跡又增加了珍貴的記錄”
62
- }
63
- }
64
-
65
- # 塔羅牌數據
66
-
67
- TAROT_CARDS = {
68
- “The Fool”: {
69
- “meaning”: “New beginnings, adventure, innocence”,
70
- “description”: “Represents the beginning of a life journey, symbolizing infinite possibilities”
71
- },
72
- “The Magician”: {
73
- “meaning”: “Creativity, skill, willpower”,
74
- “description”: “Has all the tools needed to achieve goals”
75
- },
76
- “The High Priestess”: {
77
- “meaning”: “Intuition, mystery, inner wisdom”,
78
- “description”: “Represents inner wisdom and intuitive guidance”
79
- },
80
- “The Empress”: {
81
- “meaning”: “Fertility, motherhood, creation”,
82
- “description”: “Symbolizes maternal energy and creativity”
83
- },
84
- “The Emperor”: {
85
- “meaning”: “Authority, structure, control”,
86
- “description”: “Represents authority and order”
87
- },
88
- “The Hierophant”: {
89
- “meaning”: “Spiritual guidance, tradition”,
90
- “description”: “Provides spiritual guidance and wisdom”
91
- },
92
- “The Lovers”: {
93
- “meaning”: “Love, relationships, choices”,
94
- “description”: “Symbolizes love and important choices”
95
- },
96
- “The Chariot”: {
97
- “meaning”: “Victory, willpower, control”,
98
- “description”: “Achieving victory through determination”
99
- },
100
- “Strength”: {
101
- “meaning”: “Inner strength, courage”,
102
- “description”: “Symbolizes inner courage and gentle strength”
103
- },
104
- “The Hermit”: {
105
- “meaning”: “Introspection, searching, wisdom”,
106
- “description”: “Represents inner exploration and seeking wisdom”
107
- },
108
- “Wheel of Fortune”: {
109
- “meaning”: “Fate, cycles, change”,
110
- “description”: “Symbolizes life cycles and transformation”
111
- },
112
- “Justice”: {
113
- “meaning”: “Fairness, balance, truth”,
114
- “description”: “Represents fairness and moral choices”
115
- },
116
- “The Hanged Man”: {
117
- “meaning”: “Sacrifice, pause, new perspective”,
118
- “description”: “Gaining new insights through letting go”
119
- },
120
- “Death”: {
121
- “meaning”: “Transformation, endings, rebirth”,
122
- “description”: “Represents endings and new beginnings”
123
- },
124
- “Temperance”: {
125
- “meaning”: “Balance, patience, harmony”,
126
- “description”: “Teaching balance and moderation”
127
- },
128
- “The Devil”: {
129
- “meaning”: “Bondage, temptation, addiction”,
130
- “description”: “Symbolizes inner fears and bondage”
131
- },
132
- “The Tower”: {
133
- “meaning”: “Sudden change, destruction, awakening”,
134
- “description”: “Represents sudden awakening and transformation”
135
- },
136
- “The Star”: {
137
- “meaning”: “Hope, inspiration, healing”,
138
- “description”: “Symbolizes hope and guidance”
139
- },
140
- “The Moon”: {
141
- “meaning��: “Illusion, intuition, subconscious”,
142
- “description”: “Represents subconscious and intuition”
143
- },
144
- “The Sun”: {
145
- “meaning”: “Success, joy, vitality”,
146
- “description”: “Symbolizes success and positive energy”
147
- },
148
- “Judgement”: {
149
- “meaning”: “Rebirth, inner calling”,
150
- “description”: “Represents spiritual awakening and rebirth”
151
- },
152
- “The World”: {
153
- “meaning”: “Completion, achievement, fulfillment”,
154
- “description”: “Represents goal achievement and completion”
155
- }
156
- }
157
-
158
- # 初始化會話狀態
159
 
160
  if ‘daily_usage’ not in st.session_state:
161
  st.session_state.daily_usage = 0
162
 
163
- if ‘language’ not in st.session_state:
164
- st.session_state.language = ‘en’
165
-
166
- if ‘journal_entries’ not in st.session_state:
167
- st.session_state.journal_entries = []
168
-
169
- def get_text(key):
170
- “”“獲取當前語言的文本”””
171
- return TEXTS[st.session_state.language].get(key, key)
172
-
173
- def change_language():
174
- “”“語言切換”””
175
- lang_names = list(LANGUAGES.keys())
176
- lang_codes = list(LANGUAGES.values())
177
-
178
- ```
179
- current_index = 0
180
- if st.session_state.language in lang_codes:
181
- current_index = lang_codes.index(st.session_state.language)
182
-
183
- selected_lang_name = st.selectbox(
184
- "Language / 語言",
185
- lang_names,
186
- index=current_index
187
- )
188
-
189
- new_lang_code = LANGUAGES[selected_lang_name]
190
- if new_lang_code != st.session_state.language:
191
- st.session_state.language = new_lang_code
192
- st.rerun()
193
- ```
194
-
195
- # CSS樣式
196
 
197
  st.markdown(”””
198
 
199
  <style>
200
- .main-header {
201
  text-align: center;
202
- background: linear-gradient(135deg, #6366F1 0%, #C084FC 100%);
203
  color: white;
204
- padding: 3rem 2rem;
205
  border-radius: 20px;
206
  margin-bottom: 2rem;
207
- box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
208
- }
209
-
210
- .main-header h1 {
211
- font-size: 3.5rem;
212
- font-weight: 600;
213
- margin-bottom: 1rem;
214
- text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
215
  }
216
 
217
- .compass-icon {
218
- font-size: 4rem;
219
- margin-bottom: 1rem;
220
- display: inline-block;
221
- animation: compass-spin 3s ease-in-out infinite;
222
- }
223
-
224
- @keyframes compass-spin {
225
- 0%, 100% { transform: rotate(-10deg); }
226
- 50% { transform: rotate(10deg); }
227
- }
228
-
229
- .tarot-card {
230
- background: linear-gradient(135deg, #1E3A8A 0%, #6366F1 100%);
231
- border: 3px solid #F59E0B;
232
- border-radius: 20px;
233
- padding: 2rem;
234
  color: white;
235
- text-align: center;
 
236
  margin: 1rem;
237
- box-shadow: 0 15px 35px rgba(0,0,0,0.3);
238
- transition: all 0.4s ease;
239
- }
240
-
241
- .tarot-card:hover {
242
- transform: translateY(-5px) scale(1.02);
243
  }
244
 
245
- .reading-result {
246
- background: linear-gradient(135deg, #6366F1 0%, #C084FC 100%);
247
  color: white;
248
- padding: 2.5rem;
249
- border-radius: 20px;
250
  margin: 2rem 0;
251
- box-shadow: 0 15px 35px rgba(99, 102, 241, 0.3);
252
  }
253
 
254
- .quota-display {
255
- background: linear-gradient(135deg, #F59E0B 0%, #FB923C 100%);
256
  color: white;
257
  padding: 1rem 2rem;
258
  border-radius: 50px;
259
  text-align: center;
260
- font-weight: 600;
261
  margin: 2rem auto;
262
  max-width: 400px;
263
  }
264
-
265
- .feature-card {
266
- background: white;
267
- border-radius: 15px;
268
- padding: 2rem;
269
- box-shadow: 0 4px 15px rgba(0,0,0,0.1);
270
- border: 2px solid transparent;
271
- transition: all 0.3s ease;
272
- height: 100%;
273
- }
274
-
275
- .feature-card:hover {
276
- border-color: #6366F1;
277
- transform: translateY(-2px);
278
- }
279
-
280
- .journal-entry {
281
- background: #F8FAFC;
282
- border-radius: 10px;
283
- padding: 1.5rem;
284
- margin: 1rem 0;
285
- border-left: 4px solid #6366F1;
286
- }
287
-
288
- .ai-response {
289
- background: linear-gradient(135deg, #E0E7FF 0%, #F3E8FF 100%);
290
- border-radius: 15px;
291
- padding: 1.5rem;
292
- margin: 1rem 0;
293
- border-left: 4px solid #6366F1;
294
- }
295
  </style>
296
 
297
  “””, unsafe_allow_html=True)
298
 
299
- # 語言選擇器
300
-
301
- col1, col2, col3 = st.columns([2, 1, 1])
302
- with col3:
303
- change_language()
304
-
305
  # 主標題
306
 
307
- header_html = f”””
308
 
309
- <div class="main-header">
310
- <div class="compass-icon">🧭</div>
311
- <h1>{get_text('title')}</h1>
312
- <h2 style="font-size: 2rem; margin: 1rem 0;">{get_text('subtitle')}</h2>
313
- <p style="font-size: 1.2rem; opacity: 0.9;">{get_text('features')}</p>
314
  <div style="margin-top: 20px;">
315
- <span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 0 10px;">
316
  ⭐ 15,247 users
317
  </span>
318
- <span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 0 10px;">
319
  💯 4.9/5 rating
320
  </span>
321
  </div>
322
  </div>
323
- """
324
- st.markdown(header_html, unsafe_allow_html=True)
325
 
326
- # 剩餘額度顯示
327
 
328
  remaining = 5 - st.session_state.daily_usage
329
- quota_html = f”””
330
 
331
- <div class="quota-display">
332
- 🎫 {get_text('quota_text')}: {remaining}/5
333
  </div>
334
- """
335
- st.markdown(quota_html, unsafe_allow_html=True)
336
-
337
- # 主功能區域
338
 
339
- tab1, tab2, tab3, tab4 = st.tabs([
340
- f”🔮 {get_text(‘tarot_tab’)}”,
341
- f”🔢 {get_text(‘numerology_tab’)}”,
342
- f”📖 {get_text(‘journal_tab’)}”,
343
- f”🤖 {get_text(‘ai_tab’)}”
344
- ])
345
 
346
- # 塔羅占卜標籤
347
 
348
  with tab1:
349
- st.header(f”🔮 {get_text(‘tarot_tab’)}”)
350
- st.markdown(”*Let ancient tarot wisdom guide your life’s direction*”)
351
 
352
  ```
353
  question = st.text_area(
354
- get_text('question_label'),
355
- placeholder=get_text('question_placeholder'),
356
  height=100
357
  )
358
 
359
  if question:
360
- col1, col2 = st.columns(2)
361
-
362
- with col1:
363
- spread_type = st.selectbox(
364
- "Choose Tarot Spread",
365
- ["Single Card - Quick Guidance", "Three Cards - Past Present Future", "Love Triangle - Relationship Focus"]
366
- )
367
-
368
- with col2:
369
- spread_info = {
370
- "Single Card - Quick Guidance": "Perfect for daily guidance and simple questions",
371
- "Three Cards - Past Present Future": "Timeline reading to understand development",
372
- "Love Triangle - Relationship Focus": "Specialized for relationship questions"
373
- }
374
- st.info(spread_info[spread_type])
375
 
376
- if st.button(get_text('start_reading'), type="primary", use_container_width=True):
377
  if st.session_state.daily_usage >= 5:
378
- st.error(get_text('quota_exceeded'))
379
  else:
380
  st.session_state.daily_usage += 1
381
 
382
- with st.spinner("🌟 Drawing tarot cards for you..."):
383
  import time
384
  time.sleep(2)
385
 
386
- # 抽牌邏輯
387
- num_cards = 1 if "Single" in spread_type else 3
388
- drawn_cards = random.sample(list(TAROT_CARDS.keys()), num_cards)
389
 
390
- st.success(f" {get_text('reading_complete')}")
391
 
392
- # 顯示抽到的牌
393
- cols = st.columns(len(drawn_cards))
394
- for i, card in enumerate(drawn_cards):
395
- with cols[i]:
396
- is_reversed = random.choice([True, False])
397
- status = "Reversed" if is_reversed else "Upright"
398
- card_html = f"""
399
- <div class="tarot-card">
400
- <h3>{card}</h3>
401
- <p><strong>{status}</strong></p>
402
- <p style="font-size: 0.9rem; opacity: 0.8;">{TAROT_CARDS[card]['meaning']}</p>
403
- </div>
404
- """
405
- st.markdown(card_html, unsafe_allow_html=True)
406
 
407
- # 生成解讀
408
- reading_text = f"""
409
  ```
410
 
411
- 🔮 **SoulCompass Reading for You**
412
-
413
- **Your Question:** {question}
414
- **Spread Used:** {spread_type}
415
- **Cards Drawn:** {’, ’.join(drawn_cards)}
416
 
417
- **Detailed Interpretation:**
418
 
419
- {chr(10).join([f”**{card}:** {TAROT_CARDS[card][‘description’]}” for card in drawn_cards])}
420
 
421
- **Overall Guidance:**
422
- The cards reveal important insights about your situation. Trust your intuition as you move forward, and remember that you have the wisdom within you to make the right choices.
423
 
424
- 🌟 **Key Message:** Embrace the journey ahead with confidence and openness to new possibilities.
425
 
426
- 💫 **Readings used today:** {st.session_state.daily_usage}/5
427
  “””
428
 
429
  ```
430
- reading_html = f"""
431
- <div class="reading-result">
432
- {reading_text.replace(chr(10), '<br>')}
433
  </div>
434
- """
435
- st.markdown(reading_html, unsafe_allow_html=True)
436
  ```
437
 
438
- # 數字占卜標籤
439
-
440
  with tab2:
441
- st.header(f”🔢 {get_text(‘numerology_tab’)}”)
442
- st.markdown(”*Discover your life’s mysteries through the power of numbers*”)
443
 
444
  ```
445
  col1, col2 = st.columns(2)
446
 
447
  with col1:
448
- st.subheader("📅 Life Path Number")
449
- birth_date = st.date_input("Select your birth date")
450
 
451
- if birth_date and st.button("🌟 Calculate Life Number"):
452
- # 生命靈數計算
453
  date_str = birth_date.strftime('%Y%m%d')
454
- total = sum(int(digit) for digit in date_str if digit.isdigit())
455
- while total > 9 and total not in [11, 22, 33]:
456
- total = sum(int(digit) for digit in str(total))
457
 
458
- life_meanings = {
459
- 1: "The Leader - Independent, pioneering, ambitious",
460
- 2: "The Cooperator - Diplomatic, peaceful, intuitive",
461
- 3: "The Communicator - Creative, expressive, optimistic",
462
- 4: "The Builder - Practical, disciplined, hardworking",
463
- 5: "The Freedom Seeker - Adventurous, energetic, curious",
464
- 6: "The Nurturer - Caring, responsible, family-oriented",
465
- 7: "The Seeker - Analytical, introspective, spiritual",
466
- 8: "The Achiever - Ambitious, organized, business-minded",
467
- 9: "The Humanitarian - Compassionate, generous, idealistic"
468
  }
469
 
470
- meaning = life_meanings.get(total, "Master Number - Special spiritual significance")
471
-
472
- result_html = f"""
473
- <div class="feature-card">
474
- <h3>🌟 Your Life Path Number: {total}</h3>
475
- <p><strong>{meaning}</strong></p>
476
- <p>This number represents your core personality traits and life lessons.
477
- It reveals the path you're meant to walk in this lifetime.</p>
478
- </div>
479
- """
480
- st.markdown(result_html, unsafe_allow_html=True)
481
 
482
  with col2:
483
- st.subheader("📝 Name Numerology")
484
- name = st.text_input("Enter your full name")
485
 
486
- if name and st.button("Analyze Name Number"):
487
- # 簡化的姓名數字計算
488
- name_value = len(name) % 9 + 1
489
-
490
- name_meanings = {
491
- 1: "Leadership Energy - You inspire others naturally",
492
- 2: "Harmony Energy - You bring peace and cooperation",
493
- 3: "Creative Energy - You express joy and optimism",
494
- 4: "Stability Energy - You provide structure and reliability",
495
- 5: "Freedom Energy - You bring change and adventure",
496
- 6: "Nurturing Energy - You care for and support others",
497
- 7: "Wisdom Energy - You seek deeper understanding",
498
- 8: "Success Energy - You achieve material accomplishment",
499
- 9: "Service Energy - You serve the greater good"
500
- }
501
-
502
- meaning = name_meanings[name_value]
503
-
504
- result_html = f"""
505
- <div class="feature-card">
506
- <h3>✨ Your Name Number: {name_value}</h3>
507
- <p><strong>{meaning}</strong></p>
508
- <p>Your name carries this vibrational energy that influences how others
509
- perceive you and how you express yourself in the world.</p>
510
- </div>
511
- """
512
- st.markdown(result_html, unsafe_allow_html=True)
513
  ```
514
 
515
- # 心靈日記標籤
516
-
517
  with tab3:
518
- st.header(f”📖 {get_text(‘journal_tab’)}”)
519
- st.markdown(”*Track your emotional journey and connect with your inner self*”)
520
 
521
  ```
522
- # 今日心情記錄
523
- st.subheader("🌈 Today's Mood Record")
524
-
525
- col1, col2 = st.columns(2)
526
-
527
- with col1:
528
- mood_score = st.slider(get_text('mood_score'), 1, 10, 7)
529
- main_emotion = st.selectbox(
530
- "Primary emotion",
531
- ["😊 Happy", "😔 Sad", "😰 Anxious", "😡 Angry", "😌 Calm", "🤗 Grateful", "😴 Tired", "🤔 Confused"]
532
- )
533
 
534
- with col2:
535
- energy_level = st.slider(get_text('energy_level'), 1, 10, 6)
536
- gratitude = st.text_input("What are you grateful for today?", placeholder="Something that made you smile today...")
537
-
538
- # 日記內容
539
- journal_content = st.text_area(
540
- "📝 Today's Soul Journal Entry",
541
- placeholder="Write about your thoughts, feelings, experiences, or anything you want to record today...",
542
- height=150
543
  )
544
 
545
- if st.button(get_text('save_journal'), type="primary"):
546
- if journal_content:
547
- entry = {
548
- 'date': datetime.now().strftime('%Y-%m-%d'),
549
- 'time': datetime.now().strftime('%H:%M'),
550
- 'mood': mood_score,
551
- 'emotion': main_emotion,
552
- 'energy': energy_level,
553
- 'gratitude': gratitude,
554
- 'content': journal_content
555
- }
556
-
557
- st.session_state.journal_entries.append(entry)
558
- st.success(get_text('journal_saved'))
559
  st.balloons()
560
  else:
561
- st.warning("Please write something in your journal entry")
562
-
563
- # 顯示最近的日記記錄
564
- if st.session_state.journal_entries:
565
- st.subheader("📚 Recent Journal Entries")
566
-
567
- for entry in reversed(st.session_state.journal_entries[-3:]): # 顯示最近3條
568
- entry_html = f"""
569
- <div class="journal-entry">
570
- <div style="display: flex; justify-content: space-between; align-items: center;">
571
- <strong>{entry['date']} {entry['time']}</strong>
572
- <span>{entry['emotion']} | Mood: {entry['mood']}/10 | Energy: {entry['energy']}/10</span>
573
- </div>
574
- <p style="margin: 10px 0;"><strong>Grateful for:</strong> {entry['gratitude']}</p>
575
- <p style="margin: 10px 0; font-style: italic;">"{entry['content'][:100]}{'...' if len(entry['content']) > 100 else ''}"</p>
576
- </div>
577
- """
578
- st.markdown(entry_html, unsafe_allow_html=True)
579
  ```
580
 
581
- # AI療癒師標籤
582
-
583
  with tab4:
584
- st.header(f”🤖 {get_text(‘ai_tab’)}”)
585
- st.markdown(”*24/7 soul guide providing warm support and guidance*”)
586
 
587
  ```
588
- # AI療癒師介紹
589
- ai_intro_html = """
590
- <div style="background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%); padding: 20px; border-radius: 15px; margin: 20px 0;">
591
- <div style="display: flex; align-items: center; margin-bottom: 15px;">
592
  <div style="font-size: 3rem; margin-right: 15px;">🤖</div>
593
  <div>
594
- <h4 style="margin: 0; color: #6366F1;">SoulCompass AI Therapist</h4>
595
- <p style="margin: 5px 0; color: #6B7280;">Your dedicated soul guide, always here to provide support and companionship</p>
596
  </div>
597
  </div>
598
- <div style="color: #6B7280; font-size: 0.9rem;">
599
- 💬 Emotional support 🧘 Relaxation guidance 🌱 Growth advice 🫂 24/7 companionship
600
- </div>
601
  </div>
602
- """
603
- st.markdown(ai_intro_html, unsafe_allow_html=True)
604
-
605
- # 對話類型選擇
606
- conversation_type = st.selectbox(
607
- "🎯 Choose conversation topic",
608
- [
609
- "💭 General Soul Conversation",
610
- "😰 Stress & Anxiety Support",
611
- "💔 Relationship Counseling",
612
- "🎯 Life Goals Discussion",
613
- "🧘 Meditation & Relaxation",
614
- "🌱 Personal Growth Advice"
615
- ]
616
  )
617
 
618
- # 對話輸入
619
- user_message = st.text_area(
620
- "💬 Share your thoughts with the AI Therapist",
621
- placeholder="Tell me how you're feeling, or what you'd like to discuss...",
622
  height=100
623
  )
624
 
625
- if user_message and st.button("💫 Start Conversation", type="primary"):
626
- with st.spinner("🤖 AI Therapist is listening and preparing a response..."):
627
  import time
628
- time.sleep(1.5)
629
 
630
- # AI回應生成
631
- responses = {
632
- "💭 General Soul Conversation": [
633
- f"Thank you for sharing with me. I can sense that what you've told me - '{user_message}' - comes from a place of genuine reflection. Your willingness to explore your inner world shows great courage.",
634
- f"I hear you saying '{user_message}' and I want you to know that your feelings are completely valid. Sometimes the simple act of expressing our thoughts can be the first step toward greater clarity.",
635
- f"What you've shared - '{user_message}' - resonates deeply. Every person's journey is unique, and I'm honored that you've chosen to share this part of yours with me."
636
- ],
637
- "😰 Stress & Anxiety Support": [
638
- f"I understand you're experiencing stress around '{user_message}'. Anxiety can feel overwhelming, but remember - you've successfully navigated 100% of your difficult days so far. Let's breathe through this together.",
639
- f"Your stress about '{user_message}' is completely understandable. Right now, let's focus on what you can control in this moment. Take a deep breath in for 4 counts, hold for 4, and exhale for 6.",
640
- f"Thank you for trusting me with your anxiety about '{user_message}'. You're stronger than you realize, and this feeling will pass. Let's find some small steps to help you feel more grounded."
641
- ],
642
- "💔 Relationship Counseling": [
643
- f"Relationships can be complex, and what you've shared about '{user_message}' shows how much you care. Love requires both vulnerability and strength - you're showing both right now.",
644
- f"I can hear the emotion in your words about '{user_message}'. Relationships are mirrors that help us grow, even when they challenge us. Your heart's capacity for love is a gift.",
645
- f"The situation you've described - '{user_message}' - touches on the deep human need for connection. Remember, the relationship you have with yourself sets the foundation for all others."
646
- ]
647
- }
648
 
649
- response_list = responses.get(conversation_type, responses["💭 General Soul Conversation"])
650
- ai_response = random.choice(response_list)
651
 
652
- # 顯示對話
653
- conversation_html = f"""
654
  <div style="margin: 20px 0;">
655
- <div style="background: #E5E7EB; padding: 15px; border-radius: 15px 15px 5px 15px; margin-bottom: 10px;">
656
- <strong>You:</strong> {user_message}
657
  </div>
658
- <div class="ai-response">
659
- <strong>🤖 AI Therapist:</strong> {ai_response}
660
  <br><br>
661
- <small style="opacity: 0.8;">💙 Remember: I'm here to support you, but for serious mental health concerns, please consult a professional therapist.</small>
662
  </div>
663
  </div>
664
- """
665
- st.markdown(conversation_html, unsafe_allow_html=True)
666
  ```
667
 
668
  # 頁腳
669
 
670
  st.markdown(”—”)
671
- footer_html = “””
672
 
673
  <div style="text-align: center; color: #6B7280; padding: 2rem;">
674
  <p>🧭 <strong>SoulCompass</strong> - Find Your Inner North Star</p>
675
- <p>Made with ❤️ for seekers of wisdom and growth worldwide</p>
676
- <div style="margin: 20px 0;">
677
- <span style="margin: 0 15px;">📧 [email protected]</span>
678
- <span style="margin: 0 15px;">🌐 www.soulcompass.ai</span>
679
- <span style="margin: 0 15px;">📱 @SoulCompassAI</span>
680
- </div>
681
- <p>💎 <a href="#" style="color: #6366F1; text-decoration: none;">Upgrade to Pro</a> for unlimited readings and advanced features</p>
682
  </div>
683
- """
684
- st.markdown(footer_html, unsafe_allow_html=True)
 
2
  import random
3
  from datetime import datetime
4
 
 
 
5
  st.set_page_config(
6
  page_title=“SoulCompass - Find Your Inner North Star”,
7
  page_icon=“🧭”,
8
  layout=“wide”
9
  )
10
 
11
+ # 初始化
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  if ‘daily_usage’ not in st.session_state:
14
  st.session_state.daily_usage = 0
15
 
16
+ # 簡化塔羅牌
17
+
18
+ tarot_cards = [
19
+ “The Fool - New beginnings and fresh starts”,
20
+ “The Magician - Power to manifest your dreams”,
21
+ “The High Priestess - Trust your intuition”,
22
+ “The Empress - Creativity and abundance”,
23
+ “The Emperor - Structure and authority”,
24
+ “The Lovers - Love and important choices”,
25
+ “The Chariot - Victory through determination”,
26
+ “Strength - Inner courage and compassion”,
27
+ “The Hermit - Soul searching and wisdom”,
28
+ “Wheel of Fortune - Life cycles and destiny”,
29
+ “Justice - Balance and fairness”,
30
+ “The Hanged Man - New perspective needed”,
31
+ “Death - Transformation and renewal”,
32
+ “Temperance - Patience and moderation”,
33
+ “The Devil - Breaking free from limitations”,
34
+ “The Tower - Sudden change and awakening”,
35
+ “The Star - Hope and inspiration”,
36
+ “The Moon - Dreams and subconscious”,
37
+ “The Sun - Joy and success”,
38
+ “Judgement - Spiritual awakening”,
39
+ “The World - Completion and achievement”
40
+ ]
41
+
42
+ # CSS
 
 
 
 
 
 
43
 
44
  st.markdown(”””
45
 
46
  <style>
47
+ .header {
48
  text-align: center;
49
+ background: linear-gradient(135deg, #6366F1, #C084FC);
50
  color: white;
51
+ padding: 3rem;
52
  border-radius: 20px;
53
  margin-bottom: 2rem;
 
 
 
 
 
 
 
 
54
  }
55
 
56
+ .card {
57
+ background: linear-gradient(135deg, #1E3A8A, #6366F1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  color: white;
59
+ padding: 2rem;
60
+ border-radius: 15px;
61
  margin: 1rem;
62
+ text-align: center;
63
+ border: 2px solid #F59E0B;
 
 
 
 
64
  }
65
 
66
+ .result {
67
+ background: linear-gradient(135deg, #6366F1, #C084FC);
68
  color: white;
69
+ padding: 2rem;
70
+ border-radius: 15px;
71
  margin: 2rem 0;
 
72
  }
73
 
74
+ .quota {
75
+ background: linear-gradient(135deg, #F59E0B, #FB923C);
76
  color: white;
77
  padding: 1rem 2rem;
78
  border-radius: 50px;
79
  text-align: center;
80
+ font-weight: bold;
81
  margin: 2rem auto;
82
  max-width: 400px;
83
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  </style>
85
 
86
  “””, unsafe_allow_html=True)
87
 
 
 
 
 
 
 
88
  # 主標題
89
 
90
+ st.markdown(”””
91
 
92
+ <div class="header">
93
+ <h1>🧭 SoulCompass</h1>
94
+ <h2>Find Your Inner North Star</h2>
95
+ <p>🔮 Tarot Reading | 🔢 Numerology | 📖 Soul Journal | 🤖 AI Therapist</p>
 
96
  <div style="margin-top: 20px;">
97
+ <span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 10px;">
98
  ⭐ 15,247 users
99
  </span>
100
+ <span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 10px;">
101
  💯 4.9/5 rating
102
  </span>
103
  </div>
104
  </div>
105
+ """, unsafe_allow_html=True)
 
106
 
107
+ # 剩餘次數
108
 
109
  remaining = 5 - st.session_state.daily_usage
110
+ st.markdown(f”””
111
 
112
+ <div class="quota">
113
+ 🎫 Daily Free Readings: {remaining}/5
114
  </div>
115
+ """, unsafe_allow_html=True)
 
 
 
116
 
117
+ # 主要功能
 
 
 
 
 
118
 
119
+ tab1, tab2, tab3, tab4 = st.tabs([“🔮 Tarot Reading”, “🔢 Numerology”, “📖 Soul Journal”, “🤖 AI Therapist”])
120
 
121
  with tab1:
122
+ st.header(“🔮 Tarot Reading”)
123
+ st.write(”*Let ancient wisdom guide your path*”)
124
 
125
  ```
126
  question = st.text_area(
127
+ "What would you like guidance on?",
128
+ placeholder="Example: I'm facing a difficult decision at work...",
129
  height=100
130
  )
131
 
132
  if question:
133
+ spread = st.selectbox(
134
+ "Choose your reading type",
135
+ ["Single Card - Quick Guidance", "Three Cards - Past Present Future", "Five Cards - Deep Insight"]
136
+ )
 
 
 
 
 
 
 
 
 
 
 
137
 
138
+ if st.button("🔮 Draw Cards", type="primary"):
139
  if st.session_state.daily_usage >= 5:
140
+ st.error("😔 Daily limit reached! Come back tomorrow")
141
  else:
142
  st.session_state.daily_usage += 1
143
 
144
+ with st.spinner(" Drawing your cards..."):
145
  import time
146
  time.sleep(2)
147
 
148
+ num_cards = 1 if "Single" in spread else (3 if "Three" in spread else 5)
149
+ drawn = random.sample(tarot_cards, num_cards)
 
150
 
151
+ st.success("🌟 Your reading is complete!")
152
 
153
+ # Show cards
154
+ for i, card in enumerate(drawn):
155
+ st.markdown(f"""
156
+ <div class="card">
157
+ <h3>Card {i+1}</h3>
158
+ <p>{card}</p>
159
+ </div>
160
+ """, unsafe_allow_html=True)
 
 
 
 
 
 
161
 
162
+ # Reading
163
+ reading = f"""
164
  ```
165
 
166
+ 🔮 **Your SoulCompass Reading**
 
 
 
 
167
 
168
+ **Question:** {question}
169
 
170
+ **Cards Drawn:** {len(drawn)} cards
171
 
172
+ **Interpretation:**
173
+ The cards reveal important insights about your situation. The first card shows your current energy, while the others provide guidance for moving forward.
174
 
175
+ **Key Message:** Trust your inner wisdom and stay open to new possibilities. The universe is supporting your journey.
176
 
177
+ **Readings used today:** {st.session_state.daily_usage}/5
178
  “””
179
 
180
  ```
181
+ st.markdown(f"""
182
+ <div class="result">
183
+ {reading.replace(chr(10), '<br>')}
184
  </div>
185
+ """, unsafe_allow_html=True)
 
186
  ```
187
 
 
 
188
  with tab2:
189
+ st.header(“🔢 Numerology”)
190
+ st.write(”*Discover your numbers*”)
191
 
192
  ```
193
  col1, col2 = st.columns(2)
194
 
195
  with col1:
196
+ st.subheader("Life Path Number")
197
+ birth_date = st.date_input("Your birth date")
198
 
199
+ if birth_date and st.button("Calculate"):
 
200
  date_str = birth_date.strftime('%Y%m%d')
201
+ total = sum(int(d) for d in date_str)
202
+ while total > 9:
203
+ total = sum(int(d) for d in str(total))
204
 
205
+ meanings = {
206
+ 1: "Leader - Independent and pioneering",
207
+ 2: "Peacemaker - Cooperative and diplomatic",
208
+ 3: "Creative - Expressive and optimistic",
209
+ 4: "Builder - Practical and hardworking",
210
+ 5: "Explorer - Freedom-loving and adventurous",
211
+ 6: "Nurturer - Caring and responsible",
212
+ 7: "Seeker - Analytical and spiritual",
213
+ 8: "Achiever - Ambitious and organized",
214
+ 9: "Humanitarian - Compassionate and wise"
215
  }
216
 
217
+ st.success(f"Your Life Path Number: **{total}**")
218
+ st.info(meanings.get(total, "Special number with unique meaning"))
 
 
 
 
 
 
 
 
 
219
 
220
  with col2:
221
+ st.subheader("Name Number")
222
+ name = st.text_input("Your full name")
223
 
224
+ if name and st.button("Analyze Name"):
225
+ name_num = len(name) % 9 + 1
226
+ st.success(f"Your Name Number: **{name_num}**")
227
+ st.info("This number influences how others see you")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  ```
229
 
 
 
230
  with tab3:
231
+ st.header(“📖 Soul Journal”)
232
+ st.write(”*Record your inner journey*”)
233
 
234
  ```
235
+ mood = st.slider("Today's mood (1-10)", 1, 10, 7)
236
+ emotion = st.selectbox("Main emotion", ["😊 Happy", "😔 Sad", "😰 Worried", "😌 Calm", "🤗 Grateful"])
 
 
 
 
 
 
 
 
 
237
 
238
+ entry = st.text_area(
239
+ "Write your thoughts",
240
+ placeholder="How are you feeling today? What's on your mind?",
241
+ height=120
 
 
 
 
 
242
  )
243
 
244
+ if st.button("💾 Save Entry"):
245
+ if entry:
246
+ st.success("✅ Your journal entry has been saved!")
 
 
 
 
 
 
 
 
 
 
 
247
  st.balloons()
248
  else:
249
+ st.warning("Please write something first")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  ```
251
 
 
 
252
  with tab4:
253
+ st.header(“🤖 AI Therapist”)
254
+ st.write(”*Your 24/7 companion*”)
255
 
256
  ```
257
+ st.markdown("""
258
+ <div style="background: #F3F4F6; padding: 20px; border-radius: 15px; margin: 20px 0;">
259
+ <div style="display: flex; align-items: center;">
 
260
  <div style="font-size: 3rem; margin-right: 15px;">🤖</div>
261
  <div>
262
+ <h4 style="margin: 0; color: #6366F1;">SoulCompass AI Guide</h4>
263
+ <p style="margin: 5px 0; color: #6B7280;">Here to listen and support you</p>
264
  </div>
265
  </div>
 
 
 
266
  </div>
267
+ """, unsafe_allow_html=True)
268
+
269
+ topic = st.selectbox(
270
+ "What would you like to talk about?",
271
+ ["General Support", "Stress & Anxiety", "Relationships", "Life Goals", "Personal Growth"]
 
 
 
 
 
 
 
 
 
272
  )
273
 
274
+ message = st.text_area(
275
+ "Share your thoughts",
276
+ placeholder="Tell me what's on your mind...",
 
277
  height=100
278
  )
279
 
280
+ if message and st.button("💫 Get Support"):
281
+ with st.spinner("🤖 Thinking..."):
282
  import time
283
+ time.sleep(1)
284
 
285
+ responses = [
286
+ f"Thank you for sharing about {topic.lower()}. I hear that you're saying: '{message}'. Your feelings are completely valid, and it's brave of you to reach out.",
287
+ f"I understand you're dealing with {topic.lower()}. What you've shared - '{message}' - shows real self-awareness. You're taking positive steps by talking about it.",
288
+ f"Regarding {topic.lower()}, I want you to know that '{message}' resonates with me. Remember, you have inner strength and wisdom to navigate this."
289
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
290
 
291
+ response = random.choice(responses)
 
292
 
293
+ st.markdown(f"""
 
294
  <div style="margin: 20px 0;">
295
+ <div style="background: #E5E7EB; padding: 15px; border-radius: 15px; margin-bottom: 10px;">
296
+ <strong>You:</strong> {message}
297
  </div>
298
+ <div style="background: #6366F1; color: white; padding: 15px; border-radius: 15px;">
299
+ <strong>🤖 AI Guide:</strong> {response}
300
  <br><br>
301
+ <small>💙 I'm here to support you. For serious concerns, please reach out to a professional.</small>
302
  </div>
303
  </div>
304
+ """, unsafe_allow_html=True)
 
305
  ```
306
 
307
  # 頁腳
308
 
309
  st.markdown(”—”)
310
+ st.markdown(”””
311
 
312
  <div style="text-align: center; color: #6B7280; padding: 2rem;">
313
  <p>🧭 <strong>SoulCompass</strong> - Find Your Inner North Star</p>
314
+ <p>Made with ❤️ for spiritual seekers worldwide</p>
315
+ <p>💎 <a href="#" style="color: #6366F1;">Upgrade to Pro</a> | 📧 [email protected] | 🌐 soulcompass.ai</p>
 
 
 
 
 
316
  </div>
317
+ """, unsafe_allow_html=True)