openfree commited on
Commit
a22942c
ยท
verified ยท
1 Parent(s): 9a2e3f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -60
app.py CHANGED
@@ -144,44 +144,9 @@ def get_reading(question, selected_cards):
144
  return result + "\n\n๐ŸŒŸ May these insights guide your path! ๐ŸŒŸ"
145
 
146
 
147
- # ... (์ด์ „ ์ฝ”๋“œ๋Š” ๋™์ผ)
148
 
149
- demo = gr.Interface(
150
- fn=get_reading,
151
- inputs=[
152
- gr.Textbox(
153
- label="๐Ÿค” What would you like to know?",
154
- placeholder="Enter your question here...",
155
- lines=3
156
- ),
157
- gr.CheckboxGroup( # CheckboxGroup์œผ๋กœ ์ˆ˜์ •
158
- choices=list(tarot_cards.keys()),
159
- label="๐ŸŽด Select Your Cards (Max 5)",
160
- info="Choose 1-5 cards for your reading"
161
- )
162
- ],
163
- outputs=gr.Textbox(
164
- label="๐Ÿ”ฎ Your Mystical Reading",
165
- lines=20
166
- ),
167
- title="โœจ Mystical Tarot Reading Experience โœจ",
168
- description="""
169
- ๐ŸŒŸ Welcome to Your Personal Tarot Journey ๐ŸŒŸ
170
-
171
- ๐ŸŽด How to Use:
172
- 1. ๐Ÿ’ญ Focus on your question
173
- 2. ๐Ÿ” Select 1-5 cards that call to you
174
- 3. ๐Ÿ“– Receive your personalized mystical reading
175
-
176
- ๐ŸŒ™ Let the ancient wisdom guide your path ๐ŸŒ™
177
- """,
178
- article="""
179
- <div style="text-align: center;">
180
- <a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-tarotcard.hf.space">
181
- <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-tarotcard.hf.space&countColor=%23263759" />
182
- </a>
183
- </div>
184
- """,
185
  theme=gr.themes.Soft(
186
  primary_hue="purple",
187
  secondary_hue="pink",
@@ -209,29 +174,71 @@ demo = gr.Interface(
209
  padding: 20px;
210
  }
211
  """
212
- )
213
-
214
- # ์นด๋“œ ์„ ํƒ ์ œํ•œ์„ ์œ„ํ•œ ํ•จ์ˆ˜ ์ˆ˜์ •
215
- def validate_selection(selected_cards):
216
- if len(selected_cards) > 5:
217
- return selected_cards[:5]
218
- return selected_cards
219
-
220
- demo.input_components[1].change(
221
- fn=validate_selection,
222
- inputs=[demo.input_components[1]],
223
- outputs=[demo.input_components[1]]
224
- )
225
-
226
-
227
-
228
- # Example questions
229
- examples = [
230
- ["What energies surround my current path? ๐Ÿ›ฃ๏ธ", ["โœจ The Fool โœจ", "๐ŸŽฏ The Magician ๐ŸŽฏ"]],
231
- ["What should I know about my love life? โค๏ธ", ["โค๏ธ The Lovers โค๏ธ", "๐ŸŒบ The Empress ๐ŸŒบ"]],
232
- ["Guide me about my career decisions ๐Ÿ’ผ", ["โš”๏ธ The Emperor โš”๏ธ", "๐ŸŽก Wheel of Fortune ๐ŸŽก"]],
233
- ["What's my spiritual lesson for this month? ๐Ÿ™", ["๐Ÿ•Š๏ธ The Hierophant ๐Ÿ•Š๏ธ", "๐Ÿฎ The Hermit ๐Ÿฎ", "โญ The Star โญ"]]
234
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  if __name__ == "__main__":
237
  demo.launch(share=True)
 
144
  return result + "\n\n๐ŸŒŸ May these insights guide your path! ๐ŸŒŸ"
145
 
146
 
147
+ # ... (์ด์ „ tarot_cards ๋”•์…”๋„ˆ๋ฆฌ์™€ get_reading ํ•จ์ˆ˜๋Š” ๋™์ผ)
148
 
149
+ with gr.Blocks(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  theme=gr.themes.Soft(
151
  primary_hue="purple",
152
  secondary_hue="pink",
 
174
  padding: 20px;
175
  }
176
  """
177
+ ) as demo:
178
+ gr.HTML("""<h1 style='text-align: center'>โœจ Mystical Tarot Reading Experience โœจ</h1>""")
179
+
180
+ gr.HTML("""
181
+ <div style='text-align: center'>
182
+ ๐ŸŒŸ Welcome to Your Personal Tarot Journey ๐ŸŒŸ<br><br>
183
+ ๐ŸŽด How to Use:<br>
184
+ 1. ๐Ÿ’ญ Focus on your question<br>
185
+ 2. ๐Ÿ” Select 1-5 cards that call to you<br>
186
+ 3. ๐Ÿ“– Receive your personalized mystical reading<br><br>
187
+ ๐ŸŒ™ Let the ancient wisdom guide your path ๐ŸŒ™
188
+ </div>
189
+ """)
190
+
191
+ with gr.Row():
192
+ with gr.Column():
193
+ question = gr.Textbox(
194
+ label="๐Ÿค” What would you like to know?",
195
+ placeholder="Enter your question here...",
196
+ lines=3
197
+ )
198
+ cards = gr.CheckboxGroup(
199
+ choices=list(tarot_cards.keys()),
200
+ label="๐ŸŽด Select Your Cards (Max 5)",
201
+ info="Choose 1-5 cards for your reading"
202
+ )
203
+ submit_btn = gr.Button("๐Ÿ”ฎ Get Your Reading", variant="primary")
204
+
205
+ with gr.Column():
206
+ output = gr.Textbox(
207
+ label="๐Ÿ”ฎ Your Mystical Reading",
208
+ lines=20
209
+ )
210
+
211
+ def validate_and_read(question, selected_cards):
212
+ if not selected_cards:
213
+ return "โš ๏ธ Please select at least one card for your reading."
214
+ if len(selected_cards) > 5:
215
+ selected_cards = selected_cards[:5]
216
+ return get_reading(question, selected_cards)
217
+
218
+ submit_btn.click(
219
+ fn=validate_and_read,
220
+ inputs=[question, cards],
221
+ outputs=output
222
+ )
223
+
224
+ # Examples
225
+ gr.Examples(
226
+ examples=[
227
+ ["What energies surround my current path? ๐Ÿ›ฃ๏ธ", ["โœจ The Fool โœจ", "๐ŸŽฏ The Magician ๐ŸŽฏ"]],
228
+ ["What should I know about my love life? โค๏ธ", ["โค๏ธ The Lovers โค๏ธ", "๐ŸŒบ The Empress ๐ŸŒบ"]],
229
+ ["Guide me about my career decisions ๐Ÿ’ผ", ["โš”๏ธ The Emperor โš”๏ธ", "๐ŸŽก Wheel of Fortune ๐ŸŽก"]],
230
+ ["What's my spiritual lesson for this month? ๐Ÿ™", ["๐Ÿ•Š๏ธ The Hierophant ๐Ÿ•Š๏ธ", "๐Ÿฎ The Hermit ๐Ÿฎ", "โญ The Star โญ"]]
231
+ ],
232
+ inputs=[question, cards]
233
+ )
234
+
235
+ gr.HTML("""
236
+ <div style="text-align: center; margin-top: 20px;">
237
+ <a href="https://visitorbadge.io/status?path=https%3A%2F%2Fopenfree-tarotcard.hf.space">
238
+ <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fopenfree-tarotcard.hf.space&countColor=%23263759" />
239
+ </a>
240
+ </div>
241
+ """)
242
 
243
  if __name__ == "__main__":
244
  demo.launch(share=True)