Template request | Bug report | Generate Data Product
Tags: #openai #outline #writing #topic #structure #organize
Author: Florent Ravenel
Description: This notebook will provide an outline for writing a specific topic. An outline is a structured plan or framework that serves as a blueprint for organizing and presenting information in a clear and logical way. Outlines can be used for a variety of purposes, such as organizing an essay or research paper, preparing a speech or presentation, or planning a project.
References:
try:
import openai
except:
!pip install openai --user
import openai
import naas
api_key
: OpenAI API key, to obtain an OpenAI API key, please refer to the OpenAI Documentation.topic
: the topic to be written aboutsubtopics
: a list of subtopics related to the main topic
# Inputs
api_key = naas.secret.get(name="OPENAI_API_KEY") or "ENTER_YOUR_OPENAI_API_KEY"
topic = "OpenAI"
subtopics = "GPT-3, Reinforcement Learning, Generative Models"
prompt = f"Write an outline about '{topic}' with this subtopics '{subtopics}' and references and citations at the end."
# Outputs
file_path = f"Outline_{topic.replace(' ', '_')}.txt"
openai.api_key = api_key
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=2048,
temperature=0.5,
)
text = response['choices'][0]['text']
print(text)
text_file = open(file_path, "w")
text_file.write(text)
text_file.close()