ui: sort cards with explicit (근거N) chip to the top of references panel
Browse files- src/kpaa/server.py +8 -2
- src/kpaa/ui/gradio.py +8 -2
src/kpaa/server.py
CHANGED
|
@@ -947,8 +947,14 @@ function render(payload) {
|
|
| 947 |
// 이 순서가 답변 본문의 (근거N) 의 N 과 일치 (context_builder 가 같은 순서로 [근거N] 박음).
|
| 948 |
const indexed = rawExcerpts.map((e, i) => ({ ...e, _idx: i + 1 }));
|
| 949 |
|
| 950 |
-
//
|
| 951 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 952 |
const excerpts = [...indexed].sort((a, b) => tier(a) - tier(b));
|
| 953 |
|
| 954 |
// 헤더 — "8건 · LLM 전달 7건"
|
|
|
|
| 947 |
// 이 순서가 답변 본문의 (근거N) 의 N 과 일치 (context_builder 가 같은 순서로 [근거N] 박음).
|
| 948 |
const indexed = rawExcerpts.map((e, i) => ({ ...e, _idx: i + 1 }));
|
| 949 |
|
| 950 |
+
// 3-tier 정렬: LLM 명시 인용(근거N)(0) → LLM 전달(1) → 검색만(2). stable.
|
| 951 |
+
// (근거N) chip 카드를 위로 올려 사용자가 명시 인용된 카드 빨리 찾을 수 있게.
|
| 952 |
+
const tier = (e) => {
|
| 953 |
+
const passed = llmSet.has((e.citation || "").trim());
|
| 954 |
+
if (passed && geungeoSet.has(e._idx)) return 0;
|
| 955 |
+
if (passed) return 1;
|
| 956 |
+
return 2;
|
| 957 |
+
};
|
| 958 |
const excerpts = [...indexed].sort((a, b) => tier(a) - tier(b));
|
| 959 |
|
| 960 |
// 헤더 — "8건 · LLM 전달 7건"
|
src/kpaa/ui/gradio.py
CHANGED
|
@@ -107,9 +107,15 @@ def _render_references_html(
|
|
| 107 |
# 카드별 원본 LLM 입력 순서(1-based) 보존 — 정렬 후에도 (근거N) 매핑 유지.
|
| 108 |
indexed: list[tuple[int, Excerpt]] = list(enumerate(excerpts, 1))
|
| 109 |
|
| 110 |
-
#
|
| 111 |
def _tier(item: tuple[int, Excerpt]) -> int:
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
sorted_items = sorted(indexed, key=_tier)
|
| 115 |
|
|
|
|
| 107 |
# 카드별 원본 LLM 입력 순서(1-based) 보존 — 정렬 후에도 (근거N) 매핑 유지.
|
| 108 |
indexed: list[tuple[int, Excerpt]] = list(enumerate(excerpts, 1))
|
| 109 |
|
| 110 |
+
# 3-tier 정렬 (stable): LLM 명시 인용(근거N) → LLM 전달 → 나머지.
|
| 111 |
def _tier(item: tuple[int, Excerpt]) -> int:
|
| 112 |
+
idx, e = item
|
| 113 |
+
passed = (e.citation or "").strip() in llm_set
|
| 114 |
+
if passed and idx in geungeo_set:
|
| 115 |
+
return 0
|
| 116 |
+
if passed:
|
| 117 |
+
return 1
|
| 118 |
+
return 2
|
| 119 |
|
| 120 |
sorted_items = sorted(indexed, key=_tier)
|
| 121 |
|