Hasitha16 commited on
Commit
25a23d8
Β·
verified Β·
1 Parent(s): 996d2c2

Update frontend.py

Browse files
Files changed (1) hide show
  1. frontend.py +29 -0
frontend.py CHANGED
@@ -279,3 +279,32 @@ with tab2:
279
  st.error(f"❌ Bulk API Error ({res.status_code}): {err_detail}")
280
  except Exception as e:
281
  st.error(f"Bulk analysis failed: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  st.error(f"❌ Bulk API Error ({res.status_code}): {err_detail}")
280
  except Exception as e:
281
  st.error(f"Bulk analysis failed: {e}")
282
+
283
+ # === ROOT CAUSE & FIX (AI Product Triage) ===
284
+ tab3 = st.container()
285
+ with tab3:
286
+ st.title("πŸ› οΈ Root Cause & Fix Suggestion")
287
+ st.markdown("Get AI-generated issue triage from user feedback.")
288
+
289
+ triage_input = st.text_area("πŸ“ Paste a customer review or complaint here")
290
+
291
+ if st.button("πŸ€– Analyze Root Cause"):
292
+ if len(triage_input.strip().split()) < 5:
293
+ st.warning("Please enter at least one complete issue or sentence.")
294
+ else:
295
+ with st.spinner("Analyzing..."):
296
+ try:
297
+ res = requests.post(f"{backend_url}/rootcause/", json={"text": triage_input}, headers={"x-api-key": api_token})
298
+ if res.ok:
299
+ triage = res.json()
300
+ st.success("βœ… Analysis complete")
301
+ st.markdown("### 🧩 Detected Problem")
302
+ st.info(triage.get("problem", "β€”"))
303
+ st.markdown("### πŸ› οΈ Inferred Root Cause")
304
+ st.warning(triage.get("cause", "β€”"))
305
+ st.markdown("### πŸ’‘ Suggested Fix or Team")
306
+ st.success(triage.get("suggestion", "β€”"))
307
+ else:
308
+ st.error(f"API Error: {res.status_code}")
309
+ except Exception as e:
310
+ st.error(f"Root cause analysis failed: {e}")