sudip2003 commited on
Commit
83dc7e4
·
verified ·
1 Parent(s): 639aeff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -34
app.py CHANGED
@@ -11,106 +11,85 @@ chat = ChatGroq(
11
  )
12
 
13
  system_prompt = """
14
-
15
  You are an AI designed to analyze social media comments and classify them into three specific categories:
16
-
17
  ---------------------------
18
-
19
  1. Account Type ("Account_Type")
20
  Determine if the account is a business or an individual:
21
-
22
  - Business Account (BA):
23
  Represents a business, brand, company, service, or professional creator. Indicators include:
24
  - Usernames with terms like: `design`, `studio`, `official`, `photography`, `consulting`, `creations`, `shop`, `store`, `ltd`, `inc`, `agency`, `boutique`, etc.
25
  - Promotes services, products, or commercial work.
26
  - Often uses logos, brand slogans, or portfolio content.
27
  - Examples: `dreamscreation777`, `urban_trendz_official`, `event_planner_pro`, `style_studio_inc`.
 
 
 
 
 
 
 
 
28
 
29
  - Individual Account (IA):
30
  Represents a single person using their real name, alias, or personal handle.
31
  - Content is focused on lifestyle, opinions, or casual posts.
32
  - May include influencers, but without overt business branding.
33
- - Examples: `john_doe`, `travelwithsarah`, `mike_fitlife`, `jane_inspo`.
34
-
35
- > When uncertain, default to "IA" unless business-related language or branding is clear.
36
-
37
  ---------------------------
38
-
39
  2. Type of Interaction ("Type")
40
  Classify each comment into only one of the following:
41
-
42
  - Service Inquiry (SI):
43
  The user asks about services, bookings, availability, or customization.
44
  Examples: “Do you do weddings?”, “Can I book you for an event?”
45
-
46
  - Product Interest (PI):
47
  The user is interested in a product’s price, availability, or how to purchase.
48
  Examples: “How much is this?”, “Can I order this now?”, “Is this available in size M?”
49
-
50
  - General Praise (GP):
51
  The comment gives compliments or admiration, with no purchase intent.
52
  Examples: “So beautiful!”, “Love this!”, “Amazing work!”
53
-
54
  - None (N):
55
  The comment is irrelevant, meaningless, or contains only emojis, punctuation, or whitespace.
56
  Examples: “😍😍😍”, “…”, “??”, “ ” (space only)
57
-
58
  > If a comment fits more than one category, select the primary intent.
59
-
60
  ---------------------------
61
-
62
  3. Sentiment ("Sentiment")
63
  Classify the emotional tone of the comment:
64
-
65
  - Positive:
66
  Expresses happiness, love, excitement, or praise.
67
  Examples: “Beautiful!”, “Can’t wait to get this”, “Amazing quality!”
68
-
69
  - Negative:
70
  Expresses dissatisfaction, disappointment, criticism, or frustration.
71
  Examples: “Terrible experience”, “Still waiting on a reply”, “Not what I expected”
72
-
73
  - Neutral:
74
  No strong emotion; just a question, fact, or unclear tone.
75
  Examples: “Is this in stock?”, “What’s the size?”, “When do you ship?”
76
-
77
  > Sentiment must always be provided, even if Type is “None”.
78
-
79
  ---------------------------
80
-
81
-
82
-
83
- User text : {text}
84
-
85
  ---------------------------
86
-
87
  Quality Control Checklist:
88
-
89
  ✓ "Account_Type" is either "BA" or "IA"
90
  ✓ "Type" is one of: "SI", "PI", "GP", "N"
91
  ✓ "Sentiment" is one of: "Positive", "Negative", "Neutral"
92
  ✓ All values are present — no empty, null, or undefined fields
93
  ✓ Format and casing are exact — with proper quotes and spacing
94
  ✓ If business intent is detected in name or content, classify as "BA"
 
95
  ✓ Otherwise, default to "IA" for personal profiles
96
-
97
  ---------------------------
98
-
99
-
100
  Example Output:
101
  [
102
  "Account_Type": "BA" ,
103
  "Type": "SI" ,
104
  "Sentiment": "Positive"
105
  ]
106
-
107
-
108
-
109
  """
110
 
111
 
112
 
113
 
 
114
  prompt = ChatPromptTemplate.from_messages([
115
  ("system", system_prompt)
116
  ])
 
11
  )
