nniehaus commited on
Commit
868be87
·
verified ·
1 Parent(s): 7409805

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
app.py CHANGED
@@ -5,33 +5,28 @@ import os
5
  # Ensure your OpenAI API key is set in your environment variables
6
  openai.api_key = os.environ["OPENAI_API_KEY"]
7
 
8
- # Initial system message setup for the video topic generator
9
  initial_messages = [{
10
  "role": "system",
11
  "content": """
12
- You are an assistant helping a real estate agent brainstorm video topics and outlines.
13
- Based on a specified goal or area of focus, suggest five video topics with outlines.
14
- Each topic should be numbered (1-5) and should include:
15
- - A catchy title for the video
16
- - A brief summary of the video's content
17
- - Key points or segments the video should cover (bullet points)
18
  """
19
  }]
20
 
21
  def call_openai_api(messages):
22
  return openai.ChatCompletion.create(
23
- model="gpt-3.5-turbo",
24
  messages=messages,
25
- max_tokens=500
26
  )
27
 
28
- def CustomChatGPT(goal, messages):
29
  query = f"""
30
- The real estate agent's goal is: {goal}.
31
- Please provide five video topic ideas with the following structure:
32
- 1. Title: A catchy title
33
- 2. Summary: Brief description of the content
34
- 3. Key Points: Bullet points of segments to cover
35
  """
36
 
37
  messages.append({"role": "user", "content": query})
@@ -48,22 +43,22 @@ if "reply" not in st.session_state:
48
  st.session_state["reply"] = None
49
 
50
  # Centered title
51
- st.markdown("<h1 style='text-align: center; color: black;'>Real Estate Video Topic Generator</h1>", unsafe_allow_html=True)
52
 
53
  # User inputs
54
  col1, col2 = st.columns(2)
55
  with col1:
56
- st.markdown("<h2 style='text-align: center; color: black;'>Your Video Goal</h2>", unsafe_allow_html=True)
57
- goal = st.text_area("Describe the focus or goal for your videos", placeholder="E.g., attracting first-time homebuyers, showcasing luxury properties, or explaining market trends.")
58
- generate_button = st.button('Generate Video Topics')
59
 
60
  # Process results on button click
61
- if generate_button and goal:
62
  messages = initial_messages.copy()
63
- st.session_state["reply"], _ = CustomChatGPT(goal, messages)
64
 
65
  # Display results if there is a reply in session state
66
  if st.session_state["reply"]:
67
  with col2:
68
- st.markdown("<h2 style='text-align: center; color: black;'>Video Topics & Outlines ⬇️</h2>", unsafe_allow_html=True)
69
  st.write(st.session_state["reply"])
 
5
  # Ensure your OpenAI API key is set in your environment variables
6
  openai.api_key = os.environ["OPENAI_API_KEY"]
7
 
8
+ # Initial system message setup for the emoji adder
9
  initial_messages = [{
10
  "role": "system",
11
  "content": """
12
+ You are an assistant that adds appropriate emojis to a given text.
13
+ Analyze the content for tone, context, and meaning, and then insert emojis
14
+ in a way that enhances the message without overwhelming it.
15
+ Make sure the emojis match the sentiment and key points of the text.
 
 
16
  """
17
  }]
18
 
19
  def call_openai_api(messages):
20
  return openai.ChatCompletion.create(
21
+ model="gpt-4",
22
  messages=messages,
23
+ max_tokens=500 # Adjust based on the expected length of emoji-enhanced output
24
  )
25
 
26
+ def CustomChatGPT(text, messages):
27
  query = f"""
28
+ Enhance the following text by adding emojis to match the tone and context:
29
+ {text}
 
 
 
30
  """
31
 
32
  messages.append({"role": "user", "content": query})
 
43
  st.session_state["reply"] = None
44
 
45
  # Centered title
46
+ st.markdown("<h1 style='text-align: center; color: black;'>Emoji Enhancer Tool</h1>", unsafe_allow_html=True)
47
 
48
  # User inputs
49
  col1, col2 = st.columns(2)
50
  with col1:
51
+ st.markdown("<h2 style='text-align: center; color: black;'>Your Text</h2>", unsafe_allow_html=True)
52
+ user_text = st.text_area("Paste your text here", placeholder="Enter your text...")
53
+ add_emojis_button = st.button('Add Emojis')
54
 
55
  # Process results on button click
56
+ if add_emojis_button and user_text:
57
  messages = initial_messages.copy()
58
+ st.session_state["reply"], _ = CustomChatGPT(user_text, messages)
59
 
60
  # Display results if there is a reply in session state
61
  if st.session_state["reply"]:
62
  with col2:
63
+ st.markdown("<h2 style='text-align: center; color: black;'>Enhanced Text ⬇️</h2>", unsafe_allow_html=True)
64
  st.write(st.session_state["reply"])