VivekDS commited on
Commit
570ffda
·
verified ·
1 Parent(s): 3dbdadf

Update app3.py

Browse files
Files changed (1) hide show
  1. app3.py +19 -5
app3.py CHANGED
@@ -2,7 +2,8 @@
2
  import streamlit as st
3
  from langchain_community.llms import OpenAI
4
  #from langchain_community.llms import Gemini
5
- from langchain_google_gemini import Gemini
 
6
 
7
 
8
  def main():
@@ -31,12 +32,13 @@ def generate_openai_post(role, temp):
31
  # Enhanced prompt with additional context for better post generation
32
  prompt = (
33
  f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
 
34
  "It should start with an attention grabbing hook based on audience pain. "
35
  "Then a line to agitate the user. This should be in the next line. "
36
  "The post should be concise, informative, and suitable for a professional audience. "
37
  "It should provide value, insights, or thought-provoking content related to the topic. "
38
  "And only contain 3 points. "
39
- "The tone should be positive and encouraging, suitable for networking and professional growth."
40
  )
41
  llm = OpenAI(temperature=temp, openai_api_key=st.secrets["OPENAI_API_KEY"]) # Corrected variable name
42
  response = llm(prompt)
@@ -52,12 +54,24 @@ def generate_openai_post(role, temp):
52
  st.error("Please enter a topic to generate a post.")
53
 
54
  def generate_gemini_post(role, temp):
55
- # Define a function to generate LinkedIn posts using the Gemini API
56
  # Example implementation:
57
- gemini = Gemini(api_key=st.secrets["YOUR_GEMINI_API_KEY"], temperature=temp)
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Call Gemini API functions to generate LinkedIn post
59
  # gemini.generate_linkedin_post(topic, role)
60
  st.error("Gemini API integration is not yet implemented.")
61
-
62
  if __name__ == "__main__":
63
  main()
 
2
  import streamlit as st
3
  from langchain_community.llms import OpenAI
4
  #from langchain_community.llms import Gemini
5
+ #from langchain_google_gemini import Gemini
6
+ from langchain_google_genai import ChatGoogleGenerativeAI
7
 
8
 
9
  def main():
 
32
  # Enhanced prompt with additional context for better post generation
33
  prompt = (
34
  f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
35
+ f"Adjust the tone and style based on a temperature of {temp}. "
36
  "It should start with an attention grabbing hook based on audience pain. "
37
  "Then a line to agitate the user. This should be in the next line. "
38
  "The post should be concise, informative, and suitable for a professional audience. "
39
  "It should provide value, insights, or thought-provoking content related to the topic. "
40
  "And only contain 3 points. "
41
+
42
  )
43
  llm = OpenAI(temperature=temp, openai_api_key=st.secrets["OPENAI_API_KEY"]) # Corrected variable name
44
  response = llm(prompt)
 
54
  st.error("Please enter a topic to generate a post.")
55
 
56
  def generate_gemini_post(role, temp):
57
+ { # Define a function to generate LinkedIn posts using the Gemini API
58
  # Example implementation:
59
+ #gemini = Gemini(api_key=st.secrets["YOUR_GEMINI_API_KEY"], temperature=temp)
60
+ user_input = (
61
+ f"You as {role} Create a professional, engaging LinkedIn post about {topic}. "
62
+ f"Adjust the tone and style based on a temperature of {temp}. "
63
+ "It should start with an attention grabbing hook based on audience pain. "
64
+ "Then a line to agitate the user. This should be in the next line. "
65
+ "The post should be concise, informative, and suitable for a professional audience. "
66
+ "It should provide value, insights, or thought-provoking content related to the topic. "
67
+ "And only contain 3 points. "
68
+ )
69
+ llm = ChatGoogleGenerativeAI(model="gemini-pro")
70
+ result = llm.invoke(user_input)
71
+ return print(result.content)
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()