horriblecpp commited on
Commit
11b29e8
·
1 Parent(s): 8f8552b

Fix Streamlit nested expander exception using HTML details tag

Browse files
Files changed (1) hide show
  1. frontend/app.py +15 -5
frontend/app.py CHANGED
@@ -881,11 +881,21 @@ with tab_intents:
881
  is_match = bool(classified and classified.get("intent") == il and classified.get("domain") == dom)
882
  prefix = "🎯 " if is_match else ""
883
 
884
- # Show utterances in a nested expander
885
- with st.expander(f"{prefix}`{il}` ({count})", expanded=is_match):
886
- utts = [r["utterance"] for r in rows_i if r["domain"] == dom and r["intent"] == il]
887
- for u in utts:
888
- st.markdown(f"<small>• {u}</small>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
889
 
890
 
891
  # ---------------------------------------------------------------------------
 
881
  is_match = bool(classified and classified.get("intent") == il and classified.get("domain") == dom)
882
  prefix = "🎯 " if is_match else ""
883
 
884
+ # Use HTML details tag to avoid nested expander exception
885
+ utts_html = "".join([f"<li><small>{u}</small></li>" for u in utts])
886
+ st.markdown(
887
+ f"""
888
+ <details {"open" if is_match else ""}>
889
+ <summary style="cursor: pointer; padding: 2px 0;">
890
+ {prefix}<code>{il}</code> ({count})
891
+ </summary>
892
+ <ul style="list-style-type: none; margin-top: 5px; padding-left: 15px;">
893
+ {utts_html}
894
+ </ul>
895
+ </details>
896
+ """,
897
+ unsafe_allow_html=True
898
+ )
899
 
900
 
901
  # ---------------------------------------------------------------------------