meraj12 commited on
Commit
53ccc83
Β·
verified Β·
1 Parent(s): 8deb7d7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -0
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()