Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
import json
|
| 4 |
+
tarot_data = {
|
| 5 |
+
"The Fool": {
|
| 6 |
+
"keywords": "New beginnings, innocence, spontaneity",
|
| 7 |
+
"description": "A young person standing on a cliff, with a small dog at their feet",
|
| 8 |
+
"upright": "Taking a leap of faith, being spontaneous, following your heart",
|
| 9 |
+
"reversed": "Recklessness, foolishness, risk-taking",
|
| 10 |
+
"advice": "Trust your instincts and take that first step",
|
| 11 |
+
"color": "Yellow",
|
| 12 |
+
"symbols": "White rose, mountains, dog"
|
| 13 |
+
},
|
| 14 |
+
"The Magician": {
|
| 15 |
+
"keywords": "Manifestation, resourcefulness, power",
|
| 16 |
+
"description": "A figure with one arm raised holding a wand, symbols of all suits on table",
|
| 17 |
+
"upright": "Power, skill, concentration, action, resourcefulness",
|
| 18 |
+
"reversed": "Manipulation, poor planning, untapped talents",
|
| 19 |
+
"advice": "You have all the tools - use them wisely",
|
| 20 |
+
"color": "Red",
|
| 21 |
+
"symbols": "Infinity sign, wand, elements"
|
| 22 |
+
},
|
| 23 |
+
"The High Priestess": {
|
| 24 |
+
"keywords": "Intuition, mystery, spirituality",
|
| 25 |
+
"description": "A woman sitting between two pillars with a crescent moon",
|
| 26 |
+
"upright": "Inner voice, unconscious knowledge, mystery",
|
| 27 |
+
"reversed": "Secrets, disconnected from intuition",
|
| 28 |
+
"advice": "Listen to your inner voice",
|
| 29 |
+
"color": "Blue",
|
| 30 |
+
"symbols": "Crescent moon, pillars, pomegranates"
|
| 31 |
+
},
|
| 32 |
+
"The Empress": {
|
| 33 |
+
"keywords": "Abundance, nurturing, fertility",
|
| 34 |
+
"description": "A woman in a flowing dress surrounded by nature",
|
| 35 |
+
"upright": "Abundance, nurturing, fertility, feminine energy",
|
| 36 |
+
"reversed": "Creative block, neglect, nature",
|
| 37 |
+
"advice": "Embrace your nurturing side",
|
| 38 |
+
"color": "Green",
|
| 39 |
+
"symbols": "Stars, flowing water, heart"
|
| 40 |
+
},
|
| 41 |
+
"The Emperor": {
|
| 42 |
+
"keywords": "Authority, structure, leadership",
|
| 43 |
+
"description": "A stern figure seated on a throne decorated with rams",
|
| 44 |
+
"upright": "Authority, structure, control, fatherhood",
|
| 45 |
+
"reversed": "Tyranny, rigidity, lack of discipline",
|
| 46 |
+
"advice": "Take charge and establish order",
|
| 47 |
+
"color": "Red",
|
| 48 |
+
"symbols": "Rams, ankh, orb"
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
def get_random_cards(num_cards):
|
| 52 |
+
cards = list(tarot_data.keys())
|
| 53 |
+
return random.sample(cards, min(num_cards, len(cards)))
|
| 54 |
+
def format_reading(card_name):
|
| 55 |
+
card = tarot_data[card_name]
|
| 56 |
+
reading = (
|
| 57 |
+
f"๐ด {card_name}\n\n"
|
| 58 |
+
f"๐ Description: {card['description']}\n\n"
|
| 59 |
+
f"โจ Keywords: {card['keywords']}\n\n"
|
| 60 |
+
f"๐ฎ Upright: {card['upright']}\n"
|
| 61 |
+
f"๐ Reversed: {card['reversed']}\n\n"
|
| 62 |
+
f"โก Advice: {card['advice']}\n\n"
|
| 63 |
+
f"๐จ Color Energy: {card['color']}\n"
|
| 64 |
+
f"๐ซ Key Symbols: {card['symbols']}\n"
|
| 65 |
+
f"-------------------\n\n"
|
| 66 |
+
)
|
| 67 |
+
return reading
|
| 68 |
+
def tarot_reading(question, num_cards):
|
| 69 |
+
if not question:
|
| 70 |
+
return "Please ask a question for your reading."
|
| 71 |
+
selected_cards = get_random_cards(num_cards)
|
| 72 |
+
response = f"๐ฎ Reading for your question: {question}\n\n"
|
| 73 |
+
response += "โจ The cards have revealed:\n\n"
|
| 74 |
+
for i, card in enumerate(selected_cards, 1):
|
| 75 |
+
response += f"Card {i}:\n{format_reading(card)}"
|
| 76 |
+
response += "\n๐ Final Guidance: Trust in the wisdom of the cards and follow your intuition."
|
| 77 |
+
return response
|
| 78 |
+
interface = gr.Interface(
|
| 79 |
+
fn=tarot_reading,
|
| 80 |
+
inputs=[
|
| 81 |
+
gr.Textbox(label="What question would you like to ask the cards?", placeholder="Enter your question here..."),
|
| 82 |
+
gr.Slider(minimum=1, maximum=5, value=3, step=1, label="Number of cards (1-5)")
|
| 83 |
+
],
|
| 84 |
+
outputs=gr.Textbox(label="Your Tarot Reading", lines=20),
|
| 85 |
+
title="๐ฎ Mystic Tarot Reading",
|
| 86 |
+
theme=gr.themes.Soft(),
|
| 87 |
+
css=".gradio-container {background-color: #2D3250;} .gradio-interface {border-radius: 15px; padding: 20px;}"
|
| 88 |
+
)
|
| 89 |
+
interface.launch()
|
| 90 |
+
|
| 91 |
+
if __name__ == '__main__':
|
| 92 |
+
demo.launch()
|