Update app.py
Browse files
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
|
9 |
initial_messages = [{
|
10 |
"role": "system",
|
11 |
"content": """
|
12 |
-
You are an assistant
|
13 |
-
|
14 |
-
|
15 |
-
|
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-
|
24 |
messages=messages,
|
25 |
-
max_tokens=500
|
26 |
)
|
27 |
|
28 |
-
def CustomChatGPT(
|
29 |
query = f"""
|
30 |
-
|
31 |
-
|
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;'>
|
52 |
|
53 |
# User inputs
|
54 |
col1, col2 = st.columns(2)
|
55 |
with col1:
|
56 |
-
st.markdown("<h2 style='text-align: center; color: black;'>Your
|
57 |
-
|
58 |
-
|
59 |
|
60 |
# Process results on button click
|
61 |
-
if
|
62 |
messages = initial_messages.copy()
|
63 |
-
st.session_state["reply"], _ = CustomChatGPT(
|
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;'>
|
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"])
|