├── README.md └── main.py /README.md: -------------------------------------------------------------------------------- 1 | # ChatGPT-SEO-Article-Generator 2 | Making a SEO article generator using ChatGPT with StreamLit 3 | 4 | ### Step 1: Install Anaconda by downloading the latest version from the official website: 5 | https://www.anaconda.com/products/individual 6 | 7 | ### Step 2: Install the dependencies by opening your command prompt or terminal application. (Note: I used VS Code) 8 | 1. OpenAI 9 | ```bash 10 | pip install openai --user 11 | ``` 12 | 13 | 2. Streamlit 14 | ```bash 15 | pip install streamlit --user 16 | ``` 17 | 18 | ### Step 3: Navigate to the directory where your app's code is stored using the command prompt or terminal application. 19 | 20 | ### Step 4: Run the Streamlit app by typing the following command and pressing Enter: 21 | ```bash 22 | streamlit run main.py 23 | ``` 24 | 25 | ### NOTE:- In this line of code: 26 | ```bash 27 | openai.api_key = "Paste your api here" 28 | ``` 29 | You need your API key from ChatGPT. Do the following steps: 30 | 1. Go to https://openai.com/blog/chatgpt 31 | 2. Click the dropdown: "Developers" -> "API Reference" 32 | 3. Click the top-right icon which is your account. If not signed in, please do so to proceed to the next step. 33 | 4. Then in the dropdown of your icon, click "View API keys". 34 | 5. Create new secret key and copy-paste the API key in the above line of code. 35 | 36 | ### Output: 37 | https://user-images.githubusercontent.com/67680115/227016923-73b2d547-93d2-4bfb-a2b8-9eadc14bb590.mp4 38 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import openai 3 | 4 | openai.api_key = "Paste your api here" 5 | st.title("SEO Article Writer with ChatGPT") 6 | 7 | def generate_article(keyword, writing_style, word_count): 8 | response = openai.ChatCompletion.create( 9 | model = "gpt-3.5-turbo", 10 | messages = [ 11 | {"role":"user", "content":"Write a SEO optimized word article about" + keyword}, 12 | {"role":"user", "content":"This article should be in style" + writing_style}, 13 | {"role":"user", "content":"This article length should be" + str(word_count)} 14 | ] 15 | ) 16 | result = '' 17 | for choice in response.choices: 18 | result += choice.message.content 19 | 20 | print(result) 21 | return result 22 | # return "This is a test article generated without any API calls." 23 | 24 | keyword = st.text_input("Enter a keyword") 25 | writing_style = st.selectbox("Select a writing style", 26 | ["Narrative", "Descriptive", "Academic", "Expository", "Persuasive", "Creative", "Technical", "Journalistic"]) 27 | word_count = st.slider("Select word count", min_value=300, max_value=1000, step=100, value=300) 28 | submit_button = st.button( 29 | label="Generate Article", 30 | help="Click to generate your SEO article", 31 | key="generate_button" 32 | ) 33 | 34 | if submit_button: 35 | with st.spinner("Generating article..."): 36 | article = generate_article(keyword, writing_style, word_count) 37 | st.write(article) 38 | st.download_button( 39 | label="Download Article", 40 | data=article, 41 | file_name='Article.txt', 42 | mime='text/txt' 43 | ) --------------------------------------------------------------------------------