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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -12,7 +12,7 @@ initial_messages = [{
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
 
@@ -23,10 +23,14 @@ def call_openai_api(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})
@@ -46,16 +50,33 @@ if "reply" not in st.session_state:
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"]:
 
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
+ The style of emoji usage will depend on the user's preferences for tone, density, and placement.
16
  """
17
  }]
18
 
 
23
  max_tokens=500 # Adjust based on the expected length of emoji-enhanced output
24
  )
25
 
26
+ def CustomChatGPT(text, tone, density, placement, messages):
27
  query = f"""
28
+ Enhance the following text by adding emojis based on these preferences:
29
+ - Tone: {tone}
30
+ - Density: {density}
31
+ - Placement: {placement}
32
+
33
+ Text: {text}
34
  """
35
 
36
  messages.append({"role": "user", "content": query})
 
50
  st.markdown("<h1 style='text-align: center; color: black;'>Emoji Enhancer Tool</h1>", unsafe_allow_html=True)
51
 
52
  # User inputs
53
+ st.markdown("<h2 style='text-align: center; color: black;'>Customize Your Emojis</h2>", unsafe_allow_html=True)
54
+
55
  col1, col2 = st.columns(2)
56
+
57
  with col1:
 
58
  user_text = st.text_area("Paste your text here", placeholder="Enter your text...")
59
+
60
+ # Dropdown menus for user customization
61
+ tone = st.selectbox(
62
+ "Select the tone:",
63
+ ["Friendly", "Professional", "Playful", "Romantic", "Excited"]
64
+ )
65
+ density = st.selectbox(
66
+ "Select emoji density:",
67
+ ["Minimal (few emojis)", "Moderate (balanced emojis)", "Heavy (lots of emojis)"]
68
+ )
69
+ placement = st.selectbox(
70
+ "Select emoji placement:",
71
+ ["At the end of sentences", "Inline with text", "Start of key points"]
72
+ )
73
+
74
  add_emojis_button = st.button('Add Emojis')
75
 
76
  # Process results on button click
77
  if add_emojis_button and user_text:
78
  messages = initial_messages.copy()
79
+ st.session_state["reply"], _ = CustomChatGPT(user_text, tone, density, placement, messages)
80
 
81
  # Display results if there is a reply in session state
82
  if st.session_state["reply"]: