fix: wire bm25_score through Citation so Natural 20 easter egg fires
Citation dataclass gains bm25_score field populated from the retrieved chunk. chat.py serializes it. api.ts interface updated to include it. ChatView passes :bm25-score to CitationPanel so the Nat20 threshold check in onMounted actually has data to evaluate.
This commit is contained in:
parent
6bda1143cc
commit
6fc8e7faa6
4 changed files with 5 additions and 0 deletions
|
|
@ -120,6 +120,7 @@ def chat(req: ChatRequest) -> ChatResponse:
|
||||||
"doc_id": c.doc_id,
|
"doc_id": c.doc_id,
|
||||||
"page_number": c.page_number,
|
"page_number": c.page_number,
|
||||||
"snippet": c.snippet,
|
"snippet": c.snippet,
|
||||||
|
"bm25_score": c.bm25_score,
|
||||||
}
|
}
|
||||||
for c in result.citations
|
for c in result.citations
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class Citation:
|
||||||
doc_id: str
|
doc_id: str
|
||||||
page_number: int
|
page_number: int
|
||||||
snippet: str
|
snippet: str
|
||||||
|
bm25_score: float
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
@ -52,6 +53,7 @@ class Synthesizer:
|
||||||
doc_id=c.doc_id,
|
doc_id=c.doc_id,
|
||||||
page_number=c.page_number,
|
page_number=c.page_number,
|
||||||
snippet=c.text[:200],
|
snippet=c.text[:200],
|
||||||
|
bm25_score=c.bm25_score,
|
||||||
)
|
)
|
||||||
for c in chunks
|
for c in chunks
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export interface Citation {
|
||||||
doc_id: string
|
doc_id: string
|
||||||
page_number: number
|
page_number: number
|
||||||
snippet: string
|
snippet: string
|
||||||
|
bm25_score: number | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChatResponse {
|
export interface ChatResponse {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
:key="j"
|
:key="j"
|
||||||
:citation="cite"
|
:citation="cite"
|
||||||
:doc-title="docTitles[cite.doc_id] ?? cite.doc_id"
|
:doc-title="docTitles[cite.doc_id] ?? cite.doc_id"
|
||||||
|
:bm25-score="cite.bm25_score ?? undefined"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue