Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import random
|
| 3 |
+
import openai
|
| 4 |
+
|
| 5 |
+
# Set your Groq API key
|
| 6 |
+
GROQ_API_KEY = "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"
|
| 7 |
+
|
| 8 |
+
# Predefined comments by category
|
| 9 |
+
comments = {
|
| 10 |
+
"funny": [
|
| 11 |
+
"This is hilarious! ππ",
|
| 12 |
+
"I can't stop laughing! π€£",
|
| 13 |
+
"Who comes up with these things?! π",
|
| 14 |
+
],
|
| 15 |
+
"sarcastic": [
|
| 16 |
+
"Oh wow, what a groundbreaking post. π",
|
| 17 |
+
"Yeah sure, because that makes total sense... π€",
|
| 18 |
+
"Incredible. Truly life-changing. π",
|
| 19 |
+
],
|
| 20 |
+
"supportive": [
|
| 21 |
+
"You're amazing! Keep it up! πͺ",
|
| 22 |
+
"This is so inspiring! β€οΈ",
|
| 23 |
+
"We all believe in you! Keep going! π",
|
| 24 |
+
],
|
| 25 |
+
"random": [
|
| 26 |
+
"Pineapple on pizza is a crime! ππ",
|
| 27 |
+
"Why is this post making me hungry? π",
|
| 28 |
+
"I just saw a cat do a backflip! π±",
|
| 29 |
+
],
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
# Function to generate AI comments
|
| 33 |
+
def generate_ai_comment(user_input, tone):
|
| 34 |
+
prompt = f"Generate a {tone} comment for this post: {user_input}"
|
| 35 |
+
response = openai.ChatCompletion.create(
|
| 36 |
+
model="gpt-3.5-turbo",
|
| 37 |
+
messages=[{"role": "user", "content": prompt}],
|
| 38 |
+
api_key=GROQ_API_KEY,
|
| 39 |
+
)
|
| 40 |
+
return response["choices"][0]["message"]["content"].strip()
|
| 41 |
+
|
| 42 |
+
# Function to generate fake profile details
|
| 43 |
+
def generate_fake_profile():
|
| 44 |
+
names = ["John Doe", "Emily Smith", "Mike Johnson", "Sarah Brown", "Chris Lee"]
|
| 45 |
+
avatars = [
|
| 46 |
+
"https://randomuser.me/api/portraits/men/1.jpg",
|
| 47 |
+
"https://randomuser.me/api/portraits/women/2.jpg",
|
| 48 |
+
"https://randomuser.me/api/portraits/men/3.jpg",
|
| 49 |
+
"https://randomuser.me/api/portraits/women/4.jpg",
|
| 50 |
+
]
|
| 51 |
+
return random.choice(names), random.choice(avatars)
|
| 52 |
+
|
| 53 |
+
# Streamlit UI
|
| 54 |
+
st.title("Fake Facebook Comments Generator")
|
| 55 |
+
|
| 56 |
+
user_input = st.text_area("Enter your post:")
|
| 57 |
+
tone = st.selectbox("Choose comment tone:", ["funny", "sarcastic", "supportive", "random", "AI-Generated"])
|
| 58 |
+
|
| 59 |
+
if st.button("Generate Comments"):
|
| 60 |
+
st.subheader("Fake Comments:")
|
| 61 |
+
for _ in range(5): # Generate 5 comments
|
| 62 |
+
name, avatar = generate_fake_profile()
|
| 63 |
+
|
| 64 |
+
if tone == "AI-Generated":
|
| 65 |
+
comment = generate_ai_comment(user_input, "random")
|
| 66 |
+
else:
|
| 67 |
+
comment = random.choice(comments[tone])
|
| 68 |
+
|
| 69 |
+
col1, col2 = st.columns([1, 5])
|
| 70 |
+
with col1:
|
| 71 |
+
st.image(avatar, width=50)
|
| 72 |
+
with col2:
|
| 73 |
+
st.write(f"**{name}**: {comment}")
|
| 74 |
+
|
| 75 |
+
# Emoji Reactions
|
| 76 |
+
st.subheader("React to this Post:")
|
| 77 |
+
st.write("π β€οΈ π π‘ π’")
|
| 78 |
+
|
| 79 |
+
# Regenerate Button
|
| 80 |
+
if st.button("Regenerate Comments"):
|
| 81 |
+
st.experimental_rerun()
|