Skip to content

Instantly share code, notes, and snippets.

@Mediatros
Forked from skolo-online/blog.py
Created July 7, 2022 10:29
Show Gist options
  • Save Mediatros/a72ce6caecac9d4f1fca8124ba16c1c7 to your computer and use it in GitHub Desktop.
Save Mediatros/a72ce6caecac9d4f1fca8124ba16c1c7 to your computer and use it in GitHub Desktop.
AI Blog Generator Tool
import os
import openai
import config
openai.api_key = config.OPENAI_API_KEY
def generateBlogTopics(prompt1):
response = openai.Completion.create(
engine="davinci-instruct-beta-v3",
prompt="Generate blog topics on: {}. \n \n 1. ".format(prompt1),
temperature=0.7,
max_tokens=100,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response['choices'][0]['text']
def generateBlogSections(prompt1):
response = openai.Completion.create(
engine="davinci-instruct-beta-v3",
prompt="Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1),
temperature=0.6,
max_tokens=100,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response['choices'][0]['text']
def blogSectionExpander(prompt1):
response = openai.Completion.create(
engine="davinci-instruct-beta-v3",
prompt="Expand the blog section in to a detailed professional , witty and clever explanation.\n\n {}".format(prompt1),
temperature=0.7,
max_tokens=200,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response['choices'][0]['text']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment