Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|