Skip to content

Instantly share code, notes, and snippets.

@urfolomeus
Last active March 22, 2023 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urfolomeus/ea21c904d236511beb2aa815dc517649 to your computer and use it in GitHub Desktop.
Save urfolomeus/ea21c904d236511beb2aa815dc517649 to your computer and use it in GitHub Desktop.
"""
" 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