Case
January 13, 2023
0
import openai_secret_manager
# Let's setup the OpenAI API client
secrets = openai_secret_manager.get_secrets("openai")
import openai
openai.api_key = secrets["api_key"]
# Define the prompt
prompt = (f"write an article about the benefits of machine learning")
# Generate text
completions = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
# Get the generated text
message = completions.choices[0].text
print(message)