Update app.py
Browse files
app.py
CHANGED
@@ -113,39 +113,27 @@ def main():
|
|
113 |
max_label, max_score = max(sentiment_results.items(), key=lambda x: x[1])
|
114 |
st.markdown(f"**Highest Sentiment:** **{max_label}** ({max_score:.4f})")
|
115 |
|
116 |
-
|
117 |
progress.text("Generating detailed recommendations...")
|
118 |
if max_label in ["Very Negative", "Negative", "Neutral"]:
|
119 |
-
prompt =
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
"
|
137 |
-
" 4. a bullet-point list of 3–5 clear steps for operations or product teams to execute.
|
138 |
-
"
|
139 |
-
" 5. how to measure the impact.
|
140 |
-
|
141 |
-
"
|
142 |
-
"Write each recommendation in at least 5–7 sentences, grounding every detail in the customer's own words. "
|
143 |
-
"Avoid generic advice—focus on specifics from the review.
|
144 |
-
|
145 |
-
"
|
146 |
-
"Recommendations:
|
147 |
-
"
|
148 |
-
)
|
149 |
response = generation_pipeline(prompt)
|
150 |
detailed = response[0]["generated_text"]
|
151 |
st.markdown(detailed)
|
@@ -160,3 +148,4 @@ def main():
|
|
160 |
if __name__ == "__main__":
|
161 |
main()
|
162 |
|
|
|
|
113 |
max_label, max_score = max(sentiment_results.items(), key=lambda x: x[1])
|
114 |
st.markdown(f"**Highest Sentiment:** **{max_label}** ({max_score:.4f})")
|
115 |
|
116 |
+
# Generate Detailed Recommendations for select sentiments
|
117 |
progress.text("Generating detailed recommendations...")
|
118 |
if max_label in ["Very Negative", "Negative", "Neutral"]:
|
119 |
+
prompt = f"""
|
120 |
+
You are a senior product quality and customer experience specialist at an e-commerce food retailer.
|
121 |
+
|
122 |
+
Customer Review:
|
123 |
+
"{review}"
|
124 |
+
|
125 |
+
Please analyze this feedback and provide **three** distinct, actionable improvement recommendations designed to reduce customer pain points.
|
126 |
+
For each recommendation, include:
|
127 |
+
1. **Recommendation Title**: a concise summary of the action.
|
128 |
+
2. The specific issue or frustration extracted from the review.
|
129 |
+
3. Why this action addresses the pain point and how it will improve the customer experience.
|
130 |
+
4. A bullet-point list of 3–5 clear steps for operations or product teams to execute.
|
131 |
+
5. How to measure the impact.
|
132 |
+
|
133 |
+
Write each recommendation in at least 5–7 sentences, grounding every detail in the customer's own words. Avoid generic advice—focus on specifics from the review.
|
134 |
+
|
135 |
+
Recommendations:
|
136 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
response = generation_pipeline(prompt)
|
138 |
detailed = response[0]["generated_text"]
|
139 |
st.markdown(detailed)
|
|
|
148 |
if __name__ == "__main__":
|
149 |
main()
|
150 |
|
151 |
+
|