VivekDS commited on
Commit
a89ba22
·
verified ·
1 Parent(s): f38eb7b

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +42 -44
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
- # Radio
8
  st.header("Radio:")
9
- radio = st.radio("Radio", ["Open AI", "Gemini ", "TBD"])
10
  st.write("Selected option:", radio)
11
 
12
- if (st.radio == "OpenAI")
13
- {
14
- rol = st.text_input("Enter Role")
15
- st.write("Entered role:", rol)
16
- #st.header("Slider:")
17
- temp = st.slider("temperature", min_value=0.0, max_value=1, value=0.7, step=0.1)
18
- st.write("Selected value:", temp)
19
-
20
- from langchain_community.llms import OpenAI
21
-
22
- def generate_linkedin_post(topic):
23
- # Enhanced prompt with additional context for better post generation
24
- prompt = (
25
- f"Create a professional, engaging LinkedIn post about {topic}. "
26
- "It should start with a attention grabbing hook based on audience pain"
27
- "Then a line to agitate the user. This should be in the next line"
28
- "The post should be concise, informative, and suitable for a professional audience. "
29
- "It should provide value, insights, or thought-provoking content related to the topic. "
30
- "And only contain 3 points."
31
- "The tone should be positive and encouraging, suitable for networking and professional growth." )
32
- llm = OpenAI(temperature=temp,role= rol, openai_api_key=st.secrets["OPENAI_API_KEY"])
33
- response = llm(prompt)
34
- return response
35
-
36
- with st.form("my_form"):
37
- {
38
- topic = st.text_area("Enter the topic for your LinkedIn post:")
39
- submitted = st.form_submit_button("Generate Post")
40
- if submitted and topic:
41
- post = generate_linkedin_post(topic)
42
- st.info(post)
43
- elif submitted and not topic:
44
- st.error("Please enter a topic to generate a post.")
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()"""