Spaces:
Running
Running
Update frontend.py
Browse files- 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}")
|