Spaces:
Sleeping
Sleeping
| #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 LinkedIn post about {topic} that grabs attention and makes people chuckle. Here's how:" + | |
| f"Start with a relatable pain point:** Something the audience groans about inwardly (e.g., 'Ever spend hours on a task that should take minutes?')"+ | |
| f"Agitate with a pinch of absurdity:** Exaggerate the pain point in a slightly ridiculous way (e.g., '...only to discover your cat was sitting on the keyboard the whole time.')"+ | |
| f"***Offer a solution (with a twist):** Provide a real tip but phrase it unexpectedly (e.g., 'Turns out, the answer lies in [insightful tip] - and checking for rogue felines.')"+ | |
| f"***Tone:** Confident, slightly tongue-in-cheek. Aim for a knowing smile, not a belly laugh.") | |
| 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.") |