Soulcompass / app.py
Rong6693's picture
Update app.py
c0cc997 verified
raw
history blame
9.8 kB
import streamlit as st
import random
from datetime import datetime
st.set_page_config(
page_title=“SoulCompass - Find Your Inner North Star”,
page_icon=“🧭”,
layout=“wide”
)
# 初始化
if ‘daily_usage’ not in st.session_state:
st.session_state.daily_usage = 0
# 簡化塔羅牌
tarot_cards = [
“The Fool - New beginnings and fresh starts”,
“The Magician - Power to manifest your dreams”,
“The High Priestess - Trust your intuition”,
“The Empress - Creativity and abundance”,
“The Emperor - Structure and authority”,
“The Lovers - Love and important choices”,
“The Chariot - Victory through determination”,
“Strength - Inner courage and compassion”,
“The Hermit - Soul searching and wisdom”,
“Wheel of Fortune - Life cycles and destiny”,
“Justice - Balance and fairness”,
“The Hanged Man - New perspective needed”,
“Death - Transformation and renewal”,
“Temperance - Patience and moderation”,
“The Devil - Breaking free from limitations”,
“The Tower - Sudden change and awakening”,
“The Star - Hope and inspiration”,
“The Moon - Dreams and subconscious”,
“The Sun - Joy and success”,
“Judgement - Spiritual awakening”,
“The World - Completion and achievement”
]
# CSS
st.markdown(”””
<style>
.header {
text-align: center;
background: linear-gradient(135deg, #6366F1, #C084FC);
color: white;
padding: 3rem;
border-radius: 20px;
margin-bottom: 2rem;
}
.card {
background: linear-gradient(135deg, #1E3A8A, #6366F1);
color: white;
padding: 2rem;
border-radius: 15px;
margin: 1rem;
text-align: center;
border: 2px solid #F59E0B;
}
.result {
background: linear-gradient(135deg, #6366F1, #C084FC);
color: white;
padding: 2rem;
border-radius: 15px;
margin: 2rem 0;
}
.quota {
background: linear-gradient(135deg, #F59E0B, #FB923C);
color: white;
padding: 1rem 2rem;
border-radius: 50px;
text-align: center;
font-weight: bold;
margin: 2rem auto;
max-width: 400px;
}
</style>
“””, unsafe_allow_html=True)
# 主標題
st.markdown(”””
<div class="header">
<h1>🧭 SoulCompass</h1>
<h2>Find Your Inner North Star</h2>
<p>🔮 Tarot Reading | 🔢 Numerology | 📖 Soul Journal | 🤖 AI Therapist</p>
<div style="margin-top: 20px;">
<span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 10px;">
15,247 users
</span>
<span style="background: rgba(255,255,255,0.2); padding: 8px 16px; border-radius: 20px; margin: 10px;">
💯 4.9/5 rating
</span>
</div>
</div>
""", unsafe_allow_html=True)
# 剩餘次數
remaining = 5 - st.session_state.daily_usage
st.markdown(f”””
<div class="quota">
🎫 Daily Free Readings: {remaining}/5
</div>
""", unsafe_allow_html=True)
# 主要功能
tab1, tab2, tab3, tab4 = st.tabs([“🔮 Tarot Reading”, “🔢 Numerology”, “📖 Soul Journal”, “🤖 AI Therapist”])
with tab1:
st.header(“🔮 Tarot Reading”)
st.write(”*Let ancient wisdom guide your path*”)
```
question = st.text_area(
"What would you like guidance on?",
placeholder="Example: I'm facing a difficult decision at work...",
height=100
)
if question:
spread = st.selectbox(
"Choose your reading type",
["Single Card - Quick Guidance", "Three Cards - Past Present Future", "Five Cards - Deep Insight"]
)
if st.button("🔮 Draw Cards", type="primary"):
if st.session_state.daily_usage >= 5:
st.error("😔 Daily limit reached! Come back tomorrow")
else:
st.session_state.daily_usage += 1
with st.spinner("✨ Drawing your cards..."):
import time
time.sleep(2)
num_cards = 1 if "Single" in spread else (3 if "Three" in spread else 5)
drawn = random.sample(tarot_cards, num_cards)
st.success("🌟 Your reading is complete!")
# Show cards
for i, card in enumerate(drawn):
st.markdown(f"""
<div class="card">
<h3>Card {i+1}</h3>
<p>{card}</p>
</div>
""", unsafe_allow_html=True)
# Reading
reading = f"""
```
🔮 **Your SoulCompass Reading**
**Question:** {question}
**Cards Drawn:** {len(drawn)} cards
**Interpretation:**
The cards reveal important insights about your situation. The first card shows your current energy, while the others provide guidance for moving forward.
**Key Message:** Trust your inner wisdom and stay open to new possibilities. The universe is supporting your journey.
**Readings used today:** {st.session_state.daily_usage}/5
“””
```
st.markdown(f"""
<div class="result">
{reading.replace(chr(10), '<br>')}
</div>
""", unsafe_allow_html=True)
```
with tab2:
st.header(“🔢 Numerology”)
st.write(”*Discover your numbers*”)
```
col1, col2 = st.columns(2)
with col1:
st.subheader("Life Path Number")
birth_date = st.date_input("Your birth date")
if birth_date and st.button("Calculate"):
date_str = birth_date.strftime('%Y%m%d')
total = sum(int(d) for d in date_str)
while total > 9:
total = sum(int(d) for d in str(total))
meanings = {
1: "Leader - Independent and pioneering",
2: "Peacemaker - Cooperative and diplomatic",
3: "Creative - Expressive and optimistic",
4: "Builder - Practical and hardworking",
5: "Explorer - Freedom-loving and adventurous",
6: "Nurturer - Caring and responsible",
7: "Seeker - Analytical and spiritual",
8: "Achiever - Ambitious and organized",
9: "Humanitarian - Compassionate and wise"
}
st.success(f"Your Life Path Number: **{total}**")
st.info(meanings.get(total, "Special number with unique meaning"))
with col2:
st.subheader("Name Number")
name = st.text_input("Your full name")
if name and st.button("Analyze Name"):
name_num = len(name) % 9 + 1
st.success(f"Your Name Number: **{name_num}**")
st.info("This number influences how others see you")
```
with tab3:
st.header(“📖 Soul Journal”)
st.write(”*Record your inner journey*”)
```
mood = st.slider("Today's mood (1-10)", 1, 10, 7)
emotion = st.selectbox("Main emotion", ["😊 Happy", "😔 Sad", "😰 Worried", "😌 Calm", "🤗 Grateful"])
entry = st.text_area(
"Write your thoughts",
placeholder="How are you feeling today? What's on your mind?",
height=120
)
if st.button("💾 Save Entry"):
if entry:
st.success("✅ Your journal entry has been saved!")
st.balloons()
else:
st.warning("Please write something first")
```
with tab4:
st.header(“🤖 AI Therapist”)
st.write(”*Your 24/7 companion*”)
```
st.markdown("""
<div style="background: #F3F4F6; padding: 20px; border-radius: 15px; margin: 20px 0;">
<div style="display: flex; align-items: center;">
<div style="font-size: 3rem; margin-right: 15px;">🤖</div>
<div>
<h4 style="margin: 0; color: #6366F1;">SoulCompass AI Guide</h4>
<p style="margin: 5px 0; color: #6B7280;">Here to listen and support you</p>
</div>
</div>
</div>
""", unsafe_allow_html=True)
topic = st.selectbox(
"What would you like to talk about?",
["General Support", "Stress & Anxiety", "Relationships", "Life Goals", "Personal Growth"]
)
message = st.text_area(
"Share your thoughts",
placeholder="Tell me what's on your mind...",
height=100
)
if message and st.button("💫 Get Support"):
with st.spinner("🤖 Thinking..."):
import time
time.sleep(1)
responses = [
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.",
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.",
f"Regarding {topic.lower()}, I want you to know that '{message}' resonates with me. Remember, you have inner strength and wisdom to navigate this."
]
response = random.choice(responses)
st.markdown(f"""
<div style="margin: 20px 0;">
<div style="background: #E5E7EB; padding: 15px; border-radius: 15px; margin-bottom: 10px;">
<strong>You:</strong> {message}
</div>
<div style="background: #6366F1; color: white; padding: 15px; border-radius: 15px;">
<strong>🤖 AI Guide:</strong> {response}
<br><br>
<small>💙 I'm here to support you. For serious concerns, please reach out to a professional.</small>
</div>
</div>
""", unsafe_allow_html=True)
```
# 頁腳
st.markdown(”—”)
st.markdown(”””
<div style="text-align: center; color: #6B7280; padding: 2rem;">
<p>🧭 <strong>SoulCompass</strong> - Find Your Inner North Star</p>
<p>Made with ❤️ for spiritual seekers worldwide</p>
<p>💎 <a href="#" style="color: #6366F1;">Upgrade to Pro</a> | 📧 [email protected] | 🌐 soulcompass.ai</p>
</div>
""", unsafe_allow_html=True)