├── README.md ├── app.py ├── blog.py ├── config.py └── index.html /README.md: -------------------------------------------------------------------------------- 1 | # AI Blog Content Generator 2 | 3 | Created an AI Blog Topic Ideas and Content Generator using OPENAI's GPT-3 and Flask for Python Web App 4 | 5 | Screenshot: 6 | 7 | ![image](https://user-images.githubusercontent.com/71244843/174126795-3022927c-d97f-4f90-a8e2-611e3c88e5c6.png) 8 | 9 | Screenshots with Generated Content: 10 | 11 | ![image](https://user-images.githubusercontent.com/71244843/174127321-37fcdd3a-264b-468d-ad8c-34adf27a382c.png) 12 | 13 | 14 | ![image](https://user-images.githubusercontent.com/71244843/174127458-239a6674-6a93-4b6b-940d-38b979456eb7.png) 15 | 16 | 17 | ![imaga](https://user-images.githubusercontent.com/71244843/174128421-6ada8517-8b41-4c1a-9337-2fce84d882a2.png) 18 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request 2 | import config 3 | import blog 4 | 5 | 6 | def page_not_found(e): 7 | return render_template('404.html'), 404 8 | 9 | 10 | app = Flask(__name__) 11 | app.config.from_object(config.config['development']) 12 | 13 | app.register_error_handler(404, page_not_found) 14 | 15 | 16 | @app.route('/', methods=["GET", "POST"]) 17 | def index(): 18 | 19 | if request.method == 'POST': 20 | if 'form1' in request.form: 21 | prompt = request.form['blogTopic'] 22 | blogT = blog.generateBlogTopics(prompt) 23 | blogTopicIdeas = blogT.replace('\n', '
') 24 | 25 | if 'form2' in request.form: 26 | prompt = request.form['blogSection'] 27 | blogT = blog.generateBlogSections(prompt) 28 | blogSectionIdeas = blogT.replace('\n', '
') 29 | 30 | if 'form3' in request.form: 31 | prompt = request.form['blogExpander'] 32 | blogT = blog.blogSectionExpander(prompt) 33 | blogExpanded = blogT.replace('\n', '
') 34 | 35 | 36 | return render_template('index.html', **locals()) 37 | 38 | 39 | if __name__ == '__main__': 40 | app.run(host='0.0.0.0', port='8888', debug=True) -------------------------------------------------------------------------------- /blog.py: -------------------------------------------------------------------------------- 1 | import os 2 | import openai 3 | import config 4 | openai.api_key = config.OPENAI_API_KEY 5 | 6 | def generateBlogTopics(prompt1): 7 | response = openai.Completion.create( 8 | engine="davinci-instruct-beta-v3", 9 | prompt="Generate blog topics on: {}. \n \n 1. ".format(prompt1), 10 | temperature=0.7, 11 | max_tokens=100, 12 | top_p=1, 13 | frequency_penalty=0, 14 | presence_penalty=0 15 | ) 16 | 17 | return response['choices'][0]['text'] 18 | 19 | def generateBlogSections(prompt1): 20 | response = openai.Completion.create( 21 | engine="davinci-instruct-beta-v3", 22 | prompt="Expand the blog title in to high level blog sections: {} \n\n- Introduction: ".format(prompt1), 23 | temperature=0.6, 24 | max_tokens=100, 25 | top_p=1, 26 | frequency_penalty=0, 27 | presence_penalty=0 28 | ) 29 | 30 | return response['choices'][0]['text'] 31 | 32 | 33 | def blogSectionExpander(prompt1): 34 | response = openai.Completion.create( 35 | engine="davinci-instruct-beta-v3", 36 | prompt="Expand the blog section in to a detailed professional , witty and clever explanation.\n\n {}".format(prompt1), 37 | temperature=0.7, 38 | max_tokens=200, 39 | top_p=1, 40 | frequency_penalty=0, 41 | presence_penalty=0 42 | ) 43 | 44 | return response['choices'][0]['text'] -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | OPENAI_API_KEY = '' 2 | 3 | class Config(object): 4 | DEBUG = True 5 | TESTING =False 6 | 7 | class DevelopmentConfig(Config): 8 | SECRET_KEY = "this-is-my-api" 9 | 10 | config = { 11 | 'development': DevelopmentConfig, 12 | 'testing': DevelopmentConfig, 13 | 'production': DevelopmentConfig 14 | 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | AI Content Gen 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |

AI Blog Writing Tool

19 | 20 |

This AI Blog Content Generator will allow you to enter a blog topic and keywords --- and get in return a full blog that you can use anywhere. The tool intiially provides a list of topic ideas to choose from, once you select a topic, you can go ahead and generate a full content AI blog.

21 | 22 |
23 |
24 |
25 |
26 | 27 | 28 |
29 | 30 | 31 | 32 |
33 |
34 | 35 |
36 | 1. {{blogTopicIdeas|safe}} 37 |
38 |
39 | 40 |
41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 | 49 | 50 |
51 | 52 | 53 | 54 |
55 |
56 | 57 |
58 | {{blogSectionIdeas|safe}} 59 |
60 |
61 | 62 |
63 |
64 |
65 | 66 |
67 |
68 |
69 |
70 | 71 | 72 |
73 | 74 | 75 | 76 |
77 |
78 | 79 |
80 | {{blogExpanded|safe}} 81 |
82 |
83 |
84 |
Made with OpenAI's GPT3 by Venkat
85 |
86 | 87 | 88 | 89 | 90 | 91 | --------------------------------------------------------------------------------