Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,36 +2,35 @@ import streamlit as st
|
|
| 2 |
import openai
|
| 3 |
|
| 4 |
def main():
|
| 5 |
-
st.title("
|
|
|
|
| 6 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
if st.button('Generate
|
| 13 |
-
response =
|
| 14 |
if response:
|
| 15 |
-
st.subheader("Suggested
|
| 16 |
st.write(response)
|
| 17 |
else:
|
| 18 |
-
st.error("Failed to generate
|
| 19 |
|
| 20 |
-
def
|
| 21 |
try:
|
| 22 |
-
prompt_text = f"""
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
Reply with a list of the best 10 engagement ring options."""
|
| 31 |
response = openai.ChatCompletion.create(
|
| 32 |
-
model="gpt-
|
| 33 |
messages=[{"role": "system", "content": prompt_text}],
|
| 34 |
-
max_tokens=
|
| 35 |
)
|
| 36 |
return response.choices[0].message['content']
|
| 37 |
except Exception as e:
|
|
@@ -39,4 +38,4 @@ def generate_ring_suggestions(fiancée_description, relationship_details, budget
|
|
| 39 |
return None
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
| 42 |
-
main()
|
|
|
|
| 2 |
import openai
|
| 3 |
|
| 4 |
def main():
|
| 5 |
+
st.title("Blog Post Idea and Outline Generator")
|
| 6 |
+
|
| 7 |
openai.api_key = st.secrets["OPENAI_API_KEY"]
|
| 8 |
|
| 9 |
+
blog_topic = st.text_input("Enter your blog topic:", value="", placeholder="e.g., Artificial Intelligence in Healthcare")
|
| 10 |
+
target_audience = st.text_input("Describe your target audience:", value="", placeholder="e.g., healthcare professionals")
|
| 11 |
+
post_length = st.selectbox("Choose the length of your blog post:", ['Short (500 words)', 'Medium (1000 words)', 'Long (1500+ words)'])
|
| 12 |
|
| 13 |
+
if st.button('Generate Blog Post Ideas and Outlines'):
|
| 14 |
+
response = generate_blog_ideas_and_outlines(blog_topic, target_audience, post_length)
|
| 15 |
if response:
|
| 16 |
+
st.subheader("Suggested Blog Post Ideas and Outlines:")
|
| 17 |
st.write(response)
|
| 18 |
else:
|
| 19 |
+
st.error("Failed to generate blog post ideas and outlines. Please check the inputs and try again.")
|
| 20 |
|
| 21 |
+
def generate_blog_ideas_and_outlines(topic, audience, length):
|
| 22 |
try:
|
| 23 |
+
prompt_text = f"""As an expert content strategist and writer, create 5 unique blog post ideas on the topic of {topic} for {audience}. For each idea, provide a brief outline suitable for a {length} post. Each outline should include:
|
| 24 |
+
1. An attention-grabbing title
|
| 25 |
+
2. 3-5 main sections with brief descriptions
|
| 26 |
+
3. A concluding thought or call-to-action
|
| 27 |
+
|
| 28 |
+
Ensure that each idea is distinct and tailored to the interests and needs of the target audience."""
|
| 29 |
+
|
|
|
|
|
|
|
| 30 |
response = openai.ChatCompletion.create(
|
| 31 |
+
model="gpt-4",
|
| 32 |
messages=[{"role": "system", "content": prompt_text}],
|
| 33 |
+
max_tokens=1000
|
| 34 |
)
|
| 35 |
return response.choices[0].message['content']
|
| 36 |
except Exception as e:
|
|
|
|
| 38 |
return None
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
+
main()
|