Spaces:
Runtime error
Runtime error
Delete main.py
Browse files
main.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import openai
|
| 3 |
-
|
| 4 |
-
openai.api_key = "OPEN_AI_API"
|
| 5 |
-
st.title("SEO Article Writer with ChatGPT")
|
| 6 |
-
|
| 7 |
-
def generate_article(keyword, writing_style, word_count):
|
| 8 |
-
#return "This is a test article generated without making API calls."
|
| 9 |
-
response = openai.ChatCompletion.create(
|
| 10 |
-
model="gpt-3.5-turbo",
|
| 11 |
-
messages=[
|
| 12 |
-
{"role": "user", "content": "Write a SEO optimized word article about " + keyword},
|
| 13 |
-
{"role": "user", "content": "The article should be " + writing_style},
|
| 14 |
-
{"role": "user", "content": "The article length should " + str(word_count)},
|
| 15 |
-
]
|
| 16 |
-
)
|
| 17 |
-
result = ''
|
| 18 |
-
for choice in response.choices:
|
| 19 |
-
result += choice.message.content
|
| 20 |
-
|
| 21 |
-
print(result)
|
| 22 |
-
return result
|
| 23 |
-
|
| 24 |
-
keyword = st.text_input("Enter a keyword:")
|
| 25 |
-
writing_style = st.selectbox("Select writing style:", ["Casual", "Informative", "Professional"])
|
| 26 |
-
word_count = st.slider("Select word count:", min_value=1000, max_value=10000, step=100, value=3000)
|
| 27 |
-
submit_button = st.button("Generate Article")
|
| 28 |
-
|
| 29 |
-
if submit_button:
|
| 30 |
-
message = st.empty()
|
| 31 |
-
message.text("Busy generating...")
|
| 32 |
-
article = generate_article(keyword, writing_style, word_count)
|
| 33 |
-
message.text("")
|
| 34 |
-
st.write(article)
|
| 35 |
-
st.download_button(
|
| 36 |
-
label="Download article",
|
| 37 |
-
data=article,
|
| 38 |
-
file_name= 'Article.txt',
|
| 39 |
-
mime='text/txt',
|
| 40 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|