Last active
March 22, 2023 19:44
-
-
Save urfolomeus/ea21c904d236511beb2aa815dc517649 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
" Simple D&D Flavor Text Generator | |
""" | |
import openai | |
import pprint | |
# Please sign up for an OpenAI account, generate an API key and paste it below | |
# https://platform.openai.com/docs/api-reference/authentication | |
openai.api_key = "ADD VALID OPENAI API KEY HERE" | |
# prompt user for a short adventure topic, i.e. goblin bandits | |
topic = input("Enter adventure topic: ") | |
# generate flavor text | |
response = openai.Completion.create( | |
model="text-davinci-003", | |
prompt=f"Topic: {topic}\nDungeons and dragons adventure:", | |
temperature=0.8, | |
max_tokens=100, | |
top_p=1, | |
frequency_penalty=0.5, | |
presence_penalty=0, | |
) | |
# we use a pretty printer to make the output a bit easier to read | |
pp = pprint.PrettyPrinter(indent=2) | |
pp.pprint(response.choices[0].text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment