Spaces:
Running
Running
import gradio as gr | |
import random | |
from datetime import datetime | |
# Complete Tarot Card Dictionary | |
tarot_cards = { | |
"โจ The Fool โจ": { | |
"meaning": "New beginnings, innocence, spontaneity", | |
"description": "๐ A fresh start awaits! Take that leap of faith with an open heart.", | |
"image": "fool.jpg" | |
}, | |
"๐ฏ The Magician ๐ฏ": { | |
"meaning": "Manifestation, resourcefulness, power", | |
"description": "โก You have all tools to manifest your desires. Trust your abilities!", | |
"image": "magician.jpg" | |
}, | |
"๐ The High Priestess ๐": { | |
"meaning": "Intuition, mystery, inner wisdom", | |
"description": "๐ Listen to your inner voice. Deep wisdom lies within.", | |
"image": "priestess.jpg" | |
}, | |
"๐บ The Empress ๐บ": { | |
"meaning": "Abundance, nurturing, fertility", | |
"description": "๐ธ Embrace your creative power and nurture growth.", | |
"image": "empress.jpg" | |
}, | |
"โ๏ธ The Emperor โ๏ธ": { | |
"meaning": "Authority, structure, leadership", | |
"description": "๐ Time to take charge and establish order.", | |
"image": "emperor.jpg" | |
}, | |
"๐๏ธ The Hierophant ๐๏ธ": { | |
"meaning": "Tradition, spirituality, guidance", | |
"description": "๐ Seek wisdom from traditional sources and mentors.", | |
"image": "hierophant.jpg" | |
}, | |
"โค๏ธ The Lovers โค๏ธ": { | |
"meaning": "Love, harmony, relationships", | |
"description": "๐ Important choices about relationships await.", | |
"image": "lovers.jpg" | |
}, | |
"๐ The Chariot ๐": { | |
"meaning": "Victory, willpower, determination", | |
"description": "๐ฏ Success through determination and self-control.", | |
"image": "chariot.jpg" | |
}, | |
"๐ฆ Strength ๐ฆ": { | |
"meaning": "Courage, patience, inner strength", | |
"description": "๐ช Overcome challenges through inner power.", | |
"image": "strength.jpg" | |
}, | |
"๐ฎ The Hermit ๐ฎ": { | |
"meaning": "Introspection, searching, guidance", | |
"description": "๐ Time for inner reflection and spiritual search.", | |
"image": "hermit.jpg" | |
}, | |
"๐ก Wheel of Fortune ๐ก": { | |
"meaning": "Destiny, cycles, turning point", | |
"description": "๐ Change is coming. Fortune favors the prepared.", | |
"image": "wheel.jpg" | |
}, | |
"โ๏ธ Justice โ๏ธ": { | |
"meaning": "Justice, fairness, truth", | |
"description": "๐ Truth and karma will prevail.", | |
"image": "justice.jpg" | |
}, | |
"๐ The Hanged Man ๐": { | |
"meaning": "Surrender, letting go, new perspective", | |
"description": "๐ See things from a different angle.", | |
"image": "hanged.jpg" | |
}, | |
"๐ฆ Death ๐ฆ": { | |
"meaning": "Transformation, endings, change", | |
"description": "๐ End of one chapter, beginning of another.", | |
"image": "death.jpg" | |
}, | |
"๐ Temperance ๐": { | |
"meaning": "Balance, moderation, harmony", | |
"description": "โฏ๏ธ Find middle ground and inner peace.", | |
"image": "temperance.jpg" | |
}, | |
"๐ The Devil ๐": { | |
"meaning": "Bondage, materialism, temptation", | |
"description": "โ๏ธ Break free from what binds you.", | |
"image": "devil.jpg" | |
}, | |
"โก The Tower โก": { | |
"meaning": "Sudden change, chaos, revelation", | |
"description": "๐ฅ Dramatic change leads to breakthrough.", | |
"image": "tower.jpg" | |
}, | |
"โญ The Star โญ": { | |
"meaning": "Hope, inspiration, serenity", | |
"description": "โจ Light shines in the darkness.", | |
"image": "star.jpg" | |
}, | |
"๐ The Moon ๐": { | |
"meaning": "Illusion, intuition, dreams", | |
"description": "๐ Trust your intuition in uncertain times.", | |
"image": "moon.jpg" | |
}, | |
"โ๏ธ The Sun โ๏ธ": { | |
"meaning": "Joy, success, vitality", | |
"description": "๐ Positivity and success shine bright.", | |
"image": "sun.jpg" | |
}, | |
"๐ฏ Judgement ๐ฏ": { | |
"meaning": "Rebirth, inner calling, absolution", | |
"description": "๐ Answer the call to higher purpose.", | |
"image": "judgement.jpg" | |
}, | |
"๐ The World ๐": { | |
"meaning": "Completion, achievement, integration", | |
"description": "๐ A cycle completes, bringing fulfillment.", | |
"image": "world.jpg" | |
} | |
} | |
def get_reading(question, selected_cards): | |
if not selected_cards: | |
return "โ ๏ธ Please select at least one card for your reading." | |
result = f""" | |
๐ฎ YOUR MYSTICAL TAROT READING ๐ฎ | |
๐ซ Question: {question} | |
โง๏ฝฅ๏พ: *โง๏ฝฅ๏พ:* *:๏ฝฅ๏พโง*:๏ฝฅ๏พโง | |
""" | |
for i, card in enumerate(selected_cards, 1): | |
card_info = tarot_cards[card] | |
result += f""" | |
โจ Card {i}: {card} | |
๐ด Meaning: {card_info['meaning']} | |
๐ Message: {card_info['description']} | |
โยฐโยฐโยฐโยฐโยฐโยฐโยฐโยฐโยฐโยฐโ | |
""" | |
return result + "\n\n๐ May these insights guide your path! ๐" | |
# ... (์ด์ tarot_cards ๋์ ๋๋ฆฌ์ get_reading ํจ์๋ ๋์ผ) | |
with gr.Blocks( | |
theme=gr.themes.Soft( | |
primary_hue="purple", | |
secondary_hue="pink", | |
neutral_hue="slate", | |
font=["Arial", "sans-serif"] | |
), | |
css=""" | |
.gradio-container { | |
background: linear-gradient(to right, #1a1a2e, #16213e); | |
color: white; | |
} | |
.gr-button { | |
background: linear-gradient(45deg, #ff6b6b, #ff8e8e); | |
border: none; | |
color: white; | |
} | |
.gr-input { | |
border: 2px solid #ff6b6b; | |
} | |
.gr-box { | |
border-radius: 15px; | |
border: 2px solid #ff6b6b; | |
} | |
.gr-padded { | |
padding: 20px; | |
} | |
""" | |
) as demo: | |
gr.HTML("""<h1 style='text-align: center'>โจ Mystical Tarot Reading Experience โจ</h1>""") | |
gr.HTML(""" | |
<div style='text-align: center'> | |
๐ Welcome to Your Personal Tarot Journey ๐<br><br> | |
๐ด How to Use:<br> | |
1. ๐ญ Focus on your question<br> | |
2. ๐ Select 1-5 cards that call to you<br> | |
3. ๐ Receive your personalized mystical reading<br><br> | |
๐ Let the ancient wisdom guide your path ๐ | |
</div> | |
""") | |
with gr.Row(): | |
with gr.Column(): | |
question = gr.Textbox( | |
label="๐ค What would you like to know?", | |
placeholder="Enter your question here...", | |
lines=3 | |
) | |
cards = gr.CheckboxGroup( | |
choices=list(tarot_cards.keys()), | |
label="๐ด Select Your Cards (Max 5)", | |
info="Choose 1-5 cards for your reading" | |
) | |
submit_btn = gr.Button("๐ฎ Get Your Reading", variant="primary") | |
with gr.Column(): | |
output = gr.Textbox( | |
label="๐ฎ Your Mystical Reading", | |
lines=20 | |
) | |
def validate_and_read(question, selected_cards): | |
if not selected_cards: | |
return "โ ๏ธ Please select at least one card for your reading." | |
if len(selected_cards) > 5: | |
selected_cards = selected_cards[:5] | |
return get_reading(question, selected_cards) | |
submit_btn.click( | |
fn=validate_and_read, | |
inputs=[question, cards], | |
outputs=output | |
) | |
# Examples | |
gr.Examples( | |
examples=[ | |
["What energies surround my current path? ๐ฃ๏ธ", ["โจ The Fool โจ", "๐ฏ The Magician ๐ฏ"]], | |
["What should I know about my love life? โค๏ธ", ["โค๏ธ The Lovers โค๏ธ", "๐บ The Empress ๐บ"]], | |
["Guide me about my career decisions ๐ผ", ["โ๏ธ The Emperor โ๏ธ", "๐ก Wheel of Fortune ๐ก"]], | |
["What's my spiritual lesson for this month? ๐", ["๐๏ธ The Hierophant ๐๏ธ", "๐ฎ The Hermit ๐ฎ", "โญ The Star โญ"]] | |
], | |
inputs=[question, cards] | |
) | |
gr.HTML(""" | |
<div style="text-align: center; margin-top: 20px;"> | |
<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-tarotcard.hf.space"> | |
<img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-tarotcard.hf.space&countColor=%23263759" /> | |
</a> | |
</div> | |
""") | |
if __name__ == "__main__": | |
demo.launch(share=True) |