Update app3.py
Browse files
app3.py
CHANGED
|
@@ -22,7 +22,45 @@ def main():
|
|
| 22 |
st.header("Slider:")
|
| 23 |
temp = st.slider("Temperature", min_value=0.0, max_value=1.0, value=0.7, step=0.1) # Corrected slider label
|
| 24 |
st.write("Selected value:", temp)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
if radio == "Open AI": # Corrected if statement syntax and comparison
|
| 27 |
generate_openai_post(role, temp)
|
| 28 |
|
|
@@ -30,7 +68,7 @@ def main():
|
|
| 30 |
generate_gemini_post(role, temp)
|
| 31 |
|
| 32 |
def generate_openai_post(role, temp):
|
| 33 |
-
|
| 34 |
# Enhanced prompt with additional context for better post generation
|
| 35 |
prompt = (
|
| 36 |
f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
|
|
@@ -72,6 +110,6 @@ def generate_gemini_post(role, temp):
|
|
| 72 |
# Call Gemini API functions to generate LinkedIn post
|
| 73 |
# gemini.generate_linkedin_post(topic, role)
|
| 74 |
st.error("Gemini API integration is not yet implemented.")
|
| 75 |
-
|
| 76 |
if __name__ == "__main__":
|
| 77 |
main()
|
|
|
|
| 22 |
st.header("Slider:")
|
| 23 |
temp = st.slider("Temperature", min_value=0.0, max_value=1.0, value=0.7, step=0.1) # Corrected slider label
|
| 24 |
st.write("Selected value:", temp)
|
| 25 |
+
|
| 26 |
+
# Topic
|
| 27 |
+
with st.form("my_form"):
|
| 28 |
+
topic = st.text_area("Enter the topic for your LinkedIn post:")
|
| 29 |
+
submitted = st.form_submit_button("Generate Post")
|
| 30 |
+
if submitted and topic:
|
| 31 |
+
# if radio == "Open AI": # Corrected if statement syntax and comparison
|
| 32 |
+
#generate_openai_post(role, temp)
|
| 33 |
+
post = generate_linkedin_post(topic, role,temp,radio)
|
| 34 |
+
st.info(post)
|
| 35 |
+
elif submitted and not topic:
|
| 36 |
+
st.error("Please enter a topic to generate a post.")
|
| 37 |
+
|
| 38 |
+
def generate_linkedin_post(topic, role,temp,radio):
|
| 39 |
+
# Enhanced prompt with additional context for better post generation
|
| 40 |
+
prompt = (
|
| 41 |
+
f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
|
| 42 |
+
f"Adjust the tone and style based on a temperature of {temp}. "
|
| 43 |
+
"It should start with an attention grabbing hook based on audience pain. "
|
| 44 |
+
"Then a line to agitate the user. This should be in the next line. "
|
| 45 |
+
"The post should be concise, informative, and suitable for a professional audience. "
|
| 46 |
+
"It should provide value, insights, or thought-provoking content related to the topic. "
|
| 47 |
+
"And only contain 3 points. "
|
| 48 |
+
|
| 49 |
+
)
|
| 50 |
+
if radio == "Open AI": # Corrected if statement syntax and comparison
|
| 51 |
+
# generate_openai_post(role, temp)
|
| 52 |
+
llm = OpenAI(temperature=temp, openai_api_key=st.secrets["OPENAI_API_KEY"]) # Corrected variable name
|
| 53 |
+
response = llm(prompt)
|
| 54 |
+
return response
|
| 55 |
+
|
| 56 |
|
| 57 |
+
elif radio == "Gemini":
|
| 58 |
+
#generate_gemini_post(role, temp)
|
| 59 |
+
llm = ChatGoogleGenerativeAI(model="gemini-pro")
|
| 60 |
+
result = llm.invoke(prompt)
|
| 61 |
+
return print(result.content)
|
| 62 |
+
|
| 63 |
+
""""
|
| 64 |
if radio == "Open AI": # Corrected if statement syntax and comparison
|
| 65 |
generate_openai_post(role, temp)
|
| 66 |
|
|
|
|
| 68 |
generate_gemini_post(role, temp)
|
| 69 |
|
| 70 |
def generate_openai_post(role, temp):
|
| 71 |
+
def generate_linkedin_post(topic, role):
|
| 72 |
# Enhanced prompt with additional context for better post generation
|
| 73 |
prompt = (
|
| 74 |
f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
|
|
|
|
| 110 |
# Call Gemini API functions to generate LinkedIn post
|
| 111 |
# gemini.generate_linkedin_post(topic, role)
|
| 112 |
st.error("Gemini API integration is not yet implemented.")
|
| 113 |
+
"""
|
| 114 |
if __name__ == "__main__":
|
| 115 |
main()
|