Spaces:
Runtime error
Runtime error
Commit
•
b286257
1
Parent(s):
c513013
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,30 @@
|
|
1 |
import streamlit as st
|
2 |
#from langchain.llms import OpenAI
|
3 |
from langchain_community.llms import OpenAI
|
4 |
-
from auth import *
|
5 |
|
6 |
-
if __name__ == '__app__':
|
7 |
-
|
8 |
-
st.title("🔗 LinkedIn Post Generator")
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
st.info(post)
|
36 |
-
elif submitted and not topic:
|
37 |
-
st.error("Please enter a topic to generate a post.")
|
|
|
1 |
import streamlit as st
|
2 |
#from langchain.llms import OpenAI
|
3 |
from langchain_community.llms import OpenAI
|
|
|
4 |
|
|
|
|
|
|
|
5 |
|
6 |
+
st.title("🔗 LinkedIn Post Generator")
|
7 |
|
8 |
+
def generate_linkedin_post(topic):
|
9 |
+
# Enhanced prompt with additional context for better post generation
|
10 |
+
prompt = (
|
11 |
+
f"Create a professional, engaging LinkedIn post about {topic}. "
|
12 |
+
"It should start with a attention grabbing hook based on audience pain"
|
13 |
+
"Then a line to agitate the user. This should be in the next line"
|
14 |
+
"The post should be concise, informative, and suitable for a professional audience. "
|
15 |
+
"It should provide value, insights, or thought-provoking content related to the topic. "
|
16 |
+
"And only contain 3 points."
|
17 |
+
"The tone should be positive and encouraging, suitable for networking and professional growth."
|
18 |
+
)
|
19 |
+
llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["OPENAI_API_KEY"])
|
20 |
+
response = llm(prompt)
|
21 |
+
return response
|
22 |
+
|
23 |
+
with st.form("my_form"):
|
24 |
+
topic = st.text_area("Enter the topic for your LinkedIn post:")
|
25 |
+
submitted = st.form_submit_button("Generate Post")
|
26 |
+
if submitted and topic:
|
27 |
+
post = generate_linkedin_post(topic)
|
28 |
+
st.info(post)
|
29 |
+
elif submitted and not topic:
|
30 |
+
st.error("Please enter a topic to generate a post.")
|
|
|
|
|
|