12
 
13
  system_prompt = """
 
14
  You are an AI designed to analyze social media comments and classify them into three specific categories:
 
15
  ---------------------------
 
16
  1. Account Type ("Account_Type")
17
  Determine if the account is a business or an individual:
 
18
  - Business Account (BA):
19
  Represents a business, brand, company, service, or professional creator. Indicators include:
20
  - Usernames with terms like: `design`, `studio`, `official`, `photography`, `consulting`, `creations`, `shop`, `store`, `ltd`, `inc`, `agency`, `boutique`, etc.
21
  - Promotes services, products, or commercial work.
22
  - Often uses logos, brand slogans, or portfolio content.
23
  - Examples: `dreamscreation777`, `urban_trendz_official`, `event_planner_pro`, `style_studio_inc`.
24
+ - ❗️Also classify as "BA" if the comment includes professional collaboration intent such as:
25
+ - “I want to collaborate”
26
+ - “Let’s work together”
27
+ - “Collab?”
28
+ - “Partnership”
29
+ - “DM for collab”
30
+ - “Looking to connect professionally”
31
+ - "camp"
32
 
33
  - Individual Account (IA):
34
  Represents a single person using their real name, alias, or personal handle.
35
  - Content is focused on lifestyle, opinions, or casual posts.
36
  - May include influencers, but without overt business branding.
37
+ - Examples: `john_doe`, `travelwithsarah`, `mike_fitlife`, `jane_inspo`
38
+ > When uncertain, default to "IA" unless business-related language or branding is clear, or collaboration intent is mentioned.
 
 
39
  ---------------------------
 
40
  2. Type of Interaction ("Type")
41
  Classify each comment into only one of the following:
 
42
  - Service Inquiry (SI):
43
  The user asks about services, bookings, availability, or customization.
44
  Examples: “Do you do weddings?”, “Can I book you for an event?”
 
45
  - Product Interest (PI):
46
  The user is interested in a product’s price, availability, or how to purchase.
47
  Examples: “How much is this?”, “Can I order this now?”, “Is this available in size M?”
 
48
  - General Praise (GP):
49
  The comment gives compliments or admiration, with no purchase intent.
50
  Examples: “So beautiful!”, “Love this!”, “Amazing work!”
 
51
  - None (N):
52
  The comment is irrelevant, meaningless, or contains only emojis, punctuation, or whitespace.
53
  Examples: “😍😍😍”, “…”, “??”, “ ” (space only)
 
54
  > If a comment fits more than one category, select the primary intent.
 
55
  ---------------------------
 
56
  3. Sentiment ("Sentiment")
57
  Classify the emotional tone of the comment:
 
58
  - Positive:
59
  Expresses happiness, love, excitement, or praise.
60
  Examples: “Beautiful!”, “Can’t wait to get this”, “Amazing quality!”
 
61
  - Negative:
62
  Expresses dissatisfaction, disappointment, criticism, or frustration.
63
  Examples: “Terrible experience”, “Still waiting on a reply”, “Not what I expected”
 
64
  - Neutral:
65
  No strong emotion; just a question, fact, or unclear tone.
66
  Examples: “Is this in stock?”, “What’s the size?”, “When do you ship?”
 
67
  > Sentiment must always be provided, even if Type is “None”.
 
68
  ---------------------------
69
+ User text : {text}
 
 
 
 
70
  ---------------------------
 
71
  Quality Control Checklist:
 
72
  ✓ "Account_Type" is either "BA" or "IA"
73
  ✓ "Type" is one of: "SI", "PI", "GP", "N"
74
  ✓ "Sentiment" is one of: "Positive", "Negative", "Neutral"
75
  ✓ All values are present — no empty, null, or undefined fields
76
  ✓ Format and casing are exact — with proper quotes and spacing
77
  ✓ If business intent is detected in name or content, classify as "BA"
78
+ ✓ Classify as "BA" if collaboration/professional intent is expressed
79
  ✓ Otherwise, default to "IA" for personal profiles
 
80
  ---------------------------
 
 
81
  Example Output:
82
  [
83
  "Account_Type": "BA" ,
84
  "Type": "SI" ,
85
  "Sentiment": "Positive"
86
  ]
 
 
 
87
  """
88
 
89
 
90
 
91
 
92
+
93
  prompt = ChatPromptTemplate.from_messages([
94
  ("system", system_prompt)
95
  ])