Hasitha16 commited on
Commit
82b3c12
Β·
verified Β·
1 Parent(s): fadde82

Update frontend.py

Browse files
Files changed (1) hide show
  1. frontend.py +3 -6
frontend.py CHANGED
@@ -72,7 +72,6 @@ def speak(text, lang='en'):
72
 
73
  tab1, tab2 = st.tabs(["🧠 Analyze Review", "πŸ“š Bulk Reviews"])
74
 
75
- # === SINGLE REVIEW ANALYSIS ===
76
  # === SINGLE REVIEW ANALYSIS ===
77
  with tab1:
78
  st.title("πŸ“Š ChurnSight AI β€” Product Feedback Assistant")
@@ -81,9 +80,8 @@ with tab1:
81
  review = st.text_area("πŸ“ Enter Customer Feedback", value=st.session_state.review, height=180)
82
  st.session_state.review = review
83
 
84
- analyze = False # βœ… Flag to track if analyze was clicked
85
  col1, col2, col3 = st.columns(3)
86
-
87
  with col1:
88
  analyze = st.button("πŸ” Analyze")
89
  with col2:
@@ -100,7 +98,7 @@ with tab1:
100
  st.session_state[key] = ""
101
  st.rerun()
102
 
103
- if st.session_state.review and (analyze or st.session_state.trigger_example_analysis):
104
  with st.spinner("Analyzing feedback..."):
105
  try:
106
  model_used = None if sentiment_model == "Auto-detect" else sentiment_model
@@ -111,7 +109,7 @@ with tab1:
111
  "product_category": product_category,
112
  "verbosity": verbosity,
113
  "aspects": use_aspects,
114
- "intelligence": st.session_state.intelligence_mode
115
  }
116
  headers = {"x-api-key": st.session_state.get("api_token", "my-secret-key")}
117
  res = requests.post(f"{backend_url}/analyze/", json=payload, headers=headers)
@@ -174,7 +172,6 @@ with tab1:
174
  "question": q_input,
175
  "verbosity": verbosity
176
  }
177
- headers = {"x-api-key": st.session_state.get("api_token", "my-secret-key")}
178
  res = requests.post(f"{backend_url}/followup/", json=follow_payload, headers=headers)
179
  if res.ok:
180
  st.success(res.json().get("answer"))
 
72
 
73
  tab1, tab2 = st.tabs(["🧠 Analyze Review", "πŸ“š Bulk Reviews"])
74
 
 
75
  # === SINGLE REVIEW ANALYSIS ===
76
  with tab1:
77
  st.title("πŸ“Š ChurnSight AI β€” Product Feedback Assistant")
 
80
  review = st.text_area("πŸ“ Enter Customer Feedback", value=st.session_state.review, height=180)
81
  st.session_state.review = review
82
 
83
+ analyze = False
84
  col1, col2, col3 = st.columns(3)
 
85
  with col1:
86
  analyze = st.button("πŸ” Analyze")
87
  with col2:
 
98
  st.session_state[key] = ""
99
  st.rerun()
100
 
101
+ if st.session_state.review and (analyze or st.session_state.get("trigger_example_analysis")):
102
  with st.spinner("Analyzing feedback..."):
103
  try:
104
  model_used = None if sentiment_model == "Auto-detect" else sentiment_model
 
109
  "product_category": product_category,
110
  "verbosity": verbosity,
111
  "aspects": use_aspects,
112
+ "intelligence": st.session_state.get("intelligence_mode", False)
113
  }
114
  headers = {"x-api-key": st.session_state.get("api_token", "my-secret-key")}
115
  res = requests.post(f"{backend_url}/analyze/", json=payload, headers=headers)
 
172
  "question": q_input,
173
  "verbosity": verbosity
174
  }
 
175
  res = requests.post(f"{backend_url}/followup/", json=follow_payload, headers=headers)
176
  if res.ok:
177
  st.success(res.json().get("answer"))