Download make_dataset.py from HeatherFeist/QuanTarot: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/HeatherFeist/QuanTarot/resolve/main/make_dataset.py
- Command line
-
hf download hf://HeatherFeist/QuanTarot/make_dataset.py
-
curl -L -o make_dataset.py https://huggingface.co/HeatherFeist/QuanTarot/resolve/main/make_dataset.py
2.37 kB
| #!/usr/bin/python3 | |
| # This script gets tarot card readings from ChatGPT and appends them to the 'tarot_readings.csv' dataset. | |
| # Set your OpenAI key as an environment variable before running this script. | |
| import os | |
| import openai | |
| import random | |
| from csv import writer | |
| OPENAI_KEY = os.environ['OPENAI_KEY'] | |
| OPENAI_MODEL = "text-davinci-003" | |
| TAROT_CARDS = [ | |
| "The fool", | |
| "The magician", | |
| "The high priestess", | |
| "The empress", | |
| "The emperor", | |
| "The hierophant", | |
| "The lovers", | |
| "The chariot", | |
| "Strength", | |
| "The hermit", | |
| "The wheel of fortune", | |
| "Justice", | |
| "The hanged man", | |
| "Death", | |
| "Temperance", | |
| "The devil", | |
| "The tower", | |
| "The star", | |
| "The moon", | |
| "The sun", | |
| "Judgement", | |
| "The world", | |
| "Two of Cups", | |
| "Three of Cups", | |
| "Four of Cups", | |
| "Five of Cups", | |
| "Six of Cups", | |
| "Seven of Cups", | |
| "Eight of Cups", | |
| "Nine of Cups", | |
| "Ten of Cups", | |
| "Ace of Cups", | |
| "Knight of Cups", | |
| "Queen of Cups", | |
| "King of Cups", | |
| "Page of Cups", | |
| "Two of Pentacles", | |
| "Three of Pentacles", | |
| "Four of Pentacles", | |
| "Five of Pentacles", | |
| "Six of Pentacles", | |
| "Seven of Pentacles", | |
| "Eight of Pentacles", | |
| "Nine of Pentacles", | |
| "Ten of Pentacles", | |
| "Ace of Pentacles", | |
| "Knight of Pentacles", | |
| "Queen of Pentacles", | |
| "King of Pentacles", | |
| "Page of Pentacles", | |
| "Two of Wands", | |
| "Three of Wands", | |
| "Four of Wands", | |
| "Five of Wands", | |
| "Six of Wands", | |
| "Seven of Wands", | |
| "Eight of Wands", | |
| "Nine of Wands", | |
| "Ten of Wands", | |
| "Ace of Wands", | |
| "Knight of Wands", | |
| "Queen of Wands", | |
| "King of Wands", | |
| "Page of Wands", | |
| "Two of Swords", | |
| "Three of Swords", | |
| "Four of Swords", | |
| "Five of Swords", | |
| "Six of Swords", | |
| "Seven of Swords", | |
| "Eight of Swords", | |
| "Nine of Swords", | |
| "Ten of Swords", | |
| "Ace of Swords", | |
| "Knight of Swords", | |
| "Queen of Swords", | |
| "King of Swords", | |
| "Page of Swords" | |
| ] | |
| openai.api_key = OPENAI_KEY | |
| while(True): | |
| (card1, card2, card3) = random.sample(TAROT_CARDS, 3) | |
| prompt = "Give me a one paragraph tarot reading if I pull the cards {}, {} and {}.\n\nReading:\n".format(card1, card2, card3) | |
| completion = openai.Completion.create(engine=OPENAI_MODEL, prompt=prompt, max_tokens=500, top_p=1, temperature=0.7, frequency_penalty=0, presence_penalty=0) | |
| output = str(completion.choices[0].text).replace('\n','') | |
| row = [card1, card2, card3, output] | |
| print(row) | |
| with open('tarot_readings.csv', 'a') as fd: | |
| csvwriter = writer(fd) | |
| csvwriter.writerow(row) | |
| fd.close() | |