|
import gradio as gr |
|
import random |
|
import json |
|
tarot_data = { |
|
"The Fool": { |
|
"keywords": "New beginnings, innocence, spontaneity", |
|
"description": "A young person standing on a cliff, with a small dog at their feet", |
|
"upright": "Taking a leap of faith, being spontaneous, following your heart", |
|
"reversed": "Recklessness, foolishness, risk-taking", |
|
"advice": "Trust your instincts and take that first step", |
|
"color": "Yellow", |
|
"symbols": "White rose, mountains, dog" |
|
}, |
|
"The Magician": { |
|
"keywords": "Manifestation, resourcefulness, power", |
|
"description": "A figure with one arm raised holding a wand, symbols of all suits on table", |
|
"upright": "Power, skill, concentration, action, resourcefulness", |
|
"reversed": "Manipulation, poor planning, untapped talents", |
|
"advice": "You have all the tools - use them wisely", |
|
"color": "Red", |
|
"symbols": "Infinity sign, wand, elements" |
|
}, |
|
"The High Priestess": { |
|
"keywords": "Intuition, mystery, spirituality", |
|
"description": "A woman sitting between two pillars with a crescent moon", |
|
"upright": "Inner voice, unconscious knowledge, mystery", |
|
"reversed": "Secrets, disconnected from intuition", |
|
"advice": "Listen to your inner voice", |
|
"color": "Blue", |
|
"symbols": "Crescent moon, pillars, pomegranates" |
|
}, |
|
"The Empress": { |
|
"keywords": "Abundance, nurturing, fertility", |
|
"description": "A woman in a flowing dress surrounded by nature", |
|
"upright": "Abundance, nurturing, fertility, feminine energy", |
|
"reversed": "Creative block, neglect, nature", |
|
"advice": "Embrace your nurturing side", |
|
"color": "Green", |
|
"symbols": "Stars, flowing water, heart" |
|
}, |
|
"The Emperor": { |
|
"keywords": "Authority, structure, leadership", |
|
"description": "A stern figure seated on a throne decorated with rams", |
|
"upright": "Authority, structure, control, fatherhood", |
|
"reversed": "Tyranny, rigidity, lack of discipline", |
|
"advice": "Take charge and establish order", |
|
"color": "Red", |
|
"symbols": "Rams, ankh, orb" |
|
} |
|
} |
|
def get_random_cards(num_cards): |
|
cards = list(tarot_data.keys()) |
|
return random.sample(cards, min(num_cards, len(cards))) |
|
def format_reading(card_name): |
|
card = tarot_data[card_name] |
|
reading = ( |
|
f"๐ด {card_name}\n\n" |
|
f"๐ Description: {card['description']}\n\n" |
|
f"โจ Keywords: {card['keywords']}\n\n" |
|
f"๐ฎ Upright: {card['upright']}\n" |
|
f"๐ Reversed: {card['reversed']}\n\n" |
|
f"โก Advice: {card['advice']}\n\n" |
|
f"๐จ Color Energy: {card['color']}\n" |
|
f"๐ซ Key Symbols: {card['symbols']}\n" |
|
f"-------------------\n\n" |
|
) |
|
return reading |
|
def tarot_reading(question, num_cards): |
|
if not question: |
|
return "Please ask a question for your reading." |
|
selected_cards = get_random_cards(num_cards) |
|
response = f"๐ฎ Reading for your question: {question}\n\n" |
|
response += "โจ The cards have revealed:\n\n" |
|
for i, card in enumerate(selected_cards, 1): |
|
response += f"Card {i}:\n{format_reading(card)}" |
|
response += "\n๐ Final Guidance: Trust in the wisdom of the cards and follow your intuition." |
|
return response |
|
interface = gr.Interface( |
|
fn=tarot_reading, |
|
inputs=[ |
|
gr.Textbox(label="What question would you like to ask the cards?", placeholder="Enter your question here..."), |
|
gr.Slider(minimum=1, maximum=5, value=3, step=1, label="Number of cards (1-5)") |
|
], |
|
outputs=gr.Textbox(label="Your Tarot Reading", lines=20), |
|
title="๐ฎ Mystic Tarot Reading", |
|
theme=gr.themes.Soft(), |
|
css=".gradio-container {background-color: #2D3250;} .gradio-interface {border-radius: 15px; padding: 20px;}" |
|
) |
|
interface.launch() |
|
|
|
if __name__ == '__main__': |
|
demo.launch() |