Spaces:
Runtime error
Runtime error
IamVicky111
commited on
Upload 2 files
Browse files- main.py +40 -0
- requirements.txt +57 -0
main.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import openai
|
3 |
+
|
4 |
+
openai.api_key = "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"
|
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", "Witty"])
|
26 |
+
word_count = st.slider("Select word count:", min_value=300, max_value=1000, step=100, value=300)
|
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 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.8.4
|
2 |
+
aiosignal==1.3.1
|
3 |
+
altair==4.2.2
|
4 |
+
async-timeout==4.0.2
|
5 |
+
attrs==22.2.0
|
6 |
+
blinker==1.5
|
7 |
+
cachetools==5.3.0
|
8 |
+
certifi==2023.5.7
|
9 |
+
charset-normalizer==3.1.0
|
10 |
+
click==8.1.3
|
11 |
+
decorator==5.1.1
|
12 |
+
entrypoints==0.4
|
13 |
+
frozenlist==1.3.3
|
14 |
+
gitdb==4.0.10
|
15 |
+
GitPython==3.1.31
|
16 |
+
idna==3.4
|
17 |
+
importlib-metadata==6.0.0
|
18 |
+
Jinja2==3.1.2
|
19 |
+
jsonschema==4.17.3
|
20 |
+
lxml==4.9.2
|
21 |
+
markdown-it-py==2.2.0
|
22 |
+
MarkupSafe==2.1.2
|
23 |
+
mdurl==0.1.2
|
24 |
+
multidict==6.0.4
|
25 |
+
numpy==1.24.2
|
26 |
+
openai==0.27.2
|
27 |
+
packaging==23.0
|
28 |
+
pandas==1.5.3
|
29 |
+
Pillow==9.4.0
|
30 |
+
protobuf==3.20.3
|
31 |
+
pyarrow==11.0.0
|
32 |
+
pydeck==0.8.0
|
33 |
+
Pygments==2.14.0
|
34 |
+
Pympler==1.0.1
|
35 |
+
pyrsistent==0.19.3
|
36 |
+
python-dateutil==2.8.2
|
37 |
+
python-docx==0.8.11
|
38 |
+
pytz==2022.7.1
|
39 |
+
pytz-deprecation-shim==0.1.0.post0
|
40 |
+
requests==2.28.2
|
41 |
+
rich==13.3.2
|
42 |
+
semver==2.13.0
|
43 |
+
six==1.16.0
|
44 |
+
smmap==5.0.0
|
45 |
+
streamlit==1.20.0
|
46 |
+
toml==0.10.2
|
47 |
+
toolz==0.12.0
|
48 |
+
tornado==6.2
|
49 |
+
tqdm==4.65.0
|
50 |
+
typing_extensions==4.5.0
|
51 |
+
tzdata==2022.7
|
52 |
+
tzlocal==4.2
|
53 |
+
urllib3==1.26.15
|
54 |
+
validators==0.20.0
|
55 |
+
watchdog==2.3.1
|
56 |
+
yarl==1.8.2
|
57 |
+
zipp==3.15.0
|