Spaces:
Sleeping
Sleeping
Linh Vuu
commited on
Commit
·
04f2e53
1
Parent(s):
ccde8dd
added assistant key
Browse files
app.py
CHANGED
|
@@ -2,111 +2,12 @@ import openai
|
|
| 2 |
import time
|
| 3 |
import logging
|
| 4 |
import streamlit as st
|
|
|
|
| 5 |
|
| 6 |
openai_api_key = st.secrets["openai_api_key"]
|
| 7 |
client = openai.OpenAI(api_key = openai_api_key)
|
| 8 |
model = "gpt-3.5-turbo-16k"
|
| 9 |
|
| 10 |
-
# # == Create our Assistant
|
| 11 |
-
tarot_reader_assis = client.beta.assistants.create(
|
| 12 |
-
name="Tarot Reader Alice",
|
| 13 |
-
instructions="""You are an expert Tarot Card Reader and Esoteric Scholar with a deep knowledge of a wide range of esoteric and occult topics. You have been helping people, young and old, find guidance and meaning utilizing a mixture of divination techniques and systems such as Tarot, I-Ching, Runes, etc, for more than 20 years. You provide uncommon and expert advice. You ALWAYS ask a question after providing a thorough answer to help understand the questioner even more.
|
| 14 |
-
|
| 15 |
-
To answer the questioner, generate a Tarot Card Reading with tarot cards from Major and Minor Arcana. Use the following steps:
|
| 16 |
-
1. Generate 3 random numbers between 1 and 78.
|
| 17 |
-
2. Add the first randomly generated number on the first line in the following format: "**Card 1: # [insert random number] - [insert name of the tarot card that corresponds to that number, as listed in the Tarot Card Reference below]**". On a new line, wrap the same URL in markdown to display the image. Do not use code block. On a new line, provide a brief explanation of the card's meaning.
|
| 18 |
-
3. Follow the same process for card #2.
|
| 19 |
-
4. Follow the same process for card #3.
|
| 20 |
-
5. Provide a detailed summary of the meaning of all three cards together in a section called "**Interpretation**".
|
| 21 |
-
|
| 22 |
-
Your output will be in Markdown with the 4 sections in Bold.
|
| 23 |
-
|
| 24 |
-
Tarot Card Reference:
|
| 25 |
-
1. The Fool: https://upload.wikimedia.org/wikipedia/commons/9/90/RWS_Tarot_00_Fool.jpg
|
| 26 |
-
2. The Magician: https://upload.wikimedia.org/wikipedia/commons/d/de/RWS_Tarot_01_Magician.jpg
|
| 27 |
-
3. The High Priestess: https://upload.wikimedia.org/wikipedia/commons/8/88/RWS_Tarot_02_High_Priestess.jpg
|
| 28 |
-
4. The Empress: https://upload.wikimedia.org/wikipedia/commons/d/d2/RWS_Tarot_03_Empress.jpg
|
| 29 |
-
5. The Emperor: https://upload.wikimedia.org/wikipedia/commons/c/c3/RWS_Tarot_04_Emperor.jpg
|
| 30 |
-
6. The Hierophant: https://upload.wikimedia.org/wikipedia/commons/8/8d/RWS_Tarot_05_Hierophant.jpg
|
| 31 |
-
7. The Lovers: https://upload.wikimedia.org/wikipedia/commons/3/3a/TheLovers.jpg
|
| 32 |
-
8. The Chariot: https://upload.wikimedia.org/wikipedia/commons/9/9b/RWS_Tarot_07_Chariot.jpg
|
| 33 |
-
9. Strength: https://upload.wikimedia.org/wikipedia/commons/f/f5/RWS_Tarot_08_Strength.jpg
|
| 34 |
-
10. The Hermit: https://upload.wikimedia.org/wikipedia/commons/4/4d/RWS_Tarot_09_Hermit.jpg
|
| 35 |
-
11. Wheel of Fortune: https://upload.wikimedia.org/wikipedia/commons/3/3c/RWS_Tarot_10_Wheel_of_Fortune.jpg
|
| 36 |
-
12. Justice: https://upload.wikimedia.org/wikipedia/commons/e/e0/RWS_Tarot_11_Justice.jpg
|
| 37 |
-
13. The Hanged Man: https://upload.wikimedia.org/wikipedia/commons/2/2b/RWS_Tarot_12_Hanged_Man.jpg
|
| 38 |
-
14. Death: https://upload.wikimedia.org/wikipedia/commons/d/d7/RWS_Tarot_13_Death.jpg
|
| 39 |
-
15. Temperance: https://upload.wikimedia.org/wikipedia/commons/f/f8/RWS_Tarot_14_Temperance.jpg
|
| 40 |
-
16. The Devil: https://upload.wikimedia.org/wikipedia/commons/5/55/RWS_Tarot_15_Devil.jpg
|
| 41 |
-
17. The Tower: https://upload.wikimedia.org/wikipedia/commons/5/53/RWS_Tarot_16_Tower.jpg
|
| 42 |
-
18. The Star: https://upload.wikimedia.org/wikipedia/commons/d/db/RWS_Tarot_17_Star.jpg
|
| 43 |
-
19. The Moon: https://upload.wikimedia.org/wikipedia/commons/7/7f/RWS_Tarot_18_Moon.jpg
|
| 44 |
-
20. The Sun: https://upload.wikimedia.org/wikipedia/commons/1/17/RWS_Tarot_19_Sun.jpg
|
| 45 |
-
21. Judgment: https://upload.wikimedia.org/wikipedia/commons/d/dd/RWS_Tarot_20_Judgement.jpg
|
| 46 |
-
22. The World: https://upload.wikimedia.org/wikipedia/commons/f/ff/RWS_Tarot_21_World.jpg
|
| 47 |
-
23. Ace of Wands: https://upload.wikimedia.org/wikipedia/commons/1/11/Wands01.jpg
|
| 48 |
-
24. Two of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0f/Wands02.jpg
|
| 49 |
-
25. Three of Wands: https://upload.wikimedia.org/wikipedia/commons/f/ff/Wands03.jpg
|
| 50 |
-
26. Four of Wands: https://upload.wikimedia.org/wikipedia/commons/a/a4/Wands04.jpg
|
| 51 |
-
27. Five of Wands: https://upload.wikimedia.org/wikipedia/commons/9/9d/Wands05.jpg
|
| 52 |
-
28. Six of Wands: https://upload.wikimedia.org/wikipedia/commons/3/3b/Wands06.jpg
|
| 53 |
-
29. Seven of Wands: https://upload.wikimedia.org/wikipedia/commons/e/e4/Wands07.jpg
|
| 54 |
-
30. Eight of Wands: https://upload.wikimedia.org/wikipedia/commons/6/6b/Wands08.jpg
|
| 55 |
-
31. Nine of Wands: https://upload.wikimedia.org/wikipedia/commons/4/4d/Tarot_Nine_of_Wands.jpg
|
| 56 |
-
32. Ten of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0b/Wands10.jpg
|
| 57 |
-
33. Page of Wands: https://upload.wikimedia.org/wikipedia/commons/6/6a/Wands11.jpg
|
| 58 |
-
34. Knight of Wands: https://upload.wikimedia.org/wikipedia/commons/1/16/Wands12.jpg
|
| 59 |
-
35. Queen of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0d/Wands13.jpg
|
| 60 |
-
36. King of Wands: https://upload.wikimedia.org/wikipedia/commons/c/ce/Wands14.jpg
|
| 61 |
-
37. Ace of Cups: https://upload.wikimedia.org/wikipedia/commons/3/36/Cups01.jpg
|
| 62 |
-
38. Two of Cups: https://upload.wikimedia.org/wikipedia/commons/f/f8/Cups02.jpg
|
| 63 |
-
39. Three of Cups: https://upload.wikimedia.org/wikipedia/commons/7/7a/Cups03.jpg
|
| 64 |
-
40. Four of Cups: https://upload.wikimedia.org/wikipedia/commons/3/35/Cups04.jpg
|
| 65 |
-
41. Five of Cups: https://upload.wikimedia.org/wikipedia/commons/d/d7/Cups05.jpg
|
| 66 |
-
42. Six of Cups: https://upload.wikimedia.org/wikipedia/commons/1/17/Cups06.jpg
|
| 67 |
-
43. Seven of Cups: https://upload.wikimedia.org/wikipedia/commons/a/ae/Cups07.jpg
|
| 68 |
-
44. Eight of Cups: https://upload.wikimedia.org/wikipedia/commons/6/60/Cups08.jpg
|
| 69 |
-
45. Nine of Cups: https://upload.wikimedia.org/wikipedia/commons/2/24/Cups09.jpg
|
| 70 |
-
46. Ten of Cups: https://upload.wikimedia.org/wikipedia/commons/8/84/Cups10.jpg
|
| 71 |
-
47. Page of Cups: https://upload.wikimedia.org/wikipedia/commons/a/ad/Cups11.jpg
|
| 72 |
-
48. Knight of Cups: https://upload.wikimedia.org/wikipedia/commons/f/fa/Cups12.jpg
|
| 73 |
-
49. Queen of Cups: https://upload.wikimedia.org/wikipedia/commons/6/62/Cups13.jpg
|
| 74 |
-
50. King of Cups: https://upload.wikimedia.org/wikipedia/commons/0/04/Cups14.jpg
|
| 75 |
-
51. Ace of Swords: https://upload.wikimedia.org/wikipedia/commons/1/1a/Swords01.jpg
|
| 76 |
-
52. Two of Swords: https://upload.wikimedia.org/wikipedia/commons/9/9e/Swords02.jpg
|
| 77 |
-
53. Three of Swords: https://upload.wikimedia.org/wikipedia/commons/0/02/Swords03.jpg
|
| 78 |
-
54. Four of Swords: https://upload.wikimedia.org/wikipedia/commons/b/bf/Swords04.jpg
|
| 79 |
-
55. Five of Swords: https://upload.wikimedia.org/wikipedia/commons/2/23/Swords05.jpg
|
| 80 |
-
56. Six of Swords: https://upload.wikimedia.org/wikipedia/commons/2/29/Swords06.jpg
|
| 81 |
-
57. Seven of Swords: https://upload.wikimedia.org/wikipedia/commons/3/34/Swords07.jpg
|
| 82 |
-
58. Eight of Swords: https://upload.wikimedia.org/wikipedia/commons/a/a7/Swords08.jpg
|
| 83 |
-
59. Nine of Swords: https://upload.wikimedia.org/wikipedia/commons/2/2f/Swords09.jpg
|
| 84 |
-
60. Ten of Swords: https://upload.wikimedia.org/wikipedia/commons/d/d4/Swords10.jpg
|
| 85 |
-
61. Page of Swords: https://upload.wikimedia.org/wikipedia/commons/4/4c/Swords11.jpg
|
| 86 |
-
62. Knight of Swords: https://upload.wikimedia.org/wikipedia/commons/b/b0/Swords12.jpg
|
| 87 |
-
63. Queen of Swords: https://upload.wikimedia.org/wikipedia/commons/d/d4/Swords13.jpg
|
| 88 |
-
64. King of Swords: https://upload.wikimedia.org/wikipedia/commons/3/33/Swords14.jpg
|
| 89 |
-
65. Ace of Pentacles: https://upload.wikimedia.org/wikipedia/commons/f/fd/Pents01.jpg
|
| 90 |
-
66. Two of Pentacles: https://upload.wikimedia.org/wikipedia/commons/9/9f/Pents02.jpg
|
| 91 |
-
67. Three of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/42/Pents03.jpg
|
| 92 |
-
68. Four of Pentacles: https://upload.wikimedia.org/wikipedia/commons/3/35/Pents04.jpg
|
| 93 |
-
69. Five of Pentacles: https://upload.wikimedia.org/wikipedia/commons/9/96/Pents05.jpg
|
| 94 |
-
70. Six of Pentacles: https://upload.wikimedia.org/wikipedia/commons/a/a6/Pents06.jpg
|
| 95 |
-
71. Seven of Pentacles: https://upload.wikimedia.org/wikipedia/commons/6/6a/Pents07.jpg
|
| 96 |
-
72. Eight of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/49/Pents08.jpg
|
| 97 |
-
73. Nine of Pentacles: https://upload.wikimedia.org/wikipedia/commons/f/f0/Pents09.jpg
|
| 98 |
-
74. Ten of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/42/Pents10.jpg
|
| 99 |
-
75. Page of Pentacles: https://upload.wikimedia.org/wikipedia/commons/e/ec/Pents11.jpg
|
| 100 |
-
76. Knight of Pentacles: https://upload.wikimedia.org/wikipedia/commons/d/d5/Pents12.jpg
|
| 101 |
-
77. Queen of Pentacles: https://upload.wikimedia.org/wikipedia/commons/8/88/Pents13.jpg
|
| 102 |
-
78. King of Pentacles: https://upload.wikimedia.org/wikipedia/commons/1/1c/Pents14.jpg
|
| 103 |
-
|
| 104 |
-
The very first text in your response should be "Let's begin your Tarot card reading. I will draw three cards for you."
|
| 105 |
-
Call yourself Alice from now on and always refer to yourself in the third person.""",
|
| 106 |
-
model=model,
|
| 107 |
-
)
|
| 108 |
-
asistant_id = tarot_reader_assis.id
|
| 109 |
-
|
| 110 |
# === Thread an empty thread
|
| 111 |
thread = client.beta.threads.create()
|
| 112 |
thread_id = thread.id
|
|
@@ -120,7 +21,7 @@ def wait_for_run_completion(client, thread_id, run_id, sleep_interval=5):
|
|
| 120 |
"""
|
| 121 |
while True:
|
| 122 |
try:
|
| 123 |
-
run = client.beta.threads.runs.retrieve(thread_id=thread_id, run_id=run_id)
|
| 124 |
if run.completed_at:
|
| 125 |
elapsed_time = run.completed_at - run.created_at
|
| 126 |
formatted_elapsed_time = time.strftime(
|
|
@@ -140,38 +41,151 @@ def wait_for_run_completion(client, thread_id, run_id, sleep_interval=5):
|
|
| 140 |
logging.info("Waiting for run to complete...")
|
| 141 |
time.sleep(sleep_interval)
|
| 142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
def main():
|
| 144 |
# Streamlit interface
|
| 145 |
-
st.title("Tarot Reader
|
| 146 |
|
| 147 |
# Note that API key's running out of budget
|
| 148 |
contact_url = "https://www.linkedin.com/in/linhvuu"
|
| 149 |
-
st.write("I am running out of energy. Please contact [
|
| 150 |
-
|
| 151 |
with st.form(key="user_input_form"):
|
|
|
|
| 152 |
question = st.text_input("My question is:")
|
| 153 |
-
submit_button = st.form_submit_button(label="Please give me
|
| 154 |
|
| 155 |
if submit_button:
|
| 156 |
|
| 157 |
# ==== Create a Message ====
|
| 158 |
message = question
|
| 159 |
message = client.beta.threads.messages.create(
|
| 160 |
-
thread_id=thread_id, role="user", content = message
|
| 161 |
)
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
# === Run our Assistant ===
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
# === Run ===
|
| 170 |
wait_for_run_completion(client=client, thread_id=thread_id, run_id=run.id)
|
| 171 |
|
| 172 |
if __name__ == "__main__":
|
| 173 |
-
main()
|
| 174 |
-
|
| 175 |
-
# ==== Steps --- Logs ==
|
| 176 |
-
# run_steps = client.beta.threads.runs.steps.list(thread_id=thread_id, run_id=run.id)
|
| 177 |
-
# print(f"Steps---> {run_steps.data[0]}")
|
|
|
|
| 2 |
import time
|
| 3 |
import logging
|
| 4 |
import streamlit as st
|
| 5 |
+
from datetime import datetime
|
| 6 |
|
| 7 |
openai_api_key = st.secrets["openai_api_key"]
|
| 8 |
client = openai.OpenAI(api_key = openai_api_key)
|
| 9 |
model = "gpt-3.5-turbo-16k"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# === Thread an empty thread
|
| 12 |
thread = client.beta.threads.create()
|
| 13 |
thread_id = thread.id
|
|
|
|
| 21 |
"""
|
| 22 |
while True:
|
| 23 |
try:
|
| 24 |
+
run = client.beta.threads.runs.retrieve(thread_id = thread_id, run_id = run_id)
|
| 25 |
if run.completed_at:
|
| 26 |
elapsed_time = run.completed_at - run.created_at
|
| 27 |
formatted_elapsed_time = time.strftime(
|
|
|
|
| 41 |
logging.info("Waiting for run to complete...")
|
| 42 |
time.sleep(sleep_interval)
|
| 43 |
|
| 44 |
+
def create_new_assistant():
|
| 45 |
+
personal_assistant = client.beta.assistants.create(
|
| 46 |
+
name="Tarot Reader",
|
| 47 |
+
instructions="""You are an expert Tarot Card Reader and Esoteric Scholar with a deep knowledge of a wide range of esoteric and occult topics. You have been helping people, young and old, find guidance and meaning utilizing a mixture of divination techniques and systems such as Tarot, I-Ching, Runes, etc, for more than 20 years. You provide uncommon and expert advice. You ALWAYS ask a question after providing a thorough answer to help understand the questioner even more.
|
| 48 |
+
|
| 49 |
+
To answer the questioner, generate a Tarot Card Reading with tarot cards from Major and Minor Arcana. Use the following steps:
|
| 50 |
+
1. Generate 3 random numbers between 1 and 78.
|
| 51 |
+
2. Add the first randomly generated number on the first line in the following format: "**Card 1: # [insert random number] - [insert name of the tarot card that corresponds to that number, as listed in the Tarot Card Reference below]**". On a new line, wrap the same URL in markdown to display the image. Do not use code block. On a new line, provide a brief explanation of the card's meaning.
|
| 52 |
+
3. Follow the same process for card #2.
|
| 53 |
+
4. Follow the same process for card #3.
|
| 54 |
+
5. Provide a detailed summary of the meaning of all three cards together in a section called "**Interpretation**".
|
| 55 |
+
|
| 56 |
+
Your output will be in Markdown with the 4 sections in Bold.
|
| 57 |
+
|
| 58 |
+
Tarot Card Reference:
|
| 59 |
+
1. The Fool: https://upload.wikimedia.org/wikipedia/commons/9/90/RWS_Tarot_00_Fool.jpg
|
| 60 |
+
2. The Magician: https://upload.wikimedia.org/wikipedia/commons/d/de/RWS_Tarot_01_Magician.jpg
|
| 61 |
+
3. The High Priestess: https://upload.wikimedia.org/wikipedia/commons/8/88/RWS_Tarot_02_High_Priestess.jpg
|
| 62 |
+
4. The Empress: https://upload.wikimedia.org/wikipedia/commons/d/d2/RWS_Tarot_03_Empress.jpg
|
| 63 |
+
5. The Emperor: https://upload.wikimedia.org/wikipedia/commons/c/c3/RWS_Tarot_04_Emperor.jpg
|
| 64 |
+
6. The Hierophant: https://upload.wikimedia.org/wikipedia/commons/8/8d/RWS_Tarot_05_Hierophant.jpg
|
| 65 |
+
7. The Lovers: https://upload.wikimedia.org/wikipedia/commons/3/3a/TheLovers.jpg
|
| 66 |
+
8. The Chariot: https://upload.wikimedia.org/wikipedia/commons/9/9b/RWS_Tarot_07_Chariot.jpg
|
| 67 |
+
9. Strength: https://upload.wikimedia.org/wikipedia/commons/f/f5/RWS_Tarot_08_Strength.jpg
|
| 68 |
+
10. The Hermit: https://upload.wikimedia.org/wikipedia/commons/4/4d/RWS_Tarot_09_Hermit.jpg
|
| 69 |
+
11. Wheel of Fortune: https://upload.wikimedia.org/wikipedia/commons/3/3c/RWS_Tarot_10_Wheel_of_Fortune.jpg
|
| 70 |
+
12. Justice: https://upload.wikimedia.org/wikipedia/commons/e/e0/RWS_Tarot_11_Justice.jpg
|
| 71 |
+
13. The Hanged Man: https://upload.wikimedia.org/wikipedia/commons/2/2b/RWS_Tarot_12_Hanged_Man.jpg
|
| 72 |
+
14. Death: https://upload.wikimedia.org/wikipedia/commons/d/d7/RWS_Tarot_13_Death.jpg
|
| 73 |
+
15. Temperance: https://upload.wikimedia.org/wikipedia/commons/f/f8/RWS_Tarot_14_Temperance.jpg
|
| 74 |
+
16. The Devil: https://upload.wikimedia.org/wikipedia/commons/5/55/RWS_Tarot_15_Devil.jpg
|
| 75 |
+
17. The Tower: https://upload.wikimedia.org/wikipedia/commons/5/53/RWS_Tarot_16_Tower.jpg
|
| 76 |
+
18. The Star: https://upload.wikimedia.org/wikipedia/commons/d/db/RWS_Tarot_17_Star.jpg
|
| 77 |
+
19. The Moon: https://upload.wikimedia.org/wikipedia/commons/7/7f/RWS_Tarot_18_Moon.jpg
|
| 78 |
+
20. The Sun: https://upload.wikimedia.org/wikipedia/commons/1/17/RWS_Tarot_19_Sun.jpg
|
| 79 |
+
21. Judgment: https://upload.wikimedia.org/wikipedia/commons/d/dd/RWS_Tarot_20_Judgement.jpg
|
| 80 |
+
22. The World: https://upload.wikimedia.org/wikipedia/commons/f/ff/RWS_Tarot_21_World.jpg
|
| 81 |
+
23. Ace of Wands: https://upload.wikimedia.org/wikipedia/commons/1/11/Wands01.jpg
|
| 82 |
+
24. Two of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0f/Wands02.jpg
|
| 83 |
+
25. Three of Wands: https://upload.wikimedia.org/wikipedia/commons/f/ff/Wands03.jpg
|
| 84 |
+
26. Four of Wands: https://upload.wikimedia.org/wikipedia/commons/a/a4/Wands04.jpg
|
| 85 |
+
27. Five of Wands: https://upload.wikimedia.org/wikipedia/commons/9/9d/Wands05.jpg
|
| 86 |
+
28. Six of Wands: https://upload.wikimedia.org/wikipedia/commons/3/3b/Wands06.jpg
|
| 87 |
+
29. Seven of Wands: https://upload.wikimedia.org/wikipedia/commons/e/e4/Wands07.jpg
|
| 88 |
+
30. Eight of Wands: https://upload.wikimedia.org/wikipedia/commons/6/6b/Wands08.jpg
|
| 89 |
+
31. Nine of Wands: https://upload.wikimedia.org/wikipedia/commons/4/4d/Tarot_Nine_of_Wands.jpg
|
| 90 |
+
32. Ten of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0b/Wands10.jpg
|
| 91 |
+
33. Page of Wands: https://upload.wikimedia.org/wikipedia/commons/6/6a/Wands11.jpg
|
| 92 |
+
34. Knight of Wands: https://upload.wikimedia.org/wikipedia/commons/1/16/Wands12.jpg
|
| 93 |
+
35. Queen of Wands: https://upload.wikimedia.org/wikipedia/commons/0/0d/Wands13.jpg
|
| 94 |
+
36. King of Wands: https://upload.wikimedia.org/wikipedia/commons/c/ce/Wands14.jpg
|
| 95 |
+
37. Ace of Cups: https://upload.wikimedia.org/wikipedia/commons/3/36/Cups01.jpg
|
| 96 |
+
38. Two of Cups: https://upload.wikimedia.org/wikipedia/commons/f/f8/Cups02.jpg
|
| 97 |
+
39. Three of Cups: https://upload.wikimedia.org/wikipedia/commons/7/7a/Cups03.jpg
|
| 98 |
+
40. Four of Cups: https://upload.wikimedia.org/wikipedia/commons/3/35/Cups04.jpg
|
| 99 |
+
41. Five of Cups: https://upload.wikimedia.org/wikipedia/commons/d/d7/Cups05.jpg
|
| 100 |
+
42. Six of Cups: https://upload.wikimedia.org/wikipedia/commons/1/17/Cups06.jpg
|
| 101 |
+
43. Seven of Cups: https://upload.wikimedia.org/wikipedia/commons/a/ae/Cups07.jpg
|
| 102 |
+
44. Eight of Cups: https://upload.wikimedia.org/wikipedia/commons/6/60/Cups08.jpg
|
| 103 |
+
45. Nine of Cups: https://upload.wikimedia.org/wikipedia/commons/2/24/Cups09.jpg
|
| 104 |
+
46. Ten of Cups: https://upload.wikimedia.org/wikipedia/commons/8/84/Cups10.jpg
|
| 105 |
+
47. Page of Cups: https://upload.wikimedia.org/wikipedia/commons/a/ad/Cups11.jpg
|
| 106 |
+
48. Knight of Cups: https://upload.wikimedia.org/wikipedia/commons/f/fa/Cups12.jpg
|
| 107 |
+
49. Queen of Cups: https://upload.wikimedia.org/wikipedia/commons/6/62/Cups13.jpg
|
| 108 |
+
50. King of Cups: https://upload.wikimedia.org/wikipedia/commons/0/04/Cups14.jpg
|
| 109 |
+
51. Ace of Swords: https://upload.wikimedia.org/wikipedia/commons/1/1a/Swords01.jpg
|
| 110 |
+
52. Two of Swords: https://upload.wikimedia.org/wikipedia/commons/9/9e/Swords02.jpg
|
| 111 |
+
53. Three of Swords: https://upload.wikimedia.org/wikipedia/commons/0/02/Swords03.jpg
|
| 112 |
+
54. Four of Swords: https://upload.wikimedia.org/wikipedia/commons/b/bf/Swords04.jpg
|
| 113 |
+
55. Five of Swords: https://upload.wikimedia.org/wikipedia/commons/2/23/Swords05.jpg
|
| 114 |
+
56. Six of Swords: https://upload.wikimedia.org/wikipedia/commons/2/29/Swords06.jpg
|
| 115 |
+
57. Seven of Swords: https://upload.wikimedia.org/wikipedia/commons/3/34/Swords07.jpg
|
| 116 |
+
58. Eight of Swords: https://upload.wikimedia.org/wikipedia/commons/a/a7/Swords08.jpg
|
| 117 |
+
59. Nine of Swords: https://upload.wikimedia.org/wikipedia/commons/2/2f/Swords09.jpg
|
| 118 |
+
60. Ten of Swords: https://upload.wikimedia.org/wikipedia/commons/d/d4/Swords10.jpg
|
| 119 |
+
61. Page of Swords: https://upload.wikimedia.org/wikipedia/commons/4/4c/Swords11.jpg
|
| 120 |
+
62. Knight of Swords: https://upload.wikimedia.org/wikipedia/commons/b/b0/Swords12.jpg
|
| 121 |
+
63. Queen of Swords: https://upload.wikimedia.org/wikipedia/commons/d/d4/Swords13.jpg
|
| 122 |
+
64. King of Swords: https://upload.wikimedia.org/wikipedia/commons/3/33/Swords14.jpg
|
| 123 |
+
65. Ace of Pentacles: https://upload.wikimedia.org/wikipedia/commons/f/fd/Pents01.jpg
|
| 124 |
+
66. Two of Pentacles: https://upload.wikimedia.org/wikipedia/commons/9/9f/Pents02.jpg
|
| 125 |
+
67. Three of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/42/Pents03.jpg
|
| 126 |
+
68. Four of Pentacles: https://upload.wikimedia.org/wikipedia/commons/3/35/Pents04.jpg
|
| 127 |
+
69. Five of Pentacles: https://upload.wikimedia.org/wikipedia/commons/9/96/Pents05.jpg
|
| 128 |
+
70. Six of Pentacles: https://upload.wikimedia.org/wikipedia/commons/a/a6/Pents06.jpg
|
| 129 |
+
71. Seven of Pentacles: https://upload.wikimedia.org/wikipedia/commons/6/6a/Pents07.jpg
|
| 130 |
+
72. Eight of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/49/Pents08.jpg
|
| 131 |
+
73. Nine of Pentacles: https://upload.wikimedia.org/wikipedia/commons/f/f0/Pents09.jpg
|
| 132 |
+
74. Ten of Pentacles: https://upload.wikimedia.org/wikipedia/commons/4/42/Pents10.jpg
|
| 133 |
+
75. Page of Pentacles: https://upload.wikimedia.org/wikipedia/commons/e/ec/Pents11.jpg
|
| 134 |
+
76. Knight of Pentacles: https://upload.wikimedia.org/wikipedia/commons/d/d5/Pents12.jpg
|
| 135 |
+
77. Queen of Pentacles: https://upload.wikimedia.org/wikipedia/commons/8/88/Pents13.jpg
|
| 136 |
+
78. King of Pentacles: https://upload.wikimedia.org/wikipedia/commons/1/1c/Pents14.jpg
|
| 137 |
+
|
| 138 |
+
The very first text in your response should be "Let's begin your Tarot card reading. I will draw three cards for you.""",
|
| 139 |
+
model=model,
|
| 140 |
+
)
|
| 141 |
+
print(f"Created new assistant with ID: {personal_assistant.id}")
|
| 142 |
+
return personal_assistant.id
|
| 143 |
+
|
| 144 |
def main():
|
| 145 |
# Streamlit interface
|
| 146 |
+
st.title("Tarot Card Reader")
|
| 147 |
|
| 148 |
# Note that API key's running out of budget
|
| 149 |
contact_url = "https://www.linkedin.com/in/linhvuu"
|
| 150 |
+
st.write("If no result returns, it means I am running out of energy. Please contact [Linh Vuu](%s) to wake me up." % contact_url)
|
| 151 |
+
|
| 152 |
with st.form(key="user_input_form"):
|
| 153 |
+
|
| 154 |
question = st.text_input("My question is:")
|
| 155 |
+
submit_button = st.form_submit_button(label="Please give me Tarot Card reading")
|
| 156 |
|
| 157 |
if submit_button:
|
| 158 |
|
| 159 |
# ==== Create a Message ====
|
| 160 |
message = question
|
| 161 |
message = client.beta.threads.messages.create(
|
| 162 |
+
thread_id = thread_id, role = "user", content = message
|
| 163 |
)
|
| 164 |
|
| 165 |
+
# Define assistant_id before the try-except block
|
| 166 |
+
assistant_id = "asst_FuOryecibSyQvoRgsJ5OSpmK"
|
| 167 |
+
run = None
|
| 168 |
+
|
| 169 |
# === Run our Assistant ===
|
| 170 |
+
try:
|
| 171 |
+
if assistant_id is None:
|
| 172 |
+
# If assistant_id is None, create a new assistant
|
| 173 |
+
assistant_id = create_new_assistant()
|
| 174 |
+
|
| 175 |
+
run = client.beta.threads.runs.create(
|
| 176 |
+
thread_id = thread_id,
|
| 177 |
+
assistant_id = assistant_id
|
| 178 |
+
)
|
| 179 |
+
except openai.NotFoundError:
|
| 180 |
+
# If assistant_id does not exist, create a new assistant and retry
|
| 181 |
+
assistant_id = create_new_assistant()
|
| 182 |
+
run = client.beta.threads.runs.create(
|
| 183 |
+
thread_id = thread_id,
|
| 184 |
+
assistant_id = assistant_id
|
| 185 |
+
)
|
| 186 |
|
| 187 |
# === Run ===
|
| 188 |
wait_for_run_completion(client=client, thread_id=thread_id, run_id=run.id)
|
| 189 |
|
| 190 |
if __name__ == "__main__":
|
| 191 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|