SuhasGholkar commited on
Commit
ec13609
·
verified ·
1 Parent(s): 6950772

Update src/chat.py

Browse files
Files changed (1) hide show
  1. src/chat.py +25 -0
src/chat.py CHANGED
@@ -347,6 +347,31 @@ def _inject_chat_css():
347
  def _fmt_ts():
348
  return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  def _bubble(role: str, msg: str, ts: str = None, analysis: dict | None = None):
351
  """
352
  Render a chat bubble with optional analysis block.
 
347
  def _fmt_ts():
348
  return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
349
 
350
+ def _render_analysis_chips(turn: dict):
351
+ """
352
+ Render a compact analysis row for one conversation turn.
353
+ Expected keys on 'turn': intent, sentiment, resolution, ftr_ms
354
+ """
355
+ intent = turn.get("intent", "—")
356
+ sentiment = turn.get("sentiment", "—")
357
+ resolution = turn.get("resolution", "—")
358
+ ftr_ms = turn.get("ftr_ms", None)
359
+
360
+ res_cls = "resolved" if str(resolution).lower().startswith("resol") else "unresolved"
361
+ lat = f"{float(ftr_ms):.2f} ms" if ftr_ms is not None else "—"
362
+
363
+ st.markdown(
364
+ f"""
365
+ <div class="analysis-row">
366
+ <span class="chip intent">Intent: {intent}</span>
367
+ <span class="chip sentiment">Sentiment: {sentiment}</span>
368
+ <span class="chip {res_cls}">Resolution: {resolution}</span>
369
+ <span class="chip latency">Latency: {lat}</span>
370
+ </div>
371
+ """,
372
+ unsafe_allow_html=True,
373
+ )
374
+
375
  def _bubble(role: str, msg: str, ts: str = None, analysis: dict | None = None):
376
  """
377
  Render a chat bubble with optional analysis block.