mayf commited on
Commit
5e67ce7
·
verified ·
1 Parent(s): 533636b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -59,7 +59,7 @@ def main():
59
  # Highest sentiment
60
  max_label, max_score = max(sentiment_results.items(), key=lambda x: x[1])
61
  st.subheader("Highest Sentiment")
62
- st.write(f"**{max_label}** ({max_score:.4f})")
63
 
64
  # Top 3 keywords
65
  keywords = kw_model.extract_keywords(
@@ -72,16 +72,16 @@ def main():
72
  for kw, score in keywords:
73
  st.write(f"• {kw} ({score:.4f})")
74
 
75
- # GPT-Driven Analysis & Suggestions (concise)
76
  st.subheader("GPT Analysis & Seller Suggestions")
77
  prompt = f"""
78
- You are a concise e-commerce feedback analyst.
79
  Review: "{review}"
80
- Scores: {sentiment_results}
81
- Keywords: {[kw for kw, _ in keywords]}
82
- Provide:
83
- 1. One-sentence summary of customer sentiment.
84
- 2. Three bullet-point suggestions, each no more than 8 words.
85
  """
86
 
87
  response = openai_client.chat.completions.create(
@@ -90,11 +90,11 @@ Provide:
90
  {"role": "system", "content": "You are a product-feedback analyst."},
91
  {"role": "user", "content": prompt}
92
  ],
93
- temperature=0.5,
94
- max_tokens=120
95
  )
96
  gpt_reply = response.choices[0].message.content.strip()
97
  st.markdown(gpt_reply)
98
 
99
  if __name__ == "__main__":
100
- main()
 
59
  # Highest sentiment
60
  max_label, max_score = max(sentiment_results.items(), key=lambda x: x[1])
61
  st.subheader("Highest Sentiment")
62
+ st.markdown(f"**Highest Sentiment:** **{max_label}** ({max_score:.4f})")
63
 
64
  # Top 3 keywords
65
  keywords = kw_model.extract_keywords(
 
72
  for kw, score in keywords:
73
  st.write(f"• {kw} ({score:.4f})")
74
 
75
+ # GPT-Driven Analysis & Suggestions (detailed)
76
  st.subheader("GPT Analysis & Seller Suggestions")
77
  prompt = f"""
78
+ You are an analytical e-commerce feedback expert.
79
  Review: "{review}"
80
+ Sentiment Scores: {sentiment_results}
81
+ Top Keywords: {[kw for kw, _ in keywords]}
82
+ Tasks:
83
+ 1. Write a concise paragraph (2 sentences) interpreting customer sentiment by combining the scores and keywords.
84
+ 2. Provide 3 actionable suggestions with brief explanations (up to 5 sentences each).
85
  """
86
 
87
  response = openai_client.chat.completions.create(
 
90
  {"role": "system", "content": "You are a product-feedback analyst."},
91
  {"role": "user", "content": prompt}
92
  ],
93
+ temperature=0.7,
94
+ max_tokens=200
95
  )
96
  gpt_reply = response.choices[0].message.content.strip()
97
  st.markdown(gpt_reply)
98
 
99
  if __name__ == "__main__":
100
+ main()