Update app2.py
Browse files
app2.py
CHANGED
|
@@ -1,53 +1,51 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
|
| 4 |
def main():
|
| 5 |
st.title("Open AI or Gemini Options")
|
| 6 |
|
| 7 |
-
|
| 8 |
st.header("Radio:")
|
| 9 |
-
radio = st.radio("Radio", ["Open AI", "Gemini
|
| 10 |
st.write("Selected option:", radio)
|
| 11 |
|
| 12 |
-
if
|
| 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 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
}
|
| 50 |
-
"""" # Selectbox
|
| 51 |
st.header("Select Box:")
|
| 52 |
selectbox = st.selectbox("Selectbox", ["Option 1", "Option 2", "Option 3"])
|
| 53 |
st.write("Selected option:", selectbox)
|
|
@@ -108,6 +106,6 @@ def main():
|
|
| 108 |
st.header("Color Picker :")
|
| 109 |
color_picker = st.color_picker("Color Picker")
|
| 110 |
st.write("Selected color:", color_picker)
|
| 111 |
-
|
| 112 |
if __name__ == "__main__":
|
| 113 |
-
main()
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from langchain_community.llms import OpenAI
|
| 3 |
|
| 4 |
def main():
|
| 5 |
st.title("Open AI or Gemini Options")
|
| 6 |
|
| 7 |
+
# Radio
|
| 8 |
st.header("Radio:")
|
| 9 |
+
radio = st.radio("Radio", ["Open AI", "Gemini", "TBD"]) # Removed extra space after "Gemini"
|
| 10 |
st.write("Selected option:", radio)
|
| 11 |
|
| 12 |
+
if radio == "Open AI": # Corrected if statement syntax and comparison
|
| 13 |
+
role = st.text_input("Enter Role")
|
| 14 |
+
st.write("Entered role:", role)
|
| 15 |
+
|
| 16 |
+
# Slider
|
| 17 |
+
st.header("Slider:")
|
| 18 |
+
temp = st.slider("Temperature", min_value=0.0, max_value=1, value=0.7, step=0.1) # Corrected slider label
|
| 19 |
+
st.write("Selected value:", temp)
|
| 20 |
+
|
| 21 |
+
def generate_linkedin_post(topic):
|
| 22 |
+
# Enhanced prompt with additional context for better post generation
|
| 23 |
+
prompt = (
|
| 24 |
+
f"Create a professional, engaging LinkedIn post about {topic}. "
|
| 25 |
+
"It should start with a attention grabbing hook based on audience pain. "
|
| 26 |
+
"Then a line to agitate the user. This should be in the next line. "
|
| 27 |
+
"The post should be concise, informative, and suitable for a professional audience. "
|
| 28 |
+
"It should provide value, insights, or thought-provoking content related to the topic. "
|
| 29 |
+
"And only contain 3 points. "
|
| 30 |
+
"The tone should be positive and encouraging, suitable for networking and professional growth."
|
| 31 |
+
)
|
| 32 |
+
llm = OpenAI(temperature=temp, role=role, openai_api_key=st.secrets["OPENAI_API_KEY"]) # Corrected variable name
|
| 33 |
+
response = llm(prompt)
|
| 34 |
+
return response
|
| 35 |
+
|
| 36 |
+
with st.form("my_form"):
|
| 37 |
+
topic = st.text_area("Enter the topic for your LinkedIn post:")
|
| 38 |
+
submitted = st.form_submit_button("Generate Post")
|
| 39 |
+
if submitted and topic:
|
| 40 |
+
post = generate_linkedin_post(topic)
|
| 41 |
+
st.info(post)
|
| 42 |
+
elif submitted and not topic:
|
| 43 |
+
st.error("Please enter a topic to generate a post.")
|
| 44 |
+
|
| 45 |
+
if __name__ == "__main__":
|
| 46 |
+
main()
|
| 47 |
+
|
| 48 |
+
"""" # Selectbox
|
|
|
|
|
|
|
| 49 |
st.header("Select Box:")
|
| 50 |
selectbox = st.selectbox("Selectbox", ["Option 1", "Option 2", "Option 3"])
|
| 51 |
st.write("Selected option:", selectbox)
|
|
|
|
| 106 |
st.header("Color Picker :")
|
| 107 |
color_picker = st.color_picker("Color Picker")
|
| 108 |
st.write("Selected color:", color_picker)
|
| 109 |
+
|
| 110 |
if __name__ == "__main__":
|
| 111 |
+
main()"""
|