Linh Vuu commited on
Commit
ceef703
1 Parent(s): cb6f87d

added files

Browse files
Files changed (4) hide show
  1. .gitattributes copy +35 -0
  2. .gitignore +1 -0
  3. app.py +173 -0
  4. requirements.txt +1 -0
.gitattributes copy ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .streamlit
app.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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
113
+
114
+ def wait_for_run_completion(client, thread_id, run_id, sleep_interval=5):
115
+ """
116
+ Waits for a run to complete and prints the elapsed time.:param client: The OpenAI client object.
117
+ :param thread_id: The ID of the thread.
118
+ :param run_id: The ID of the run.
119
+ :param sleep_interval: Time in seconds to wait between checks.
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(
127
+ "%H:%M:%S", time.gmtime(elapsed_time)
128
+ )
129
+ print(f"Run completed in {formatted_elapsed_time}")
130
+ logging.info(f"Run completed in {formatted_elapsed_time}")
131
+ # Get messages here once Run is completed!
132
+ messages = client.beta.threads.messages.list(thread_id=thread_id)
133
+ last_message = messages.data[0]
134
+ response = last_message.content[0].text.value
135
+ st.write(response)
136
+ break
137
+ except Exception as e:
138
+ logging.error(f"An error occurred while retrieving the run: {e}")
139
+ break
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 Alice")
146
+
147
+ with st.form(key="user_input_form"):
148
+ question = st.text_input("My question is:")
149
+ submit_button = st.form_submit_button(label="Please give me a Tarot Card reading")
150
+
151
+ if submit_button:
152
+
153
+ # ==== Create a Message ====
154
+ message = question
155
+ message = client.beta.threads.messages.create(
156
+ thread_id=thread_id, role="user", content = message
157
+ )
158
+
159
+ # === Run our Assistant ===
160
+ run = client.beta.threads.runs.create(
161
+ thread_id=thread_id,
162
+ assistant_id=asistant_id
163
+ )
164
+
165
+ # === Run ===
166
+ wait_for_run_completion(client=client, thread_id=thread_id, run_id=run.id)
167
+
168
+ if __name__ == "__main__":
169
+ main()
170
+
171
+ # ==== Steps --- Logs ==
172
+ # run_steps = client.beta.threads.runs.steps.list(thread_id=thread_id, run_id=run.id)
173
+ # print(f"Steps---> {run_steps.data[0]}")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai