diff --git a/app/api/chat.py b/app/api/chat.py index 1ec6547..c973ffe 100644 --- a/app/api/chat.py +++ b/app/api/chat.py @@ -120,6 +120,7 @@ def chat(req: ChatRequest) -> ChatResponse: "doc_id": c.doc_id, "page_number": c.page_number, "snippet": c.snippet, + "bm25_score": c.bm25_score, } for c in result.citations ], diff --git a/app/services/synthesizer.py b/app/services/synthesizer.py index d1273dc..634b523 100644 --- a/app/services/synthesizer.py +++ b/app/services/synthesizer.py @@ -23,6 +23,7 @@ class Citation: doc_id: str page_number: int snippet: str + bm25_score: float @dataclass(frozen=True) @@ -52,6 +53,7 @@ class Synthesizer: doc_id=c.doc_id, page_number=c.page_number, snippet=c.text[:200], + bm25_score=c.bm25_score, ) for c in chunks ) diff --git a/web/src/api.ts b/web/src/api.ts index 37daf48..0c004fc 100644 --- a/web/src/api.ts +++ b/web/src/api.ts @@ -23,6 +23,7 @@ export interface Citation { doc_id: string page_number: number snippet: string + bm25_score: number | null } export interface ChatResponse { diff --git a/web/src/views/ChatView.vue b/web/src/views/ChatView.vue index c5cb448..763fd77 100644 --- a/web/src/views/ChatView.vue +++ b/web/src/views/ChatView.vue @@ -22,6 +22,7 @@ :key="j" :citation="cite" :doc-title="docTitles[cite.doc_id] ?? cite.doc_id" + :bm25-score="cite.bm25_score ?? undefined" />