File size: 1,667 Bytes
cf1605d
9818b5d
cf1605d
 
 
ad9d11e
cf1605d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
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
36
37
38
39
#from langchain.llms import OpenAI
import streamlit as st
from langchain_community.llms import OpenAI


st.title("🔗 LinkedIn  Test Post Generator two options")

def generate_linkedin_post(topic):
    # Enhanced prompt with additional context for better post generation
    prompt = (
        f"Create a professional, engaging LinkedIn post about {topic}. "
        "It should start with a attention grabbing hook based on audience pain"
        "Then a line to agitate the user. This should be in the next line"
        "The post should be concise, informative, and suitable for a professional audience. "
        "It should provide value, insights, or thought-provoking content related to the topic. "
        "And only contain 3 points."
        "The tone should be positive and encouraging, suitable for networking and professional growth."
    )
    llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["OPENAI_API_KEY"])
    response = llm(prompt)
    return response

with st.form("my_form"):
    topic = st.text_area("Enter the topic for your LinkedIn post:")
    submitted = st.form_submit_button("Generate Post")
    if submitted and topic:
        post = generate_linkedin_post(topic)
        st.info(post)
    elif submitted and not topic:
        st.error("Please enter a topic to generate a post.")

with st.form("my_form1"):
    topic2 = st.text_area("Enter the topic 2 for your LinkedIn post:")
    submitted2 = st.form_submit_button("Generate Post")
    if submitted2 and topic2:
        post = generate_linkedin_post(topic)
        st.info(post)
    elif submitted2 and not topic2:
        st.error("Please enter a topic 2 to generate a post.")