ChogwuCY commited on
Commit
d6b3464
·
verified ·
1 Parent(s): ecaae2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -90,7 +90,11 @@ def ask_only(question, top_k, max_len, threshold):
90
  if best_sim < threshold:
91
  return "—", "", "Konteks kurang pasti (skor rendah). Cuba jelaskan soalan.", f"Best sim: {best_sim:.3f}"
92
  ans, hl, tops = extract(question, best_ctx, max_len)
93
- md = "\n".join([f"- *{i}* (sim={s:.3f}) {CONTEXTS[i][:120].replace('\n',' ')}…" for i,s,_ in cands[:3]])
 
 
 
 
94
  return ans, hl, tops, md
95
 
96
  with gr.Blocks(title="Salatus QA — Question-Only (RAG)", css=CSS, theme=gr.themes.Soft(primary_hue="slate", secondary_hue="amber")) as demo:
 
90
  if best_sim < threshold:
91
  return "—", "", "Konteks kurang pasti (skor rendah). Cuba jelaskan soalan.", f"Best sim: {best_sim:.3f}"
92
  ans, hl, tops = extract(question, best_ctx, max_len)
93
+ md_lines = []
94
+ for i, s, _ in cands[:3]:
95
+ snippet = CONTEXTS[i][:120].replace("\n", " ")
96
+ md_lines.append(f"- {i} (sim={s:.3f}) {snippet}…")
97
+ md = "\n".join(md_lines)
98
  return ans, hl, tops, md
99
 
100
  with gr.Blocks(title="Salatus QA — Question-Only (RAG)", css=CSS, theme=gr.themes.Soft(primary_hue="slate", secondary_hue="amber")) as demo: